-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_bittorrent_docs.sh
More file actions
executable file
·228 lines (177 loc) · 6.73 KB
/
Copy pathinstall_bittorrent_docs.sh
File metadata and controls
executable file
·228 lines (177 loc) · 6.73 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
#!/usr/bin/env bash
#
# install_bittorrent_docs.sh
#
# Idempotent documentation wiring for the curated BitTorrent summary:
# - evidence/derived/pcap_csv_archive/README.md
# - references in:
# OPTION_D_PACKET_LEVEL_VERIFICATION.md
# README.md
#
# Assumes:
# - bittorrent_summary.csv already created by build_bittorrent_summary.sh
# - SHA-256 known / reproducible
#
# Usage:
# ./install_bittorrent_docs.sh
set -euo pipefail
say() { printf '%s\n' "$*" >&2; }
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
if [[ -z "$REPO_ROOT" ]]; then
say "ERROR: Must be run from inside the forensics-review repository."
exit 1
fi
cd "$REPO_ROOT"
BITTORRENT_DIR="$REPO_ROOT/evidence/derived/pcap_csv_archive"
SUMMARY_PATH="$BITTORRENT_DIR/bittorrent_summary.csv"
if [[ ! -f "$SUMMARY_PATH" ]]; then
say "ERROR: Expected summary not found:"
say " $SUMMARY_PATH"
say "Run stage_and_build_bittorrent_summary.sh first."
exit 1
fi
SUMMARY_SHA="$(sha256sum "$SUMMARY_PATH" | cut -d' ' -f1)"
say "=== Repo root ==="
say " $REPO_ROOT"
say ""
say "=== bittorrent_summary.csv ==="
say " Path: $SUMMARY_PATH"
say " SHA-256: $SUMMARY_SHA"
say ""
###############################################################################
# 1) evidence/derived/pcap_csv_archive/README.md
###############################################################################
DEST_README="$BITTORRENT_DIR/README.md"
say "=== Writing evidence/derived/pcap_csv_archive/README.md ==="
mkdir -p "$BITTORRENT_DIR"
cat > "$DEST_README" << EOF_INNER
# PCAPdroid-Derived PCAP CSV Archive (HappyMod Window)
This directory contains curated CSV exports derived from PCAPdroid packet
captures associated with the HappyMod investigation window.
## Contents
- \`PCAPdroid_*.csv\`
Raw flow-level CSV exports from PCAPdroid, filtered and curated for the
Option D packet-level verification.
- \`bittorrent_hits.csv\`
Manually curated subset focusing on flows classified as BitTorrent by
PCAPdroid.
- \`mintegral_hits.csv\`
Manually curated subset focusing on flows associated with the Mintegral
ad/telemetry infrastructure (e.g., \`configure-tcp.rayjump.com\`).
- \`bittorrent_summary.csv\`
Machine-generated aggregation of flows where \`protocol == "BitTorrent"\`
across the above CSVs. Intended for cross-checkable, non-interpretive
packet-level verification, not for legal or policy conclusions.
## bittorrent_summary.csv
- Path (repo-relative):
\`\`\`
evidence/derived/pcap_csv_archive/bittorrent_summary.csv
\`\`\`
- SHA-256:
\`\`\`
$SUMMARY_SHA
\`\`\`
- Generation procedure (reproducible):
1. Ensure the curated source CSVs are present under
\`~/arch/root/pcap_csv_archive\` (or another authoritative archive)
including:
- \`PCAPdroid_13_Sep_22_02_08.csv\`
- \`PCAPdroid_17_Aug_20_53_38.csv\`
- \`PCAPdroid_22_Jun_18_22_50.csv\`
- \`PCAPdroid_24_Jun_21_02_38.csv\`
- \`PCAPdroid_28_Jul_01_41_40.csv\`
- \`PCAPdroid_28_Jul_06_40_58.csv\`
- \`bittorrent_hits.csv\`
- \`mintegral_hits.csv\`
2. From within the \`forensics-review\` repo (Termux):
\`\`\`bash
cd "$HOME/repos/forensics-review"
# 2a) Stage curated CSVs into the evidence tree:
./stage_and_build_bittorrent_summary.sh
# 2b) The script will:
# - discover the authoritative pcap_csv_archive under \$HOME
# - copy the CSVs into:
# evidence/derived/pcap_csv_archive/
# - run:
# ./build_bittorrent_summary.sh evidence/derived/pcap_csv_archive
\`\`\`
3. The resulting \`bittorrent_summary.csv\` should have SHA-256:
\`\`\`
$SUMMARY_SHA
\`\`\`
## Scope and Limitations
- This directory and its derived summary are strictly descriptive of observed
network flows (as represented in the CSV exports).
- No claims are made here regarding user identity, intent, or legality.
EOF_INNER
say " Wrote: $DEST_README"
say ""
###############################################################################
# 2) Wire into OPTION_D_PACKET_LEVEL_VERIFICATION.md (if not already)
###############################################################################
OPTION_D="$REPO_ROOT/OPTION_D_PACKET_LEVEL_VERIFICATION.md"
if [[ -f "$OPTION_D" ]]; then
if grep -q 'bittorrent_summary.csv' "$OPTION_D"; then
say "=== OPTION_D already references bittorrent_summary.csv; leaving as-is. ==="
else
say "=== Appending BitTorrent CSV section to OPTION_D_PACKET_LEVEL_VERIFICATION.md ==="
cat >> "$OPTION_D" << EOF_INNER
## Derived BitTorrent CSV Summary
For convenience in cross-checking BitTorrent-related flows across the
PCAPdroid-derived CSVs, this repository includes a machine-generated summary:
- File: \`evidence/derived/pcap_csv_archive/bittorrent_summary.csv\`
- SHA-256:
\`\`\`
$SUMMARY_SHA
\`\`\`
This artifact is derived by applying a simple filter over the curated
\`pcap_csv_archive\` CSVs where \`protocol == "BitTorrent"\`. It is provided
only as a non-interpretive aggregation to simplify packet-level verification.
EOF_INNER
fi
else
say "WARNING: OPTION_D_PACKET_LEVEL_VERIFICATION.md not found; skipping Option D wiring."
fi
say ""
###############################################################################
# 3) Wire into root README.md (if not already)
###############################################################################
ROOT_README="$REPO_ROOT/README.md"
if [[ -f "$ROOT_README" ]]; then
if grep -q 'bittorrent_summary.csv' "$ROOT_README"; then
say "=== Root README already references bittorrent_summary.csv; leaving as-is. ==="
else
say "=== Appending Derived BitTorrent Summary section to README.md ==="
cat >> "$ROOT_README" << EOF_INNER
## Derived BitTorrent Summary (HappyMod Window)
The \`evidence/derived/pcap_csv_archive\` directory contains curated PCAPdroid
CSV exports and a machine-generated BitTorrent summary:
- \`evidence/derived/pcap_csv_archive/bittorrent_summary.csv\`
- Description: aggregation of rows where \`protocol == "BitTorrent"\` across
the curated PCAPdroid CSVs for the HappyMod observation window.
- SHA-256:
\`\`\`
$SUMMARY_SHA
\`\`\`
See \`evidence/derived/pcap_csv_archive/README.md\` for generation steps and
scope limitations.
EOF_INNER
fi
else
say "WARNING: README.md not found; skipping README wiring."
fi
say ""
###############################################################################
# 4) Final summary
###############################################################################
say "=== Documentation wiring complete ==="
say " - $DEST_README"
if [[ -f "$OPTION_D" ]]; then
say " - $OPTION_D (BitTorrent section ensured)"
fi
if [[ -f "$ROOT_README" ]]; then
say " - $ROOT_README (BitTorrent section ensured)"
fi
say ""
say "You can now review changes via:"
say " git diff"