houndsniff

Hash identification tool
git clone git@git.mcdim.xyz:/var/www/git/houndsniff.git
Log | Files | Refs | README | LICENSE

commit bb4e9c980aa43b6e0320abba7797b27c291bafc1
parent 7436292ee21a74e8b9bb7d7ccb43080deb78fbc2
Author: Michael Constantine Dimopoulos <mk@mcdim.xyz>
Date:   Fri, 15 Oct 2021 23:31:04 +0000

Code readability improvements

Diffstat:
Msrc/main.c | 68++++++++++++++++++++++++++++++++++++++++++--------------------------
Msrc/select.c | 91+++++++++++++++++++++++++++++++++++++++++--------------------------------------
2 files changed, 89 insertions(+), 70 deletions(-)

diff --git a/src/main.c b/src/main.c @@ -1,3 +1,14 @@ +/* + * Houndsniff - version 1.9 + * + * by Michael Constantine + * Dimopoulos et al + * https://mcdim.xyz + * <mk@mcdim.xyz> + * GNU GPLv3 + * + */ + #include <stdio.h> #include <stdlib.h> #include <stdbool.h> @@ -7,12 +18,6 @@ #include <readline/readline.h> #include "select.h" -/* - * Houndsniff - * hash identification - * - * by Michael Constantine Dimopoulos et al - */ #define VERSION "1.9" @@ -42,6 +47,20 @@ banner() "\n",VERSION); } +static int +starts_with(const char *a, const char *b) +{ + if(strncmp(a, b, strlen(b)) == 0) return 1; + return 0; +} + +static void +dprint(char *name) +{ + printf("[" RED "+" RESET "] Definite identification %s\n", name); +} + + /* This is the first test; * here we identify the hash * based on *definite* characteristics @@ -49,28 +68,25 @@ banner() void definite(char string[], int length) { - char *def = "[" RED "+" RESET "] Definite identification"; - - if (string[0]=='$' && string[1]=='P' && string[2]=='$') - printf("%s Wordpress hash\n", def); - else if (string[0]=='$' && string[1]=='1' && string[2]=='$') - printf("%s MD5 crypt(3)\n", def); - else if (string[0]=='$' && string[1]=='5' && string[2]=='$') - printf("%s SHA256 crypt(3)\n", def); - else if (string[0]=='$' && string[1]=='6' && string[2]=='$') - printf("%s SHA512 crypt(3)\n", def); + + if (starts_with(string, "$P")) + dprint("Wordpress hash"); + else if (starts_with(string, "$1$")) + dprint("MD5 crypt(3)"); + else if (starts_with(string, "$5$")) + dprint("SHA256 crypt(3)"); + else if (starts_with(string, "$6$")) + dprint("SHA512 crypt(3)"); else if (string[length-1]=='=') - printf("%s Base64 or Base32\n", def); - else if (string[0]=='$' && string[1]=='a' && string[2]=='p' - && string[3]=='r' && string[4]=='1' && string[5]=='$') - printf("%s APR1\n", def); - else if (string[0]=='$' && string[1]=='H' && string[2]=='$') - printf("%s phpBB\n", def); - else if (string[0]=='s' && string[1]=='h' && string[2]=='a' && - string[3]=='1' && string[4]=='$') - printf("%s SHA1 Django\n", def); + dprint("Base64 or Base32"); + else if (starts_with(string, "$apr1$")) + dprint("APR1"); + else if (starts_with(string, "$H$")) + dprint("phpBB"); + else if (starts_with(string, "sha1$")) + dprint("SHA1 Django"); else if (length==65 && string[32]==':') - printf("%s MD5 Joomla (pass:salt)\n", def); + dprint("MD5 Joomla (pass:salt)"); } /* this function determines charset*/ diff --git a/src/select.c b/src/select.c @@ -1,16 +1,19 @@ +/* + * Houndsniff - version 1.9 + * + * by Michael Constantine + * Dimopoulos et al + * https://mcdim.xyz + * <mk@mcdim.xyz> + * GNU GPLv3 + * + */ + #include <stdio.h> #include <string.h> #include <stdlib.h> #include "select.h" -/* houndsniff - * hash identification program - * - * this is basically where the program - * indexes through the database and picks - * out the rows with desired values - */ - #define RED "\x1b[31m" #define RESET "\x1b[0m" @@ -37,57 +40,57 @@ static const struct { char charset; char popularity; } hashes[] = { + {"CRC16", 4, 'a', 50}, + {"CRC32b", 8, 'a', 10}, + {"ADLER32", 8, 'a', 8}, + {"CRC32", 8, 'a', 19}, + {"MySQL 3.2.3", 16, 'a', 20}, + {"MD5 (half)", 16, 'a', 10}, {"MD5", 32, 'a', 100}, - {"SHA1", 40, 'a', 85}, - {"SHA256", 64, 'a', 87}, - {"SHA224", 56, 'a', 79}, - {"SHA384", 96, 'a', 58}, - {"SHA512", 128, 'a', 70}, - {"RIPEMD160 ", 40, 'a', 38}, {"MD4", 32, 'a', 40}, {"MD2", 32, 'a', 35}, - {"CRC32b", 8, 'a', 10}, - {"ADLER32", 8, 'a', 8}, - {"CRYPT16", 24, 'c', 10}, {"LanManager Hash", 32, 'a', 25}, {"Windows NT-Hash", 32, 'a', 20}, - {"MSSQL 2000", 94, 'd', 20}, - {"MSSQL 2005", 54, 'd', 20}, - {"MySQL 3.2.3", 16, 'a', 20}, - {"DES Crypt", 13, 'e', 20}, - {"FreeBSD nthash", 36, 'b', 20}, - {"CRC32", 8, 'a', 19}, {"HAVAL128,5", 32, 'a', 28}, {"HAVAL128,4", 32, 'a', 26}, {"HAVAL128,3", 32, 'a', 27}, - {"HAVAL256,5", 64, 'a', 20}, - {"HAVAL224,5", 56, 'a', 21}, - {"HAVAL192,5", 48, 'a', 27}, + {"Tiger128,3", 32, 'a', 5}, + {"RIPEMD128", 32, 'a', 9}, + {"DomainCachedCredentials", 32, 'a', 10}, + {"MD4 HMAC", 32, 'a', 7}, + {"MD5 HMAC", 32, 'a', 12}, + {"Tiger128,4", 32, 'a', 7}, + {"SHA1", 40, 'a', 85}, {"HAVAL160,5", 40, 'a', 22}, - {"HAVAL224,4", 56, 'a', 25}, - {"HAVAL192,4", 48, 'a', 26}, + {"RIPEMD160 ", 40, 'a', 38}, {"HAVAL160,4", 40, 'a', 21}, - {"HAVAL256,3", 64, 'a', 18}, - {"HAVAL224,3", 56, 'a', 20}, - {"HAVAL192,3", 48, 'a', 25}, {"HAVAL160,3", 40, 'a', 22}, - {"Whirpool", 128, 'a', 50}, + {"Tiger160,3", 40, 'a', 5}, + {"Tiger160,4", 40, 'a', 7}, + {"HAVAL192,5", 48, 'a', 27}, + {"HAVAL192,4", 48, 'a', 26}, + {"Tiger192,3", 48, 'a', 6}, + {"HAVAL192,3", 48, 'a', 25}, + {"Tiger192,4", 48, 'a', 5}, + {"SHA224", 56, 'a', 79}, + {"HAVAL224,3", 56, 'a', 20}, + {"HAVAL224,5", 56, 'a', 21}, + {"HAVAL224,4", 56, 'a', 25}, {"GOST Hash", 64, 'a', 10}, {"Snefru-128", 64, 'a', 5}, - {"RIPEMD128", 32, 'a', 9}, {"RIPEMD256", 64, 'a', 9}, + {"HAVAL256,5", 64, 'a', 20}, + {"HAVAL256,3", 64, 'a', 18}, + {"SHA256", 64, 'a', 87}, {"RIPEMD320", 80, 'a', 8}, - {"Tiger128,3", 32, 'a', 5}, - {"Tiger160,3", 40, 'a', 5}, - {"Tiger192,3", 48, 'a', 6}, - {"Tiger128,4", 32, 'a', 7}, - {"Tiger160,4", 40, 'a', 7}, - {"Tiger192,4", 48, 'a', 5}, - {"CRC16", 4, 'a', 50}, - {"DomainCachedCredentials", 32, 'a', 10}, - {"MD5 (half)", 16, 'a', 10}, - {"MD4 HMAC", 32, 'a', 7}, - {"MD5 HMAC", 32, 'a', 12}, + {"SHA384", 96, 'a', 58}, + {"SHA512", 128, 'a', 70}, + {"Whirpool", 128, 'a', 50}, + {"FreeBSD nthash", 36, 'b', 20}, + {"CRYPT16", 24, 'c', 10}, + {"MSSQL 2000", 94, 'd', 20}, + {"MSSQL 2005", 54, 'd', 20}, + {"DES Crypt", 13, 'e', 20}, }; void