-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharset.h
79 lines (64 loc) · 2.05 KB
/
charset.h
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
/*
* This file is part of John the Ripper password cracker,
* Copyright (c) 1996-2001,2005,2008,2013 by Solar Designer
*/
/*
* Charset file generation.
*/
#ifndef _JOHN_CHARSET_H
#define _JOHN_CHARSET_H
#include "params.h"
#include "loader.h"
/*
* While CHARSET_MIN and CHARSET_MAX are configurable in params.h, CHARSET_SIZE
* is expected (by declarations and code in charset.c and inc.c) to be exactly
* (CHARSET_MAX - CHARSET_MIN + 1). So let's define it that way in here.
*/
#define CHARSET_SIZE (CHARSET_MAX - CHARSET_MIN + 1)
/*
* Charset file control char codes (only CHARSET_ESC is reserved, and can't
* be used in a charset).
*/
#define CHARSET_ESC 0
#define CHARSET_NEW 1
#define CHARSET_LINE 2
/*
* Charset file header.
*/
struct charset_header {
/* CHARSET_V* */
char version[4];
/* A checksum of the file or equivalent plus some space for future extensions
* (only 4 bytes are used currently) */
unsigned char check[24];
/* CHARSET_MIN, CHARSET_MAX */
unsigned char min, max;
/* CHARSET_LENGTH */
unsigned char length;
/* Number of different characters, up to (max - min + 1) */
unsigned char count;
/* File offsets for each length, 32-bit little endian */
unsigned char offsets[CHARSET_LENGTH][4];
/*
* Cracking order.
*
* This is a list of current {length, fixed index position, character count}.
* There are CHARSET_LENGTH different lengths, and fixed index position is up
* to the current length, which means that we have exactly (CHARSET_LENGTH *
* (CHARSET_LENGTH + 1) / 2) different {length, fixed index position} pairs;
* for each such pair we need to try all charsets from 1 character and up to
* CHARSET_SIZE characters large.
*/
unsigned char order
[CHARSET_LENGTH * (CHARSET_LENGTH + 1) / 2 * CHARSET_SIZE * 3];
};
/*
* Reads a charset file header.
* Returns zero on success, non-zero on error.
*/
extern int charset_read_header(FILE *file, struct charset_header *header);
/*
* Generates a charset file, based on plaintexts in the database.
*/
extern void do_makechars(struct db_main *db, char *charset);
#endif