Skip to content

Commit 69b004f

Browse files
committed
Fixed recaf, jbytemod and threadtear support, and improved the readme
1 parent 0f1b587 commit 69b004f

File tree

13 files changed

+176
-44
lines changed

13 files changed

+176
-44
lines changed

readme-assets/7zip.png

38.7 KB
Loading

readme-assets/ark.png

20 KB
Loading
13 KB
Loading

readme-assets/jbytemod.png

19.7 KB
Loading

readme-assets/recaf.png

49.4 KB
Loading

readme-assets/threadtear.png

15.5 KB
Loading
50.1 KB
Loading
30.1 KB
Loading

readme-assets/winrar.png

75.1 KB
Loading

readme.md

Lines changed: 120 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
This library add all entries you want it to add, and make it a zipbomb + semi-invalid zip file as a (very) basic
44
protection layer to protect your software from being cracked.
55

6+
## Size Limit
7+
The actual size limit should be Integer.MAX_VALUE, but the tested size limit is 1 million. I tested
8+
10 million and it actually dies with `OutOfMemoryError`, and I didn't test anything between 1 million
9+
and 10 million.
10+
11+
So let's say the size limit is 1 million, the unzip size should be 2.14 PB
12+
(`(Integer.MAX_VALUE - 2)*1000000 bytes`), which is more than enough.
13+
614
## Features
715
#### **`ZipInputStream` File Name Faker**
816
> Fakes the file name from ZipInputStream. There are some deobfuscator uses this, and I'm talking to
@@ -11,7 +19,7 @@ protection layer to protect your software from being cracked.
1119
> It also hides file name from these following archive managers:
1220
> - 7-zip
1321
>
14-
> But tt doesn't work from these following archive managers:
22+
> But it doesn't work for these following archive managers:
1523
> - `unzip` Linux command
1624
> - WinRAR
1725
@@ -33,20 +41,94 @@ protection layer to protect your software from being cracked.
3341
> - Gnome's Archive Manager - crashes
3442
> - Window's File Explorer - crashes
3543
>
36-
> Archive Managers that's tested and doesn't work:
44+
> Archive Managers that's tested and don't work:
3745
> - WinRAR
3846
> - 7-zip, but the file name faker works
3947
> - `unzip` Linux Command
48+
#### **Archive Manager Overload**
49+
> As I said, the limit is pretty high (Tested: 1 mil, and in theory: max signed int (`int` limit in java))
50+
> , which means there's a pretty high chance it'll freeze most unzipping tools for around 5 ~ 10 minutes
51+
>
52+
> Tested archive managers (Exclude ones that crash or disallow unzipping):
53+
> - WinRar
54+
>
55+
> Archive managers that's tested and don't work:
56+
> - `unzip` Linux command
57+
58+
## How does it work?
59+
The main cause of the crash of unzip tools and differential between each unzip api is because JVM
60+
actually has 2 (or probably 3) different zip/jar file parser. One is `ZipInputStream`, and another
61+
one is `ZipFile`. JVM's class loader uses something similar to `ZipFile`, and using `ZipInputStream`
62+
will result in different result.
63+
64+
Actually, I didn't find any archive manager that has the same result.
65+
- Windows' Builtin Archive Manager
66+
- 7-zip
67+
- WinRAR
68+
- Ark (KDE Plasma's default archive manager)
69+
- Gnome's Archive Manager
70+
- `unzip` command
71+
- `zip` command
72+
- JVM's class loader (`ZipFile`)
73+
- `ZipInputStream`
74+
75+
All of them parses the zip bomb crafted by this API differently, and has different result.
76+
But there's no software that actually parses this correctly, the zip file is already corrupted,
77+
the correct answer should be: Zip file corrupted, includes WinRAR, which is the one that bypasses
78+
all of them, it's also parsing it incorrectly because it can still parse it without complaining.
79+
80+
This zipbomb is using a technique called `Overlapped Zipbomb`. Inside the zip file, there
81+
are a few sections:
82+
- Local File Headers
83+
- Central Directory Headers
84+
- End Of Central Directory Record (EOCD)
85+
86+
Local File Headers contains file name, raw compressed data and other attributes, central directory
87+
headers also have file name and other attributes, and the offset of the entry in local file headers
88+
section. So you can know it as central directory file header has a pointer that points to its
89+
local file header. EOCD contains information like how large is local file section and CD
90+
section, how many entries are there in CD etc., so basically attribute of entire zip file,
91+
92+
But you can probably already tell that local file header and cd(central directory) header has a lot
93+
of duplicated attributes, and if you make them unmatched, it will cause some issues.
94+
95+
First, JVM reads the file name at Central Directory Headers, but ZipInputStream and 7-zip reads
96+
Local File Headers first, and if it can't find the entry (Which I'll talk about it later), it will
97+
use the file name at Central Directory Headers.
98+
99+
Also, some unzip tools like `Ark`, `Gnome's Archive Manager` already crashed with unmatched file name.
100+
101+
Now next thing is `Overlapped`, you can change the pointer in CD header to same local file with
102+
unmatched file name, so if you point like 100000 entries to one 2GB local file, it will result
103+
in having 100000 2GB entries with only 1 entry's actual data stored. Overlapped means that
104+
they are pointing to the same local file, and those data are overlapped.
40105

