Jump to content
Nytro

Sample Code – Dictionary Zip Cracker

Recommended Posts

Posted

[h=2]Sample Code – Dictionary Zip Cracker[/h]

Posted by Adam on November 4, 2013 Leave a comment (0) Go to comments

After reading Violent Python, I decided to try my hand at making a basic dictionary zip cracker just for fun. Some of the other free open source tools out there are great but it does work. I’m primarily posting it for fun and to test the blog’s new syntax highlighting.

It can generate a biographical dictionary from a specified file’s ASCII strings as well as populate it with a recursive directory listing. Got the idea while studying for my AccessData cert. Their Password Recovery Toolkit does this in hopes of increasing the likelihood that the dictionary will contain a relevant password. The idea is that a user either used the word in the past or that it can be found elsewhere on his or her computer. A very cool idea that’s helped me on forensics challenges.

I’ve designed the code below for Python 2.7.5 on Windows 7. It uses the Strings binary from Picnix Utils. You can also click here to download a copy.

import argparse

import zipfile

import subprocess

import os

print ''' SYNTAX:

Dictionary: zipdict.py -f (zip) -d (dict)

Bio Dictionary Generator: zipdict.py -f (zip) -s (file with desired strings)

'''

parser = argparse.ArgumentParser(description='Zip file dictionary attack tool.')

parser.add_argument('-f', help='Specifies input file (ZIP)', required=True)

parser.add_argument('-d', help='Specifies the dictionary.', required=False)

parser.add_argument('-s', help='Build ASCII strings dictionary.', required=False)

args = parser.parse_args()

zipfile = zipfile.ZipFile(args.f)

print '{*} Cracking: %s' % args.f

print '{*} Dictionary: %s' % args.d

def biodictattack():

print '{*} Generating biographical dictionary...'

stringsdict = open('stringsdict', 'w')

stringsout = subprocess.Popen(['strings', args.f], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

for string in stringsout.stdout:

stringsdict.write(string)

stringsout.wait()

walkpath = raw_input("Directory listing starting where? [ex. C:\] ")

for root, dirs, files in os.walk(walkpath):

for name in files:

filenames = os.path.join(name)

stringsdict.write(filenames + '\n')

for root, dirs, files in os.walk(walkpath):

for name in dirs:

dirlisting = os.path.join(name)

stringsdict.write(dirlisting + '\n')

print '{*} Done. Re-run to crack with zipdict.py -f (zip) -d stringsdict'

def dictattack():

dict = open(args.d, 'r')

with open(args.d, 'r') as dict:

for x in dict.readlines():

dictword = x.strip('\n')

try:

zipfile.extractall(pwd=dictword)

print '{*} Password found = ' + dictword + '\n'

print '{*} File contents extracted to zipdict path.'

exit(0)

except Exception, e:

pass

if args.s:

biodictattack()

else:

dictattack()

My next post will be on analyzing Volume Shadow Copies on Linux and some cool methods that I used on the 2013 DC3 Forensic Challenge.

Sursa: Sample Code - Dictionary Zip Cracker | fork()

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...