UNIX. octopus.stu.lipetsk.ru
9

dummy_format.params.plaintext_length = options.length;

dummy_format.params.flags = FMT_CASE | FMT_8_BIT;

}

if (options.flags & FLG_PASSWD) {

if (options.flags & FLG_SHOW_CHK) {

options.loader.flags |= DB_CRACKED;

ldr_init_database(&database, &options.loader);

ldr_show_pot_file(&database, LOG_NAME);

if ((current = options.passwd->head))

do {

ldr_show_pw_file(&database, current->data);

} while ((current = current->next));

printf("%s%d password%s cracked, %d left\n",

database.guess_count ? "\n" : "",

database.guess_count,

database.guess_count != 1 ? "s" : "",

database.password_count -

database.guess_count);

return;

}

if (options.flags & (FLG_SINGLE_CHK | FLG_BATCH_CHK))

options.loader.flags |= DB_WORDS;

else

if (mem_saving_level)

options.loader.flags &= ~DB_LOGIN;

ldr_init_database(&database, &options.loader);

if ((current = options.passwd->head))

do {

ldr_load_pw_file(&database, current->data);

} while ((current = current->next));

ldr_load_pot_file(&database, LOG_NAME);

ldr_fix_database(&database);

printf("Loaded %d password%s%s",

database.password_count,

database.password_count != 1 ? "s" : "",

database.password_count ? "" : ", exiting .");

if (database.password_count > 1) {

printf(" with ");

printf(database.salt_count != 1 ? "%d" : "no",

database.salt_count);

printf(" different salts");

}

if (database.password_count)

printf(" (%s [%s])\n",

database.format->params.format_name,

database.format->params.algorith_name);

else

putchar('\n');

if ((options.flags & FLG_PWD_REQ) && !database.salts) exit(0);

}

}

static void john_init(int argc, char **argv)

{

#if CPU_DETECT

if (!CPU_detect()) {

#if CPU_REQ

fprintf(stderr, "Sorry, %s is required\n", CPU_NAME);

error();

#endif

}

#endif

path_init(argv);

cfg_init(CFG_NAME);

status_init(NULL, 1);

opt_init(argc, argv);

john_register_all();

common_init();

sig_init(idle_yield);

john_load();

}

static void john_run()

{

if (options.flags & FLG_TEST_CHK)

benchmark_all();

else

if (options.flags & FLG_MAKECHARS_CHK)

do_makechars(&database, options.charset);

else

if (options.flags & FLG_CRACKING_CHK) {

if (!(options.flags & FLG_STDOUT)) log_init(LOG_NAME);

tty_init();

if (options.flags & FLG_SINGLE_CHK)

do_single_crack(&database);

else

if (options.flags & FLG_WORDLIST_CHK)

do_wordlist_crack(&database, options.wordlist,

(options.flags & FLG_RULES) != 0);

else

if (options.flags & FLG_INC_CHK)

do_incremental_crack(&database, options.charset);

else

if (options.flags & FLG_EXTERNAL_CHK)

do_external_crack(&database);

else

if (options.flags & FLG_BATCH_CHK)

do_batch_crack(&database);

status_print();

tty_done();

if (!(options.flags & FLG_STDOUT)) log_done();

}

}

static void john_done()

{

path_done();

check_abort();

}

int main(int argc, char **argv)

{

char *name;

#ifdef DJGPP

if (--argc <= 0) return 1;

if ((name = strrchr(argv[0], '/')))

strcpy(name + 1, argv[1]);

name = argv[1];

argv[1] = argv[0];

argv++;

#else

if (!argv[0])

name = "";

else

if ((name = strrchr(argv[0], '/')))

name++;

else

name = argv[0];

#endif

#ifdef CYGWIN32

if (strlen(name) > 4)

if (!strcmp(strlwr(name) + strlen(name) - 4, ".exe"))

: 1 2 3 4 5 6 7 8 9 10 11