106+
There are some more technique going on, you can find those by messing around, and I recommend you to
107+
try it yourself, it's fun and you can learn a lot (If it's your first time doing it)
41108

109+
## How does it protect your Java programs from being cracked?
110+
JVM won't crash while loading a zipbomb as class path, and funny enough, it can find classes
111+
correctly in the zipbomb. If you try and load it with tools, it will die, because those tools are
112+
actually listing all entries of it, and some of them are even loading every single of them, or
113+
store all of them into 1 single array. If you do that, your program will freeze, well, not technically
114+
a "crash", but you'll have to wait fo around 100 years.
115+
116+
So there you go, most unzip tools die (except WinRAR and `unzip` Linux command), and it's great
117+
enough to stop skids who don't know anything but using recaf to change the source and recompile it.
118+
119+
It's also a good idea to use it as a final protection layer of your obfuscator.
120+
121+
## Example
122+
You can find examples in the release tab!
42123

43124
## Use cases
44125
This is obviously for obfuscation and educational purposes only, and I'm dead serious, using this
45126
to do bad stuff is actually very stupid, and you shouldn't be doing it under any condition.
46127

47-
Here are some use cases:
48128
1. Learn how the code works
49-
2. Protect your Java programs
129+
2. Learn how Zipbomb works
130+
3. Protect your Java programs
131+
4. Security usage (e.g. test if your software has prevented zipbomb)
50132

51133
## Usage
52134
1. Clone this repository, and `mvn clean package install`
@@ -84,4 +166,37 @@ public class Main {
84166
}
85167

86168
}
87-
```
169+
```
170+
171+
## Gallery
172+
Ark
173+
![img.png](readme-assets/ark.png)
174+
175+
Gnome Archive Managers
176+
![](readme-assets/gnome-archive-manager.png)
177+
178+
`unzip` Linux Command
179+
![](readme-assets/unzip-linux-command.png)
180+
181+
Windows Archive Manager
182+
![](readme-assets/windows-archive-manager.png)
183+
184+
7-zip
185+
(Showing fake file name `FakeEntryName`(customizable), the real names are `T-0.class` (probably)
186+
and `Main.class`)
187+
![](readme-assets/7zip.png)
188+
189+
WinRAR
190+
(It works well except it takes 20 minutes to load)
191+
![](readme-assets/winrar.png)
192+
193+
Recaf
194+
![](readme-assets/recaf.png)
195+
196+
JBytemod Remastered
197+
(JBytemod should result in the same)
198+
![](readme-assets/jbytemod.png)
199+
200+
Threadtear
201+
(It takes forever to load)
202+
![](readme-assets/threadtear.png)

0 commit comments

Comments
 (0)