fork download
  1. #!/usr/bin/python3
  2.  
  3. import hashlib
  4. import sys
  5.  
  6. FLAG = "Braindead{"
  7.  
  8. def printAllKLength(set, k):
  9.  
  10. n = len(set)
  11. printAllKLengthRec(set, "", n, k)
  12.  
  13. # The main recursive method
  14. # to print all possible
  15. # strings of length k
  16. def printAllKLengthRec(set, prefix, n, k):
  17.  
  18. # Base case: k is 0,
  19. # print prefix
  20. if (k == 0) :
  21. learn = flip(prefix,n)
  22. #print(learn)
  23. if(learn == "85c44317bd031ad8ba13e622d38198a1"):
  24. print("THE ANSWER IS " + prefix)
  25. return
  26. return
  27.  
  28. # One by one add all characters
  29. # from set and recursively
  30. # call for k equals to k-1
  31. for i in range(n):
  32.  
  33. # Next character of input added
  34. newPrefix = prefix + set[i]
  35.  
  36. # k is decreased, because
  37. # we have added a new character
  38. printAllKLengthRec(set, newPrefix, n, k - 1)
  39.  
  40. def flip(data, n):
  41. data = FLAG + data + "}"
  42. buflen = len(data)
  43. while n > buflen:
  44. n -= buflen
  45. buf = ["$"] * buflen
  46. for i in range(buflen):
  47. try:
  48. buf[i] = data[i - n]
  49. except:
  50. pass
  51. return hashlib.md5("".join(buf).encode("utf-8")).hexdigest()
  52.  
  53.  
  54.  
  55. if __name__ == "__main__":
  56. #print("welcome to fliphash!")
  57. #print("e.g. flip(\"hello-world!\", 5) =", flip("hello-world!", 5))
  58. try:
  59. value = 0
  60. set = ['a'] * 88
  61. for x in range(36,124):
  62. set[x-36] = chr(x)
  63. k = 15
  64. print(set)
  65. printAllKLength(set, k)
  66. except:
  67. pass
  68.  
Success #stdin #stdout 0.03s 11152KB
stdin
Standard input is empty
stdout
how much do you want to flip? (please enter a digit)