Created
December 11, 2021 15:20
-
-
Save akamajoris/bbd3e4395a87fdca2af2fedaf9cf70e0 to your computer and use it in GitHub Desktop.
Sofia hash bruteforce (hisilicon)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import hashlib | |
hash = 'tlJwpbo6' # for example | |
def sofia_hash(msg): | |
h = "" | |
m = hashlib.md5() | |
m.update(msg) | |
msg_md5 = m.digest() | |
for i in range(8): | |
n = (ord(msg_md5[2*i]) + ord(msg_md5[2*i+1])) % 0x3e | |
if n > 9: | |
if n > 35: | |
n += 61 | |
else: | |
n += 55 | |
else: | |
n += 0x30 | |
h += chr(n) | |
return h | |
try: | |
wordlistfile = open(sys.argv[1], "r", ,encoding='utf-8') | |
except IOError: | |
print("Invalid file.") | |
raw_input() | |
sys.exit() | |
else: | |
pass | |
for line in wordlistfile: | |
line = line.strip() | |
line = line.replace("\n", "") | |
word_hash = sofia_hash(line) | |
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment