-
Notifications
You must be signed in to change notification settings - Fork 0
/
L05C03.py
36 lines (29 loc) · 992 Bytes
/
L05C03.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#
# Sample Alien Zip file found at /tmp/alien-zip-2092.zip is password protected
# We have worked out they are using three digit code
# Brute force the Zip file to extract to /tmp
#
# Note: The script can timeout if this occurs try narrowing
# down your search
import string, zipfile
chars = string.digits
def extract_zip(filename, password):
with zipfile.ZipFile(filename) as zFile:
try:
password_encoded = bytes(password.encode("utf-8"))
zFile.extractall("/tmp", pwd=password_encoded)
print("[+] Password Found: " + password + "\n")
return password
except:
pass
stop = False
for i in chars:
if not stop:
for j in chars:
if not stop:
for k in chars:
pw = extract_zip("/tmp/alien-zip-2092.zip", i + k + j)
if pw is not None:
print(pw)
stop = True
break