-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner.py
More file actions
177 lines (150 loc) · 5.2 KB
/
runner.py
File metadata and controls
177 lines (150 loc) · 5.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import sys
import os
import subprocess
# Define the available tools and their relative paths
TOOLS = [
{
"name": "TCP Client",
"path": "client_TCP/main.py",
"description": "A simple TCP client to send data."
},
{
"name": "UDP Client",
"path": "client_UDP/main.py",
"description": "A simple UDP client to send packets."
},
{
"name": "TCP Server",
"path": "server_TCP/main.py",
"description": "A multithreaded TCP server."
},
{
"name": "Netcat (Szynet)",
"path": "netcat/szynet.py",
"description": "A custom Netcat implementation."
},
{
"name": "TCP Proxy",
"path": "proxy_TCP/main.py",
"description": "A TCP proxy to intercept and modify traffic."
}
]
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
def print_header():
print("=" * 60)
print(" PYTHON NETWORKS - TOOLS RUNNER")
print("=" * 60)
print("\nSelect a tool to run from the list below:\n")
def run_netcat_with_params():
"""Run netcat with interactive parameter input"""
print("\n[*] Netcat (Szynet) - Interactive Parameter Input")
print("=" * 60)
print("\nAvailable options:")
print(" -t, --target Target host")
print(" -p, --port Target port")
print(" -l, --listen Listen mode")
print(" -e, --execute Execute command")
print(" -c, --command Command shell")
print(" -u, --upload Upload file")
print(" -d, --data Data to send")
print("\nLeave empty to skip optional parameters.")
# Collect parameters
params = []
# Target
target = input("\nTarget host (-t): ").strip()
if target:
params.extend(["-t", target])
# Port
port = input("Target port (-p): ").strip()
if port:
params.extend(["-p", port])
# Listen mode
listen = input("Listen mode? (-l) [y/N]: ").strip().lower()
if listen in ['y', 'yes']:
params.append("-l")
# Execute command
execute = input("Execute command (-e): ").strip()
if execute:
params.extend(["-e", execute])
# Command shell
command = input("Command shell? (-c) [y/N]: ").strip().lower()
if command in ['y', 'yes']:
params.append("-c")
# Upload
upload = input("Upload destination (-u): ").strip()
if upload:
params.extend(["-u", upload])
# Data
data = input("Data to send (-d): ").strip()
if data:
params.extend(["-d", data])
# Show the command that will be executed
if params:
print(f"\n[*] Executing: python3 netcat/szynet.py {' '.join(params)}")
print("-" * 60)
try:
# Run netcat with the collected parameters
full_path = os.path.join(os.getcwd(), "netcat/szynet.py")
subprocess.run([sys.executable, full_path] + params, check=False)
except KeyboardInterrupt:
print("\n\n[!] Execution interrupted by user.")
except Exception as e:
print(f"\n[!] An error occurred: {e}")
else:
print("\n[!] No parameters provided. Showing help...")
full_path = os.path.join(os.getcwd(), "netcat/szynet.py")
subprocess.run([sys.executable, full_path], check=False)
print("-" * 60)
input("\nPress Enter to return to menu...")
def run_tool(tool_path):
# Check if this is the netcat tool
if "netcat" in tool_path or "szynet" in tool_path:
run_netcat_with_params()
return
# Construct the full path
full_path = os.path.join(os.getcwd(), tool_path)
if not os.path.exists(full_path):
print(f"\n[!] Error: File not found at {full_path}")
input("\nPress Enter to return to menu...")
return
print(f"\n[*] Starting {tool_path}...")
print("-" * 60)
try:
# Running the script using subprocess
# We use python3 explicitly
subprocess.run([sys.executable, full_path], check=False)
except KeyboardInterrupt:
print("\n\n[!] Execution interrupted by user.")
except Exception as e:
print(f"\n[!] An error occurred: {e}")
print("-" * 60)
input("\nPress Enter to return to menu...")
def main():
while True:
clear_screen()
print_header()
for idx, tool in enumerate(TOOLS, 1):
print(f"[{idx}] {tool['name']}")
# print(f" - {tool['description']}") # Optional description
print("\n[q] Quit")
choice = input("\nEnter your choice: ").strip().lower()
if choice == 'q':
print("\nExiting...")
break
if choice.isdigit():
idx = int(choice) - 1
if 0 <= idx < len(TOOLS):
run_tool(TOOLS[idx]['path'])
else:
print("\n[!] Invalid selection. Please try again.")
input("\nPress Enter to continue...")
else:
print("\n[!] Invalid input. Please enter a number or 'q'.")
input("\nPress Enter to continue...")
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\n\nExiting...")
sys.exit(0)