/* * NTLM patch for john version 0.3 * * (C) 2001 Olle Segerdahl * * license: GPL * * This file is based on code from John the Ripper, * Copyright (c) 1996-99 by Solar Designer * * performance enhancements by bartavelle@bandecon.com */ #include #include "arch.h" #include "memory.h" #include "common.h" #include "formats.h" #include "md4.h" #ifndef uchar #define uchar unsigned char #endif #define FORMAT_LABEL "ntmmx" #define FORMAT_NAME "NT MD4 MMX" #define BENCHMARK_COMMENT MMX_TYPE #define BENCHMARK_LENGTH -1 #define PLAINTEXT_LENGTH 32 #define CIPHERTEXT_LENGTH 36 static struct fmt_tests tests[] = { {"$NT$b7e4b9022cd45f275334bbdb83bb5be5", "John the Ripper"}, {"$NT$8846f7eaee8fb117ad06bdd830b7586c", "password"}, {"$NT$0cb6948805f797bf2a82807973b89537", "test"}, {"$NT$31d6cfe0d16ae931b73c59d7e0c089c0", ""}, {NULL} }; #define ALGORITHM_NAME "bartavelle" #define BINARY_SIZE 16 #define SALT_SIZE 0 #define MIN_KEYS_PER_CRYPT MMX_COEF #define MAX_KEYS_PER_CRYPT MMX_COEF #define GETPOS(i,idx) ( ((i)&0xfffe)*MMX_COEF + ((i)&1) + ((idx)<<1) ) //uchar saved_plain[PLAINTEXT_LENGTH + 1]; static unsigned char saved_plain[64 * MMX_COEF] __attribute__ ((aligned(32))); static unsigned char tmpbuf[64 * MMX_COEF] __attribute__ ((aligned(32))); static unsigned char output[BINARY_SIZE*MMX_COEF + 1] __attribute__ ((aligned(32))); static unsigned char out[32]; static unsigned long total_len; static int global_watch = 0; static int valid(char *ciphertext) { char *pos; if (strncmp(ciphertext, "$NT$", 4)!=0) return 0; for (pos = &ciphertext[4]; atoi16[ARCH_INDEX(*pos)] != 0x7F; pos++); if (!*pos && pos - ciphertext == CIPHERTEXT_LENGTH) return 1; else return 0; } static void *get_binary(char *ciphertext) { static uchar binary[BINARY_SIZE]; int i; ciphertext+=4; for (i=0; i 1 ) && ( ((unsigned long *)binary)[i] != ((unsigned long *)output)[i*MMX_COEF+1]) #endif #if (MMX_COEF > 3) && ( ((unsigned long *)binary)[i] != ((unsigned long *)output)[i*MMX_COEF+2]) && ( ((unsigned long *)binary)[i] != ((unsigned long *)output)[i*MMX_COEF+3]) #endif ) return 0; i++; } return 1; } static int cmp_one(void * binary, int index) { int i = 0; for(i=0;i<(BINARY_SIZE/4);i++) if ( ((unsigned long *)binary)[i] != ((unsigned long *)output)[i*MMX_COEF+index] ) return 0; return 1; } static int cmp_exact(char *source, int index) { return 1; } static void set_salt(void *salt) { } static void set_key(char *key, int index) { int len; int i; if(index==0) { total_len = 0; memset(saved_plain, 0, 64*MMX_COEF); } len = strlen(key); if(len > 32) len = 32; total_len += len << (1 + ( (32/MMX_COEF) * index ) ); for(i=0;i> (1+((32/MMX_COEF)*(index)))) & 0xff; #else if(index == 0) s = (total_len & 0xffff) >> 1 ; else s = total_len >> 17; #endif for(i=0;i