-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulate.py
More file actions
116 lines (93 loc) · 3.87 KB
/
Copy pathsimulate.py
File metadata and controls
116 lines (93 loc) · 3.87 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
# simulate.py (FIXED)
#!/usr/bin/env python3
"""
Real attack simulator CLI - deploys actual attack containers.
Usage:
python simulate.py attack cryptominer
python simulate.py attack reverse_shell
python simulate.py attack cpu_bomb
python simulate.py attack all
python simulate.py cleanup <container_id>
python simulate.py cleanup-all
"""
import asyncio
import sys
import logging # ADD THIS IMPORT
import structlog
structlog.configure(
processors=[
structlog.processors.TimeStamper(fmt="iso"),
structlog.processors.add_log_level,
structlog.dev.ConsoleRenderer(colors=True)
],
wrapper_class=structlog.make_filtering_bound_logger(logging.INFO),
context_class=dict,
logger_factory=structlog.PrintLoggerFactory(),
)
log = structlog.get_logger()
async def main():
from attack_simulator.real_attacks import real_attacker
from core import queue
# Connect to Redis
await queue.connect()
if len(sys.argv) < 2:
print("Usage:")
print(" python simulate.py attack cryptominer")
print(" python simulate.py attack reverse_shell")
print(" python simulate.py attack cpu_bomb")
print(" python simulate.py attack all")
print(" python simulate.py cleanup <container_id>")
print(" python simulate.py cleanup-all")
await queue.disconnect()
return
cmd = sys.argv[1]
if cmd == "attack":
if len(sys.argv) < 3:
print("Specify attack type: cryptominer, reverse_shell, cpu_bomb, or all")
await queue.disconnect()
return
attack_type = sys.argv[2]
if attack_type == "cryptominer":
container_id = await real_attacker.attack_cryptominer()
print(f"\n✅ CRYPTOMINER DEPLOYED: {container_id}")
print(f" Falco should detect this in 5-10 seconds...")
print(f" To stop: python simulate.py cleanup {container_id}\n")
elif attack_type == "reverse_shell":
container_id = await real_attacker.attack_reverse_shell()
print(f"\n✅ REVERSE SHELL DEPLOYED: {container_id}")
print(f" Falco should detect this in 5-10 seconds...")
print(f" To stop: python simulate.py cleanup {container_id}\n")
elif attack_type == "cpu_bomb":
container_id = await real_attacker.attack_cpu_bomb()
print(f"\n✅ CPU BOMB DEPLOYED: {container_id}")
print(f" Falco should detect this in 5-10 seconds...")
print(f" To stop: python simulate.py cleanup {container_id}\n")
elif attack_type == "all":
print("\n🚨 DEPLOYING ALL ATTACKS...\n")
c1 = await real_attacker.attack_cryptominer()
print(f"✅ Cryptominer: {c1}")
await asyncio.sleep(2)
c2 = await real_attacker.attack_reverse_shell()
print(f"✅ Reverse Shell: {c2}")
await asyncio.sleep(2)
c3 = await real_attacker.attack_cpu_bomb()
print(f"✅ CPU Bomb: {c3}")
print("\n🎯 All attacks deployed!")
print(f" To stop all: python simulate.py cleanup-all\n")
else:
print(f"Unknown attack type: {attack_type}")
elif cmd == "cleanup":
if len(sys.argv) < 3:
print("Usage: python simulate.py cleanup <container_id>")
else:
container_id = sys.argv[2]
await real_attacker.cleanup_attack(container_id)
print(f"✅ Cleaned up: {container_id}")
elif cmd == "cleanup-all":
await real_attacker.cleanup_all()
print("✅ All attack containers stopped")
else:
print(f"Unknown command: {cmd}")
await queue.disconnect()
if __name__ == "__main__":
asyncio.run(main())