mvd001/cyberset / scripts /net /make_network_docs.py
mvd001's picture
download
raw
29.1 kB
#!/usr/bin/env python3
"""Compute network-tier statistics from data/network/ and write data/network/STATS.md, data/network/README.md,
data/network/net_capture.parquet (one row per source capture/file) and work/net/card_section.md (for the bucket README)."""
import os, json, glob, datetime, duckdb
ROOT = "/workspace/security-dataset"; D = f"{ROOT}/data/network"; W = f"{ROOT}/work/net"
NFUQ_NOTICE = open(f"{ROOT}/scripts/net/nfuq_notice.md").read().strip()
IST = datetime.timezone(datetime.timedelta(hours=5, minutes=30)); now = datetime.datetime.now(IST).strftime("%Y-%m-%d %H:%M IST")
c = duckdb.connect(); c.execute("SET threads=6; SET memory_limit='6GB'")
NF = f"read_parquet('{D}/net_flow/*/*.parquet', hive_partitioning=true)"
fmt = lambda n: f"{int(n):,}" if n is not None else "–"
def table(head, rows):
out = ["| " + " | ".join(head) + " |", "|" + "|".join("---:" if i else "---" for i in range(len(head))) + "|"]
for r in rows: out.append("| " + " | ".join(fmt(x) if isinstance(x, int) and not isinstance(x, bool) else (f"{x:.3f}" if isinstance(x, float) else str(x)) for x in r) + " |")
return "\n".join(out)
size = lambda p: sum(os.path.getsize(f) for f in glob.glob(p, recursive=True) if os.path.isfile(f))
q = lambda s: c.execute(s).fetchall()
by_ds = q(f"""select dataset, count(*), count(*) filter (where label_binary='benign'), count(*) filter (where label_binary='malicious'),
count(feat_cic), count(feat_pkt_seq), count(*) filter (where len(cve_ids) > 0), count(ts_start) from {NF} group by 1 order by 2 desc""")
fam = q(f"select label_family, any_value(label_binary), count(*) from {NF} group by 1 order by 3 desc")
fam_ds = q(f"select dataset, label_family, count(*) from {NF} group by all order by 1, 3 desc")
cve = q(f"select dataset, cve_link_source, count(*), count(distinct cve_ids) from {NF} where len(cve_ids) > 0 group by all order by 1")
cve_ids = q(f"select dataset, cv, count(*) from (select dataset, unnest(cve_ids) cv from {NF}) group by all order by 3 desc")
splits = q(f"select dataset, split_strategy, split, count(*) from {NF} group by all order by 1, 2, 3")
sub = q(f"select dataset, holdout_group, sub_dataset, count(*), count(*) filter (where label_binary='malicious') from {NF} group by all order by 1, 3")
ids = q(f"select dataset, count(*) filter (where ids_sids is not null), count(distinct sid) from (select dataset, ids_sids, unnest(coalesce(ids_sids, [NULL])) sid from {NF} where dataset='ctu13') group by 1")
tot = q(f"select count(*), count(*) filter (where label_binary='benign'), count(*) filter (where label_binary='malicious') from {NF}")[0]
cap = f"{D}/net_capture.parquet"
c.execute(f"""COPY (SELECT capture_id, dataset, any_value(sub_dataset) AS sub_dataset, any_value(holdout_group) AS holdout_group, count(*) AS n_flows,
count(*) filter (where label_binary='malicious') AS n_malicious, min(ts_start) AS ts_min, max(ts_start) AS ts_max, count(feat_pkt_seq) AS n_with_pkt_seq,
any_value(source_license) AS source_license, false AS pcap_published FROM {NF} GROUP BY capture_id, dataset ORDER BY dataset, capture_id)
TO '{cap}' (FORMAT parquet, COMPRESSION zstd)""")
RI = f"{D}/restricted_index"; ri = []
for p in sorted(glob.glob(f"{RI}/dataset=*/index.parquet")):
ds = p.split("dataset=")[1].split("/")[0]; g = f"read_parquet('{p}')"
ri.append((ds,) + q(f"select count(*), count(*) filter (where label_binary='malicious'), count(*) filter (where len(cve_ids) > 0), (select count(distinct cv) from (select unnest(cve_ids) cv from {g})) from {g}")[0])
ri_fam = q(f"select label_family, count(*) from read_parquet('{RI}/dataset=*/index.parquet') where sub_dataset='full_csv' group by 1 order by 2 desc") if ri else []
meta = {os.path.basename(f)[5:-5]: json.load(open(f)) for f in glob.glob(f"{W}/ctu13/join/meta_*.json")}
ctu_rows = [(int(k), m.get("pcap") or "– (not extracted, 70.7 GB)", m.get("pcap_packets"), m.get("pcap_matched"), m.get("pcap_duplicates_dropped"),
m.get("flows_with_seq"), m.get("alerts"), m.get("alerts_matched"), m.get("clock_skew_s_initial")) for k, m in sorted(meta.items(), key=lambda x: int(x[0]))]
nf_bytes = {r[0]: size(f"{D}/net_flow/dataset={r[0]}/*.parquet") for r in by_ds}
# ---- CVE-linked flows: before/after, by source & method, top CVEs, net_alert
BASE = json.load(open(f"{W}/ids/cve_baseline.json"))
cve_tot = q(f"select count(*), (select count(distinct cv) from (select unnest(cve_ids) cv from {NF})) from {NF} where len(cve_ids) > 0")[0]
cve_by = q(f"""select dataset, cve_link_source, label_source, count(*), (select count(distinct cv) from (select unnest(cve_ids) cv from {NF} x
where x.dataset = n.dataset and x.cve_link_source = n.cve_link_source)), round(avg(label_confidence), 3), round(min(label_confidence), 2), round(max(label_confidence), 2)
from {NF} n where len(cve_ids) > 0 group by all order by 4 desc""")
cve_method = q(f"select cve_link_source, count(*), (select count(distinct cv) from (select unnest(cve_ids) cv from {NF} x where x.cve_link_source = n.cve_link_source)) from {NF} n where len(cve_ids) > 0 group by 1 order by 2 desc")
top = q(f"""select cv, count(*) n, string_agg(distinct dataset, ', '), string_agg(distinct cve_link_source, ', '), any_value(label_family),
any_value(array_to_string(cwe_ids[1:3], ' ')) from (select dataset, cve_link_source, label_family, cwe_ids, unnest(cve_ids) cv from {NF}) group by 1 order by 2 desc, 1 limit 20""")
fam_cve = q(f"""select f.label_family, f.n, d.n_cve from (select label_family, count(*) n from {NF} where len(cve_ids) > 0 group by 1) f
join (select label_family, count(distinct cv) n_cve from (select label_family, unnest(cve_ids) cv from {NF}) group by 1) d using (label_family) order by 2 desc""")
NA = f"read_parquet('{D}/net_alert/*/*.parquet', hive_partitioning=true, union_by_name=true)"
na = q(f"""select dataset, count(*), sum(n_alerts), count(distinct sid), count(*) filter (where cve_plausible), count(distinct flow_id) from {NA} group by 1 order by 2 desc""") if glob.glob(f"{D}/net_alert/*/*.parquet") else []
na_top = q(f"""select sid::VARCHAR, any_value(signature), any_value(array_to_string(plausible_cve_ids, ' ')), count(distinct flow_id), sum(n_alerts), any_value(alert_confidence)
from {NA} where cve_plausible group by 1 order by 4 desc limit 15""") if na else []
units = [json.load(open(f)) for f in sorted(glob.glob(f"{W}/ids/*/*/unit_stats.json"))]
if os.path.exists(f"{W}/ids/exploit/summary.json"):
units += [v[k] for v in json.load(open(f"{W}/ids/exploit/summary.json")).values() for k in ("tagged_unit", "ids_unit") if isinstance(v.get(k), dict)]
units += [json.load(open(f)).get("build", {}) for f in sorted(glob.glob(f"{W}/cic2017/*/ids_meta.json"))]
anach = sum(u.get("dropped_anachronistic_flows", 0) for u in units)
# ---- CIC-IDS2017 raw pcaps (one day at a time): pcap -> published cic_ids2017 flow join + Suricata
cic_rows = []
for d in ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]:
mj, ij = f"{W}/cic2017/{d}/meta.json", f"{W}/cic2017/{d}/ids_meta.json"
if not os.path.exists(mj): continue
m = json.load(open(mj)); im = json.load(open(ij)) if os.path.exists(ij) else {}; b = im.get("build", {})
cic_rows.append((d, m.get("pcap"), m.get("pcap_sha256", "")[:16], m.get("packets"), m.get("published_flows"), m.get("matched"), f"{100*m.get('match_rate', 0):.1f} %",
m.get("pcap_ts_min_utc"), m.get("pcap_ts_max_utc"), (im.get("suricata") or {}).get("packets"), (im.get("harvest") or {}).get("eve_alerts"),
b.get("flows", 0), b.get("distinct_cves", 0), im.get("xref_matched", 0)))
CIC_DONE = len(cic_rows) == 5
CIC_COV = ("complete — all 5 days (Monday–Friday)" if CIC_DONE else "days processed so far: " + ", ".join(r[0] for r in cic_rows))
CVE_MD = "\n".join([
f"**Before the IDS / exploit-pcap expansion ({BASE['measured_ist']}): {fmt(BASE['cve_flows'])} CVE-linked flows, {BASE['distinct_cves']} distinct CVEs. "
f"Now: {fmt(cve_tot[0])} CVE-linked flows, {fmt(cve_tot[1])} distinct CVEs.**\n",
"### By method (`cve_link_source`)\n", table(["cve_link_source", "flows", "distinct CVEs"], cve_method),
"\n### By source dataset and method\n", table(["dataset", "cve_link_source", "label_source", "flows", "distinct CVEs", "mean conf", "min", "max"], cve_by),
"\n### Top 20 CVEs by flow count\n", table(["CVE", "flows", "datasets", "method", "label_family", "CWE (first 3)"], top),
"\n### CVE-linked flows by label_family\n", table(["label_family", "flows", "distinct CVEs"], fam_cve),
"\n### net_alert (Suricata alerts on published flows; one row per flow × rule)\n",
table(["dataset", "rows (flow×sid)", "raw alerts", "distinct SIDs", "rows with plausible CVE rule", "flows"], na),
"\nTop CVE rules by flows:\n", table(["sid", "signature", "CVEs (plausible)", "flows", "raw alerts", "alert conf"], na_top),
f"\nTemporal plausibility filter: {fmt(anach)} flows were dropped because every CVE their alerting rule references was assigned *after* the capture year "
"(e.g. a 2024 Zyxel telnet rule firing on 1999 telnet). The ruleset is ET Open for Suricata 7.0.3, snapshot 2026-10-03 (Suricata 7.0.10), "
"CVE subset: 5,914 enabled rules with `reference:cve` + 82 flowbit dependencies (2,430 CVEs); full rule metadata in `ids_rule_meta.parquet` is not published, "
"each net_alert row carries the rule's metadata.\n"])
S = ["# Network tier statistics", f"\n*Generated {now} by `scripts/net/make_network_docs.py` from the published Parquet.*\n",
"## net_flow (features + labels)\n", table(["dataset", "flows", "benign", "malicious", "with feat_cic", "with feat_pkt_seq", "with CVE link", "with ts_start", "size MB"],
[r + (f"{nf_bytes[r[0]]/1e6:,.1f}",) for r in by_ds]),
f"\n**Total: {fmt(tot[0])} flows — {fmt(tot[1])} benign / background, {fmt(tot[2])} malicious.**\n",
"## By label_family (all net_flow datasets)\n", table(["label_family", "binary", "flows"], fam),
"\n## By dataset × label_family\n", table(["dataset", "label_family", "flows"], fam_ds),
"\n## CVE-linked flows\n", CVE_MD,
"\n## Sub-datasets / holdout groups\n", table(["dataset", "holdout_group", "sub_dataset", "flows", "malicious"], sub),
"\n## Splits\n", table(["dataset", "split_strategy", "split", "flows"], splits),
"\n## CTU-13 pcap processing (botnet-only pcaps → feat_pkt_seq, Suricata ET Open)\n",
table(["scenario", "pcap", "packets", "matched", "duplicates dropped", "flows with pkt_seq", "Suricata alerts", "alerts matched to flows", "initial clock skew s"], ctu_rows),
f"\nCTU-13 flows with ≥1 Suricata SID: {fmt(ids[0][1]) if ids else 0} ({fmt(ids[0][2]) if ids else 0} distinct SIDs).\n",
f"\n## CIC-IDS2017 raw pcap processing (one day at a time → cic_ids2017 ts/feat_pkt_seq repair + `cic_ids2017_pcap_ids`)\n\nCoverage: {CIC_COV}.\n",
table(["day", "pcap", "sha256 (16)", "packets", "published flows (day)", "matched (ts + pkt_seq)", "match rate", "pcap first (UTC)", "pcap last (UTC)",
"Suricata packets", "Suricata alerts", "CVE-linked flows", "distinct CVEs", "CVE flows ↔ CIC flow"], cic_rows) if cic_rows else "not processed yet",
"\nA published flow is matched when the pcap holds a run of consecutive packets of its (pseudonymised) 5-tuple starting from its source endpoint with exactly "
"its forward / backward packet counts and a duration within max(2 ms, 0.1 %) of `flow_duration`. Matched flows get `ts_start` / `ts_end` in UTC from the pcap, "
"`feat_pkt_seq` (first 32 packets, no payload) and `feat_native['ts_source'] = 'pcap_utc'`; unmatched flows keep NULL timestamps. CVE-linked flows of "
"`cic_ids2017_pcap_ids` carry the CIC ground-truth label of the cross-referenced flow in `feat_native['xref_label']` — Monday is benign-only, so its "
"CVE alerts are signature hits on benign traffic.\n",
"\n## restricted_index (IDs + labels only, no features)\n", table(["dataset", "rows", "malicious", "with GT CVE", "distinct CVEs"], ri),
"\n### UNSW-NB15 full CSV records by label_family\n", table(["label_family", "records"], ri_fam)]
open(f"{D}/STATS.md", "w").write("\n".join(S) + "\n")
json.dump(dict(by_ds=by_ds, fam=fam, cve=cve, tot=tot, ri=ri, bytes=nf_bytes, cve_tot=cve_tot, cve_by=cve_by, top=top, net_alert=na, anachronistic=anach), open(f"{W}/network_stats.json", "w"), default=str, indent=1)
dsrow = {r[0]: r for r in by_ds}
LAY = "\n".join(f"| `network/net_flow/dataset={r[0]}/` | {fmt(r[1])} flows ({fmt(r[3])} malicious) | {nf_bytes[r[0]]/1e6:,.1f} MB |" for r in by_ds)
NA_LAY = "\n".join(f"| `network/net_alert/dataset={r[0]}/` | {fmt(r[1])} alert rows (flow × Suricata rule; {fmt(r[2])} raw alerts, {fmt(r[3])} SIDs) | {size(f'{D}/net_alert/dataset={r[0]}/*.parquet')/1e6:,.2f} MB |" for r in na)
README = f"""# network/ — flow tier (Stage 5)
Built {now}. Flow-level features and labels from public intrusion-detection datasets, harmonised into one schema (`net_flow`) and linked to
CWE / CAPEC / ATT&CK through the hub's `kb/taxonomy_map`, with CVE ids where they are ground truth. **No packet captures, payload bytes, malware or
exploit traffic are published** (`payload_head` is always NULL). Statistics: `STATS.md`.
{NFUQ_NOTICE}
| Path | What | Size |
|---|---|---:|
{LAY}
{NA_LAY}
| `network/net_capture.parquet` | one row per source capture / file: dataset, flows, malicious flows, time range, licence | {size(cap)/1e6:,.2f} MB |
| `network/restricted_index/dataset=unsw_nb15/index.parquet` | UNSW-NB15: flow IDs + labels + GT CVE ids only (academic-only dataset) | {size(f"{RI}/**/*.parquet")/1e6:,.1f} MB |
| `network/restricted_index/rebuild_unsw_nb15.py` | re-attach UNSW-NB15 features locally after downloading it yourself | |
```sql
-- DuckDB
SELECT dataset, label_family, count(*) FROM read_parquet('hf://buckets/mvd001/cyberset/network/net_flow/*/*.parquet', hive_partitioning=true) GROUP BY ALL;
```
## Schema (`net_flow`, identical for every `dataset=` partition)
| column | meaning |
|---|---|
| `flow_id` | sha256(dataset:source key)[:24] — stable within this release |
| `capture_id`, `sub_dataset`, `source_row_id` | source file / scenario / day, and the row key in the source file (row index, Zeek `uid`, …) |
| `ts_start`, `ts_end` | metadata only (never inside a feature struct). UTC for CTU-13 (binetflow local CEST −2 h) and IoT-23 (Zeek epoch); CSE-CIC-IDS2018 as recorded (zone undocumented); NULL for NF-UQ (no timestamps); CIC-IDS2017: mirror timestamps damaged → NULL, except flows matched to the raw CIC pcaps (UTC from the pcap, `feat_native['ts_source'] = 'pcap_utc'`; {'all 5 days' if CIC_DONE else 'days so far in `STATS.md`'}) |
| `proto`, `l7_proto`, `src_port`, `dst_port` | IANA protocol number, L7 label where the source has one (nDPI id for NF-v2, Zeek `service` for IoT-23), ports (TCP/UDP only) |
| `src_ip_anon`, `dst_ip_anon` | keyed-hash pseudonyms (secret per-release key, not published; consistent within a release, not across releases) |
| `src_ip_scope`, `dst_ip_scope` | private / public / multicast / broadcast / loopback / link_local / ipv6 |
| `feat_core` | NetFlow-v9 / NF-v2 style struct (39 fields, `protocol`, `in_bytes`, `in_pkts`, `out_bytes`, `out_pkts`, `flow_duration_milliseconds`, TTL / packet-length / throughput / TCP-window / DNS / FTP fields …). Complete for NF-UQ; partially derived for the others (in = src→dst) — fields a source lacks are NULL |
| `feat_cic` | CICFlowMeter struct (76 canonical snake_case features) — CIC-IDS2017 (Engelen-corrected) and CSE-CIC-IDS2018 |
| `feat_pkt_seq` | first 32 packets `[{{dir (+1 = src→dst, −1), size (IP total length), iat_ms (since previous packet of the flow), tcp_flags}}]` — CTU-13 botnet flows recovered from the botnet pcaps, and CIC-IDS2017 flows matched to the raw CIC pcaps |
| `feat_native` | `MAP(VARCHAR,VARCHAR)` of source-specific fields that have no harmonised slot (Argus state/dir/ToS, Zeek conn_state/history, CIC RST flags / ICMP / attempted category) |
| `payload_head` | always NULL (no payload published) |
| `label_binary`, `label_family`, `label_original`, `label_detail` | benign / malicious; harmonised family (taxonomy_map); raw source label; finer source detail |
| `cve_ids`, `cve_link_source` | `ground_truth_family` (family with a single CVE, e.g. Heartbleed → CVE-2014-0160); `ids_signature` (an ET Open rule with `reference:cve` alerted on the flow — weak, confidence 0.30–0.50; CVEs assigned after the capture year are filtered out); `exploit_pcap` (the flow comes from a capture whose name / README pins the CVE — strong, 0.6–0.95) |
| `ids_sids` | Suricata ET Open SIDs that fired on the flow (rules from the hub's ET Open snapshot 2026-10-03); details per alert in `net_alert` |
| `cwe_ids`, `capec_ids`, `attack_techniques` | from the family's curated taxonomy_map entry (weak, family-level) |
| `label_source`, `label_confidence` | `dataset_gt` (labels shipped with the dataset), `ids_signature` (pcap datasets labelled only by Suricata: only CVE-alerted flows are published, label = malicious, confidence = 0.30 + 0.10/0.05 for ET confidence High/Medium + 0.10/0.05 for signature_severity Major-Critical/Minor), `exploit_pcap` (capture-level CVE tag: 0.85 exploit capture, 0.7/0.6 MS17-010 probes, +0.1 (max 0.95) when Suricata alerts on the same CVE; DNS/NetBIOS/DHCP noise flows → benign 0.5; benign counterpart captures → benign 0.9); confidence per dataset/label otherwise (e.g. CTU-13 Background 0.4, Engelen '- Attempted' 0.6) |
| `holdout_group`, `split`, `split_strategy` | cross-dataset holdout key and within-dataset time / order split (80/10/10) |
| `source_license` | licence of the upstream dataset |
## `net_alert` (Suricata alerts, one row per flow × rule)
| column | meaning |
|---|---|
| `alert_id`, `flow_id`, `dataset`, `capture_id`, `sub_dataset` | sha256(flow_id, sid)[:24]; joins to `net_flow.flow_id` |
| `ts`, `ts_last`, `n_alerts` | first / last alert time (UTC) and number of raw alerts of this rule on the flow |
| `sid`, `gid`, `rev`, `signature`, `category`, `classtype`, `severity`, `action`, `directions`, `app_proto` | Suricata alert fields |
| `rule_cve_ids`, `is_cve_rule`, `plausible_cve_ids`, `cve_plausible` | CVEs in the rule's `reference:cve`; those assigned no later than the capture year |
| `alert_confidence` | confidence the alert gives the CVE link (see `label_source=ids_signature`) |
| `signature_severity`, `rule_confidence`, `rule_metadata` | ET rule metadata (JSON: attack_target, deployment, mitre_*, created/updated_at, …) |
| `ruleset`, `engine` | pinned ET Open snapshot (`sources.yaml` → `et_open`) and Suricata version |
| `src_ip_anon`, `dst_ip_anon`, `src_port`, `dst_port`, `proto` | of the first alert (same keyed pseudonyms as net_flow) |
## Datasets
| dataset | source | licence | notes |
|---|---|---|---|
| `cic_ids2017` | CIC-IDS2017, Engelen et al. 2021 corrected flows (fixed CICFlowMeter, relabelled) | UNB CIC research terms (cite Sharafaldin 2018 + Engelen 2021) | The DistriNet server rejects TLS from the build host; CSVs come from the unofficial HF mirror `bvk/CICIDS-2017@b9515d5` (Engelen files, IPs as decimals, 5 inf rows removed, Timestamp damaged → ts NULL, split by row order). '- Attempted' attacks → benign (authors' recommendation). the raw CIC pcaps (cicresearch.ca, registration form; fetched one day at a time; {'all 5 days processed' if CIC_DONE else 'partial, see `STATS.md`'}) recover `ts_start` / `ts_end` (UTC) and `feat_pkt_seq` for matched flows, see `STATS.md` |
| `nf_uq_nids_v2` | NF-UQ-NIDS-v2 (Sarhan, Layeghy, Portmann 2022), UQ RDM | UQ "Permitted Re-Use with Commercial Use Restriction" (non-commercial, attribution) | NetFlow v2 (43 nProbe features) re-extracted from UNSW-NB15, BoT-IoT, ToN-IoT and CSE-CIC-IDS2018 pcaps; `sub_dataset` = source dataset. No timestamps → split by source row order |
{NFUQ_NOTICE}
| `ctu13` | CTU-13 (Garcia et al. 2014), Stratosphere Lab | CC BY | Argus bidirectional binetflows of all traffic; Botnet / Normal / Background labels; first-32-packet sequences + Suricata SIDs recovered from the botnet-only pcaps (scenario 10's 70.7 GB pcap skipped) |
| `iot23` | IoT-23 (Garcia, Parmisano, Erquiaga 2020) | CC BY | labelled Zeek conn.log flows only (no pcaps) |
| `cse_cic_ids2018` | CSE-CIC-IDS2018 "Processed Traffic Data for ML Algorithms" from `s3://cse-cic-ids2018` | CIC/UNB research terms (Registry of Open Data on AWS) | original CICFlowMeter output (not corrected); only 20-02-2018 has IPs |
| `unsw_nb15` (restricted_index) | UNSW-NB15 (Moustafa & Slay 2015) | academic / research use only | IDs + labels + GT CVE ids only; features via `rebuild_unsw_nb15.py` |
| `cse_cic_ids2018_pcap_ids` | CSE-CIC-IDS2018 **raw pcaps** (`s3://cse-cic-ids2018/Original Network Traffic and Log data/<day>/pcap.zip`), streamed per member, repaired, read offline by Suricata | CIC/UNB research terms (AWS Open Data) | only flows alerted by a CVE rule (`ids_signature`); 9 of 10 days (20-02-2018 is a 44 GB `.rar` without range access → skipped) |
| `cic_ids2017_pcap_ids` | CIC-IDS2017 **raw pcaps** (cicresearch.ca, one pcap per day, deleted after processing), read offline by Suricata | UNB CIC research terms | only flows alerted by a CVE rule (`ids_signature`), each cross-referenced to the published `cic_ids2017` flow (`feat_native` xref_flow_id / xref_label); {'all 5 days processed' if CIC_DONE else 'days processed so far in `STATS.md`'} |
| `maccdc` | MACCDC 2010–2012 captures (National CyberWatch Mid-Atlantic CCDC, distributed by Netresec) | no explicit licence (public download); derived features only | only CVE-alerted flows (`ids_signature`); `sub_dataset` = year |
| `darpa1999` | 1999 DARPA Intrusion Detection Evaluation (MIT Lincoln Laboratory; Lippmann et al. 2000) | public release, no explicit licence; derived features only | inside/outside tcpdump of weeks 1–5; only CVE-alerted flows; CVE ids after 1999 filtered as anachronistic |
| `nccgroup_f5_honeypot` | NCC Group F5 BIG-IP honeypot capture, July 2020 (in-the-wild CVE-2020-5902 exploitation) — GitHub `nccgroup/Cyber-Defence` | no licence file; derived features only | only CVE-alerted flows (`ids_signature`) |
| `container_honeypot_raid2023` | Container-orchestration honeypots (Docker, k3s/Kubernetes, Spinnaker, Airflow, MySQL; Spahn et al., RAID 2023), Netresec share | no explicit licence; derived features only | sample: ≤ 40 files / ≤ 2 GB per service directory; only CVE-alerted flows; `sub_dataset` = honeypot service |
| `first2015_netforensics` | FIRST 2015 Hands-on Network Forensics training PCAPs (Netresec mirror) | no explicit licence; derived features only | only CVE-alerted flows |
| `wrccdc` | WRCCDC public PCAP archive, 2026 qualifiers — 64 files evenly spaced over the event (of 5,647) | no explicit licence; derived features only | only CVE-alerted flows (red-team activity) |
| `exploit_pcap` | ExploitPcapCollection (safest-place), selected-cve-dataset-2024 (V. Moholivskyi), curveball_lua (D. Lee; CVE-2020-0601) — GitHub; Shadowbrokers PCAPs (E. Conrad; EternalBlue / EternalRomance / EsteemAudit) — Dropbox | **no licence** in any of the four collections (all rights reserved by default): only derived flow features + labels are published, never pcaps or payloads | captures whose filename / README pins a CVE → all flows `exploit_pcap`; untagged captures → only CVE-alerted flows (`ids_signature`); split by CVE group hash |
## Evaluation protocol
- **Cross-dataset:** hold out a whole `holdout_group` (`cic_ids2017`, `ctu13`, `iot23`, `cse_cic_ids2018`, `NF-UNSW-NB15-v2`, `NF-BoT-IoT-v2`,
`NF-ToN-IoT-v2`, `NF-CSE-CIC-IDS2018-v2`). Caveat: `NF-CSE-CIC-IDS2018-v2` and `cse_cic_ids2018` come from the **same pcaps** (different
extractors) — never train on one and test on the other; likewise `NF-UNSW-NB15-v2` and the UNSW-NB15 restricted index.
- **Within-dataset:** `split` (first 80 % train / 10 % val / last 10 % test in time per day/scenario where timestamps exist; source order otherwise).
- Feature families differ per dataset: `feat_core` is the only struct present everywhere (partially); `feat_cic` only for CIC datasets.
## Limitations
- CIC-IDS2017 comes from an unofficial mirror of Engelen's corrected CSVs (provenance documented, sha256 in `sources.yaml`), with damaged timestamps.
- CSE-CIC-IDS2018 flows are the original (uncorrected) CICFlowMeter output with known artefacts; Engelen/Liu's corrected 2018 files were unreachable.
8 of the 10 S3 day files stop at 1,048,575 rows (the Excel row limit — the upstream processed CSVs are truncated); 14 benign rows carry 1970 timestamps (source artefact, kept).
- NF-UQ-NIDS-v2 rows are interleaved and have no timestamps; its source-order split is effectively random. Its upstream pcaps include UNSW-NB15,
BoT-IoT and ToN-IoT (academic-only); the NF-v2 derivative is published by UQ under its own non-commercial licence, which this release follows.
- CTU-13 `background` flows (96 % of CTU-13) are unlabelled real traffic, mapped to benign with confidence 0.4. `feat_pkt_seq` exists only for
flows of the infected hosts (pcaps are botnet-only), so its presence leaks the label — do not use it as a feature across classes.
- Suricata alerts were produced with today's ET Open rules on 1999–2024 traffic; CVE links from them are weak (`ids_signature`). Legacy policy rules
dominate some sources — e.g. `GPL SNMP public access udp` (CVE-1999-0517 / CVE-2002-0012/0013) fires on ordinary SNMP polling with the default
community — so filter on `alert_confidence`, `classtype` or `sid` (via `net_alert`) for a stricter set. Pcap-derived datasets publish only the
CVE-alerted flows (no benign background from those captures). Timestamps of pcap-derived flows are UTC.
- `exploit_pcap` labels are capture-level: every non-noise flow of a CVE-named capture gets that CVE, including handshake / setup flows.
- `cwe_ids` / `capec_ids` / `attack_techniques` are family-level, not per-flow.
- IP pseudonyms are not comparable across datasets in a meaningful way (different networks) and change between releases.
"""
open(f"{D}/README.md", "w").write(README)
SHORT_LIC = {"iot23": "CC BY (Stratosphere Lab)", "ctu13": "CC BY (Stratosphere Lab)", "nf_uq_nids_v2": "**NON-COMMERCIAL research use only** (UQ; cite Sarhan et al. + upstream)",
"cse_cic_ids2018": "UNB CIC research terms (AWS Open Data)", "cic_ids2017": "UNB CIC research terms; Engelen et al. corrected flows",
"cse_cic_ids2018_pcap_ids": "UNB CIC research terms (AWS Open Data); Suricata-derived", "cic_ids2017_pcap_ids": "UNB CIC research terms; Suricata-derived", "maccdc": "no explicit licence (Netresec public share); derived features only",
"darpa1999": "MIT LL public release (no explicit licence); derived features only",
"exploit_pcap": "**no upstream licence** — derived flow features + labels only, no pcaps/payloads",
"nccgroup_f5_honeypot": "no licence file (NCC Group GitHub); derived features only", "container_honeypot_raid2023": "no explicit licence (Netresec share; Spahn et al. 2023); derived features only",
"first2015_netforensics": "no explicit licence (Netresec mirror); derived features only", "wrccdc": "no explicit licence (archive.wrccdc.org); derived features only"}
CARD = f"""## Network tier (`network/`)
**{fmt(tot[0])} flows** ({fmt(tot[1])} benign/background, {fmt(tot[2])} malicious) from {len(by_ds)} public IDS datasets in one `net_flow` schema
(NetFlow-style `feat_core`, CICFlowMeter `feat_cic`, first-32-packet `feat_pkt_seq`), partitioned by `dataset`, with harmonised `label_family`
→ CWE/CAPEC/ATT&CK and ground-truth / IDS-signature CVE links. UNSW-NB15 (academic-only) is an ID+label index with a rebuild script.
No pcaps, payloads or malware. Details: `network/README.md`; statistics: `network/STATS.md`.
**CVE-linked flows: {fmt(cve_tot[0])} ({fmt(cve_tot[1])} distinct CVEs)**, up from {fmt(BASE['cve_flows'])} ({BASE['distinct_cves']}) — Suricata 7.0.10 + pinned ET Open
CVE rules over public pcaps (CSE-CIC-IDS2018, CIC-IDS2017 (day by day), MACCDC, DARPA 1999, WRCCDC, FIRST 2015, NCC Group F5 and RAID-2023 container honeypots; `ids_signature`, confidence 0.30–0.50, alerts in `network/net_alert/`) and CVE-tagged
exploit pcap collections (`exploit_pcap`, 0.6–0.95; the upstream repos have no licence, so only derived features and labels are published).
{('CIC-IDS2017 raw pcap coverage ' + CIC_COV + ' — ' + fmt(sum(r[5] for r in cic_rows)) + ' published `cic_ids2017` flows matched to the pcap now have UTC `ts_start` / `ts_end` and `feat_pkt_seq`.' + chr(10)) if cic_rows else ''}
| dataset | flows | malicious | licence |
|---|---:|---:|---|
""" + "\n".join(f"| {r[0]} | {fmt(r[1])} | {fmt(r[3])} | {SHORT_LIC.get(r[0], '')} |" for r in by_ds) + \
"".join(f"\n| {r[0]} (restricted_index) | {fmt(r[1])} | {fmt(r[2])} | academic-only — IDs/labels only |" for r in ri) + "\n" + "\n" + NFUQ_NOTICE + "\n"
open(f"{W}/card_section.md", "w").write(CARD); print("network docs written", tot)

Xet Storage Details

Size:
29.1 kB
·
Xet hash:
870671e7130aa397964a5261ca968a1c1e2c12ab4b0f44e34b7f380b66b4b1de

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.