forked from pmittaldev/john-the-ripper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBFEgg_fmt_plug.c
127 lines (107 loc) · 2.52 KB
/
BFEgg_fmt_plug.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
* This file is part of Eggdrop blowfish patch for John The Ripper.
* Copyright (c) 2002 by Sun-Zero <sun-zero at freemail.hu>
* This is a free software distributable under terms of the GNU GPL.
*/
#include <string.h>
#include "misc.h"
#include "formats.h"
#include "common.h"
#include "blowfish.c"
#define FORMAT_LABEL "bfegg"
#define FORMAT_NAME "Eggdrop Blowfish"
#define ALGORITHM_NAME "32/" ARCH_BITS_STR
#define BENCHMARK_COMMENT ""
#define BENCHMARK_LENGTH -1
#define PLAINTEXT_LENGTH 31
#define CIPHERTEXT_LENGTH 33
#define BINARY_SIZE 13
#define SALT_SIZE 0
#define MIN_KEYS_PER_CRYPT 1
#define MAX_KEYS_PER_CRYPT 1
static struct fmt_tests tests[] = {
{"+9F93o1OxwgK1", "123456"},
{"+C/.8o.Wuph9.", "qwerty"},
{"+EEHgy/MBLDd0", "walkman"},
{"+vPBrs07OTXE/", "tesztuser"},
{"+zIvO/1nDsd9.", "654321"},
{NULL}
};
int zerolengthkey = 0;
static char crypt_key[BINARY_SIZE + 1];
static char saved_key[PLAINTEXT_LENGTH + 1];
static int valid(char *ciphertext, struct fmt_main *self) {
if (strncmp(ciphertext, "+", 1) != 0) return 0;
if (strlen(ciphertext) != 13) return 0;
return 1;
}
void init(struct fmt_main *self) {
blowfish_first_init();
}
static void set_key(char *key, int index) {
strnzcpy(saved_key, key, PLAINTEXT_LENGTH+1);
}
static char *get_key(int index) {
return saved_key;
}
static int cmp_all(void *binary, int index) {
if (zerolengthkey) return 0;
return !memcmp(binary, crypt_key, BINARY_SIZE);
}
static int cmp_exact(char *source, int index) {
return 1;
}
static void crypt_all(int count) {
if (saved_key[0] == '\0') {
zerolengthkey = 1;
} else {
zerolengthkey = 0;
blowfish_encrypt_pass(saved_key, crypt_key);
}
}
struct fmt_main fmt_BFEgg = {
{
FORMAT_LABEL,
FORMAT_NAME,
ALGORITHM_NAME,
BENCHMARK_COMMENT,
BENCHMARK_LENGTH,
PLAINTEXT_LENGTH,
BINARY_SIZE,
SALT_SIZE,
MIN_KEYS_PER_CRYPT,
MAX_KEYS_PER_CRYPT,
FMT_CASE | FMT_8_BIT,
tests
}, {
init,
fmt_default_prepare,
valid,
fmt_default_split,
fmt_default_binary,
fmt_default_salt,
{
fmt_default_binary_hash,
fmt_default_binary_hash,
fmt_default_binary_hash,
fmt_default_binary_hash,
fmt_default_binary_hash
},
fmt_default_salt_hash,
fmt_default_set_salt,
set_key,
get_key,
fmt_default_clear_keys,
crypt_all,
{
fmt_default_get_hash,
fmt_default_get_hash,
fmt_default_get_hash,
fmt_default_get_hash,
fmt_default_get_hash
},
cmp_all,
cmp_all,
cmp_exact
}
};