Related Reads
Welcome to next part, Python Programming For Hackers (Part 5) – Cracking Zipped Passwords
> Before starting, you must be familiar with .RAR and .ZIP
> This process quickly tries for different passwords. If it misses, then it moves to the next one. If the password matches, then the zip file is easily extracted.
# Creating a Program
– We create python file called zipcracker.py
– Lock your zip file with common password like abcdef or 123456 (whatever). Rename file to as your wish. Here, I’ll use the name “secured.zip“.
– Next, we need a dictionary file that contains our list of passwords. Create a dictionary file in .txt format. Place that common password in .txt file. Like abcdef or 123456 or whatever. Read my previous article on Dictionaries. Or optionally, you can search for dictionary files in google too.
– In this python program,we’ll need the main and extract_zip functions.
# OS used for writing python script is ‘Ubuntu‘.
# let’s begin writing our .py file in terminal of ubuntu.
python@ubuntu:-/bj/pytut5$ vim zipcracker.py
/* vim zipcracker.py opens vim editor box, so now write below commands */
import optparse
import zipfile
from threading import Thread
def extract_zip(zFile, password):
try:
zFile.extractall(pwd=password)
print “[+] Pass Found: ” + password + ‘n’
except:
pass
/* The above line of code from DEF to PASS works if password is found. If it’s not found, then it just passes. And, this will help program not to crash */
def Main():
parser = optparse.OptionParser(“usage %prog “+
“-f <zipfile> -d <dictionary>”)
parser.add_option(‘-f’, dest=’zname’, type=’string’,
help=’specify zip file’)
parser.add_option(‘-d’, dest=dname’, type=’string’,
help=’specify dictionary file’)
(options, arg) = parser.parse_args()
if (options.zname == None) | (options.dname == None):
print parser.usage
exit(0)
else:
zname = options.zname
dname = options.dname
zFile = zipfile.ZipFile(zname)
passFile = open(dname)
for line in passFile.readlines():
password = line.strip(‘n’)
t = Thread(target=extract_zip, args=(zFile, password))
t.start()
if __name__ == ‘__main__’:
Main()
:wq
/* The program is finished. Now, lets run our zipcracker.py in terminal. Note: I’ve assigned -d and -f for file and dictionary */
python@ubuntu:-/bj/pytut5$ python zipcracker.py -f secured.zip -d dictionary.txt /*press Enter. You’ll get the password in a picture format */
/* Make sure that, all three files zipcracker.py, dictionary.txt and secured.zip are in same folder. This is for beginners. But once you knew about it, you can place them anywhere and can start cracking */
By : Bijay Acharya (CEHv9. Trained Personnel)
Follow : twitter.com/acharya_bijay
Website : bijayacharya.com
Did You Know?
Cybrary training is FREE
Just create an account now for lifetime access. Members login here.
We recommend always using caution when following any link
Are you sure you want to continue?
Now it too easy and simple to unlock zip archive file password with the help of Stella zip password recovery software using by three method like brute force attack/dictionary attack and mask attack.
Read more information from here:- http://stelladatarecovery.com/zip-password-recovery.html
builtins.UnboundLocalError: local variable ‘zname’ referenced before assignment
I got this error, how can I fix it?
Bro this error shows up : File “zipcracker.py”, line 11
try:
^
IndentationError: expected an indented block
Where is part 1 please provide links for that