-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdemo.sh
More file actions
executable file
·278 lines (210 loc) · 12.1 KB
/
Copy pathdemo.sh
File metadata and controls
executable file
·278 lines (210 loc) · 12.1 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#!/usr/bin/env bash
# =============================================================================
# THEORY Demo Script
# Comprehensive walkthrough of THEORY v1.0.0 capabilities
# Run from the theory/ repo root with your .env configured
# =============================================================================
set -euo pipefail
DEMO_DIR="output/demo"
mkdir -p "$DEMO_DIR"
divider() {
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " $1"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
}
pause() {
echo ""
read -rp " [press enter to continue]" _
echo ""
}
# ─────────────────────────────────────────────────────────────────────────────
# 0. SETUP CHECK
# ─────────────────────────────────────────────────────────────────────────────
divider "0 — SETUP CHECK"
echo "Checking THEORY installation..."
theory --help > /dev/null 2>&1 && echo " ✓ theory CLI installed" || { echo " ✗ theory not found. Run: pip install -e ."; exit 1; }
echo "Checking .env..."
if [ -f .env ]; then
echo " ✓ .env exists"
grep -q "OTX_API_KEY=." .env 2>/dev/null && echo " ✓ OTX_API_KEY configured" || echo " ⚠ OTX_API_KEY not set (otx source will be skipped)"
grep -q "ANTHROPIC_API_KEY=.\|OPENAI_API_KEY=." .env 2>/dev/null && echo " ✓ LLM provider configured" || echo " ⚠ No LLM key set (vendor source and overviews will be skipped)"
else
echo " ⚠ No .env found. Proceeding with no-auth sources only."
fi
echo "Checking ATT&CK bundle..."
if [ -d ".cache" ] && find .cache -name "*.json" -size +1M 2>/dev/null | grep -q .; then
echo " ✓ ATT&CK bundle cached"
else
echo " ⚠ No ATT&CK bundle found. Downloading..."
theory --update-bundles
fi
pause
# ─────────────────────────────────────────────────────────────────────────────
# 1. INFO COMMANDS
# ─────────────────────────────────────────────────────────────────────────────
divider "1 — INFO COMMANDS"
echo "$ theory --list-sources"
echo ""
theory --list-sources
pause
echo "$ theory --list-actors"
echo ""
theory --list-actors
pause
# ─────────────────────────────────────────────────────────────────────────────
# 2. BASIC DOSSIER (default sources, terminal + markdown)
# ─────────────────────────────────────────────────────────────────────────────
divider "2 — BASIC DOSSIER: APT28 (default sources)"
echo "$ theory --actor APT28"
echo ""
theory --actor APT28
pause
# ─────────────────────────────────────────────────────────────────────────────
# 3. ALIAS RESOLUTION
# ─────────────────────────────────────────────────────────────────────────────
divider "3 — ALIAS RESOLUTION"
echo "All three of these resolve to the same actor and produce the same canonical output file:"
echo ""
echo "$ theory --actor 'Fancy Bear' --no-save"
echo "$ theory --actor 'Forest Blizzard' --no-save"
echo "$ theory --actor 'STRONTIUM' --no-save"
echo ""
echo "Running with 'Fancy Bear'..."
echo ""
theory --actor "Fancy Bear" --no-save
pause
# ─────────────────────────────────────────────────────────────────────────────
# 4. MULTI-SOURCE ENRICHMENT
# ─────────────────────────────────────────────────────────────────────────────
divider "4 — MULTI-SOURCE ENRICHMENT"
echo "Adding community IOC sources to the base dossier:"
echo ""
echo "$ theory --actor APT29 --sources mitre,cisa,malpedia,otx,sigma,threatfox"
echo ""
theory --actor APT29 --sources mitre,cisa,malpedia,otx,sigma,threatfox
pause
# ─────────────────────────────────────────────────────────────────────────────
# 5. OUTPUT FORMATS
# ─────────────────────────────────────────────────────────────────────────────
divider "5a — JSON EXPORT"
echo "$ theory --actor 'Lazarus Group' --output json"
echo ""
theory --actor "Lazarus Group" --output json
echo ""
echo " → Saved to output/dossiers/lazarus_group.json"
pause
divider "5b — STIX 2.1 BUNDLE"
echo "$ theory --actor Turla --sources mitre,malpedia --output stix"
echo ""
theory --actor Turla --sources mitre,malpedia --output stix
echo ""
echo " → Saved to output/dossiers/turla.stix.json"
echo " → Importable into MISP, OpenCTI, Splunk ES, Microsoft Sentinel"
pause
divider "5c — IOC CSV"
echo "$ theory --actor Sandworm --sources mitre,otx,threatfox --output csv"
echo ""
theory --actor Sandworm --sources mitre,otx,threatfox --output csv
echo ""
echo " → Saved to output/dossiers/sandworm.csv"
echo " → Raw IOC values (not defanged) for SIEM lookup table ingestion"
pause
divider "5d — ATT&CK NAVIGATOR LAYER"
echo "$ theory --actor APT41 --sources mitre,malpedia --output navigator"
echo ""
theory --actor APT41 --sources mitre,malpedia --output navigator
echo ""
echo " → Saved to output/dossiers/apt41.navigator.json"
echo " → Import at https://mitre-attack.github.io/attack-navigator/"
pause
divider "5e — HTML DOSSIER"
echo "$ theory --actor 'Volt Typhoon' --sources mitre,cisa,malpedia --output html"
echo ""
theory --actor "Volt Typhoon" --sources mitre,cisa,malpedia --output html
echo ""
echo " → Saved to output/dossiers/volt_typhoon.html"
echo " → Self-contained, shareable, opens in any browser"
pause
divider "5f — IR PLAYBOOK (Markdown)"
echo "$ theory --actor APT28 --sources mitre,sigma --output playbook"
echo ""
theory --actor APT28 --sources mitre,sigma --output playbook
echo ""
echo " → Saved to output/dossiers/apt28_playbook.md"
pause
divider "5g — IR PLAYBOOK (Jira)"
echo "$ theory --actor APT28 --sources mitre,sigma --output playbook --playbook-format jira"
echo ""
theory --actor APT28 --sources mitre,sigma --output playbook --playbook-format jira
echo ""
echo " → Paste directly into Jira issue descriptions"
pause
divider "5h — ALL FORMATS AT ONCE"
echo "$ theory --actor 'Kimsuky' --sources mitre,cisa,malpedia --output all"
echo ""
theory --actor "Kimsuky" --sources mitre,cisa,malpedia --output all
echo ""
echo " → Generates dossier + JSON + STIX + CSV + Navigator + HTML simultaneously"
pause
# ─────────────────────────────────────────────────────────────────────────────
# 6. VENDOR INTELLIGENCE SYNTHESIS (requires LLM key)
# ─────────────────────────────────────────────────────────────────────────────
divider "6 — VENDOR INTELLIGENCE SYNTHESIS"
if grep -q "ANTHROPIC_API_KEY=.\|OPENAI_API_KEY=." .env 2>/dev/null; then
echo "LLM provider detected. Running vendor intel synthesis..."
echo ""
echo "$ theory --actor 'Scattered Spider' --sources mitre,cisa,malpedia,vendor"
echo ""
theory --actor "Scattered Spider" --sources mitre,cisa,malpedia,vendor
else
echo " ⚠ No LLM key configured. Skipping vendor intelligence demo."
echo " To enable: add ANTHROPIC_API_KEY or OPENAI_API_KEY to .env"
fi
pause
# ─────────────────────────────────────────────────────────────────────────────
# 7. EXECUTIVE SUMMARY (requires LLM key)
# ─────────────────────────────────────────────────────────────────────────────
divider "7 — EXECUTIVE SUMMARY"
if grep -q "ANTHROPIC_API_KEY=.\|OPENAI_API_KEY=." .env 2>/dev/null; then
echo "$ theory --actor 'Salt Typhoon' --output exec --sector telecommunications"
echo ""
theory --actor "Salt Typhoon" --output exec --sector telecommunications
else
echo " ⚠ No LLM key configured. Skipping executive summary demo."
fi
pause
# ─────────────────────────────────────────────────────────────────────────────
# 8. VERBOSE MODE
# ─────────────────────────────────────────────────────────────────────────────
divider "8 — VERBOSE MODE (debug output)"
echo "$ theory --actor 'Charming Kitten' --sources mitre,cisa --verbose --no-save"
echo ""
theory --actor "Charming Kitten" --sources mitre,cisa --verbose --no-save
pause
# ─────────────────────────────────────────────────────────────────────────────
# 9. SUMMARY
# ─────────────────────────────────────────────────────────────────────────────
divider "9 — DEMO COMPLETE"
echo "Actors demonstrated:"
echo " APT28 (Fancy Bear) — basic dossier, alias resolution, IR playbook"
echo " APT29 (Cozy Bear) — multi-source enrichment"
echo " Lazarus Group — JSON export"
echo " Turla — STIX 2.1 export"
echo " Sandworm — IOC CSV export"
echo " APT41 — ATT&CK Navigator layer"
echo " Volt Typhoon — HTML dossier"
echo " Kimsuky — all-format export"
echo " Scattered Spider — vendor intel synthesis"
echo " Salt Typhoon — executive summary"
echo " Charming Kitten — verbose/debug mode"
echo ""
echo "Output files:"
ls -la output/dossiers/ 2>/dev/null || echo " (no files saved — all ran with --no-save or output dir not created)"
echo ""
echo "Tests:"
echo " $ pytest tests/ -v # 337 offline tests, no API keys needed"
echo ""
echo "Repository: github.com/threatcraft-co/theory"
echo ""