1 /*
2  * This file is part of John the Ripper password cracker,
3  * Copyright (c) 1996-98,2003,2004 by Solar Designer
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted.
7  *
8  * There's ABSOLUTELY NO WARRANTY, express or implied.
9  */
10 
11 #include <stdio.h>
12 
13 #include "params.h"
14 #include "os.h"
15 #include "signals.h"
16 #include "loader.h"
17 #include "status.h"
18 #include "config.h"
19 #include "single.h"
20 #include "wordlist.h"
21 #include "inc.h"
22 
do_single_pass(struct db_main * db)23 static void do_single_pass(struct db_main *db)
24 {
25 	do_single_crack(db);
26 	db->options->flags &= ~DB_WORDS; /* Might speed up pot sync */
27 }
28 
do_wordlist_pass(struct db_main * db)29 static void do_wordlist_pass(struct db_main *db)
30 {
31 	const char *name;
32 
33 	if (!(name = cfg_get_param(SECTION_OPTIONS, NULL, "Wordlist")))
34 	if (!(name = cfg_get_param(SECTION_OPTIONS, NULL, "Wordfile")))
35 		name = WORDLIST_NAME;
36 
37 	do_wordlist_crack(db, name, 1);
38 }
39 
do_incremental_pass(struct db_main * db)40 static void do_incremental_pass(struct db_main *db)
41 {
42 	do_incremental_crack(db, NULL);
43 }
44 
do_batch_crack(struct db_main * db)45 void do_batch_crack(struct db_main *db)
46 {
47 	switch (status.pass) {
48 	case 0:
49 	case 1:
50 		status.pass = 1;
51 		do_single_pass(db);
52 		if (event_abort || !db->salts) break;
53 		event_reload = 1;
54 
55 	case 2:
56 		status.pass = 2;
57 		do_wordlist_pass(db);
58 		if (event_abort || !db->salts) break;
59 		event_reload = 1;
60 
61 	case 3:
62 		status.pass = 3;
63 		do_incremental_pass(db);
64 	}
65 }
66