// clang -Werror -Wall -O3 -mssse3 -msha cpu-brute.c sha.c prng.c -o brute && scp brute scanifi:/tmp #include "sha1.h" #define gen_bsd_drand48 1 // #define gen_msvc_rand 1 #include "prng.h" #include #include #include #include #include #include #include #include #include #define IDA72 1 #define PARALLEL 48 int main() { char* charset = "abcdefghijkmpqrstuvwxyzABCDEFGHJKLMPQRSTUVWXYZ23456789"; #ifdef IDA72 uint8_t hash[20] = { // ida 7.2 0xF2, 0x9F, 0x55, 0xF0, 0x7C, 0x04, 0x3A, 0xD3, 0x4B, 0x3D, 0xE1, 0x50, 0x50, 0x15, 0x35, 0xF4, 0x44, 0x24, 0xED, 0xAD }; #else uint8_t hash[20] = { // ida 7.0 0x7B, 0xA6, 0xF1, 0xDF, 0x9B, 0x88, 0xA2, 0x5C, 0x6C, 0x5D, 0xA5, 0x22, 0xCC, 0xC3, 0x07, 0x24, 0x8A, 0xA0, 0xEC, 0x62 }; #endif #define SALT_LEN 25 #ifdef IDA72 uint8_t pw[49] = { // ida 7.2. utf-16 LE, unknown rng 0x50, 0x61, 0x73, 0x73, 0x77, 0x6F, 0x72, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6B, 0x48, 0x61, 0x73, 0x68, 0xC4, 0x16, 0x39, 0x79, 0x28, 0x46, 0xE4, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; #define PW_UTF16LE 1 #else uint8_t pw[37] = { // ida 7.0 MS-ANSI, msvc rng, seed=0x3AC5C29B 0x50, 0x61, 0x73, 0x73, 0x77, 0x6F, 0x72, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6B, 0x48, 0x61, 0x73, 0x68, 0x84, 0x6E, 0x85, 0x47, 0x45, 0x12, 0xDF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; #define PW_UTF16LE 0 #endif perl_rand_state rand_state; sha1_ctx ctx; uint8_t digest[20]; uint32_t seed = 0; uint32_t upto = (uint32_t)(0x100000000L / (uint64_t)PARALLEL); int worker = 0; for (; worker < PARALLEL; worker++) { if (!fork()) { printf("Worker %d, bruting %x to %x\n", worker,seed,upto); break; // child } seed = upto; upto += (uint64_t)(0x100000000L / (uint64_t)PARALLEL); } do { if (!(seed & 0xffffff)) printf("%x\n", seed); perl_srand(&rand_state, seed); #ifdef IDA72 perl_rand(&rand_state); // discard first result?! #endif for (int i = 0, j = 0; i < 12; i++) { int key = (int)(perl_rand(&rand_state) * 54.0); pw[j+++SALT_LEN] = charset[key]; if (PW_UTF16LE) pw[j+++SALT_LEN] = '\0'; } SHA1Init(&ctx); SHA1Update(&ctx, pw, sizeof(pw)); SHA1Final(&ctx, digest); if (!memcmp(digest, hash, 20)) { int fd = open("sice.txt", O_APPEND | O_RDWR | O_CREAT,0); printf("CRACKED!!!! %x\n", seed); dprintf(fd, "CRACKED!!!! %x\n", seed); for (int i = 0; i < (PW_UTF16LE ? 24 : 12); i += (PW_UTF16LE ? 2 : 1)) { printf("%c", pw[i + SALT_LEN]); dprintf(fd, "%c", pw[i + SALT_LEN]); } printf("\n"); dprintf(fd, "\n"); close(fd); kill(0, SIGQUIT); break; } } while(++seed != upto); printf("Worker %d done\n", worker); }