Created
May 22, 2019 03:46
-
-
Save NullArray/923f879c7b6f2ef0778ed43c6bdbd646 to your computer and use it in GitHub Desktop.
Simple hash checker.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
''' | |
#--ANSI Colored Formatting--# | |
#--Mini Library by Vector --# | |
#--Licensed under GNU GPL3--# | |
''' | |
_ERROR_ = "The 'text' method takes two arguments.\n" | |
_ERROR_ += "the first one of which is mandatory. \n" | |
_ERROR_ += "Valid values are passed as string and \n" | |
_ERROR_ += "Include; 'green', 'red_bg' and '~' etc\n" | |
# Custom coloring and formatting | |
def text(color, text=''): | |
# Colored text | |
green = "\x1b[32;01m" + text + "\x1b[39;49;00m" | |
cyan = "\x1b[33;36m" + text + "\x1b[39;49;00m" | |
red = "\x1b[31;01m" + text + "\x1b[39;49;00m" | |
magenta = "\x1b[0;35m" + text + "\x1b[39;49;00m" | |
#-----------Add more colors below---------------# | |
# COLOR = "[ ANSI ] + text + "\x1b[39;49;00m" | |
# Colored Background | |
green_bg = "\e[42m" + text + "\x1b[39;49;00m" | |
cyan_bg = "\e[46m" + text + "\x1b[39;49;00m" | |
red_bg = "\e[41m" + text + "\x1b[39;49;00m" | |
magenta_bg = "\e[45m" + text + "\x1b[39;49;00m" | |
#-----------Add more colors below---------------# | |
# COLOR = "[ ANSI ] + text + "\x1b[39;49;00m" | |
# Colored symbols | |
note = "\x1b[32;01m[+]\x1b[39;49;00m" | |
info = "\x1b[33;36m[i]\x1b[39;49;00m" | |
warn = "\x1b[31;01m[!]\x1b[39;49;00m" | |
misc = "\x1b[0;35m[~]\x1b[39;49;00m" | |
# Add more colored symbols below | |
# MSG = "ANSI[*]\x1b[39;49;00m" | |
if color == 'green': | |
return green | |
elif color == 'cyan': | |
return cyan | |
elif color == 'red': | |
return red | |
elif color == 'magenta': | |
return magenta | |
elif color == 'green_bg': | |
return green_bg | |
elif color == 'cyan_bg': | |
return cyan_bg | |
elif color == 'red_bg': | |
return red_bg | |
elif color == 'magenta_bg': | |
return magenta_bg | |
elif color == '+': | |
return note | |
elif color == 'i': | |
return info | |
elif color == '!': | |
return warn | |
elif color == '~': | |
return misc | |
else: | |
raise BaseException(_ERROR_) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import re | |
from chroma import text | |
HASH_TYPE_REGEX = { | |
re.compile(r"^[a-f0-9]{32}(:.+)?$", re.IGNORECASE): ["MD5", "MD4", "MD2", "Double MD5", "LM", "RIPEMD-128", "Haval-128", "Tiger-128", "Skein-256(128)", "Skein-512(128", "Lotus Notes/Domino 5", "Skype", "ZipMonster", "PrestaShop"], | |
re.compile(r"^[a-f0-9]{64}(:.+)?$", re.IGNORECASE): ["SHA-256", "RIPEMD-256", "SHA3-256", "Haval-256", "GOST R 34.11-94", "GOST CryptoPro S-Box", "Skein-256", "Skein-512(256)", "Ventrilo"], | |
re.compile(r"^[a-f0-9]{128}(:.+)?$", re.IGNORECASE): ["SHA-512", "Whirlpool", "Salsa10", "Salsa20", "SHA3-512", "Skein-512", "Skein-1024(512)"], | |
re.compile(r"^[a-f0-9]{56}$", re.IGNORECASE): ["SHA-224", "Haval-224", "SHA3-224", "Skein-256(224)", "Skein-512(224)"], | |
re.compile(r"^[a-f0-9]{40}(:.+)?$", re.IGNORECASE): ["SHA-1", "Double SHA-1", "RIPEMD-160", "Haval-160", "Tiger-160", "HAS-160","LinkedIn", "Skein-256(160)", "Skein-512(160)", "MangoWeb Enhanced CMS"], | |
re.compile(r"^[a-f0-9]{96}$", re.IGNORECASE): ["SHA-384", "SHA3-384", "Skein-512(384)","Skein-1024(384)"], | |
re.compile(r"^[a-f0-9]{16}$", re.IGNORECASE): ["MySQL323", "DES(Oracle)", "Half MD5", "Oracle 7-10g", "FNV-164", "CRC-64"], | |
re.compile(r"^\*[a-f0-9]{40}$", re.IGNORECASE): ["MySQL5.x", "MySQL4.1"], | |
re.compile(r"^[a-f0-9]{48}$", re.IGNORECASE): ["Haval-192", "Tiger-192", "SHA-1(Oracle)", "XSHA (v10.4 - v10.6)"] | |
} | |
def enumerate_hash_types(items, nb_likeliest=5, verbose=False): | |
if not verbose == False: | |
print "{} possible hash types found...".format(len(items)) | |
count = 0 | |
for item in items: | |
count += 1 | |
if count <= nb_likeliest: | |
msg = "Most likely hash type: {}".format(item) | |
if not verbose == False: | |
print text('+', msg) | |
if count == nb_likeliest: | |
print "" | |
def obtain_hash_type(check_hash, mode=''): | |
found = False | |
for algorithm, items in HASH_TYPE_REGEX.items(): | |
if algorithm.match(check_hash): | |
found = True | |
if 'silent' in mode: | |
''' | |
It might seem counter intuitive to return this string | |
When running in "silent" mode, but the result of the | |
execution of this function is checked to determine | |
whether ComproBase proper is getting hashes as input | |
through "list mode" or some other kind of data. | |
''' | |
return "Hash Found" | |
else: | |
enumerate_hash_types(items) | |
if not found: | |
return None | |
def main(): | |
check_hash = raw_input("<HASH>$ ") | |
obtain_hash_type(check_hash) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment