1 /*
2  *
3  *   Ophcrack is a Lanmanager/NTLM hash cracker based on the faster time-memory
4  *   trade-off using rainbow tables.
5  *
6  *   Created with the help of: Maxime Mueller, Luca Wullschleger, Claude
7  *   Hochreutiner, Andreas Huber and Etienne Dysli.
8  *
9  *   Copyright (c) 2008 Philippe Oechslin, Cedric Tissieres, Bertrand Mesot
10  *
11  *   Ophcrack is free software; you can redistribute it and/or modify
12  *   it under the terms of the GNU General Public License as published by
13  *   the Free Software Foundation; either version 2 of the License, or
14  *   (at your option) any later version.
15  *
16  *   Ophcrack is distributed in the hope that it will be useful,
17  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *   GNU General Public License for more details.
20  *
21  *   You should have received a copy of the GNU General Public License
22  *   along with Ophcrack; if not, write to the Free Software
23  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24  *
25  *   This program is released under the GPL with the additional exemption
26  *   that compiling, linking, and/or using OpenSSL is allowed.
27  *
28  *
29  *
30  *
31 */
32 #ifndef TABLE_H
33 #define TABLE_H
34 
35 #include <stdio.h>
36 #include <stdint.h>
37 
38 #include "misc.h"
39 #include "list.h"
40 
41 #include "proba_info.h"
42 
43 #ifdef WIN32
44 #define fstat _fstati64
45 #define stat _stati64
46 #define fseeko fseeko64
47 #endif
48 
49 #ifdef  __cplusplus
50 extern "C" {
51 #endif
52 
53 typedef enum {
54   unknown = 0,
55   lmalphanum10k,
56   lmalphanum5k,
57   lmextended,
58   ntextended,
59   lmgermanv1,
60   lmgermanv2,
61   ntdict,
62   ntnine,
63   nteight,
64   ntnum,
65   ntseven,
66   lmflash,
67   nteightxl,
68   ntspecialxl,
69   ntprobafree,
70   ntproba10g,
71   ntproba60g
72 } table_kind_t;
73 
74 typedef enum {
75   preload_none = 0x00,
76   preload_init = 0x01,
77   preload_idx  = 0x02,
78   preload_end  = 0x04,
79   preload_srt  = 0x08,
80   preload_full = preload_init + preload_idx + preload_end + preload_srt
81 } table_preload_t;
82 
83 typedef struct table_t_ {
84   table_kind_t kind;
85   uint32_t code;
86 
87   char *path;
88   char *name;
89 
90   int id;
91   int idx;
92   int cmin;
93   int cmax;
94   int ncols;
95   int offset;
96   int enabled;
97   int active;
98 
99   FILE *idxfile;
100   FILE *endfile;
101   FILE *srtfile;
102 
103   uint8_t shared_init;
104 
105   uint64_t inisize;
106   uint64_t idxsize;
107   uint64_t endsize;
108   uint64_t srtsize;
109 
110   const uint64_t *sizes;
111 
112   void *param;
113   char *idxmem;
114   char *endmem;
115   char *srtmem;
116 
117   void *(*init)(void*);
118   void  (*cleanup)(void*);
119 
120   void (*find)(void*, void*, void*);
121   int (*lookup_idx)(void*, void*, void*);
122   int (*lookup_end)(void*, void*, void*);
123   int (*lookup_srt)(void*, void*, void*);
124 
125   int (*check)(void*, void*, void*);
126   int (*isvalid)(void*, void*);
127 } table_t;
128 
129 table_t *table_alloc(uint32_t code, char *path, int idx);
130 void table_free(table_t *tbl);
131 
132 int table_load(table_t *tbl);
133 void table_set_size(table_t *tbl);
134 int table_verify(table_t *tbl);
135 uint64_t table_preload(table_t *tbl, table_preload_t preload);
136 uint64_t table_unload(table_t *tbl, table_preload_t preload);
137 
138 uint64_t table_size(table_t *tbl);
139 uint64_t table_preload_size(table_t *tbl, table_preload_t preload);
140 int table_open(list_t *tables, const char *dir, const char *tblstr);
141 
142 table_preload_t table_preload_state(table_t *tbl);
143 
144 table_kind_t table_kind(uint32_t code);
145 const char *table_string(table_kind_t kind);
146 
147 #ifdef  __cplusplus
148 }
149 #endif
150 #endif
151