100% found this document useful (3 votes)
2K views2 pages

Freebitco Pridect On Python

This document contains code to generate a dictionary of random words between a minimum and maximum length, then use that dictionary to crack a given hash by hashing each word and checking for a match. It first generates a word list of a specified maximum number of random words within the given length ranges and saves it to a file. It then opens that word list file and a file containing a hash, hashes each word read from the list, and checks for a match against the given hash. If a match is found, it prints the matching word.

Uploaded by

Ravikant sahu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
2K views2 pages

Freebitco Pridect On Python

This document contains code to generate a dictionary of random words between a minimum and maximum length, then use that dictionary to crack a given hash by hashing each word and checking for a match. It first generates a word list of a specified maximum number of random words within the given length ranges and saves it to a file. It then opens that word list file and a file containing a hash, hashes each word read from the list, and checks for a match against the given hash. If a match is found, it prints the matching word.

Uploaded by

Ravikant sahu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import string

import random
from random import sample

#============ Word List Gen ============


minimum=int(input('Please enter the minimum length of any give word to be
generated: '))
maximum=int(input('Please enter the maximum length of any give word to be
generated: '))
wmaximum=int(input('Please enter the max number of words to be generate in the
dictionary: '))

alphabet = '680113444f795fd49455201055ad275cb5feeed63e90be77e3fe7019909522c3'
string=''
xrange=range
file = open("m.txt","a")
for count in xrange(0,wmaximum):
for x in random.sample(alphabet,random.randint(minimum,maximum)):
string+=x
file.write(string+'\n')
string=''
file.close()
print ('DONE!')

#============ WLG END ============


#Begin Hash Cracker.py

import hashlib, sys


m = hashlib.sha256()
hash = ""
hash_file = 'hash.txt'
wordlist = 'm.txt'
try:
hashdocument = open(hash_file,"r")
except IOError:
print ("Invalid file.")
input()
sys.exit()
else:
hash = hashdocument.readline()
hash = hash.replace("\n","")

try:
wordlistfile = open(wordlist,"r")
except IOError:
print ("Invalid file.")
input()
sys.exit()
else:
pass
for line in wordlistfile:
m = hashlib.sha256() #flush the buffer (this caused a massive problem when
placed at the beginning of the script, because the buffer kept getting overwritten,
thus comparing incorrect hashes)
line = line.replace("\n","")
m.update(line.encode(wordlistfile.encoding))
word_hash = m.hexdigest()
if word_hash==hash:
print ("Collision! The word corresponding to the given hash is",
line,)
input()
sys.exit()

print ("The hash given does not correspond to any supplied word in the wordlist.")
input()
sys.exit()

#EoF
#Written by Neil Shah, 9th grade

You might also like