File tree 2 files changed +46
-0
lines changed
2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1
1
# python-zip-bruteforce-gci
2
2
Python script to brute force a zip file's password from a word list.
3
+
4
+ ```
5
+ ./brute_force_zip.py --help
6
+
7
+ usage: brute_force_zip.py [-h] zipfile wordlist
8
+
9
+ Bruteforce the password of a zip file.
10
+
11
+ positional arguments:
12
+ zipfile
13
+ wordlist
14
+
15
+ optional arguments:
16
+ -h, --help show this help message and exit
17
+
18
+ ```
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+ import zipfile
3
+ import argparse
4
+ import os
5
+
6
+ parser = argparse .ArgumentParser (description = 'Bruteforce the password of a zip file.' )
7
+ parser .add_argument ('zipfile' ,type = str )
8
+ parser .add_argument ('wordlist' ,type = str )
9
+
10
+ args = parser .parse_args ()
11
+ zip_file_name = os .path .abspath (os .path .realpath (args .zipfile ))
12
+ wordlist_name = os .path .abspath (os .path .realpath (args .wordlist ))
13
+
14
+ with zipfile .ZipFile (zip_file_name ,'r' ) as zip_file :
15
+ with open (wordlist_name ,'r' ) as wordlist :
16
+ for line in wordlist :
17
+ try :
18
+ password_bytes = line .rstrip ('\n ' ).encode ('utf-8' )
19
+ zip_file .extractall (pwd = password_bytes )
20
+ print ('success' )
21
+ try :
22
+ zip_file .extractall ()
23
+ print ('zip is unencrypted' );
24
+ except :
25
+ print ( 'password is {}' .format (line .rstrip ('\n ' )) )
26
+ break
27
+ except :
28
+ pass
29
+ else :
30
+ print ('fail, no password matched' )
You can’t perform that action at this time.
0 commit comments