mjbommar commited on
Commit
2fe176a
Β·
verified Β·
1 Parent(s): a3cb134

Add comprehensive README with split statistics and stratification details

Browse files
Files changed (1) hide show
  1. README.md +281 -95
README.md CHANGED
@@ -1,97 +1,283 @@
1
  ---
2
- dataset_info:
3
- features:
4
- - name: file_id
5
- dtype: string
6
- - name: file_path
7
- dtype: string
8
- - name: file_name
9
- dtype: string
10
- - name: sha256
11
- dtype: string
12
- - name: md5
13
- dtype: string
14
- - name: file_size
15
- dtype: int64
16
- - name: platform
17
- dtype: string
18
- - name: os_family
19
- dtype: string
20
- - name: os_version
21
- dtype: string
22
- - name: distribution
23
- dtype: string
24
- - name: is_malware
25
- dtype: bool
26
- - name: file_format
27
- dtype: string
28
- - name: architecture
29
- dtype: string
30
- - name: binary_type
31
- dtype: string
32
- - name: is_stripped
33
- dtype: bool
34
- - name: is_packed
35
- dtype: bool
36
- - name: is_signed
37
- dtype: bool
38
- - name: sections
39
- struct:
40
- - name: name
41
- list: string
42
- - name: size
43
- list: int64
44
- - name: entropy
45
- list: float32
46
- - name: num_sections
47
- dtype: int32
48
- - name: code_size
49
- dtype: int64
50
- - name: data_size
51
- dtype: int64
52
- - name: imports
53
- list: string
54
- - name: num_imports
55
- dtype: int32
56
- - name: exports
57
- list: string
58
- - name: num_exports
59
- dtype: int32
60
- - name: entropy
61
- dtype: float32
62
- - name: token_count
63
- dtype: int32
64
- - name: compression_ratio
65
- dtype: float32
66
- - name: unique_tokens
67
- dtype: int32
68
- - name: parse_status
69
- dtype: string
70
- - name: parse_warnings
71
- list: string
72
- - name: has_tokens
73
- dtype: bool
74
- - name: tokens
75
- list: int32
76
- splits:
77
- - name: train
78
- num_bytes: 16963298476
79
- num_examples: 20849
80
- - name: validation
81
- num_bytes: 3506519849
82
- num_examples: 4463
83
- - name: test
84
- num_bytes: 3504547971
85
- num_examples: 4481
86
- download_size: 10815742101
87
- dataset_size: 23974366296
88
- configs:
89
- - config_name: default
90
- data_files:
91
- - split: train
92
- path: data/train-*
93
- - split: validation
94
- path: data/validation-*
95
- - split: test
96
- path: data/test-*
97
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: cc-by-4.0
3
+ task_categories:
4
+ - other
5
+ language:
6
+ - en
7
+ tags:
8
+ - binary-analysis
9
+ - malware-detection
10
+ - cybersecurity
11
+ - cross-platform
12
+ - tokenized
13
+ - stratified-splits
14
+ size_categories:
15
+ - 10K<n<100K
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  ---
17
+
18
+ # Binary-30K: Cross-Platform Binary Dataset with Stratified Splits
19
+
20
+ **πŸ”— Original Dataset (no splits):** [`mjbommar/binary-30k-tokenized`](https://huggingface.co/datasets/mjbommar/binary-30k-tokenized)
21
+
22
+ This is the **stratified train/validation/test split version** of the Binary-30K dataset, containing **29,793 unique cross-platform binaries** with pre-computed tokenization. This version provides standardized splits for reproducible machine learning research.
23
+
24
+ ## 🎯 Key Features
25
+
26
+ - βœ… **Stratified 70/15/15 splits** maintaining class balance across all sets
27
+ - βœ… **4-dimensional stratification** across malware/platform/format/architecture
28
+ - βœ… **26.9% malware balance** preserved in all splits (Β±0.1%)
29
+ - βœ… **Deterministic splits** (seed=42) for reproducible research
30
+ - βœ… **Ready for ML** - no manual splitting required
31
+ - βœ… **Pre-computed BPE tokenization** for transformer models
32
+
33
+ ## πŸ“Š Dataset Splits
34
+
35
+ | Split | Samples | Malware | Benign | Malware % |
36
+ |-------|---------|---------|--------|-----------|
37
+ | **Train** | 20,849 | 5,613 | 15,236 | 26.92% |
38
+ | **Validation** | 4,463 | 1,200 | 3,263 | 26.89% |
39
+ | **Test** | 4,481 | 1,210 | 3,271 | 27.00% |
40
+ | **Total** | 29,793 | 8,023 | 21,770 | 26.93% |
41
+
42
+ ### Stratification Strategy
43
+
44
+ Splits maintain proportional representation across:
45
+ - βœ… **Malware vs. Benign** (26.9% malware in each split)
46
+ - βœ… **Platform** (Windows, Linux, macOS, Android, Other)
47
+ - βœ… **File Format** (PE, ELF, Mach-O, APK)
48
+ - βœ… **Architecture Groups** (common: x86/ARM vs. exotic: MIPS/RISC-V/PowerPC)
49
+
50
+ **19 unique strata identified** with proportional representation maintained across all splits.
51
+
52
+ ## πŸš€ Quick Start
53
+
54
+ ```python
55
+ from datasets import load_dataset
56
+
57
+ # Load dataset with splits
58
+ dataset = load_dataset("mjbommar/binary-30k")
59
+
60
+ train_ds = dataset["train"] # 20,849 samples
61
+ val_ds = dataset["validation"] # 4,463 samples
62
+ test_ds = dataset["test"] # 4,481 samples
63
+
64
+ # Access pre-computed tokens
65
+ sample = train_ds[0]
66
+ print(f"Platform: {sample['platform']}")
67
+ print(f"Malware: {sample['is_malware']}")
68
+ print(f"Tokens: {len(sample['tokens'])} tokens")
69
+ ```
70
+
71
+ ### Example: Malware Classification
72
+
73
+ ```python
74
+ from datasets import load_dataset
75
+ from transformers import Trainer, TrainingArguments
76
+
77
+ # Load data
78
+ dataset = load_dataset("mjbommar/binary-30k")
79
+
80
+ # Tokens are pre-computed - just truncate
81
+ def prepare_example(example):
82
+ return {
83
+ "input_ids": example["tokens"][:512],
84
+ "labels": int(example["is_malware"])
85
+ }
86
+
87
+ # Train on standard splits
88
+ train_ds = dataset["train"].map(prepare_example)
89
+ val_ds = dataset["validation"].map(prepare_example)
90
+
91
+ # Train your model...
92
+ ```
93
+
94
+ ### Example: Cross-Platform Transfer Learning
95
+
96
+ ```python
97
+ # Train on Windows, test on Linux
98
+ train_windows = dataset["train"].filter(lambda x: x["platform"] == "windows")
99
+ test_linux = dataset["test"].filter(lambda x: x["platform"] == "linux")
100
+
101
+ print(f"Windows training samples: {len(train_windows)}")
102
+ print(f"Linux test samples: {len(test_linux)}")
103
+ # Evaluate cross-platform generalization...
104
+ ```
105
+
106
+ ## πŸ“¦ Dataset Composition
107
+
108
+ **Platform Distribution:**
109
+ - **Windows**: 57.3% (17,239 samples) - PE32/PE32+ executables and DLLs
110
+ - **Linux**: 28.4% (8,452 samples) - ELF32/ELF64 from 9 distributions
111
+ - **macOS**: 1.9% (568 samples) - x86-64, ARM64, Universal binaries
112
+ - **Android**: 0.6% (164 samples) - APKs with native ARM libraries
113
+ - **Other**: 11.8% (3,370 samples) - Diverse formats and installers
114
+
115
+ **Architecture Diversity:**
116
+ - **Common**: x86-64 (56.4%), x86 (11.1%), ARM64 (5.9%), ARM (9.4%)
117
+ - **Exotic**: MIPS (2.3%), PowerPC (1.3%), RISC-V (0.1%), m68k, SuperH, ARCompact, SPARC, S/390
118
+
119
+ **Malware Sources:**
120
+ - **SOREL-20M**: 365 Windows PE malware samples (2017-2019)
121
+ - **Malware Bazaar**: 7,658 cross-platform malware samples (2020-2024)
122
+ - Platform-first stratified sampling
123
+ - ALL available macOS malware (560 samples)
124
+ - ALL available Android malware (164 samples)
125
+ - Balanced Windows/Linux with size stratification
126
+
127
+ ## πŸ“‹ Data Structure
128
+
129
+ Each record contains **31 fields** organized into seven categories:
130
+
131
+ **Identification** (6 fields):
132
+ - `file_id`, `file_path`, `file_name`, `sha256`, `md5`, `file_size`
133
+
134
+ **Platform/Source** (5 fields):
135
+ - `platform`, `os_family`, `os_version`, `distribution`, `is_malware`
136
+
137
+ **File Characteristics** (6 fields):
138
+ - `file_format`, `architecture`, `binary_type`, `is_stripped`, `is_packed`, `is_signed`
139
+
140
+ **Structural Analysis** (4 fields + sections):
141
+ - `num_sections`, `code_size`, `data_size`, `sections[]`
142
+
143
+ **Dependencies** (4 fields + imports/exports):
144
+ - `num_imports`, `num_exports`, `imports[]`, `exports[]`
145
+
146
+ **Complexity** (1 field):
147
+ - `entropy` (Shannon entropy 0-8 scale)
148
+
149
+ **Pre-computed Tokenization** (4 fields):
150
+ - `tokens[]`, `token_count`, `compression_ratio`, `unique_tokens`
151
+
152
+ **Parser Diagnostics** (2 fields):
153
+ - `parse_status`, `parse_warnings[]`
154
+
155
+ ### Pre-computed Tokenization
156
+
157
+ All binaries are tokenized using **BPE tokenization** ([`mjbommar/binary-tokenizer-001-64k`](https://huggingface.co/mjbommar/binary-tokenizer-001-64k)):
158
+ - **Average tokens per binary**: ~15,000
159
+ - **Compression ratio**: ~4.2 bytes/token
160
+ - **Vocabulary**: 64K tokens
161
+ - **Ready for transformers**: BERT, GPT, T5, etc.
162
+
163
+ ## πŸŽ“ Supported Research Tasks
164
+
165
+ 1. **Malware Detection**: Binary classification with balanced classes (26.9% malware)
166
+ 2. **Cross-Platform Analysis**: Transfer learning across Windows/Linux/macOS/Android
167
+ 3. **Architecture-Invariant Detection**: Generalization to exotic architectures (IoT/embedded)
168
+ 4. **Mobile Malware Research**: Dedicated Android and macOS malware samples
169
+ 5. **Binary Similarity**: Embedding learning for similar binary detection
170
+ 6. **Format-Agnostic Analysis**: Multi-format models (PE/ELF/Mach-O/APK)
171
+
172
+ ## πŸ“Š Comparison with Other Datasets
173
+
174
+ | Dataset | Size | Platforms | Architectures | Malware | Pre-tokenized | Splits |
175
+ |---------|------|-----------|---------------|---------|---------------|--------|
176
+ | **Binary-30K** | 30K | Win+Linux+macOS+Android | 15+ (incl. exotic) | 26.9% | βœ… | βœ… |
177
+ | SOREL-20M | 20M | Windows only | x86/x64 | 100% | ❌ | ❌ |
178
+ | EMBER | 1.1M | Windows only | x86/x64 | 50% | ❌ (features) | βœ… |
179
+ | Assemblage | 1.1M | Windows+Linux | x86/x64 | 0% (benign) | ❌ | ❌ |
180
+
181
+ ## πŸ” Stratification Verification
182
+
183
+ **Split Distribution Verification:**
184
+
185
+ **TRAIN (20,849 samples):**
186
+ - Malware: 5,613 (26.92%)
187
+ - Top platforms: Windows (12,065), Linux (5,915), Other (1,200)
188
+ - Top formats: PE (12,018), ELF (5,915), Unknown (1,195)
189
+
190
+ **VALIDATION (4,463 samples):**
191
+ - Malware: 1,200 (26.89%)
192
+ - Top platforms: Windows (2,584), Linux (1,266), Other (256)
193
+ - Top formats: PE (2,574), ELF (1,266), Unknown (255)
194
+
195
+ **TEST (4,481 samples):**
196
+ - Malware: 1,210 (27.00%)
197
+ - Top platforms: Windows (2,590), Linux (1,271), Other (259)
198
+ - Top formats: PE (2,577), ELF (1,271), Unknown (258)
199
+
200
+ **Statistical Tests:** Chi-square tests confirm no significant deviation from proportional representation (p > 0.05 for all dimensions).
201
+
202
+ ## πŸ”„ Reproducibility
203
+
204
+ **Split Generation:**
205
+ - **Seed**: 42 (for reproducibility)
206
+ - **Method**: Stratified sampling with composite keys
207
+ - **Date**: November 15, 2025
208
+ - **Tool**: [`binary-dataset-paper`](https://github.com/mjbommar/binary-dataset-paper)
209
+
210
+ All splits are **deterministic and reproducible**. Using the same seed will always produce identical splits.
211
+
212
+ ## πŸ“š Data Sources
213
+
214
+ **Linux Binaries:** Alpine 3.18/3.19, Debian 11-12, Ubuntu 20.04/22.04/24.04, Fedora 39-40, CentOS Stream 9, Arch Linux, Kali Linux 2024.1, Parrot OS 6.0, BusyBox 1.37.0
215
+
216
+ **Windows Binaries:** Windows 8 Pro, Windows 10 21H2/22H2, Windows 11 23H2, Windows Update Catalog
217
+
218
+ **Malware Samples:**
219
+ - SOREL-20M dataset (Sophos-ReversingLabs, 2020)
220
+ - Malware Bazaar (abuse.ch, 2020-2024) with platform-first stratified sampling
221
+
222
+ ## ⚠️ Important Considerations
223
+
224
+ **Limitations:**
225
+ - Static analysis only (no dynamic/runtime behavior)
226
+ - Some binaries cannot be parsed by LIEF
227
+ - Many binaries have stripped debug symbols
228
+ - Very large binaries produce extended token sequences
229
+ - iOS/iPadOS binaries not included
230
+ - Uneven representation of exotic architectures
231
+
232
+ **Usage Notes:**
233
+ - **Malware samples require secure, isolated research environments**
234
+ - Windows binaries subject to Microsoft licensing terms
235
+ - Fair use application depends on jurisdiction
236
+ - Splits are standardized but users may create custom splits for specific research needs
237
+
238
+ ## πŸ“„ License and Attribution
239
+
240
+ **Dataset Compilation:** CC-BY-4.0 license by Michael J. Bommarito II
241
+
242
+ **Component Licenses:**
243
+ - Linux binaries: Various open-source licenses (GPL, LGPL, MIT, BSD, Apache)
244
+ - Windows binaries: Subject to Microsoft software licenses
245
+ - SOREL-20M samples: Follow [SOREL-20M License Agreement](https://github.com/sophos-ai/SOREL-20M)
246
+ - Malware Bazaar samples: Research use only, attribution required to [abuse.ch](https://abuse.ch/)
247
+
248
+ **Malware samples** are included for research purposes only. Users must comply with applicable laws and regulations when working with malware samples.
249
+
250
+ ## πŸ“– Citation
251
+
252
+ If you use this dataset in your research, please cite:
253
+
254
+ ```bibtex
255
+ @dataset{bommarito2025binary30k,
256
+ title={Binary-30K: A Cross-Platform, Multi-Architecture Binary Dataset with Stratified Splits},
257
+ author={Bommarito, Michael J., II},
258
+ year={2025},
259
+ publisher={HuggingFace},
260
+ url={https://huggingface.co/datasets/mjbommar/binary-30k}
261
+ }
262
+ ```
263
+
264
+ ## πŸ”— Related Resources
265
+
266
+ - **Original dataset (no splits)**: [`mjbommar/binary-30k-tokenized`](https://huggingface.co/datasets/mjbommar/binary-30k-tokenized)
267
+ - **Tokenizer**: [`mjbommar/binary-tokenizer-001-64k`](https://huggingface.co/mjbommar/binary-tokenizer-001-64k)
268
+ - **Paper**: *Binary-30K: A Cross-Platform, Multi-Architecture Binary Dataset* (2025)
269
+ - **Code & Documentation**: [github.com/mjbommar/binary-dataset-paper](https://github.com/mjbommar/binary-dataset-paper)
270
+ - **Technical Documentation**: See [DATASET_SPLITS.md](https://github.com/mjbommar/binary-dataset-paper/blob/master/DATASET_SPLITS.md) for detailed stratification methodology
271
+
272
+ ## πŸ“ž Contact
273
+
274
+ **Author:** Michael J. Bommarito II
275
+ **Email:** michael.bommarito@gmail.com
276
+
277
+ ## πŸ”„ Updates
278
+
279
+ - **2025-11-15**: Initial release with stratified train/val/test splits (70/15/15)
280
+
281
+ ---
282
+
283
+ *Last Updated: November 15, 2025*