|
1 |
| -# ByteBomber |
2 |
| - |
3 |
| -ByteBomber is a tool for creating ZIP bombs. A ZIP bomb is a highly compressed ZIP file that massively expands in size when extracted. ByteBomber is designed to demonstrate how compression algorithms (specifically ZIP's DEFLATE) can be used to exhaust system resources (disk space, RAM, or CPU), potentially crashing systems or causing instability. |
| 1 | +ByteBomber is a Python tool for creating ZIP bombs. It demonstrates how compression algorithms (specifically ZIP's DEFLATE) can exploit redundancy to create highly compressed files that expand drastically when extracted. It’s primarily for educational purposes to understand the impact of such files. |
4 | 2 |
|
5 | 3 | ## Installation
|
6 | 4 |
|
7 |
| -To install ByteBomber, run the following command: `pip install bytebomber` (Alternatively, use `pip3` if necessary.) |
8 |
| - |
9 |
| -Once installed, you can integrate ByteBomber into your own project by importing the `build_zip_bomb` function: `from bytebomber import build_zip_bomb` |
10 |
| - |
11 |
| -You can then call `build_zip_bomb()` in your code to generate ZIP bombs. |
12 |
| - |
13 |
| -## What ByteBomber Does |
14 |
| - |
15 |
| -1. Takes input for how big the uncompressed bomb should be. |
16 |
| -2. Takes input for how large each individual payload file should be. |
17 |
| -3. Generates a file filled with null bytes (`\x00`) of that size. |
18 |
| -4. Creates a ZIP archive containing that file duplicated many times. |
19 |
| -5. Applies DEFLATE compression to exploit redundancy. |
20 |
| - |
21 |
| -Since every payload file is identical and filled with zeroes, compression is extremely effective—producing a small ZIP file that expands drastically when extracted. |
22 |
| - |
23 |
| -## CLI |
24 |
| - |
25 |
| -When you run the script, you'll be prompted for the following: |
26 |
| - |
27 |
| -`Bomb decompressed size:` |
28 |
| - |
29 |
| -- This is the total uncompressed size you want the final ZIP bomb to expand to. |
30 |
| -- Default is 500 GB. |
31 |
| - |
32 |
| -`Payload file size:` |
33 |
| - |
34 |
| -- Size of the individual file inside the ZIP archive. |
35 |
| -- The smaller this is, the more files the ZIP bomb will contain. |
36 |
| -- Default is 1 MB. |
| 5 | +Install ByteBomber via pip: `pip install bytebomber` |
37 | 6 |
|
38 |
| -`Output zip name:` |
| 7 | +You can then use it in your project: `from bytebomber import build_zip_bomb` |
39 | 8 |
|
40 |
| -- Name of the final ZIP file to be created. |
41 |
| -- Default is `bomb.zip`. |
| 9 | +## Usage |
42 | 10 |
|
43 |
| -`Bomb directory name:` |
44 |
| - |
45 |
| -- Directory where files are extracted when the bomb is decompressed. |
46 |
| -- Default is `bomb-dir`. |
47 |
| - |
48 |
| -Use the format `<number> <unit>` when entering values (e.g., `500 GB`, `1 TB`). |
49 |
| - |
50 |
| -| Supported Unit | Size | Size In Bytes | |
51 |
| -| -------------- | -------- | --------------------------------- | |
52 |
| -| B (byte) | 1 B | 1 | |
53 |
| -| KB (Kilobyte) | 1,024 B | 1,024 | |
54 |
| -| MB (Megabyte) | 1,024 KB | 1,048,576 | |
55 |
| -| GB (Gigabyte) | 1,024 MB | 1,073,741,824 | |
56 |
| -| TB (Terabyte) | 1,024 GB | 1,099,511,627,776 | |
57 |
| -| PB (Petabyte) | 1,024 TB | 1,125,899,906,842,624 | |
58 |
| -| EB (Exabyte) | 1,024 PB | 1,152,921,504,606,846,976 | |
59 |
| -| ZB (Zettabyte) | 1,024 EB | 1,180,591,620,717,411,303,424 | |
60 |
| -| YB (Yottabyte) | 1,024 ZB | 1,208,925,819,614,629,174,706,176 | |
61 |
| - |
62 |
| -> [!NOTE] |
63 |
| -> For most purposes, GB or TB ranges are more than sufficient to stress a system. PB, EB, ZB, and YB represent astronomical data sizes far beyond what typical systems can handle. |
64 |
| -
|
65 |
| -Once input is provided, a summary of the configuration is shown: |
| 11 | +Call `build_zip_bomb()` to create a ZIP bomb. You can pass several arguments to customize the behavior: |
66 | 12 |
|
67 | 13 | ```
|
68 |
| -Creating ZIP bomb: |
69 |
| -
|
70 |
| - Payload size: 1048576 bytes |
71 |
| - Total uncompressed: 536870912000 bytes |
72 |
| - File count: 512000 |
73 |
| - Output: bomb.zip |
| 14 | +build_zip_bomb( |
| 15 | + target_input="500 GB", |
| 16 | + payload_input="1 MB", |
| 17 | + zip_name="bomb.zip", |
| 18 | + folder_name="bomb-dir", |
| 19 | + verbose=True, |
| 20 | + show_progress=True |
| 21 | +) |
74 | 22 | ```
|
75 | 23 |
|
76 |
| -- Payload size: Size of the file being copied inside the ZIP. |
77 |
| -- Total uncompressed: Target final size when the ZIP is extracted. |
78 |
| -- File count: How many copies of the payload file are added. |
79 |
| -- Output: Filename of the ZIP bomb. |
80 |
| - |
81 |
| -It will then show live progress as files are added to the ZIP. |
82 |
| - |
83 |
| -## What's in the ZIP |
| 24 | +| **Parameter** | Description | |
| 25 | +|----------------| ----------------------------------------------------------------------------------| |
| 26 | +| `target_input` | Total uncompressed size of the ZIP bomb. Default: prompts user or uses `"500 GB"`. | |
| 27 | +| `payload_input` | Size of each file inside the ZIP. Smaller values = more files. Default: prompts user or uses `"1 MB"`. | |
| 28 | +| `zip_name` | Output ZIP file name. Default: prompts user or uses `"bomb.zip"`. | |
| 29 | +| `folder_name` | Internal folder name for the payload files. Default: prompts user or uses `"bomb_dir"`. | |
| 30 | +| `verbose` | If `True`, shows config + summary output. Default: `True`. | |
| 31 | +| `show_progress` | If `True`, shows a live progress bar. Default: `True`. | |
84 | 32 |
|
85 |
| -Inside the ZIP there are tens of thousands to millions of identical files like: |
| 33 | +Use the format `<number> <unit>` when entering values (e.g., `500 GB`, `1 TB`). ByteBomber supports B, KB, MB, GB, TB, PB, EB, ZB, and YB. Valuse in the GB-TB range are usaully more than enough to stress a system. Values above TB are astronomical data zizes far more than most systems can handle. |
86 | 34 |
|
87 |
| -- 0.txt |
88 |
| -- 1.txt |
89 |
| -- 2.txt |
90 |
| -- ... |
91 |
| - |
92 |
| -All filled with null bytes. The compression algorithm detects repetition and compresses it heavily. |
| 35 | +> [!NOTE] |
| 36 | +> The program accepts values using standard units (e.g., MB, GB), but internally it treats them as binary units (e.g., MiB, GiB). |
93 | 37 |
|
94 |
| -> [!WARNING] |
95 |
| -> **ByteBomber is for educational purposes only. Do not deploy ZIP bombs on systems you do not own or have permission to test. Misuse can result in data loss or system damage.** |
| 38 | +**ByteBomber is for educational purposes only. Do not deploy ZIP bombs on systems you do not own or have permission to test. Misuse can result in data loss or system damage.** |
0 commit comments