Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib
- import itertools
- import time
- import math
- text = "A8AXWC36F--KF1C-TF-3YW2TG\0-GBM8DOM"
- hash = "349cf6e4c59c999dd2df3fbdac8bd840db4a6dc2104b010390850777249f14a7d96fd62a5f828def0315b9c908420c646381fe1b1e67391b3f5bd0588c28fbe0"
- #code = "MTGOX-BTC-MYF8W-DWFCA-62GK8-3F31A"
- def sha512(s):
- return hashlib.sha512(s + "\n").digest().encode('hex')
- def ftime(seconds):
- m, s = divmod(seconds, 60)
- h, m = divmod(m, 60)
- d, h = divmod(h, 24)
- y, d = divmod(d, 365)
- if y > 1:
- return "%d years" % y
- elif d > 1:
- return "%d days" % d
- else:
- return "%02d:%02d:%02d" % (h, m, s)
- def bruteforce(text, hash):
- count = 0
- seconds = 0
- start = int(time.time())
- # pt = itertools.permutations("A8AWC36FKF1F3YW2GM8D")
- pt = itertools.permutations("MYF8WDWFCA26GK38F31A")
- digest = hash.decode('hex')
- for p in pt:
- a = "".join(p)
- code = "MTGOX-BTC-" + a[0:5] + "-" + a[5:10] + "-" + a[10:15] + "-" + a[15:20]
- if hashlib.sha512(code + "\n").digest() == digest:
- return code
- count = count + 1
- t = int(time.time()) - start
- if seconds < t:
- seconds = t
- ps = count / seconds
- total = math.factorial(20)
- sec_left = (total - count) / ps
- print code
- print "%d seconds, %d hashes, %d per second, %s left" % (seconds, count, ps, ftime(sec_left))
- def ibwt(r):
- """Apply inverse Burrows-Wheeler transform."""
- table = [""] * len(r) # Make empty table
- for i in range(len(r)):
- table = sorted(r[i] + table[i] for i in range(len(r))) # Add a column of r
- s = [row for row in table if row.endswith("\0")][0] # Find the correct row (ending in "\0")
- return s.rstrip("\0") # Get rid of trailing null character
- if __name__ == '__main__':
- code = bruteforce(text, hash)
- # code = ibwt(text)
- print code
- print sha512(code)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement