Advertisement
Guest User

Untitled

a guest
Feb 4th, 2018
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. import re, string, hashlib
  2.  
  3. base = "BK*C4J7*QR22*55"
  4. hash_expected = "6639983504811d176b0f6aec17609736df4aff6cb02eeafedba65b5105380d95e2aaf00cbc5b58aecd7cfda29f7ef078177b665d9475bab5ca2096d8b18f416f"
  5.  
  6. unknown_pos = [m.start() for m in re.finditer("\*", base)]
  7.  
  8. def next_perm(cnt):
  9.     alphanum = string.ascii_uppercase + string.digits
  10.     lst = [0] * cnt
  11.     m = 0
  12.     total = len(alphanum) ** cnt
  13.     print("Total permutations: " + str(total))
  14.     while m < total:
  15.         for i in reversed(range(cnt)):
  16.             if lst[i] < ( len(alphanum) - 1 ):
  17.                 lst[i] = lst[i] + 1
  18.                 break
  19.             else:
  20.                 lst[i] = 0
  21.         if (m % 1000) == 0: print('{0:.2f}'.format(float(m / total) * 100.0) + "% ", end="")
  22.         m = m + 1
  23.         yield [alphanum[n] for n in lst]
  24.  
  25. def key_from_perm(perm):
  26.     key = list(base)
  27.     i = 0
  28.     for pos in unknown_pos:
  29.         key[pos] = perm[i]
  30.         i = i + 1
  31.     return "".join(key)
  32.  
  33. for perm in next_perm(len(unknown_pos)):
  34.     key = key_from_perm(perm)
  35.     if hashlib.sha512(key.encode("ascii")).hexdigest() == hash_expected:
  36.         print("")
  37.         print("Result: " + key)
  38.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement