diff -urpN john-1.7.2/doc/LICENSING.mpi john-1.7.2-mpi/doc/LICENSING.mpi --- john-1.7.2/doc/LICENSING.mpi 1969-12-31 17:00:00.000000000 -0700 +++ john-1.7.2-mpi/doc/LICENSING.mpi 2008-06-15 00:40:33.760443270 -0600 @@ -0,0 +1,20 @@ +######## +# 2008/06/14 +# +# This file was originally doc/LICENSING and appears to have come from +# the original MPI implementation by Ryan Lim, made against 1.6.x. +######## + +John the Ripper 1.7, when released, is going to be GPL'ed. However, +the licensing status of one source file -- x86-mmx.S -- is non-obvious +to me. I have explicit permission to use the S-box code found in this +file in John, but I'm not sure whether this was meant to imply that I +am free to put this code under a license of my choice. I haven't got +a reply regarding this so far. + +Portions of this code I've placed into the public domain as a separate +package designed to provide modern password hashing for your software +and your servers (where the GPL restrictions could be a problem). The +package can be found at: + + http://www.openwall.com/crypt/ diff -urpN john-1.7.2/doc/README.MPI john-1.7.2-mpi/doc/README.MPI --- john-1.7.2/doc/README.MPI 1969-12-31 17:00:00.000000000 -0700 +++ john-1.7.2-mpi/doc/README.MPI 2008-06-15 00:40:33.763775721 -0600 @@ -0,0 +1,30 @@ +################ +# 2008/06/14 +# +# This file seems to have come from the original MPI implementation by +# Ryan Lim against JtR 1.6.x. The patchset was subsequently picked up +# and maintained by John Anderson at bindshell.net. In June 2008 in +# interest of disentangling the MPI work from the added hash formats +# as well as to bring the code base more in line with the current +# JtR 1.7.2 implementation, the patch was stripped down to the bare +# minimum required for the MPI implementation. No intentional +# functional modifications were made except for stripping the non- +# standard hash formats and streamlining the patch down from 440k and +# roughly 12000 LOC to 32k and roughly 500 LOC. This patch should be +# able to be used with (and has been tested against) the more current +# 'jumbo' patches, enabling wider hash support and more supportable +# parallelized code. This patch is offered as-is with no warranty or +# claim, as it is simply a re-arrangement of prior art. +################ + +This distribution of John the Ripper (1.6.36) requires MPI to compile. + +If you don't have MPI, download and install it before proceeeding. + +Any bugs, patches, comments or love letters should be sent to +jtr-mpi@hash.ryanlim.com. Hate mail, death threates should be sent to +/dev/null. + +Enjoy. +-- +Ryan Lim diff -urpN john-1.7.2/src/Makefile john-1.7.2-mpi/src/Makefile --- john-1.7.2/src/Makefile 2006-05-15 10:38:00.000000000 -0600 +++ john-1.7.2-mpi/src/Makefile 2008-06-15 00:41:00.926524999 -0600 @@ -3,10 +3,10 @@ # Copyright (c) 1996-2006 by Solar Designer # -CPP = gcc -CC = gcc -AS = gcc -LD = gcc +CPP = mpicc +CC = mpicc +AS = mpicc +LD = mpicc CP = cp LN = ln -sf RM = rm -f @@ -36,6 +36,8 @@ JOHN_OBJS_MINIMAL = \ unafs.o \ unique.o +JOHN_OBJS_MINIMAL += ryan.o + JOHN_OBJS_ORIG = \ $(JOHN_OBJS_MINIMAL) \ DES_bs_b.o @@ -59,6 +61,7 @@ BENCH_BF_OBJS_DEPEND = \ BF_std.o BENCH_OBJS = \ + ryan.o \ $(BENCH_DES_OBJS_DEPEND) \ DES_bs.o $(BENCH_DES_BS_OBJS_DEPEND) \ $(BENCH_MD5_OBJS_DEPEND) \ @@ -107,12 +110,12 @@ default: @echo "netbsd-sparc64 NetBSD, SPARC 64-bit" @echo "netbsd-vax NetBSD, VAX" @echo "solaris-sparc64-cc Solaris, SPARC V9 64-bit, cc (best)" - @echo "solaris-sparc64-gcc Solaris, SPARC V9 64-bit, gcc" + @echo "solaris-sparc64-mpicc Solaris, SPARC V9 64-bit, mpicc" @echo "solaris-sparcv9-cc Solaris, SPARC V9 32-bit, cc" @echo "solaris-sparcv8-cc Solaris, SPARC V8 32-bit, cc" - @echo "solaris-sparc-gcc Solaris, SPARC 32-bit, gcc" - @echo "solaris-x86-any Solaris, x86, gcc" - @echo "sco-x86-any-gcc SCO, x86, gcc" + @echo "solaris-sparc-mpicc Solaris, SPARC 32-bit, mpicc" + @echo "solaris-x86-any Solaris, x86, mpicc" + @echo "sco-x86-any-mpicc SCO, x86, mpicc" @echo "sco-x86-any-cc SCO, x86, cc" @echo "tru64-alpha Tru64 (Digital UNIX, OSF/1), Alpha" @echo "aix-ppc32 AIX, PowerPC 32-bit" @@ -121,7 +124,7 @@ default: # @echo "macosx-ppc64-altivec Mac OS X, PowerPC 64-bit w/AltiVec" @echo "macosx-ppc64 Mac OS X 10.4+, PowerPC 64-bit" @echo "macosx-x86-sse2 Mac OS X, x86 with SSE2" - @echo "hpux-pa-risc-gcc HP-UX, PA-RISC, gcc" + @echo "hpux-pa-risc-mpicc HP-UX, PA-RISC, mpicc" @echo "hpux-pa-risc-cc HP-UX, PA-RISC, ANSI cc" @echo "irix-mips64-r10k IRIX, MIPS 64-bit (R10K) (best)" @echo "irix-mips64 IRIX, MIPS 64-bit" @@ -134,7 +137,7 @@ default: @echo "beos-x86-sse2 BeOS, x86 with SSE2 (best)" @echo "beos-x86-mmx BeOS, x86 with MMX" @echo "beos-x86-any BeOS, x86" - @echo "generic Any other Unix-like system with gcc" + @echo "generic Any other Unix-like system with mpicc" linux-x86-sse2: $(LN) x86-sse.h arch.h @@ -363,7 +366,7 @@ solaris-sparc64-cc: OPT_NORMAL="" \ OPT_INLINE="-xinline=s1,s2,s3,s4,s5,s6,s7,s8" -solaris-sparc64-gcc: +solaris-sparc64-mpicc: $(LN) sparc64.h arch.h $(MAKE) $(PROJ) \ CFLAGS="$(CFLAGS) -m64 -mcpu=ultrasparc" \ @@ -381,8 +384,8 @@ solaris-sparcv9-cc: solaris-sparcv8-cc: $(MAKE) solaris-sparc-any HAMMER=use-solaris-sparcv8-cc -solaris-sparc-gcc: - $(MAKE) solaris-sparc-any HAMMER=use-solaris-sparc-gcc +solaris-sparc-mpicc: + $(MAKE) solaris-sparc-any HAMMER=use-solaris-sparc-mpicc use-solaris-sparcv9-cc: $(MAKE) $(NAIL) \ @@ -404,7 +407,7 @@ use-solaris-sparcv8-cc: OPT_NORMAL="" \ OPT_INLINE="-xinline=s1,s2,s3,s4,s5,s6,s7,s8" -use-solaris-sparc-gcc: +use-solaris-sparc-mpicc: $(MAKE) $(NAIL) \ BENCH_DES_OBJS_DEPEND="$(BENCH_DES_OBJS_ORIG) sparc.o" \ JOHN_OBJS="$(JOHN_OBJS_ORIG) sparc.o" \ @@ -437,7 +440,7 @@ solaris-x86.o: x86.S $(AS) $(ASFLAGS) tmp.s -o solaris-x86.o $(RM) tmp.s -sco-x86-any-gcc: +sco-x86-any-mpicc: $(RM) arch.h ln -s x86-any.h arch.h $(MAKE) $(PROJ) \ @@ -547,7 +550,7 @@ macosx-x86-mmx: OPT_NORMAL="-O2" \ OPT_INLINE="-O3" -hpux-pa-risc-gcc: +hpux-pa-risc-mpicc: $(LN) pa-risc.h arch.h $(MAKE) $(PROJ) \ CFLAGS="-c -Wall -O3 -fomit-frame-pointer" diff -urpN john-1.7.2/src/bench.c john-1.7.2-mpi/src/bench.c --- john-1.7.2/src/bench.c 2006-02-27 02:52:35.000000000 -0700 +++ john-1.7.2-mpi/src/bench.c 2008-06-15 00:40:33.770442393 -0600 @@ -3,6 +3,11 @@ * Copyright (c) 1996-2001,2003,2004,2006 by Solar Designer */ +/* + * 15.02.08 Elli0t: fixed get_cps; benchmark_all: double -> long; + * added: format_cps, print_cps. + */ + #ifdef __ultrix__ #define __POSIX #define _POSIX_SOURCE @@ -30,6 +35,9 @@ #include "formats.h" #include "bench.h" +#include "mpi.h" +#include "ryan.h" + long clk_tck = 0; void clk_tck_init(void) @@ -205,20 +213,69 @@ void benchmark_cps(unsigned ARCH_WORD co } } + +/* RYAN */ +long get_cps( unsigned ARCH_WORD count, clock_t time ) +{ + unsigned int cps_hi; + int64 tmp; + tmp.lo = count; + tmp.hi = 0; + mul64by32( &tmp, clk_tck ); + cps_hi = div64by32lo( &tmp, time ); + return( cps_hi ); +} + +void format_cps( char *buffer, long cps ) +{ + if ( cps >= 1000000 ) + sprintf( buffer, "%ldK", cps / 1000 ); + else + sprintf( buffer, "%ld", cps ); +} + +void print_cps( const char *msg, long cps_r, long cps_v ) +{ + char buf_r[20], buf_v[20]; + format_cps( buf_r, cps_r ); + format_cps( buf_v, cps_v ); +#if !defined(__DJGPP__) && !defined(__CYGWIN32__) && !defined(__BEOS__) + printf( "%s:\t%s c/s real, %s c/s virtual\n", + msg, buf_r, buf_v ); +#else + printf( "%s:\t%s c/s\n", + msg, buf_r ); +#endif + printf( "\n" ); + fflush( stdout ); +} + void benchmark_all(void) { struct fmt_main *format; char *result, *msg_1, *msg_m; struct bench_results results_1, results_m; - char s_real[64], s_virtual[64]; + /* char s_real[64], s_virtual[64]; */ + + /* RYAN */ + long global_rcs_m=0, global_vcs_m=0; + long local_rcs_m=0, local_vcs_m=0; + long global_rcs_1=0, global_vcs_1=0; + long local_rcs_1=0, local_vcs_1=0; + global_rcs_m = 0; + global_vcs_m = 0; + global_rcs_1 = 0; + global_vcs_1 = 0; if ((format = fmt_list)) do { - printf("Benchmarking: %s%s [%s]... ", - format->params.format_name, - format->params.benchmark_comment, - format->params.algorithm_name); - fflush(stdout); + if(mpi_id == 0) { + printf("Benchmarking: %s%s [%s]... ", + format->params.format_name, + format->params.benchmark_comment, + format->params.algorithm_name); + fflush(stdout); + } switch (format->params.benchmark_length) { case -1: @@ -239,18 +296,36 @@ void benchmark_all(void) if ((result = benchmark_format(format, format->params.salt_size ? BENCHMARK_MANY : 1, &results_m))) { - puts(result); + if(mpi_id == 0) { + puts(result); + } continue; } if (msg_1) if ((result = benchmark_format(format, 1, &results_1))) { - puts(result); + if(mpi_id == 0) { + puts(result); + } continue; } - puts("DONE"); + if(mpi_id == 0) { + puts("DONE"); + } + local_rcs_m = get_cps(results_m.count, results_m.real); + MPI_Reduce(&local_rcs_m, &global_rcs_m, 1, MPI_LONG, + MPI_SUM, 0, MPI_COMM_WORLD); + local_vcs_m = get_cps(results_m.count, results_m.virtual); + MPI_Reduce(&local_vcs_m, &global_vcs_m, 1, MPI_LONG, + MPI_SUM, 0, MPI_COMM_WORLD); + + if ( mpi_id == 0 ){ + print_cps( msg_m, global_rcs_m, global_vcs_m ); + } + + /* benchmark_cps(results_m.count, results_m.real, s_real); benchmark_cps(results_m.count, results_m.virtual, s_virtual); #if !defined(__DJGPP__) && !defined(__CYGWIN32__) && !defined(__BEOS__) @@ -260,12 +335,27 @@ void benchmark_all(void) printf("%s:\t%s c/s\n", msg_m, s_real); #endif + */ if (!msg_1) { - putchar('\n'); + if(mpi_id == 0) { + putchar('\n'); + } continue; } + local_rcs_1 = get_cps(results_1.count, results_1.real); + MPI_Reduce(&local_rcs_1, &global_rcs_1, 1, MPI_LONG, + MPI_SUM, 0, MPI_COMM_WORLD); + local_vcs_1 = get_cps(results_1.count, results_1.virtual); + MPI_Reduce(&local_vcs_1, &global_vcs_1, 1, MPI_LONG, + MPI_SUM, 0, MPI_COMM_WORLD); + + if ( mpi_id == 0 ){ + print_cps( msg_1, global_rcs_1, global_vcs_1 ); + } + + /* benchmark_cps(results_1.count, results_1.real, s_real); benchmark_cps(results_1.count, results_1.virtual, s_virtual); #if !defined(__DJGPP__) && !defined(__CYGWIN32__) && !defined(__BEOS__) @@ -275,5 +365,7 @@ void benchmark_all(void) printf("%s:\t%s c/s\n\n", msg_1, s_real); #endif + */ + } while ((format = format->next) && !event_abort); } diff -urpN john-1.7.2/src/bench.h john-1.7.2-mpi/src/bench.h --- john-1.7.2/src/bench.h 2006-02-27 02:52:35.000000000 -0700 +++ john-1.7.2-mpi/src/bench.h 2008-06-15 00:40:33.773776588 -0600 @@ -4,6 +4,11 @@ */ /* + * 15.02.08 Elli0t: added: format_cps, print_cps; + * changed: get_cps: double->long. + */ + +/* * Cracking algorithm benchmark. */ @@ -51,6 +56,18 @@ extern char *benchmark_format(struct fmt extern void benchmark_cps(unsigned ARCH_WORD count, clock_t time, char *buffer); +long get_cps(unsigned ARCH_WORD count, clock_t time); + +/* + * Format c/s string + */ +void format_cps( char *buffer, long cps ); + +/* + * Format and print c/s string + */ +void print_cps( const char *msg, long cps_r, long cps_v ); + /* * Benchmarks all the registered cracking algorithms and prints the results * to stdout. diff -urpN john-1.7.2/src/charset.c john-1.7.2-mpi/src/charset.c --- john-1.7.2/src/charset.c 2005-12-12 11:53:36.000000000 -0700 +++ john-1.7.2-mpi/src/charset.c 2008-06-15 00:40:33.777110004 -0600 @@ -20,6 +20,9 @@ #include "external.h" #include "charset.h" +#include "mpi.h" +#include "ryan.h" + typedef unsigned int (*char_counters) [CHARSET_SIZE + 1][CHARSET_SIZE + 1][CHARSET_SIZE]; @@ -287,6 +290,10 @@ static void charset_generate_all(struct char_counters chars; crack_counters cracks; +/* deprecated */ +/* strcat(charset, "."); */ +/* strcat(charset, id2string()); */ + header = (struct charset_header *)mem_alloc(sizeof(*header)); memset(header, 0, sizeof(*header)); diff -urpN john-1.7.2/src/cracker.c john-1.7.2-mpi/src/cracker.c --- john-1.7.2/src/cracker.c 2006-02-26 23:21:11.000000000 -0700 +++ john-1.7.2-mpi/src/cracker.c 2008-06-15 00:40:33.780443676 -0600 @@ -182,20 +182,27 @@ static int crk_password_loop(struct db_s crk_methods.crypt_all(crk_key_index); +/* See exactly what is going on */ +#ifdef ULTRAVERBOSE +status_print(); +fflush(stdout); +sleep(1); +#endif status_update_crypts(salt->count * crk_key_index); if (salt->hash_size < 0) { pw = salt->list; do { if (crk_methods.cmp_all(pw->binary, crk_key_index)) - for (index = 0; index < crk_key_index; index++) - if (crk_methods.cmp_one(pw->binary, index)) - if (crk_methods.cmp_exact(pw->source, index)) { - if (crk_process_guess(salt, pw, index)) - return 1; - else - break; - } + for (index = 0; index < crk_key_index; index++) { + if (crk_methods.cmp_one(pw->binary, index)) + if (crk_methods.cmp_exact(pw->source, index)) { + if (crk_process_guess(salt, pw, index)) + return 1; + else + break; + } + } } while ((pw = pw->next)); } else for (index = 0; index < crk_key_index; index++) { @@ -294,10 +301,22 @@ int crk_process_salt(struct db_salt *sal char *crk_get_key1(void) { - if (crk_db->loaded) + if (crk_db->loaded) { + /* RYAN */ + /* + fprintf(stderr, "\n"); + fprintf(stderr, "crk_key_index = %d\n", crk_key_index); + fprintf(stderr, "from = %s\n", + crk_methods.get_key(0)); + fprintf(stderr, "to = %s\n", + crk_methods.get_key(crk_key_index - 1)); + fprintf(stderr, "to = %s\n", + crk_methods.get_key(2)); + */ return crk_methods.get_key(0); - else + } else { return crk_stdout_key; + } } char *crk_get_key2(void) diff -urpN john-1.7.2/src/external.c john-1.7.2-mpi/src/external.c --- john-1.7.2/src/external.c 2006-02-26 20:46:56.000000000 -0700 +++ john-1.7.2-mpi/src/external.c 2008-06-15 00:40:33.783778814 -0600 @@ -123,6 +123,8 @@ static int restore_state(FILE *file) int count; internal = (unsigned char *)int_word; + /* RYAN2 */ + fprintf(stderr, "int_word = %s\n", int_word); external = ext_word; count = 0; do { diff -urpN john-1.7.2/src/inc.c john-1.7.2-mpi/src/inc.c --- john-1.7.2/src/inc.c 2006-03-04 18:14:13.000000000 -0700 +++ john-1.7.2-mpi/src/inc.c 2008-06-15 00:40:33.787111158 -0600 @@ -5,6 +5,7 @@ #include #include +#include #include "arch.h" #include "misc.h" @@ -22,6 +23,11 @@ #include "external.h" #include "cracker.h" +#include "mpi.h" +#include "ryan.h" + +#define DATELEN 50 + extern struct fmt_main fmt_LM; typedef char (*char2_table) @@ -311,6 +317,8 @@ update_last: } key = key_i; + /* RYAN */ + /* fprintf(stderr, "inc_key_loop = %s [%d]\n", key, mpi_id); */ if (!ext_mode || !f_filter || ext_filter_body(key_i, key = key_e)) if (crk_process_key(key)) return 1; @@ -374,6 +382,12 @@ void do_incremental_crack(struct db_main int last_length, last_count; int pos; + int progress = 0; + struct tm *myTime; + char chrDate[DATELEN]; + time_t mytm; + + if (!mode) { if (db->format == &fmt_LM) mode = "LanMan"; @@ -443,6 +457,7 @@ void do_incremental_crack(struct db_main error(); } + /* fprintf(stderr, "charset = %s\n", charset); */ if (!(file = fopen(path_expand(charset), "rb"))) pexit("fopen: %s", path_expand(charset)); @@ -535,6 +550,12 @@ void do_incremental_crack(struct db_main rec_init(db, save_state); ptr = header->order + (entry = rec_entry) * 3; + + /* RYAN */ + /* *ptr has to start at different positions so they don't overlap*/ + ptr = ptr + (3 * mpi_id * (mpi_p - 1)); + /* fprintf(stderr, "starting ptr = %d\n", ptr); */ + memcpy(numbers, rec_numbers, sizeof(numbers)); crk_init(db, fix_state, NULL); @@ -545,6 +566,10 @@ void do_incremental_crack(struct db_main while (ptr < &header->order[sizeof(header->order) - 1]) { entry++; length = *ptr++; fixed = *ptr++; count = *ptr++; + /* increment *ptr with the number of processors after this */ + ptr = ptr + (3 * (mpi_p - 1)); + /* fprintf(stderr, "ptr = %d [%d - %d]\n", ptr, mpi_id, mpi_p); */ + entry = entry + mpi_p - 1; if (length >= CHARSET_LENGTH || fixed > length || @@ -576,10 +601,46 @@ void do_incremental_crack(struct db_main log_event("- Trying length %d, fixed @%d, character count %d", length + 1, fixed + 1, count + 1); + /* RYAN */ + /* + length = 6; + fprintf(stderr, "mpi_id = %d\n", mpi_id); + fprintf(stderr, "Trying length %d, fixed @%d, character count %d\n", + length + 1, fixed + 1, count + 1); + fprintf(stderr, "real_count = %d\tpos = %d\n", real_count, pos); + fprintf(stderr, "min_length = %d\tmax_length = %d\tmax_count = %d\n", + min_length, max_length, max_count); + fprintf(stderr, "length = %d\t", length); + fprintf(stderr, "fixed = %d\t", fixed); + fprintf(stderr, "count = %d\n", count); + fprintf(stderr, "char1 = %s\n", char1); + fprintf(stderr, "char2 = |%s|\n", char2); + fprintf(stderr, "chars = %s\n", chars); + */ + + /* + fprintf(stderr, "(length, fixed, count, char2) = " ); + fprintf(stderr, "(%d %d %d |%s|)", length, fixed, count, char2 ); + */ + + if(progress++ % 100000) { + progress = 0; + time(&mytm); + myTime = localtime(&mytm); + /* + strftime(chrDate, DATELEN, "%a %b %e %H:%M:%S %Z %Y", myTime); + fprintf(stderr, "[%s] Processor %d still working ...\n", + chrDate, mpi_id); + */ + strftime(chrDate, DATELEN, "%Y/%m/%d %H:%M:%S", myTime); + } + if (inc_key_loop(length, fixed, count, char1, char2, chars)) break; } + fprintf(stderr, "Process %d completed loop.\n", mpi_id); + crk_done(); rec_done(event_abort); diff -urpN john-1.7.2/src/john.c john-1.7.2-mpi/src/john.c --- john-1.7.2/src/john.c 2006-05-08 08:48:48.000000000 -0600 +++ john-1.7.2-mpi/src/john.c 2008-06-15 00:40:33.790445945 -0600 @@ -3,6 +3,9 @@ * Copyright (c) 1996-2004,2006 by Solar Designer */ +#include "mpi.h" +#include "ryan.h" + #include #include #include @@ -115,6 +118,13 @@ static char *john_loaded_counts(void) static void john_load(void) { struct list_entry *current; + char *log__name, *pot__name; + + log__name = malloc(sizeof(char) * 25); + pot__name = malloc(sizeof(char) * 25); + + strcpy(log__name, LOG_NAME); + strcpy(pot__name, POT_NAME); umask(077); @@ -126,7 +136,7 @@ static void john_load(void) ldr_init_database(&database, &options.loader); if (options.flags & FLG_PASSWD) { - ldr_show_pot_file(&database, POT_NAME); + ldr_show_pot_file(&database, pot__name); database.options->flags |= DB_PLAINTEXTS; if ((current = options.passwd->head)) @@ -135,7 +145,7 @@ static void john_load(void) } while ((current = current->next)); } else { database.options->flags |= DB_PLAINTEXTS; - ldr_show_pot_file(&database, POT_NAME); + ldr_show_pot_file(&database, pot__name); } return; @@ -154,7 +164,7 @@ static void john_load(void) options.loader.flags |= DB_CRACKED; ldr_init_database(&database, &options.loader); - ldr_show_pot_file(&database, POT_NAME); + ldr_show_pot_file(&database, pot__name); if ((current = options.passwd->head)) do { @@ -185,7 +195,7 @@ static void john_load(void) if ((options.flags & FLG_CRACKING_CHK) && database.password_count) { - log_init(LOG_NAME, NULL, options.session); + log_init(log__name, NULL, options.session); if (status_restored_time) log_event("Continuing an interrupted session"); else @@ -193,7 +203,7 @@ static void john_load(void) log_event("Loaded a total of %s", john_loaded_counts()); } - ldr_load_pot_file(&database, POT_NAME); + ldr_load_pot_file(&database, pot__name); ldr_fix_database(&database); @@ -208,7 +218,10 @@ static void john_load(void) puts("No password hashes loaded"); } - if ((options.flags & FLG_PWD_REQ) && !database.salts) exit(0); + if ((options.flags & FLG_PWD_REQ) && !database.salts) { + MPI_Finalize(); + exit(0); + } } } @@ -259,6 +272,14 @@ static void john_init(char *name, int ar static void john_run(void) { + char *log__name, *pot__name; + + log__name = malloc(sizeof(char) * 25); + pot__name = malloc(sizeof(char) * 25); + + strcpy(log__name, LOG_NAME); + strcpy(pot__name, POT_NAME); + if (options.flags & FLG_TEST_CHK) benchmark_all(); else @@ -268,7 +289,7 @@ static void john_run(void) if (options.flags & FLG_CRACKING_CHK) { if (!(options.flags & FLG_STDOUT)) { status_init(NULL, 1); - log_init(LOG_NAME, POT_NAME, options.session); + log_init(log__name, pot__name, options.session); john_log_format(); if (cfg_get_bool(SECTION_OPTIONS, NULL, "Idle")) log_event("- Configured to use otherwise idle " @@ -315,6 +336,10 @@ static void john_done(void) int main(int argc, char **argv) { char *name; + MPI_Init(&argc, &argv); + + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_id); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_p); #ifdef __DJGPP__ if (--argc <= 0) return 1; @@ -339,18 +364,26 @@ int main(int argc, char **argv) name[strlen(name) - 4] = 0; #endif - if (!strcmp(name, "unshadow")) + if (!strcmp(name, "unshadow")) { + MPI_Finalize(); return unshadow(argc, argv); + } - if (!strcmp(name, "unafs")) + if (!strcmp(name, "unafs")) { + MPI_Finalize(); return unafs(argc, argv); + } - if (!strcmp(name, "unique")) + if (!strcmp(name, "unique")) { + MPI_Finalize(); return unique(argc, argv); + } john_init(name, argc, argv); john_run(); john_done(); + MPI_Finalize(); + return 0; } diff -urpN john-1.7.2/src/loader.c john-1.7.2-mpi/src/loader.c --- john-1.7.2/src/loader.c 2005-11-08 06:03:20.000000000 -0700 +++ john-1.7.2-mpi/src/loader.c 2008-06-15 00:40:33.793777607 -0600 @@ -19,6 +19,9 @@ #include "formats.h" #include "loader.h" +#include "ryan.h" +#include "mpi.h" + /* * Flags for read_file(). */ @@ -430,6 +433,8 @@ static void ldr_load_pot_line(struct db_ void ldr_load_pot_file(struct db_main *db, char *name) { +/* strcat(name, "."); */ +/* strcat(name, id2string()); */ if (db->format) read_file(db, name, RF_ALLOW_MISSING, ldr_load_pot_line); } @@ -662,7 +667,11 @@ static void ldr_show_pw_line(struct db_m if (!*ciphertext) { found = 1; - if (show) printf("%s:NO PASSWORD", login); + if (show) { + if(mpi_id == 0) { + printf("%s:NO PASSWORD", login); + } + } db->guess_count++; } else @@ -703,28 +712,38 @@ static void ldr_show_pw_line(struct db_m if (current) { if (show) { - printf("%s", current->plaintext); + if(mpi_id == 0) { + printf("%s", current->plaintext); + } } else list_add(db->plaintexts, current->plaintext); db->guess_count++; } else - while (chars--) - putchar('?'); + if(mpi_id == 0) { + while (chars--) + putchar('?'); + } } else if (current) { found = 1; - if (show) printf("%s:", login); + if (show) { + if(mpi_id == 0) { + printf("%s:", login); + } + } break; } } if (found && show) { - if (source[0]) - printf(":%s", source); - else - putchar('\n'); + if(mpi_id == 0) { + if (source[0]) + printf(":%s", source); + else + putchar('\n'); + } } if (format || found) db->password_count += count; diff -urpN john-1.7.2/src/logger.c john-1.7.2-mpi/src/logger.c --- john-1.7.2/src/logger.c 2004-06-13 08:36:44.000000000 -0600 +++ john-1.7.2-mpi/src/logger.c 2008-06-15 00:40:33.793777607 -0600 @@ -21,6 +21,9 @@ #include "status.h" #include "config.h" +#include "ryan.h" +#include "mpi.h" + static int cfg_beep; /* @@ -123,6 +126,10 @@ void log_init(char *log_name, char *pot_ char *p; in_logger = 1; +/* forget this */ +/* strcat(log_name, "."); */ +/* strcat(log_name, id2string()); */ + if (log_name && log.fd < 0) { if (session) { diff -urpN john-1.7.2/src/misc.c john-1.7.2-mpi/src/misc.c --- john-1.7.2/src/misc.c 2003-09-18 04:33:25.000000000 -0600 +++ john-1.7.2-mpi/src/misc.c 2008-06-15 00:40:33.797111996 -0600 @@ -3,6 +3,8 @@ * Copyright (c) 1996-99,2003 by Solar Designer */ +#include "mpi.h" +#include "ryan.h" #include #include #include @@ -18,7 +20,8 @@ void error(void) log_event("Terminating on error"); log_done(); #endif - + fprintf(stderr, "[%d] Terminating on error.\n", mpi_id); + MPI_Finalize(); exit(1); } diff -urpN john-1.7.2/src/options.c john-1.7.2-mpi/src/options.c --- john-1.7.2/src/options.c 2006-01-09 07:35:00.000000000 -0700 +++ john-1.7.2-mpi/src/options.c 2008-06-15 00:40:33.800445420 -0600 @@ -18,6 +18,9 @@ #include "recovery.h" #include "options.h" +#include "mpi.h" +#include "ryan.h" + struct options_main options; static struct opt_entry opt_list[] = { @@ -107,7 +110,10 @@ static struct opt_entry opt_list[] = { void opt_init(char *name, int argc, char **argv) { if (argc < 2) { - printf(JOHN_USAGE, name); + if(mpi_id == 0) { + printf(JOHN_USAGE, name); + MPI_Finalize(); + } exit(0); } @@ -147,6 +153,8 @@ void opt_init(char *name, int argc, char options.flags |= FLG_STATUS_SET; status_init(NULL, 1); status_print(); + + MPI_Finalize(); exit(0); } diff -urpN john-1.7.2/src/params.h john-1.7.2-mpi/src/params.h --- john-1.7.2/src/params.h 2006-05-15 10:42:04.000000000 -0600 +++ john-1.7.2-mpi/src/params.h 2008-06-15 00:40:33.803779450 -0600 @@ -15,7 +15,7 @@ /* * John's version number. */ -#define JOHN_VERSION "1.7.2" +#define JOHN_VERSION "1.7.2_mpi" /* * Notes to packagers of John for *BSD "ports", Linux distributions, etc.: @@ -107,12 +107,12 @@ #define CFG_PRIVATE_FULL_NAME JOHN_PRIVATE_HOME "/john.conf" #define CFG_PRIVATE_ALT_NAME JOHN_PRIVATE_HOME "/john.ini" #define POT_NAME JOHN_PRIVATE_HOME "/john.pot" -#define LOG_NAME JOHN_PRIVATE_HOME "/john.log" -#define RECOVERY_NAME JOHN_PRIVATE_HOME "/john.rec" +#define LOG_NAME JOHN_PRIVATE_HOME "/john_log" +#define RECOVERY_NAME JOHN_PRIVATE_HOME "/john_rec" #else #define POT_NAME "$JOHN/john.pot" -#define LOG_NAME "$JOHN/john.log" -#define RECOVERY_NAME "$JOHN/john.rec" +#define LOG_NAME "$JOHN/john_log" +#define RECOVERY_NAME "$JOHN/john_rec" #endif #define LOG_SUFFIX ".log" #define RECOVERY_SUFFIX ".rec" diff -urpN john-1.7.2/src/recovery.c john-1.7.2-mpi/src/recovery.c --- john-1.7.2/src/recovery.c 2006-02-26 20:46:56.000000000 -0700 +++ john-1.7.2-mpi/src/recovery.c 2008-06-15 00:40:33.807113804 -0600 @@ -11,6 +11,8 @@ #include #include #include +#include "mpi.h" +#include "ryan.h" #if defined(__CYGWIN32__) && !defined(__CYGWIN__) extern int ftruncate(int fd, size_t length); @@ -28,7 +30,7 @@ extern int ftruncate(int fd, size_t leng #include "recovery.h" char *rec_name = RECOVERY_NAME; -static int rec_name_fixed = 0; +/* static int rec_name_fixed = 0; */ int rec_version = 0; int rec_argc = 0; char **rec_argv; @@ -40,16 +42,32 @@ static FILE *rec_file = NULL; static struct db_main *rec_db; static void (*rec_save_mode)(FILE *file); +/* +char *id2string(); + +char *id2string() { + char *temp_name = (char*) malloc(sizeof(char)*10); + sprintf(temp_name, "%d", mpi_id); + return temp_name; +} +*/ + static char *rec_name_complete(char *rec_name) { char *result; - if (strchr(rec_name, '.')) return rec_name; + /*if (strchr(rec_name, '.')) return rec_name; */ result = mem_alloc_tiny(strlen(rec_name) + - strlen(RECOVERY_SUFFIX) + 1, MEM_ALIGN_NONE); + strlen(RECOVERY_SUFFIX) + + strlen(id2string()) + + + 2, MEM_ALIGN_NONE); strcpy(result, rec_name); strcat(result, RECOVERY_SUFFIX); + strcat(result, "."); + strcat(result, id2string()); + + /* fprintf(stderr, "result = %s\n\n", result); */ return result; } @@ -59,7 +77,8 @@ static void rec_lock(void) { if (flock(rec_fd, LOCK_EX | LOCK_NB)) { if (errno == EWOULDBLOCK) { - fprintf(stderr, "Crash recovery file is locked: %s\n", + fprintf(stderr, "Crash recovery file is locked by process %d: %s\n", + mpi_id, path_expand(rec_name)); error(); } else @@ -77,7 +96,7 @@ void rec_init(struct db_main *db, void ( if (!rec_argc) return; - if (!rec_name_fixed) + /*if (!rec_name_fixed) */ rec_name = rec_name_complete(rec_name); if ((rec_fd = open(path_expand(rec_name), O_RDWR | O_CREAT, 0600)) < 0) @@ -150,12 +169,17 @@ void rec_done(int save) if (fclose(rec_file)) pexit("fclose"); rec_file = NULL; - if (!save && unlink(path_expand(rec_name))) - pexit("unlink: %s", path_expand(rec_name)); + if (!save && unlink(path_expand(rec_name))) { + //strcat(rec_name, id2string()); + rec_name = rec_name_complete(RECOVERY_NAME); + if (unlink(path_expand(rec_name))) + pexit("unlink: %s", path_expand(rec_name)); + } } static void rec_format_error(char *fn) { + rec_name = rec_name_complete(RECOVERY_NAME); if (ferror(rec_file)) pexit(fn); else { @@ -172,6 +196,7 @@ void rec_restore_args(int lock) char **argv; char *save_rec_name; + rec_name = rec_name_complete(RECOVERY_NAME); if (!(rec_file = fopen(path_expand(rec_name), "r+"))) { save_rec_name = rec_name; rec_name = rec_name_complete(rec_name); @@ -181,7 +206,7 @@ void rec_restore_args(int lock) pexit("fopen: %s", path_expand(rec_name)); } rec_fd = fileno(rec_file); - rec_name_fixed = 1; + /* rec_name_fixed = 1; */ if (lock) rec_lock(); diff -urpN john-1.7.2/src/ryan.c john-1.7.2-mpi/src/ryan.c --- john-1.7.2/src/ryan.c 1969-12-31 17:00:00.000000000 -0700 +++ john-1.7.2-mpi/src/ryan.c 2008-06-15 00:40:33.807113804 -0600 @@ -0,0 +1,17 @@ +#include "mpi.h" +//#include "ryan.h" +#include +#include + +int mpi_p, mpi_id; + +/* Fixed version of id2string to correct a memory leak + * Submitted by Carsten G + */ +char *id2string() { + static char id_string[12] = ""; + if (strlen(id_string)) return id_string; + snprintf(id_string, 11, "%d", mpi_id); + id_string[11] = 0x00; + return id_string; +} diff -urpN john-1.7.2/src/ryan.h john-1.7.2-mpi/src/ryan.h --- john-1.7.2/src/ryan.h 1969-12-31 17:00:00.000000000 -0700 +++ john-1.7.2-mpi/src/ryan.h 2008-06-15 00:40:33.807113804 -0600 @@ -0,0 +1,8 @@ +#ifndef RYAN_INCLUDE +#define RYAN_INCLUDE + +extern int mpi_p, mpi_id; + +extern char *id2string(); + +#endif diff -urpN john-1.7.2/src/signals.c john-1.7.2-mpi/src/signals.c --- john-1.7.2/src/signals.c 2006-02-27 02:52:35.000000000 -0700 +++ john-1.7.2-mpi/src/signals.c 2008-06-15 00:40:33.810446723 -0600 @@ -3,6 +3,8 @@ * Copyright (c) 1996-2003,2006 by Solar Designer */ +#include "mpi.h" + #ifdef __ultrix__ #define __POSIX #define _POSIX_SOURCE @@ -95,17 +97,23 @@ static void sig_handle_update(int signum #endif } +static void sig_handle_status(int signum) +{ + event_status = event_pending = 1; +} + static void sig_install_update(void) { #ifdef SA_RESTART struct sigaction sa; memset(&sa, 0, sizeof(sa)); - sa.sa_handler = sig_handle_update; + sa.sa_handler = sig_handle_status; sa.sa_flags = SA_RESTART; sigaction(SIGHUP, &sa, NULL); #else - signal(SIGHUP, sig_handle_update); + signal(SIGHUP, sig_handle_status); + signal(SIGUSR1, sig_handle_status); #endif } @@ -120,6 +128,7 @@ void check_abort(int be_async_signal_saf if (be_async_signal_safe) { write_loop(2, "Session aborted\n", 16); + MPI_Finalize(); _exit(1); } diff -urpN john-1.7.2/src/status.c john-1.7.2-mpi/src/status.c --- john-1.7.2/src/status.c 2006-02-27 02:52:35.000000000 -0700 +++ john-1.7.2-mpi/src/status.c 2008-06-15 00:40:33.817115624 -0600 @@ -26,6 +26,8 @@ #include "status.h" #include "bench.h" +#include "ryan.h" + struct status_main status; unsigned int status_restored_time = 0; int (*status_get_progress)(void) = NULL; @@ -175,15 +177,16 @@ static void status_print_cracking(char * } fprintf(stderr, - "guesses: %u " + "thread: %d guesses: %u " "time: %u:%02u:%02u:%02u" "%s " - "c/s: %s", + "c/s: %s trying: %s%s%s\n", mpi_id, status.guess_count, time / 86400, time % 86400 / 3600, time % 3600 / 60, time % 60, percent, - status_get_cps(s_cps)); - + status_get_cps(s_cps), crk_get_key1(), saved_key[0] ? " - " : "", saved_key ? saved_key : ""); + fflush(stdout); +/* if (options.flags & FLG_STATUS_CHK) fputc('\n', stderr); else @@ -192,6 +195,7 @@ static void status_print_cracking(char * crk_get_key1(), saved_key[0] ? " - " : "", saved_key ? saved_key : ""); +*/ } void status_print(void)