PageRenderTime 25ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/simple_dehasher.py

https://gitlab.com/8wiw/python-dehasher
Python | 165 lines | 131 code | 11 blank | 23 comment | 20 complexity | 793b8b241de9072d4659118ef7feadfb MD5 | raw file
  1. #!/usr/bin/python3
  2. ###########################################################################
  3. # Made by http://github.com/r4v10l1 for RaidForums. #
  4. # https://raidforums.com/User-FakeRavi0li #
  5. # Thanks to @Dark Lord, you are the best! #
  6. # This script dehashes an MD5 hash using https://md5decrypt.net/en/Api/ #
  7. # If it's not found, it bruteforces it with hashcat. #
  8. ###########################################################################
  9. # Try importing stuff
  10. try:
  11. import sys
  12. import os
  13. import requests
  14. import time
  15. from bs4 import BeautifulSoup
  16. from colorama import Fore, Style
  17. except Exception:
  18. print()
  19. print(" [!] Error. Libraries not installed.")
  20. print(" [i] Run: pip install <package name>")
  21. print(" [i] Required packages: sys, os, requests, bs4, colorama, time.")
  22. print()
  23. exit(1)
  24. #--------------------------------------------------------------------------------------------------
  25. # Def the color types
  26. def info_text(text):
  27. print(" %s%s[i] %s%s" % (Style.RESET_ALL, Fore.BLUE, text, Style.RESET_ALL))
  28. def success_text(text):
  29. print(" %s%s%s[+] %s%s" % (Style.RESET_ALL, Style.BRIGHT, Fore.GREEN, text, Style.RESET_ALL))
  30. def error_text(text):
  31. print(" %s%s%s[!] %s%s" % (Style.RESET_ALL, Style.BRIGHT, Fore.RED, text, Style.RESET_ALL))
  32. def input_text(text):
  33. return input(" %s%s%s[*] %s >>%s " % (Style.RESET_ALL, Style.BRIGHT, Fore.BLUE, text, Fore.RESET))
  34. #--------------------------------------------------------------------------------------------------
  35. # Check if args are correct
  36. if len(sys.argv) == 1:
  37. print(" %s%s[-] Usagge: %s%s -s <target>" % (Style.BRIGHT, Fore.BLUE, Fore.RESET, sys.argv[0]))
  38. print(" %s│" % Fore.BLUE)
  39. print(" %s│ │%s -s --single %s-%s Use -s for single hash format." % (Fore.BLUE, Fore.RESET, Fore.BLUE, Fore.RESET))
  40. print(" %s└──│%s%s COMING SOON..." % (Fore.BLUE, Style.DIM, Fore.RESET))
  41. print(" %s│ │%s%s COMING SOON..." % (Fore.BLUE, Style.DIM , Fore.RESET))
  42. print(" %s│" % Fore.BLUE)
  43. print(" %s│" % Fore.BLUE)
  44. print(" %s└──│%s <target> %s-%s Put here your target (single hash, list comming soon)%s" % (Fore.BLUE, Fore.RESET, Fore.BLUE, Fore.RESET, Style.RESET_ALL))
  45. print()
  46. exit(1)
  47. elif len(sys.argv) == 2:
  48. print()
  49. error_text("Not enough arguments.")
  50. print()
  51. exit(1)
  52. elif len(sys.argv) == 3:
  53. if "-s" not in str(sys.argv[1]).strip():
  54. print()
  55. error_text("Error. Type -s for single hash. Multiple hashes comming soon.")
  56. print()
  57. exit(1)
  58. elif ".txt" in str(sys.argv[2]):
  59. print()
  60. error_text("Error. Multiple hashes not supported in this version.")
  61. print()
  62. exit(1)
  63. elif len(str(sys.argv[2])) != 32:
  64. print()
  65. error_text("Error. Invalid hash type. Only supported md5.")
  66. print()
  67. exit(1)
  68. elif len(sys.argv) > 3:
  69. print()
  70. error_text("Error. Too many arguments.")
  71. print()
  72. exit(1)
  73. #--------------------------------------------------------------------------------------------------
  74. # Banner
  75. def banner():
  76. os.system("clear")
  77. print("%s%s ___ ________ _____ " % (Style.BRIGHT, Fore.WHITE))
  78. print(" | \/ | _ \ ___| __ __ __ %sby @r4v10l1%s%s%s" % (Style.DIM, Style.RESET_ALL, Style.BRIGHT, Fore.WHITE))
  79. print(" | . . | | | |___ \ ____/ /__ / /_ ____ ______/ /_ ___ _____")
  80. print(" | |\/| | | | | \ \ / __ / _ \/ __ \/ __ `/ ___/ __ \/ _ \/ ___/")
  81. print(" | | | | |/ //\__/ / / /_/ / __/ / / / /_/ (__ ) / / / __/ /")
  82. print(" \_| |_/___/ \____/ \__,_/\___/_/ /_/\__,_/____/_/ /_/\___/_/%s" % Fore.BLUE)
  83. print()
  84. print()
  85. banner()
  86. #--------------------------------------------------------------------------------------------------
  87. # Loading
  88. def loading():
  89. chars = "/—\|"
  90. for char in chars:
  91. sys.stdout.write('\r'+' [i] Loading...'+char)
  92. time.sleep(.1)
  93. sys.stdout.flush()
  94. n = 4
  95. for i in range(n):
  96. loading()
  97. sys.stdout.write('\r')
  98. #--------------------------------------------------------------------------------------------------
  99. # Email code
  100. try:
  101. USER_EMAIL = input_text("Your email")
  102. data = {'email_api':USER_EMAIL}
  103. try:
  104. r = requests.post("https://md5decrypt.net/en/Api/", data=data)
  105. except Exception:
  106. error_text("Error. Request failed.")
  107. print()
  108. exit(1)
  109. input(" %s%s[i] A verification code has been sent for the use of the API. %sPress Enter to continue..." % (Style.RESET_ALL, Fore.BLUE, Fore.RESET))
  110. API_CODE = input_text("Your code")
  111. except KeyboardInterrupt:
  112. print()
  113. error_text("Detected Ctrl+C. Shutting down...")
  114. exit(1)
  115. #--------------------------------------------------------------------------------------------------
  116. # Request
  117. HEADERS = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 OPR/68.0.3618.173"} # You can replace here your user agent.
  118. def make_request() :
  119. URL = "https://md5decrypt.net/en/Api/api.php?hash=%s&hash_type=%s&email=%s&code=%s" % (HASH, "md5", USER_EMAIL, API_CODE)
  120. PAGE = requests.get(URL, headers=HEADERS) # Uses requests lib to get the content of the page
  121. PAGE_CONTENT = BeautifulSoup(PAGE.content, "html.parser").get_text()
  122. #--------------------------------------------------------------------------------------------------
  123. # Check the if sys.argv is -s
  124. if sys.argv[1] == "-s":
  125. HASH = sys.argv[2]
  126. URL = "https://md5decrypt.net/en/Api/api.php?hash=%s&hash_type=%s&email=%s&code=%s" % (HASH, "md5", USER_EMAIL, API_CODE)
  127. PAGE = requests.get(URL, headers=HEADERS) # Uses requests lib to get the content of the page
  128. PAGE_CONTENT = BeautifulSoup(PAGE.content, "html.parser").get_text()
  129. if "ERROR CODE : 001" in PAGE_CONTENT:
  130. print()
  131. error_text("Error. Day limit exceded, running hashcat...")
  132. more_than_400()
  133. exit(1)
  134. elif "ERROR CODE : 002" in PAGE_CONTENT:
  135. print()
  136. error_text("Error. Wrong email / code.")
  137. print()
  138. exit(1)
  139. elif "ERROR CODE : 005" in PAGE_CONTENT:
  140. print()
  141. error_text("Error. Wrong hash tipe. Only MD5 supported.")
  142. print()
  143. exit(1)
  144. if PAGE_CONTENT.strip() == "":
  145. print()
  146. error_text("Hash not found.")
  147. print()
  148. exit(1)
  149. else:
  150. success_text("Success! Hash found.")
  151. print(" " + HASH + Fore.RED +":" + Style.RESET_ALL + PAGE_CONTENT)
  152. exit(1)
  153. exit(1)