|
4 | 4 |
|
5 | 5 | ## Overview |
6 | 6 |
|
7 | | -This directory contains Bash and Python scripts that simulate common attack patterns, generating coordinated event chains detectable by security monitoring tools. |
| 7 | +This directory contains Bash scripts that simulate common attack patterns, generating coordinated event chains detectable by security monitoring tools. Events are written as JSON to a log file picked up by Filebeat and indexed into Elasticsearch, where they can be queried in Kibana alongside baseline traffic from the log generator. |
8 | 8 |
|
9 | | -## Structure |
| 9 | +All scripts generate **synthetic events only** — they do not execute actual attacks or make real network connections. |
10 | 10 |
|
11 | | -This directory contains Bash and Python scripts that simulate common attack patterns, generating coordinated event chains detectable by security monitoring tools. |
| 11 | +--- |
12 | 12 |
|
13 | | -**Key files:** |
| 13 | +## Scripts |
14 | 14 |
|
15 | | -- `brute_force_simulation.sh` – Simulate failed authentication attempts |
16 | | -- `lateral_movement_simulation.sh` – Simulate lateral movement (e.g., PsExec, SMB) |
17 | | -- `exfiltration_simulation.sh` – Simulate data exfiltration techniques |
18 | | -- `privilege_escalation_simulation.sh` – Simulate privilege escalation attempts |
19 | | -- `persistence_simulation.sh` – Simulate persistence mechanisms (scheduled tasks, registry keys) |
20 | | -- `c2_beacon_simulation.sh` – Simulate command-and-control beacon callbacks |
21 | | -- `utils.sh` – Shared utility functions (logging, event correlation, cleanup) |
22 | | -- `config/scenarios.yaml` – Attack scenario definitions and parameters |
| 15 | +| Script | Scenario | MITRE Techniques | |
| 16 | +|--------|----------|-----------------| |
| 17 | +| `brute_force_simulation.sh` | Credential brute force + post-compromise discovery | T1110, T1078 | |
| 18 | +| `lateral_movement_simulation.sh` | PsExec lateral movement + C2 beacon | T1021.002, T1570, T1071 | |
| 19 | +| `exfiltration_simulation.sh` | Data staging and large outbound transfer | T1005, T1560, T1048 | |
| 20 | +| `c2_beacon_simulation.sh` | Spearphishing → implant → persistent C2 callbacks | T1566.001, T1059.001, T1071.001, T1029 | |
| 21 | +| `persistence_simulation.sh` | Registry, scheduled task, WMI, service, startup folder | T1547.001, T1053.005, T1546.003, T1543.003 | |
| 22 | +| `privilege_escalation_simulation.sh` | Kerberoasting + UAC bypass + token impersonation | T1558.003, T1548.002, T1134.001 | |
| 23 | +| `apt_scenario.sh` | Full 7-phase APT kill chain (coordinator) | T1566→T1070 (12 techniques) | |
| 24 | +| `utils.sh` | Shared utilities — sourced by all other scripts | — | |
23 | 25 |
|
24 | | -## Capabilities |
| 26 | +--- |
25 | 27 |
|
26 | | -**Multi-step attack chains** |
27 | | - |
28 | | -- Coordinated sequences of events (reconnaissance → exploitation → persistence) |
29 | | -- Realistic timing and intervals between steps |
30 | | -- Event correlation IDs for tracking attack chains |
31 | | - |
32 | | -**Configurable parameters** |
33 | | - |
34 | | -- Target hosts and users |
35 | | -- Attack duration and intensity |
36 | | -- Success/failure ratio |
37 | | -- Detection avoidance techniques (optional, for advanced learning) |
38 | | - |
39 | | -**Artifact generation** |
40 | | - |
41 | | -- Network connections (logs, DNS) |
42 | | -- Process execution chains |
43 | | -- File modifications |
44 | | -- Registry changes |
45 | | -- Auth events |
46 | | - |
47 | | -**Integration with event pipeline** |
48 | | - |
49 | | -- Events written to log files |
50 | | -- Automatic pickup by log aggregator |
51 | | -- Correlation in detection engine |
52 | | - |
53 | | -## Usage Examples |
| 28 | +## Quick Start |
54 | 29 |
|
55 | 30 | ```bash |
56 | | -# Simulate brute force attack against admin account |
57 | | -./brute_force_simulation.sh --target-user admin --attempts 50 --delay 200ms |
58 | | - |
59 | | -# Simulate lateral movement chain |
60 | | -./lateral_movement_simulation.sh --start-host web-01 --targets db-01,db-02,dc-01 |
61 | | - |
62 | | -# Simulate multi-phase APT scenario |
63 | | -./c2_beacon_simulation.sh --callback-interval 60s --duration 10m --data-transfer 5gb |
64 | | - |
65 | | -# List all available scenarios |
66 | | -./attack_simulator.sh --list-scenarios |
| 31 | +# Start the lab |
| 32 | +docker compose up -d |
| 33 | + |
| 34 | +# Wait for Elasticsearch to be healthy, then run any scenario |
| 35 | +bash scripts/brute_force_simulation.sh |
| 36 | +bash scripts/c2_beacon_simulation.sh |
| 37 | +bash scripts/persistence_simulation.sh |
| 38 | +bash scripts/privilege_escalation_simulation.sh |
| 39 | +bash scripts/lateral_movement_simulation.sh |
| 40 | +bash scripts/exfiltration_simulation.sh |
| 41 | + |
| 42 | +# Full APT kill chain (runs all phases end-to-end) |
| 43 | +bash scripts/apt_scenario.sh |
67 | 44 | ``` |
68 | 45 |
|
69 | | -## Attack Scenarios |
| 46 | +After running a script, open Kibana Discover (`http://localhost:5601`) and filter on `labels.simulation: attack` to see the generated events. |
70 | 47 |
|
71 | | -The scripts provide several core attack scenarios for learning and testing: |
| 48 | +--- |
72 | 49 |
|
73 | | -**Included Scenarios:** |
| 50 | +## Usage |
74 | 51 |
|
75 | | -1. **Brute Force Attack** (`brute_force_simulation.sh`) |
76 | | - - Multiple failed login attempts |
77 | | - - Ramp-up pattern (1 attempt, then escalation) |
78 | | - - Expected detection: Failed login spike |
| 52 | +Each script supports configuration via environment variables. See the script header for the full list of options. |
79 | 53 |
|
80 | | -2. **Lateral Movement** (`lateral_movement_simulation.sh`) |
81 | | - - Initial compromise → lateral tool usage (PsExec, SMB) |
82 | | - - Expected detection: Unusual lateral connection, suspicious process parent |
| 54 | +```bash |
| 55 | +# Brute force with custom settings |
| 56 | +ATTEMPT_COUNT=100 TARGET_USER=administrator bash scripts/brute_force_simulation.sh |
83 | 57 |
|
84 | | -3. **Data Exfiltration** (`exfiltration_simulation.sh`) |
85 | | - - Large file access and transfer |
86 | | - - DNS exfiltration (optional) |
87 | | - - Expected detection: Unusual egress volume, DNS anomalies |
| 58 | +# C2 beacon with more pulses and a fixed C2 IP |
| 59 | +BEACON_COUNT=12 C2_IP=198.51.100.42 bash scripts/c2_beacon_simulation.sh |
88 | 60 |
|
89 | | -For additional scenarios and advanced attack simulations, see [docs/roadmap.md](../docs/roadmap.md). |
| 61 | +# Persistence against a specific host/user |
| 62 | +TARGET_HOST=workstation-15 TARGET_USER=bsmith bash scripts/persistence_simulation.sh |
90 | 63 |
|
91 | | -## Configuration |
| 64 | +# Privilege escalation with custom domain |
| 65 | +DOMAIN=ACME DC_HOST=addc-01 SVC_ACCOUNT=svc_exchange bash scripts/privilege_escalation_simulation.sh |
92 | 66 |
|
93 | | -See `config/scenarios.yaml` for: |
| 67 | +# Full APT scenario with custom victim context |
| 68 | +VICTIM_HOST=workstation-08 VICTIM_USER=cjones C2_IP=198.51.100.77 bash scripts/apt_scenario.sh |
94 | 69 |
|
95 | | -- Scenario definitions (steps, timings, targets) |
96 | | -- Event templates (what logs are generated) |
97 | | -- Parameter validation and constraints |
| 70 | +# Isolate a scenario to its own log file |
| 71 | +LOG_FILE=./data/logs/c2-test.json bash scripts/c2_beacon_simulation.sh |
| 72 | +``` |
98 | 73 |
|
99 | | -## Integration with Lab Stack |
| 74 | +--- |
100 | 75 |
|
101 | | -Scripts assume: |
| 76 | +## Detection Workflow |
102 | 77 |
|
103 | | -1. **Mock event generator is running** – Events are written to `/var/log/soc-lab/` |
104 | | -2. **Log aggregator is monitoring logs** – Filebeat/Logstash picks up new events |
105 | | -3. **Elasticsearch/data lake is available** – Events are indexed for querying |
| 78 | +1. Start the lab: `docker compose up -d` |
| 79 | +2. Wait for baseline data to accumulate (5–10 minutes) |
| 80 | +3. Run a simulation: `bash scripts/apt_scenario.sh` |
| 81 | +4. Open Kibana Discover: `http://localhost:5601` |
| 82 | +5. Filter: `labels.simulation: attack` to isolate simulation events |
| 83 | +6. Run the matching detection query from `detections/` |
| 84 | +7. Document which detections fired and where gaps exist |
| 85 | +8. Tune thresholds as needed |
106 | 86 |
|
107 | | -## Safety & Ethics |
| 87 | +For full event chain documentation, detection opportunities, blind spots, and MITRE mappings for each scenario, see [docs/ATTACK_SCENARIOS.md](../docs/ATTACK_SCENARIOS.md). |
108 | 88 |
|
109 | | -**Important Notes:** |
| 89 | +--- |
110 | 90 |
|
111 | | -- These scripts generate **synthetic events only** – they do NOT execute actual attacks |
112 | | -- Use **only within the SOC Lab environment** |
113 | | -- Do **not** run against production systems |
114 | | -- For learning purposes only |
115 | | -- Always document and timestamp attack simulations in lab notes |
| 91 | +## How Events Flow |
116 | 92 |
|
117 | | -## Testing Detections |
| 93 | +``` |
| 94 | +Script → data/logs/attack-simulation.json → Filebeat → Elasticsearch → Kibana |
| 95 | +``` |
118 | 96 |
|
119 | | -Typical workflow: |
| 97 | +All events use `labels.simulation: attack` for easy filtering and `labels.synthetic: true` to distinguish them from real events. |
120 | 98 |
|
121 | | -1. Start the lab with `docker-compose up` |
122 | | -2. Wait for baseline data to accumulate (5–10 minutes) |
123 | | -3. Run an attack simulation: `./brute_force_simulation.sh --target-user admin --attempts 50` |
124 | | -4. Observe detection queries firing: `http://localhost:5601` |
125 | | -5. Document which detections fired and any gaps |
126 | | -6. Tune detection thresholds if needed |
| 99 | +--- |
127 | 100 |
|
128 | | -## Next Steps |
| 101 | +## Safety & Ethics |
129 | 102 |
|
130 | | -For advanced attack scenarios and additional simulation techniques, see [docs/roadmap.md](../docs/roadmap.md) for planned enhancements. |
| 103 | +- These scripts generate **synthetic log events only** — no real network connections, no actual privilege changes, no file system modifications outside `./data/logs/` |
| 104 | +- For use **within the SOC Lab environment only** |
| 105 | +- Do **not** run against production systems or real infrastructure |
| 106 | + |
| 107 | +--- |
| 108 | + |
| 109 | +## Shared Utilities (`utils.sh`) |
| 110 | + |
| 111 | +Sourced by all scripts. Provides: |
| 112 | + |
| 113 | +| Function | Description | |
| 114 | +|----------|-------------| |
| 115 | +| `log_info` / `log_warn` / `log_error` / `log_step` | Timestamped colored output | |
| 116 | +| `check_lab_running` | Verifies Elasticsearch is reachable | |
| 117 | +| `write_event` | Appends a JSON event to `$LOG_FILE` | |
| 118 | +| `make_auth_event` | Builds an ECS authentication event | |
| 119 | +| `make_process_event` | Builds an ECS process execution event | |
| 120 | +| `make_network_event` | Builds an ECS network flow event | |
| 121 | +| `make_registry_event` | Builds an ECS registry modification event | |
| 122 | +| `make_dns_event` | Builds an ECS DNS query event | |
| 123 | +| `random_external_ip` | Returns a random RFC 5737 external IP | |
| 124 | +| `random_internal_ip` | Returns a random 10.0.x.x internal IP | |
| 125 | +| `step_delay` | Sleeps for `$ATTACK_STEP_DELAY_MS` ms (default 500ms) | |
0 commit comments