select.c (4876B)
1 /* 2 * Houndsniff - version 2.0.1 3 * 4 * by Michael Constantine 5 * Dimopoulos et al 6 * https://mcdim.xyz 7 * <mk@mcdim.xyz> 8 * GNU GPLv3 9 * 10 */ 11 12 #include <stdio.h> 13 #include <string.h> 14 #include <stdlib.h> 15 #include "select.h" 16 17 #define RED "\x1b[31m" 18 #define RESET "\x1b[0m" 19 20 void list(void); 21 int matchcmp(const void *, const void *); 22 void sel(int length, const char *charset, int clean_out); 23 char *replace(char *str); 24 25 char * 26 replace(char *str) 27 { 28 int len = strlen(str); 29 char *str2 = malloc (sizeof (char) * len); 30 int i; 31 32 for(i = 0; i < len; i++) { 33 if(str[i] == ' ') 34 str2[i] = '_'; 35 else 36 str2[i] = str[i]; 37 } 38 39 return str2; 40 } 41 42 /* Notes: 43 1. The popularity integer determines how the results are sorted 44 2. It is determined by the number web search results compared 45 to other hashing algorithms with the same characteristics. 46 47 charsets: 48 a = String is made only of numbers & lowercase letters 49 b = string includes a '$' 50 c = string includes a '/' 51 d = string begins with '$0$' 52 e = string includes uppercase letters */ 53 54 #define NHASHES (int)(sizeof(hashes) / sizeof(hashes[0])) /* array size */ 55 static const struct { 56 char *name; 57 short length; 58 char charset; 59 double likelihood; 60 } hashes[] = { 61 {"CRC16", 4, 'a', 100}, 62 63 {"CRC32b", 8, 'a', 56.84}, 64 {"CRC32", 8, 'a', 22.96}, 65 {"ADLER32", 8, 'a', 21.43}, 66 67 {"MD5 (half)", 16, 'a', 79.15}, 68 {"MySQL 3.2.3", 16, 'a', 20.85}, 69 70 {"MD5", 32, 'a', 44.1}, 71 {"LanManager Hash", 32, 'a', 25.67}, 72 {"Windows NT-Hash", 32, 'a', 5.93}, 73 {"RIPEMD128", 32, 'a', 4.81}, 74 {"MD4", 32, 'a', 3.16}, 75 {"MD2", 32, 'a', 2.56}, 76 {"Tiger128,4", 32, 'a', 2.13}, 77 {"Tiger128,3", 32, 'a', 2.13}, 78 {"HAVAL128,3", 32, 'a', 2.12}, 79 {"MD4 HMAC", 32, 'a', 1.90}, 80 {"HAVAL128,4", 32, 'a', 1.89}, 81 {"HAVAL128,5", 32, 'a', 1.88}, 82 {"DomainCachedCredentials", 32, 'a', 1.34}, 83 {"MD5 HMAC", 32, 'a', 0.33}, 84 85 {"SHA1", 40, 'a', 45.86}, 86 {"HAVAL160,4", 40, 'a', 13.83}, 87 {"Tiger160,3", 40, 'a', 8.99}, 88 {"Tiger160,4", 40, 'a', 8.81}, 89 {"RIPEMD160", 40, 'a', 8.18}, 90 {"HAVAL160,3", 40, 'a', 8.08}, 91 {"HAVAL160,5", 40, 'a', 6.21}, 92 93 {"Tiger192,4", 48, 'a', 31.14}, 94 {"Tiger192,3", 48, 'a', 19.84}, 95 {"HAVAL192,5", 48, 'a', 18.29}, 96 {"HAVAL192,4", 48, 'a', 17.67}, 97 {"HAVAL192,3", 48, 'a', 13.05}, 98 99 {"SHA224", 56, 'a', 27.79}, 100 {"HAVAL224,4", 56, 'a', 27.18}, 101 {"HAVAL224,3", 56, 'a', 22.81}, 102 {"HAVAL224,5", 56, 'a', 22.20}, 103 104 {"SHA256", 64, 'a', 66.07}, 105 {"GOST Hash", 64, 'a', 8.32}, 106 {"Snefru-128", 64, 'a', 7.52}, 107 {"RIPEMD256", 64, 'a', 6.48}, 108 {"HAVAL256,5", 64, 'a', 5.81}, 109 {"HAVAL256,3", 64, 'a', 5.77}, 110 111 {"RIPEMD320", 80, 'a', 100}, 112 113 {"SHA384", 96, 'a', 100}, 114 115 {"Whirpool", 128, 'a', 80.2}, 116 {"SHA512", 128, 'a', 19.8}, 117 118 {"FreeBSD nthash", 36, 'b', 100}, 119 120 {"CRYPT16", 24, 'c', 100}, 121 122 {"MSSQL 2005", 54, 'd', 70.16}, 123 {"MSSQL 2000", 94, 'd', 29.84}, 124 125 {"DES Crypt", 13, 'e', 100}, 126 }; 127 128 void 129 sel(int length, const char *charset, int clean_out) 130 { 131 int i; 132 int nmatch = 0; 133 int matches[NHASHES]; 134 135 for (i = 0; i < NHASHES; i++) { 136 if (hashes[i].length == length && hashes[i].charset == *charset) { 137 matches[nmatch++] = i; 138 } 139 } 140 141 qsort(matches, nmatch, sizeof(*matches), matchcmp); 142 143 if (!clean_out) printf("Possible results:\n\n"); 144 145 for (i = 0; i < nmatch; i++) { 146 if (!clean_out) { 147 printf("[" RED "%d" RESET "] %s - " RED "%.2f%" RESET "\n", 148 i + 1, hashes[matches[i]].name, 149 hashes[matches[i]].likelihood); 150 } else { 151 printf("%s %.2f\n", replace(hashes[matches[i]].name), 152 hashes[matches[i]].likelihood); 153 } 154 } 155 } 156 157 /* comparison function for qsort() */ 158 int 159 matchcmp(const void *p0, const void *p1) 160 { 161 int m0 = *(int *)p0; 162 int m1 = *(int *)p1; 163 return hashes[m1].likelihood - hashes[m0].likelihood; 164 } 165 166 void 167 list(void) 168 { 169 int i; 170 printf("\nHoundsniff supports:\n\n"); 171 for (i = 0; i < NHASHES; i++) { 172 puts(hashes[i].name); 173 } 174 175 /* hashes from main.c:definite(); */ 176 printf( "Wordpress hash \n" 177 "MD5 crypt(3) \n" 178 "SHA256 crypt(3)\n" 179 "SHA512 crypt(3)\n" 180 "Base64 \n" 181 "ARP1 \n" 182 "phpBB \n" 183 "SHA1 Django \n" 184 "PHP password_hash\n" 185 "MD5 Joomla (pass:salt)\n"); 186 }