Advertisement
Guest User

Untitled

a guest
Oct 26th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.03 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Author: Psycho_Coder <https://psychocoder.github.io/>
  4.  
  5. from re import match
  6. from sys import stdout, hexversion, exit, argv
  7. import traceback
  8.  
  9. TITLE = ("\n"
  10. " _ _ _ _____ _ _ ___ _ \n"
  11. "| | | | | | (_____) | | _ (_)/ __|_) \n"
  12. "| |__ | | ____ ___| | _ _ _ | | ____ ____ | |_ _| |__ _ ____ ____ \n"
  13. "| __)| |/ _ |/___) || \\ | | / || |/ _ ) _ \\| _)| | __) |/ _ )/ ___)\n"
  14. "| | | ( ( | |___ | | | | _| |( (_| ( (/ /| | | | |__| | | | ( (/ /| | \n"
  15. "|_| |_|\\_||_(___/|_| |_| (_____)____|\\____)_| |_|\\___)_|_| |_|\\____)_| \n"
  16. "_______________________________________________________________________________\n"
  17. "\n"
  18. "\t\t\t\t\t\t Version: 3.3.1 by Psycho_Coder\n"
  19. "_______________________________________________________________________________\n"
  20. "\t"
  21. )
  22.  
  23. USAGE = ("\tUsage: \n"
  24. "\n"
  25. "\t\tIn the terminal run : python HashIdentifier.py\n"
  26. "\n"
  27. "\t\t2.7.6 <= Python Versions Support >= 3.0\t\n"
  28. "\t"
  29. )
  30.  
  31. HASHES = (
  32. ("Blowfish(Eggdrop)", "^\+[a-zA-Z0-9\/\.]{12}$"),
  33. ("Blowfish(OpenBSD)", "^\$2a\$[0-9]{0,2}?\$[a-zA-Z0-9\/\.]{53}$"),
  34. ("Blowfish crypt", "^\$2[axy]{0,1}\$[a-zA-Z0-9./]{8}\$[a-zA-Z0-9./]{1,}$"),
  35. (("DES(Unix)", "DES crypt", "DES hash(Traditional)"), "^.{0,2}[a-zA-Z0-9\/\.]{11}$"),
  36. ("MD5(Unix)", "^\$1\$.{0,8}\$[a-zA-Z0-9\/\.]{22}$"),
  37. (("MD5(APR)", "Apache MD5"), "^\$apr1\$.{0,8}\$[a-zA-Z0-9\/\.]{22}$"),
  38. ("MD5(MyBB)", "^[a-fA-F0-9]{32}:[a-z0-9]{8}$"),
  39. ("MD5(ZipMonster)", "^[a-fA-F0-9]{32}$"),
  40. (("MD5 crypt", "FreeBSD MD5", "Cisco-IOS MD5"), "^\$1\$[a-zA-Z0-9./]{8}\$[a-zA-Z0-9./]{1,}$"),
  41. ("MD5 apache crypt", "^\$apr1\$[a-zA-Z0-9./]{8}\$[a-zA-Z0-9./]{1,}$"),
  42. ("MD5(Joomla)", "^[a-fA-F0-9]{32}:[a-zA-Z0-9]{16,32}$"),
  43. ("MD5(Wordpress)", "^\$P\$[a-zA-Z0-9\/\.]{31}$"),
  44. ("MD5(phpBB3)", "^\$H\$[a-zA-Z0-9\/\.]{31}$"),
  45. ("MD5(Cisco PIX)", "^[a-zA-Z0-9\/\.]{16}$"),
  46. (("MD5(osCommerce)", "xt:Commerce"), "^[a-fA-F0-9]{32}:[a-zA-Z0-9]{2}$"),
  47. ("MD5(Palshop)", "^[a-fA-F0-9]{51}$"),
  48. ("MD5(IP.Board)", "^[a-fA-F0-9]{32}:.{5}$"),
  49. ("MD5(Chap)", "^[a-fA-F0-9]{32}:[0-9]{32}:[a-fA-F0-9]{2}$"),
  50. ("Juniper Netscreen/SSG (ScreenOS)", "^[a-zA-Z0-9]{30}:[a-zA-Z0-9]{4,}$"),
  51. ("Fortigate (FortiOS)", "^[a-fA-F0-9]{47}$"),
  52. ("Minecraft(Authme)", "^\$sha\$[a-zA-Z0-9]{0,16}\$[a-fA-F0-9]{64}$"),
  53. ("Lotus Domino", "^\(?[a-zA-Z0-9\+\/]{20}\)?$"),
  54. ("Lineage II C4", "^0x[a-fA-F0-9]{32}$"),
  55. ("CRC-96(ZIP)", "^[a-fA-F0-9]{24}$"),
  56. ("NT crypt", "^\$3\$[a-zA-Z0-9./]{8}\$[a-zA-Z0-9./]{1,}$"),
  57. ("Skein-1024", "^[a-fA-F0-9]{256}$"),
  58. (("RIPEMD-320", "RIPEMD-320(HMAC)"), "^[A-Fa-f0-9]{80}$"),
  59. ("EPi hash", "^0x[A-F0-9]{60}$"),
  60. ("EPiServer 6.x < v4", "^\$episerver\$\*0\*[a-zA-Z0-9]{22}==\*[a-zA-Z0-9\+]{27}$"),
  61. ("EPiServer 6.x >= v4", "^\$episerver\$\*1\*[a-zA-Z0-9]{22}==\*[a-zA-Z0-9]{43}$"),
  62. ("Cisco IOS SHA256", "^[a-zA-Z0-9]{43}$"),
  63. ("SHA-1(Django)", "^sha1\$.{0,32}\$[a-fA-F0-9]{40}$"),
  64. ("SHA-1 crypt", "^\$4\$[a-zA-Z0-9./]{8}\$[a-zA-Z0-9./]{1,}$"),
  65. ("SHA-1(Hex)", "^[a-fA-F0-9]{40}$"),
  66. (("SHA-1(LDAP) Base64", "Netscape LDAP SHA", "NSLDAP"), "^\{SHA\}[a-zA-Z0-9+/]{27}=$"),
  67. ("SHA-1(LDAP) Base64 + salt", "^\{SSHA\}[a-zA-Z0-9+/]{28,}[=]{0,3}$"),
  68. ("SHA-512(Drupal)", "^\$S\$[a-zA-Z0-9\/\.]{52}$"),
  69. ("SHA-512 crypt", "^\$6\$[a-zA-Z0-9./]{8}\$[a-zA-Z0-9./]{1,}$"),
  70. ("SHA-256(Django)", "^sha256\$.{0,32}\$[a-fA-F0-9]{64}$"),
  71. ("SHA-256 crypt", "^\$5\$[a-zA-Z0-9./]{8}\$[a-zA-Z0-9./]{1,}$"),
  72. ("SHA-384(Django)", "^sha384\$.{0,32}\$[a-fA-F0-9]{96}$"),
  73. ("SHA-256(Unix)", "^\$5\$.{0,22}\$[a-zA-Z0-9\/\.]{43,69}$"),
  74. ("SHA-512(Unix)", "^\$6\$.{0,22}\$[a-zA-Z0-9\/\.]{86}$"),
  75. (("SHA-384", "SHA3-384", "Skein-512(384)", "Skein-1024(384)"), "^[a-fA-F0-9]{96}$"),
  76. (("SHA-512", "SHA-512(HMAC)", "SHA3-512", "Whirlpool", "SALSA-10", "SALSA-20", "Keccak-512", "Skein-512",
  77. "Skein-1024(512)"), "^[a-fA-F0-9]{128}$"),
  78. ("SSHA-1", "^({SSHA})?[a-zA-Z0-9\+\/]{32,38}?(==)?$"),
  79. (("SSHA-1(Base64)", "Netscape LDAP SSHA", "NSLDAPS"), "^\{SSHA\}[a-zA-Z0-9]{32,38}?(==)?$"),
  80. (("SSHA-512(Base64)", "LDAP {SSHA512}"), "^\{SSHA512\}[a-zA-Z0-9+]{96}$"),
  81. ("Oracle 11g", "^S:[A-Z0-9]{60}$"),
  82. ("SMF >= v1.1", "^[a-fA-F0-9]{40}:[0-9]{8}&"),
  83. ("MySQL 5.x", "^\*[a-f0-9]{40}$"),
  84. (("MySQL 3.x", "DES(Oracle)", "LM", "VNC", "FNV-164"), "^[a-fA-F0-9]{16}$"),
  85. ("OSX v10.7", "^[a-fA-F0-9]{136}$"),
  86. ("OSX v10.8", "^\$ml\$[a-fA-F0-9$]{199}$"),
  87. ("SAM(LM_Hash:NT_Hash)", "^[a-fA-F0-9]{32}:[a-fA-F0-9]{32}$"),
  88. ("MSSQL(2000)", "^0x0100[a-f0-9]{0,8}?[a-f0-9]{80}$"),
  89. (("MSSQL(2005)", "MSSQL(2008)"), "^0x0100[a-f0-9]{0,8}?[a-f0-9]{40}$"),
  90. ("MSSQL(2012)", "^0x02[a-f0-9]{0,10}?[a-f0-9]{128}$"),
  91. (("substr(md5($pass),0,16)", "substr(md5($pass),16,16)", "substr(md5($pass),8,16)", "CRC-64"),
  92. "^[a-fA-F0-9./]{16}$"),
  93. (("MySQL 4.x", "SHA-1", "HAVAL-160", "SHA-1(MaNGOS)", "SHA-1(MaNGOS2)", "TIGER-160", "RIPEMD-160",
  94. "RIPEMD-160(HMAC)",
  95. "TIGER-160(HMAC)", "Skein-256(160)", "Skein-512(160)"), "^[a-f0-9]{40}$"),
  96. (("SHA-256", "SHA-256(HMAC)", "SHA-3(Keccak)", "GOST R 34.11-94", "RIPEMD-256", "HAVAL-256", "Snefru-256",
  97. "Snefru-256(HMAC)", "RIPEMD-256(HMAC)", "Keccak-256", "Skein-256", "Skein-512(256)"), "^[a-fA-F0-9]{64}$"),
  98. (("SHA-1(Oracle)", "HAVAL-192", "OSX v10.4, v10.5, v10.6", "Tiger-192", "TIGER-192(HMAC)"), "^[a-fA-F0-9]{48}$"),
  99. (("SHA-224", "SHA-224(HMAC)", "HAVAL-224", "Keccak-224", "Skein-256(224)", "Skein-512(224)"), "^[a-fA-F0-9]{56}$"),
  100. (("Adler32", "FNV-32", "ELF-32", "Joaat", "CRC-32", "CRC-32B", "GHash-32-3", "GHash-32-5", "FCS-32", "Fletcher-32",
  101. "XOR-32"), "^[a-f0-9]{8}$"),
  102. (("CRC-16-CCITT", "CRC-16", "FCS-16"), "^[a-fA-F0-9]{4}$"),
  103. (("MD5(HMAC(Wordpress))", "MD5(HMAC)", "MD5", "RIPEMD-128", "RIPEMD-128(HMAC)", "Tiger-128", "Tiger-128(HMAC)",
  104. "RAdmin v2.x", "NTLM", "Domain Cached Credentials(DCC)", "Domain Cached Credentials 2(DCC2)", "MD4", "MD2",
  105. "MD4(HMAC)", "MD2(HMAC)", "Snefru-128", "Snefru-128(HMAC)", "HAVAL-128", "HAVAL-128(HMAC)", "Skein-256(128)",
  106. "Skein-512(128)", "MSCASH2"), "^[0-9A-Fa-f]{32}$"),
  107. )
  108.  
  109.  
  110. def identify_hashes(inputHash):
  111. """
  112. Function to identify all the hashes and return the results as list.
  113. """
  114.  
  115. # List to store the names of the identified Hash Algorithms
  116. res = []
  117.  
  118. # Loop through all the hashes in the HASHES tuple and find all the possible hashes.
  119. for items in HASHES:
  120. if match(items[1], inputHash):
  121. res += [items[0]] if (type(items[0]) is str) else items[0]
  122. return res
  123.  
  124.  
  125. # function Get input from the user maintaining the python compatibility with earlier and newer versions.
  126. def getInput(prompt):
  127. if hexversion > 0x03000000:
  128. return input(prompt)
  129. else:
  130. return raw_input(prompt)
  131.  
  132.  
  133. def startProcess():
  134. # Run infinite loop to ask for entering a hash everytime a hash if found.
  135. firstrun = True
  136. while True:
  137. print("_" * 80)
  138. print('\n')
  139.  
  140. # Take the Hash as Input from the User, Or from Run Args
  141. input_hash = ""
  142. if firstrun and len(argv) == 2:
  143. input_hash = argv[1]
  144. firstrun = False
  145. else:
  146. input_hash = getInput("Enter the Hash : ");
  147.  
  148.  
  149. if len(input_hash) < 1:
  150. print("\nPlease enter the hash. No input hash found.")
  151. else:
  152. # trim the hash entered and remove the unwanted spaces
  153. input_hash = input_hash.strip()
  154.  
  155. # Do the operation of Identifying the hashes.
  156. results = identify_hashes(input_hash)
  157.  
  158. # If the length of the list returned by the hash identifying method is zero
  159. # that means no hashes algorithms have been found
  160. if len(results) == 0:
  161. print("\n\nNot a Hash or Hash Unknown")
  162. elif len(results) > 2:
  163.  
  164. # Show the results with most and less probable hash algorithms
  165. print("\nMost Probable Hash Algorithms found:\n")
  166. print("[+] " + results[0])
  167. print("[+] " + results[1])
  168. print("\nOther Possible Hash Algorithms found:\n")
  169. for item in range(int(len(results)) - 2):
  170. print("[+] " + results[item + 2])
  171. else:
  172. print("\nMost Probable Hash Algorithms found:\n")
  173. for item in range(int(len(results))):
  174. print("[+] " + results[item])
  175.  
  176.  
  177. def main():
  178. # Print the TITLE and USAGE and then start the main loop.
  179. print(TITLE)
  180. print(USAGE)
  181. try:
  182. startProcess()
  183. except KeyboardInterrupt:
  184. print("Shutdown requested...exiting")
  185. except Exception:
  186. traceback.print_exc(file=stdout)
  187. exit(0)
  188.  
  189.  
  190. if __name__ == "__main__":
  191. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement