Advertisement
GoodiesHQ

ForBow

Jan 28th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.71 KB | None | 0 0
  1. from hashlib import md5
  2. from itertools import compress, product
  3. from string import printable
  4. from binascii import hexlify
  5.  
  6. def allcombos(values, max=None): # generator for yielding cartesian products of a certain set of characters
  7.     values = set(values) # erases repeating characters if any...
  8.     lenVal = len(values)
  9.     max = max if max is not None and max <= lenVal else lenVal
  10.     for i in range(0, max+1): # loop through all cartesian products from 0->len(max)
  11.         for p in product(values, repeat=i):
  12.             yield ''.join(p)
  13.            
  14. def tryReplace(origVal, newVal, lst):
  15.     for i, item in enumerate(lst):
  16.         if origVal == item:
  17.             lst[i] = newVal
  18.     return lst
  19.            
  20.  
  21. def foo(hashCollection): # string of characters... just md5's put together
  22.     size = 32 # 32 characters for an md5 hash
  23.     hashList = [hashCollection[i:i+size] for i in range(0, len(hashCollection), size)]
  24.     hashList = filter(lambda x: len(x) == size, hashList) # removes any that are not the same size as md5's
  25.     for combo in allcombos(printable, 3): #only loop through 3 at most... otherwise, it may be a LONG time
  26.         m = md5()
  27.         m.update(combo)
  28.         hashList = tryReplace(hexlify(m.digest()), combo, hashList)
  29.     return hashList
  30.    
  31. name = (
  32. "7fc56270e7a70fa81a5935b72eacbe29" # A
  33. "0b3b97fa66886c5688ee4ae80ec0c3c2" # us
  34. "2cb1b780138bc273459232edda0e4b96" # tin
  35. "cd4a2e8261ac0bdd29f6844dd4a615bc" # @ar
  36. "d88fc6edf21ea464d35ff76288b84103" # ch
  37. "818f9c45cfa30eeff277ef38bcbe9910" # er
  38. "NotAnMD5"
  39. )
  40.  
  41. thisAlsoWorks = "7fc56270e7a70fa81a5935b72eacbe290b3b97fa66886c5688ee4ae80ec0c3c22cb1b780138bc273459232edda0e4b96cd4a2e8261ac0bdd29f6844dd4a615bcd88fc6edf21ea464d35ff76288b84103818f9c45cfa30eeff277ef38bcbe9910"
  42.  
  43. attempt = foo(thisAlsoWorks) # or foo(name)
  44. print ''.join(attempt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement