CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/data/jtr/hybrid.conf
Views: 1904
1
[List.HybridLeet:new]
2
int i, j;
3
int c, p;
4
int totrots;
5
int length;
6
7
/* Get the word length */
8
length = 0; while (word[length++]) ; --length;
9
10
/* Skip if this word length is out of bounds
11
This should not be necessary, but we'll leave it here to be defensive */
12
if (req_minlen > length || (req_maxlen && req_maxlen < length ))
13
{
14
hybrid_total = 0;
15
return;
16
}
17
18
/* Calculate word rotations */
19
20
word_rot_count=0; /* Number of letter positions we are rotating for this word */
21
totrots = 1; /* Number of total rotation iterations */
22
23
i=0;
24
while (i < length)
25
{
26
/* is this letter one of our rotators? a,A, b,B etc*/
27
c = word[i];
28
j = 0;
29
while (j < rot_poslen)
30
{
31
p = rot_pos[j];
32
if (c == rot_chars[p] || c == rot_chars[p+1]) /* Is 'a' or 'A' for example */
33
{
34
word_rot_idx[word_rot_count] = i; /* Save off which letter position in the word we are rotating */
35
word_rot_pos[word_rot_count] = j; /* Save off the rotation position for this slot */
36
word_rotchars_pos[word_rot_count] = p; /* Save off the first letter position in the rotation */
37
word_rot_count++;
38
39
/* Also, set the word to the first letter in the rotation so we ensure to go through all of them */
40
word[i] = rot_chars[p];
41
42
/* And multiple number of total rotations by the number of rotations for this position */
43
totrots = totrots * rot_len[j];
44
45
break;
46
}
47
j++;
48
}
49
i++;
50
}
51
52
hybrid_total = totrots;
53
54
/* Reset or counter for THIS word. */
55
word_rot_current = 0;
56
57
[List.External:HybridLeet]
58
59
/*
60
Static context
61
String lengths here are arbitrary, increase them if you increase the
62
size of the stuff in the init() procedure
63
*/
64
65
int rot_chars[256]; /* All characters to rotate */
66
int rot_charslen; /* The length of the rot_chars buffer */
67
68
int rot_len[26]; /* The number of characters to rotate through per letter */
69
int rot_pos[26]; /* The starting position of each letter group in the rot_chars string */
70
int rot_poslen; /* Length of rot_pos and rot_len arrays (both same size) */
71
72
int word_rot_idx[128]; /* The positions in the current word that require rotations (index into word)*/
73
int word_rot_pos[128]; /* The rot_pos index for each letter position in the current word that we are rotating (index into rot_pos)*/
74
int word_rotchars_pos[128]; /* The current rot_chars index for each letter position in the current word that we are rotating (state of rotation, index into rot_chars)*/
75
int word_rot_count; /* The number of letters that we are rotating in the current word (size of word_rot_idx, word_rot_pos, and word_rotchars_pos) */
76
77
int word_rot_current; /* The rotation number of the current word */
78
79
void init()
80
{
81
int rci;
82
int ri;
83
84
rot_charslen=0;
85
rci=0;
86
ri=0;
87
88
/* a */
89
rot_pos[ri] = rci;
90
rot_chars[rci++] = 'a'; /* The first two chars are always the lower */
91
rot_chars[rci++] = 'A'; /* and upper case letters to rotate on */
92
rot_chars[rci++] = '4';
93
rot_chars[rci++] = '@';
94
rot_chars[rci++] = '8';
95
rot_len[ri] = (rci - rot_pos[ri]);
96
ri++;
97
98
/* b */
99
rot_pos[ri] = rci;
100
rot_chars[rci++] = 'b';
101
rot_chars[rci++] = 'B';
102
rot_chars[rci++] = '8';
103
rot_len[ri] = (rci - rot_pos[ri]);
104
ri++;
105
106
rot_pos[ri] = rci;
107
rot_chars[rci++] = 'c';
108
rot_chars[rci++] = 'C';
109
rot_len[ri] = (rci - rot_pos[ri]);
110
ri++;
111
112
rot_pos[ri] = rci;
113
rot_chars[rci++] = 'd';
114
rot_chars[rci++] = 'D';
115
rot_len[ri] = (rci - rot_pos[ri]);
116
ri++;
117
118
/* e */
119
rot_pos[ri] = rci;
120
rot_chars[rci++] = 'e';
121
rot_chars[rci++] = 'E';
122
rot_chars[rci++] = '3';
123
rot_len[ri] = (rci - rot_pos[ri]);
124
ri++;
125
126
rot_pos[ri] = rci;
127
rot_chars[rci++] = 'f';
128
rot_chars[rci++] = 'F';
129
rot_len[ri] = (rci - rot_pos[ri]);
130
ri++;
131
132
rot_pos[ri] = rci;
133
rot_chars[rci++] = 'g';
134
rot_chars[rci++] = 'G';
135
rot_len[ri] = (rci - rot_pos[ri]);
136
ri++;
137
138
/* h */
139
rot_pos[ri] = rci;
140
rot_chars[rci++] = 'h';
141
rot_chars[rci++] = 'H';
142
rot_chars[rci++] = '#';
143
rot_len[ri] = (rci - rot_pos[ri]);
144
ri++;
145
146
/* i */
147
rot_pos[ri] = rci;
148
rot_chars[rci++] = 'i';
149
rot_chars[rci++] = 'I';
150
rot_chars[rci++] = '1';
151
rot_chars[rci++] = '!';
152
rot_len[ri] = (rci - rot_pos[ri]);
153
ri++;
154
155
rot_pos[ri] = rci;
156
rot_chars[rci++] = 'j';
157
rot_chars[rci++] = 'J';
158
rot_len[ri] = (rci - rot_pos[ri]);
159
ri++;
160
161
rot_pos[ri] = rci;
162
rot_chars[rci++] = 'k';
163
rot_chars[rci++] = 'K';
164
rot_len[ri] = (rci - rot_pos[ri]);
165
ri++;
166
167
/* l */
168
rot_pos[ri] = rci;
169
rot_chars[rci++] = 'l';
170
rot_chars[rci++] = 'L';
171
rot_chars[rci++] = '1';
172
rot_len[ri] = (rci - rot_pos[ri]);
173
ri++;
174
175
rot_pos[ri] = rci;
176
rot_chars[rci++] = 'm';
177
rot_chars[rci++] = 'M';
178
rot_len[ri] = (rci - rot_pos[ri]);
179
ri++;
180
181
rot_pos[ri] = rci;
182
rot_chars[rci++] = 'n';
183
rot_chars[rci++] = 'N';
184
rot_len[ri] = (rci - rot_pos[ri]);
185
ri++;
186
187
/* o */
188
rot_pos[ri] = rci;
189
rot_chars[rci++] = 'o';
190
rot_chars[rci++] = 'O';
191
rot_chars[rci++] = '0';
192
rot_len[ri] = (rci - rot_pos[ri]);
193
ri++;
194
195
rot_pos[ri] = rci;
196
rot_chars[rci++] = 'p';
197
rot_chars[rci++] = 'P';
198
rot_len[ri] = (rci - rot_pos[ri]);
199
ri++;
200
201
rot_pos[ri] = rci;
202
rot_chars[rci++] = 'q';
203
rot_chars[rci++] = 'Q';
204
rot_len[ri] = (rci - rot_pos[ri]);
205
ri++;
206
207
rot_pos[ri] = rci;
208
rot_chars[rci++] = 'r';
209
rot_chars[rci++] = 'R';
210
rot_len[ri] = (rci - rot_pos[ri]);
211
ri++;
212
213
/* s */
214
rot_pos[ri] = rci;
215
rot_chars[rci++] = 's';
216
rot_chars[rci++] = 'S';
217
rot_chars[rci++] = '$';
218
rot_chars[rci++] = '5';
219
rot_len[ri] = (rci - rot_pos[ri]);
220
ri++;
221
222
/* t */
223
rot_pos[ri] = rci;
224
rot_chars[rci++] = 't';
225
rot_chars[rci++] = 'T';
226
rot_chars[rci++] = '+';
227
rot_chars[rci++] = '7';
228
rot_len[ri] = (rci - rot_pos[ri]);
229
ri++;
230
231
rot_pos[ri] = rci;
232
rot_chars[rci++] = 'u';
233
rot_chars[rci++] = 'U';
234
rot_len[ri] = (rci - rot_pos[ri]);
235
ri++;
236
237
rot_pos[ri] = rci;
238
rot_chars[rci++] = 'v';
239
rot_chars[rci++] = 'V';
240
rot_len[ri] = (rci - rot_pos[ri]);
241
ri++;
242
243
rot_pos[ri] = rci;
244
rot_chars[rci++] = 'w';
245
rot_chars[rci++] = 'W';
246
rot_len[ri] = (rci - rot_pos[ri]);
247
ri++;
248
249
rot_pos[ri] = rci;
250
rot_chars[rci++] = 'x';
251
rot_chars[rci++] = 'X';
252
rot_len[ri] = (rci - rot_pos[ri]);
253
ri++;
254
255
rot_pos[ri] = rci;
256
rot_chars[rci++] = 'y';
257
rot_chars[rci++] = 'Y';
258
rot_len[ri] = (rci - rot_pos[ri]);
259
ri++;
260
261
rot_pos[ri] = rci;
262
rot_chars[rci++] = 'z';
263
rot_chars[rci++] = 'Z';
264
rot_len[ri] = (rci - rot_pos[ri]);
265
ri++;
266
267
rot_charslen = rci;
268
rot_poslen = ri;
269
270
}
271
272
/* new word */
273
void new()
274
{
275
.include [List.HybridLeet:new]
276
}
277
278
void next()
279
{
280
int i, j;
281
282
/* If we have reached the maximum number of rotations, we're done */
283
if (word_rot_current == hybrid_total)
284
{
285
word[0] = 0;
286
return;
287
}
288
289
/* set word[] to the next candidate */
290
i=0;
291
while (i < word_rot_count)
292
{
293
/* Replace letter in word with appropriate rotated letter fom rot_chars */
294
word[word_rot_idx[i]] = rot_chars[word_rotchars_pos[i]];
295
i++;
296
}
297
298
/* Rotate the word_rotchars_pos */
299
i=0;
300
while (i < word_rot_count)
301
{
302
word_rotchars_pos[i]++;
303
304
j = word_rot_pos[i];
305
if (word_rotchars_pos[i] != (rot_pos[j] + rot_len[j]))
306
{
307
/* No carry */
308
break;
309
}
310
311
/* Rotation overflow, carry to next rotation */
312
word_rotchars_pos[i] = rot_pos[j];
313
314
i++;
315
}
316
317
word_rot_current++;
318
}
319
320
/* Called when restoring an interrupted session */
321
void restore()
322
{
323
int wrc;
324
325
.include [List.HybridLeet:new]
326
327
/* Pick up the current iteration */
328
word_rot_current = hybrid_resume;
329
330
/* Zoom the word_rotchars_pos to the hybrid_resume iteration */
331
i=0;
332
wrc = word_rot_current;
333
334
while (i < word_rot_count)
335
{
336
j = word_rot_pos[i];
337
338
/* Rotate this position */
339
word_rotchars_pos[i] = rot_pos[j] + (wrc % rot_len[j]);
340
wrc = wrc / rot_len[j];
341
342
i++;
343
}
344
}
345
346