# PE malware / benign dataset with a temporal split (2021–2026) 72,669 Windows PE files: malware from MalwareBazaar, benign software from the Scoop and winget package catalogues. Split by time: train = first seen up to 2024, validation = 2025, test = 2026. ## ⚠️ Safety warning This dataset contains **real, live Windows malware**. This repository holds **no binaries**: only a manifest (hashes, labels, sources), number-only features, and a script that re-downloads the files from their original sources. - Build it on **Linux only**. Never run, open or double-click any file it produces. - Do not install Wine on the machine that holds the samples (the script refuses to run if it finds it). - Recommended: build into a directory mounted `noexec`. - Never upload or redistribute the binaries. ## Files in this folder | File | Contents | |---|---| | `manifest.csv` | One row per file: hash, label, source, split, size and extra columns (below) | | `build_dataset.py` | Re-downloads every file, checks its SHA-256 and writes `data///` | | `features.parquet` | Per file: size, byte entropy, 256-bin byte histogram, a few PE header numbers. No raw bytes | | `collection_summary.csv` | How many files were collected, dropped and kept at each step | ## How to build ```bash sudo apt install 7zip # the only dependency besides Python 3.9+ python dataset/build_dataset.py ``` Every file is verified against the SHA-256 in the manifest and stored read-only, named by its hash. A full build downloads 941 MalwareBazaar daily archives and 14,447 software packages (hundreds of GB of downloads; only the listed files are kept, about 156 GB). For a quick check (a few minutes): ```bash python dataset/build_dataset.py --limit-days 1 --limit-containers 60 ``` That quick check was run on 2026-11-17 and rebuilt 147 of 147 files. Upstream files can disappear over time; the script reports how many could not be rebuilt. ## Contents | Split | Period | Benign | Malware | Total | Malware share | |---|---|---|---|---|---| | train | 2021–2024 | 23,947 | 36,839 | 60,786 | 60.6% | | val | 2025 | 2,874 | 2,599 | 5,473 | 47.5% | | test | 2026 (Jan–Nov) | 4,281 | 2,129 | 6,410 | 33.2% | | **all** | | **31,102** | **41,567** | **72,669** | 57.2% | | Source | Label | Files | |---|---|---| | `malwarebazaar` | malware | 41,567 (1,195 families) | | `scoop` | benign | 21,750 | | `winget` | benign | 9,352 | All files are Windows PE files, verified by the `MZ` and `PE\0\0` signatures. No SHA-256 appears twice and no file is in more than one split. ### `manifest.csv` columns | Column | Meaning | |---|---| | `sha256` | SHA-256 of the file | | `label` | 0 = benign, 1 = malware | | `source` | `malwarebazaar`, `scoop` or `winget` | | `split` | `train`, `val` or `test` | | `size_bytes` | File size | | `format` | Always `pe` | | `arch` | CPU architecture from the PE header (`x86`, `x86-64`, …) | | `kind` | `exe` (program) or `dll` (library), from the PE header flag | | `date` | Malware: date of the MalwareBazaar daily archive. Benign: Scoop quarterly snapshot that first contained the release, or the winget release date | | `family` | Malware family name from MalwareBazaar, normalised (lower case, aliases merged); empty if none | | `group` | Near-duplicate group: malware family, or benign app name | | `seen_in_train` | 1 if this family (malware) or app (benign) also occurs in the training split | | `packed_hint` | 1 if a section has entropy > 7.2 or UPX-style section names (rough heuristic) | | `container_url`, `container_sha256`, `inner_path` | Benign only: the package the file came from and its path inside it (empty `inner_path` = the package itself) | ## Sources and licences | Source | Used for | Licence / terms | |---|---|---| | [MalwareBazaar](https://bazaar.abuse.ch/) daily archives (abuse.ch) | Malware files, family names, dates | Data shared under CC0; use is subject to the abuse.ch terms of use | | [Scoop](https://scoop.sh/) buckets `Main`, `Extras`, `Versions` | Download URL, SHA-256 and date of benign releases | Catalogues: Unlicense. Each program has its own licence | | [winget-pkgs](https://github.com/microsoft/winget-pkgs) | Download URL, SHA-256 and release date of benign releases | Catalogue: MIT. Each program has its own licence | This repository redistributes none of the programs: only their hashes and public download URLs. ## How it was built 1. **Malware.** 941 MalwareBazaar daily archives between January 2021 and November 2026 were downloaded (442,385 files). Files were identified by magic bytes; 277,882 were Windows PE files. The first round kept every executable from the 1st and 15th of each month; later rounds saved only files needed to fill each family up to the cap. 2. **Benign.** The Scoop catalogues were read at 24 quarterly points in their git history and the winget catalogue by release date. Releases were downloaded, verified against the catalogue's SHA-256, unpacked with 7-Zip, and a limited number of programs and libraries kept per release. Packages over 80 MB were skipped. 3. **Split by time**, for both classes: ≤ 2024 train, 2025 validation, 2026 test. Nothing was executed at any point: files were unpacked by 7-Zip onto a `noexec` disk and read as bytes. ## Keep / drop decisions | Decision | Reason | Files affected | |---|---|---| | Windows PE only | One file format for the model; ELF and Mach-O were collected but not used | 164,503 non-PE files in the archives | | Dropped malware with no entry in MalwareBazaar's metadata | No date or family, so no label evidence | 3,916 | | Train/val malware must have a family name | A missing family is the most likely place for a wrong label | 3,216 | | At most 300 files per family per split (train, val) | Otherwise a few families dominate and the model learns those families | 10,249 | | Test keeps malware with no family name | Dropping them would remove the newest threats | 550 kept in test | | Dropped files that appear as both benign and malware | Dual-use tools: the label is ambiguous | 52 benign, 8 malware | | Dropped files over 16 MB (both classes) | Same size ceiling for both classes | 1,279 benign, 725 malware | | Dropped files whose PE header could not be parsed | Corrupted | 7 benign, 7 malware | | Identical benign files kept once | The same library ships in many packages | 10,882 copies | | Benign libraries downsampled in train/val to the malware's library share | Otherwise "library = benign" is a shortcut; after matching, that flag alone scores AUC 0.50 | 4,742 | | Test set left unmatched | Report results per group instead | — | | Time split instead of random split | A random split of the same files scores AUC 0.989 against 0.923 on the 2026 test set | — | ## Known limitations - **Source equals label.** All malware comes from one site and all benign files from two package catalogues. Commercial software, games and drivers are under-represented. - **Packing bias.** 47% of training malware looks packed against 10% of benign. - **32/64-bit mismatch.** 85% of training malware is 32-bit x86 against 51% of benign. - **Near-copies across splits.** 45% of test malware and 23% of test benign files share an import hash with a training file. Use `seen_in_train` to report new families and apps separately. - **Family names are noisy.** They come from automated rules and submitters. - **Dates are approximate.** Malware dates are submission dates; Scoop dates are quarterly. - **Test ratio.** About 2 benign files per malware file, far from real-world prevalence. - **Class balance differs per split** (60.6% / 47.5% / 33.2% malware), so compare AUC and balanced accuracy, not plain accuracy. ## Baseline (byte histogram + entropy + size, gradient-boosted trees, nothing tuned) | | val (2025) | test (2026) | |---|---|---| | AUC | 0.980 | 0.923 | | Detection at 1% false positives | 80.0% | 43.3% | On test, the baseline detects 52% of malware from families seen in training, 35% from new families and 33% of files with no family name. See `notebooks/data_exploration.ipynb`.