40 ページ、何も変わらず
あるチームが一週間テストし、丁寧な報告書を 40 ページ書きました。半年後も、同じ穴が開いたままです。どれから直すのか、誰の仕事なのか、誰にもわからなかったのです。
報告書の価値は、それで何が直ったかで決まります。このレッスンでは、自分のラボのコピーの結果を、実際に動いてもらえる報告書にします。
このレッスンのゴール
メモ
穴ごとに直し方と担当を付けて順位を付ける、パープルチームの報告書を書ける。
キーワード
| ことば | いみ |
|---|---|
| 穴 | まだ検知できない技術 |
| 優先度 | 穴をどれだけ早く直すべきか |
| 担当 | 穴を直す人やチーム |
| 再テスト日 | 直したものをもう一度試す日 |
| エグゼクティブサマリー | 経営陣向けに書く短い部分 |
学生が入力するセルは、このプレビューでは空白です。
ウォームアップ
やってみよう
ウォームアップ
3問たった一つのルール
重要
報告するのは、許されて行ったテストだけです。ここでは自分のラボのコピーです。本物の報告書は本物のネットワークを書くので、持ち主が決めた人にだけ渡します。テストそのものにも書面の許可が要ります(不正アクセス禁止法)。
穴の種類ごとに直し方がある
穴は一種類ではありません。テストなしなら、誰も知りません。テレメトリーなしなら、データがなく、センサーを扱う人の仕事です。検知なしなら、データはあるのにどのルールも読んでいません。
古くなった合格には再テストが要ります。種類がわかれば、直し方と担当が決まります。
例:穴、直し方、ふだんの担当
| 穴 | 直し方 | ふだんの担当 |
|---|---|---|
| テストなし | アトミックテストを書く | レッド側 |
| テレメトリーなし | データソースを集める | 基盤や IT のチーム |
| 検知なし | ルールを書いて試す | 検知エンジニア |
| 再テスト期限 | テストをやり直す | パープルチーム |
学生が入力するセルは、このプレビューでは空白です。
確認
やってみよう
確認
3問ラボのフォルダーへ行き emu を作る
cd ~/detect && mkdir -p emuここでは表示のみで、実行されません。「ラボを開始」を押すと、自分のラボのターミナルに入力できます。
事務所のテスト履歴を書く
printf '%s\n' 'date,tactic,technique,name,test,outcome' '2026-03-10,Execution,T1059.004,Unix Shell,X1,alert' '2026-03-10,Privilege Escalation,T1548.003,Sudo and Sudo Caching,X2,telemetry' '2026-03-10,Command and Control,T1071.001,Web Protocols,X3,alert' '2026-03-10,Command and Control,T1105,Ingress Tool Transfer,X4,none' '2026-11-16,Discovery,T1033,System Owner/User Discovery,A1,alert' '2026-11-16,Discovery,T1082,System Information Discovery,A2,alert' '2026-11-16,Persistence,T1053.003,Scheduled Task/Job: Cron,A3,alert' '2026-11-16,Collection,T1074.001,Local Data Staging,A4,alert' '2026-11-16,Defense Evasion,T1070.004,File Deletion,A5,telemetry' '2026-11-18,Command and Control,T1071.001,Web Protocols,A6,alert' '-,Exfiltration,T1048,Exfiltration Over Alternative Protocol,-,untested' > emu/history.csvここでは表示のみで、実行されません。「ラボを開始」を押すと、自分のラボのターミナルに入力できます。
報告書を作るスクリプトを書く(その1)
printf '%s\n' 'import csv, sys' 'from datetime import date' 'today = date.fromisoformat(sys.argv[1])' 'TACTIC = {"Command and Control": 3, "Exfiltration": 3, "Persistence": 3, "Privilege Escalation": 3,' ' "Execution": 2, "Defense Evasion": 2, "Collection": 2, "Discovery": 1}' 'GAP = {"no telemetry": 3, "not tested": 2, "no detection": 2, "retest due": 1}' 'FIX = {"no telemetry": "collect the data source", "not tested": "write an atomic test",' ' "no detection": "write and test a rule", "retest due": "run the test again"}' 'OWNER = {"no telemetry": "platform team", "not tested": "red side",' ' "no detection": "detection engineers", "retest due": "purple team"}' 'latest = {}' 'for row in csv.DictReader(open("emu/history.csv")):' ' if row["technique"] not in latest or row["date"] > latest[row["technique"]]["date"]:' ' latest[row["technique"]] = row' 'gaps = []' 'for tid, row in latest.items():' > emu/report.pyここでは表示のみで、実行されません。「ラボを開始」を押すと、自分のラボのターミナルに入力できます。
報告書を作るスクリプトを書く(その2)
printf '%s\n' ' old = row["date"] > "-" and (today - date.fromisoformat(row["date"])).days > 90' ' kind = {"untested": "not tested", "none": "no telemetry", "telemetry": "no detection"}.get(row["outcome"])' ' if row["outcome"] == "alert" and old:' ' kind = "retest due"' ' if kind:' ' score = TACTIC.get(row["tactic"], 1) + GAP[kind]' ' gaps.append((-score, tid, row["tactic"], kind, "high" if score >= 5 else "medium" if score == 4 else "low"))' 'out = open("emu/report.md", "w")' 'out.write("# Purple team report, Riverside office, " + sys.argv[1] + chr(10) + chr(10))' 'out.write("Techniques in the plan: " + str(len(latest)) + ". Gaps: " + str(len(gaps)) + "." + chr(10) + chr(10))' 'out.write("| Priority | Technique | Tactic | Gap | Fix | Owner | Retest by |" + chr(10) + "|---|---|---|---|---|---|---|" + chr(10))' 'for score, tid, tactic, kind, level in sorted(gaps):' >> emu/report.pyここでは表示のみで、実行されません。「ラボを開始」を押すと、自分のラボのターミナルに入力できます。
報告書を作るスクリプトを書く(その3)
printf '%s\n' ' out.write("| " + " | ".join([level, tid, tactic, kind, FIX[kind], OWNER[kind], "2027-01-15"]) + " |" + chr(10))' 'out.close()' 'print("wrote emu/report.md with", len(gaps), "gaps")' >> emu/report.pyここでは表示のみで、実行されません。「ラボを開始」を押すと、自分のラボのターミナルに入力できます。
11 月 20 日の報告書を作る
python3 emu/report.py 2026-11-20ここでは表示のみで、実行されません。「ラボを開始」を押すと、自分のラボのターミナルに入力できます。
報告書を読む
cat emu/report.mdここでは表示のみで、実行されません。「ラボを開始」を押すと、自分のラボのターミナルに入力できます。
確認
やってみよう
確認
3問よくある誤解
注意
公平な報告書は、見つけた順にどの指摘も同じように並べるものだ、と思う人が多くいます。すると読み手は簡単なものだけ直して止まります。ここで攻撃者に何を許すかで穴に順位を付け、それぞれに直し方、担当、日付を付けましょう。
二種類の読み手に書く
経営陣はエグゼクティブサマリーを読みます。何を試し、何が見え、まず直すべき三つは何かを、短く平易な文で書きます。エンジニアは表と、各行の裏付けを読みます。
うまくいったことも書き、誰も責めません。責められたチームは、テストを頼まなくなります。
優先度の高い穴を数える
grep -c "| high |" emu/report.mdここでは表示のみで、実行されません。「ラボを開始」を押すと、自分のラボのターミナルに入力できます。
報告書が次のループを始める
どの行も再テスト日で終わります。その日にパープルチームがテストをやり直し、結果を履歴に入れます。
カバレッジが動くのは何かが直ったからで、地図を塗ったからではありません。モジュール全体が、このループ一つに収まります。
試そう:二つの穴に順位を付ける
TACTIC = {"Command and Control": 3, "Discovery": 1}
GAP = {"no telemetry": 3, "no detection": 2, "retest due": 1}
gaps = [("T1105", "Command and Control", "no telemetry"), ("T1033", "Discovery", "retest due")]
for tid, tactic, kind in gaps:
score = TACTIC[tactic] + GAP[kind]
print(tid, score, "high" if score >= 5 else "medium" if score == 4 else "low")
# ("T1070.004", "Discovery", "no detection") を足してから Run を押そう。
課題:穴に名前と順位を付ける
kind(outcome, age) は、技術の最新の結果から穴の種類を返します。"untested" なら "not tested"、"none" なら "no telemetry"、"telemetry" なら "no detection"、90 日より古い "alert" なら "retest due"、それより新しい警報なら None です。
priority(tactic, gap, weights) は weights[tactic](戦術がなければ 1)に穴の重み(no telemetry は 3、not tested と no detection は 2、retest due は 1)を足します。5 以上なら "high"、4 なら "medium"、それ未満は "low" を返します。
ranked(gaps, weights) は (technique, tactic, gap) のリストを受け取り、(レベル, 技術) の組を合計の大きい順、次に技術の順で返します。
def kind(outcome, age):
# "not tested"、"no telemetry"、"no detection"、"retest due"(90 日より古い警報)、または None。
return None
def priority(tactic, gap, weights):
# 戦術の重み(なければ 1)+ 穴の重み。5 以上 "high"、4 は "medium"、ほかは "low"。
return "low"
def ranked(gaps, weights):
# [(レベル, 技術)] を合計の大きい順、次に技術の順で。
return []
まとめのクイズ
やってみよう