1
mirror of https://github.com/hashcat/hashcat synced 2024-11-24 14:27:14 +01:00
hashcat/include/types.h

547 lines
10 KiB
C
Raw Normal View History

2015-12-04 15:47:52 +01:00
/**
* Author......: Jens Steube <jens.steube@gmail.com>
* License.....: MIT
*/
#pragma once
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
2015-12-04 15:47:52 +01:00
#ifdef _WIN
#define EOL "\r\n"
#else
#define EOL "\n"
#endif
/**
* Outfile formats
*/
2015-12-04 15:47:52 +01:00
typedef enum outfile_fmt
2015-12-04 15:47:52 +01:00
{
OUTFILE_FMT_HASH = (1 << 0),
OUTFILE_FMT_PLAIN = (1 << 1),
OUTFILE_FMT_HEXPLAIN = (1 << 2),
OUTFILE_FMT_CRACKPOS = (1 << 3)
2015-12-04 15:47:52 +01:00
} outfile_fmt_t;
2015-12-04 15:47:52 +01:00
/**
* salt types
*/
2015-12-04 15:47:52 +01:00
typedef enum salt_type
2016-02-16 16:34:46 +01:00
{
SALT_TYPE_NONE = 1,
SALT_TYPE_EMBEDDED = 2,
SALT_TYPE_INTERN = 3,
SALT_TYPE_EXTERN = 4,
SALT_TYPE_VIRTUAL = 5
2016-02-16 16:34:46 +01:00
} salt_type_t;
/**
* optimizer options
*/
typedef enum opti_type
{
OPTI_TYPE_ZERO_BYTE = (1 << 1),
OPTI_TYPE_PRECOMPUTE_INIT = (1 << 2),
OPTI_TYPE_PRECOMPUTE_MERKLE = (1 << 3),
OPTI_TYPE_PRECOMPUTE_PERMUT = (1 << 4),
OPTI_TYPE_MEET_IN_MIDDLE = (1 << 5),
OPTI_TYPE_EARLY_SKIP = (1 << 6),
OPTI_TYPE_NOT_SALTED = (1 << 7),
OPTI_TYPE_NOT_ITERATED = (1 << 8),
OPTI_TYPE_PREPENDED_SALT = (1 << 9),
OPTI_TYPE_APPENDED_SALT = (1 << 10),
OPTI_TYPE_SINGLE_HASH = (1 << 11),
OPTI_TYPE_SINGLE_SALT = (1 << 12),
OPTI_TYPE_BRUTE_FORCE = (1 << 13),
OPTI_TYPE_RAW_HASH = (1 << 14),
OPTI_TYPE_SLOW_HASH_SIMD = (1 << 15),
OPTI_TYPE_USES_BITS_8 = (1 << 16),
OPTI_TYPE_USES_BITS_16 = (1 << 17),
OPTI_TYPE_USES_BITS_32 = (1 << 18),
OPTI_TYPE_USES_BITS_64 = (1 << 19)
} opti_type_t;
/**
* hash options
*/
typedef enum opts_type
{
OPTS_TYPE_PT_UNICODE = (1 << 0),
OPTS_TYPE_PT_UPPER = (1 << 1),
OPTS_TYPE_PT_LOWER = (1 << 2),
OPTS_TYPE_PT_ADD01 = (1 << 3),
OPTS_TYPE_PT_ADD02 = (1 << 4),
OPTS_TYPE_PT_ADD80 = (1 << 5),
OPTS_TYPE_PT_ADDBITS14 = (1 << 6),
OPTS_TYPE_PT_ADDBITS15 = (1 << 7),
OPTS_TYPE_PT_GENERATE_LE = (1 << 8),
OPTS_TYPE_PT_GENERATE_BE = (1 << 9),
OPTS_TYPE_PT_NEVERCRACK = (1 << 10), // if we want all possible results
OPTS_TYPE_PT_BITSLICE = (1 << 11),
OPTS_TYPE_ST_UNICODE = (1 << 12),
OPTS_TYPE_ST_UPPER = (1 << 13),
OPTS_TYPE_ST_LOWER = (1 << 14),
OPTS_TYPE_ST_ADD01 = (1 << 15),
OPTS_TYPE_ST_ADD02 = (1 << 16),
OPTS_TYPE_ST_ADD80 = (1 << 17),
OPTS_TYPE_ST_ADDBITS14 = (1 << 18),
OPTS_TYPE_ST_ADDBITS15 = (1 << 19),
OPTS_TYPE_ST_GENERATE_LE = (1 << 20),
OPTS_TYPE_ST_GENERATE_BE = (1 << 21),
OPTS_TYPE_ST_HEX = (1 << 22),
OPTS_TYPE_ST_BASE64 = (1 << 23),
OPTS_TYPE_HASH_COPY = (1 << 24),
OPTS_TYPE_HOOK12 = (1 << 25),
OPTS_TYPE_HOOK23 = (1 << 26)
} opts_type_t;
/**
* digests
*/
typedef enum dgst_size
2015-12-04 15:47:52 +01:00
{
DGST_SIZE_4_2 = (2 * sizeof (uint)), // 8
DGST_SIZE_4_4 = (4 * sizeof (uint)), // 16
DGST_SIZE_4_5 = (5 * sizeof (uint)), // 20
DGST_SIZE_4_6 = (6 * sizeof (uint)), // 24
DGST_SIZE_4_8 = (8 * sizeof (uint)), // 32
DGST_SIZE_4_16 = (16 * sizeof (uint)), // 64 !!!
DGST_SIZE_4_32 = (32 * sizeof (uint)), // 128 !!!
DGST_SIZE_4_64 = (64 * sizeof (uint)), // 256
DGST_SIZE_8_8 = (8 * sizeof (u64)), // 64 !!!
DGST_SIZE_8_16 = (16 * sizeof (u64)), // 128 !!!
DGST_SIZE_8_25 = (25 * sizeof (u64)) // 200
2015-12-04 15:47:52 +01:00
} dgst_size_t;
2015-12-04 15:47:52 +01:00
/**
* status
*/
2015-12-04 15:47:52 +01:00
typedef enum status_rc
2015-12-04 15:47:52 +01:00
{
STATUS_STARTING = 0,
STATUS_INIT = 1,
STATUS_RUNNING = 2,
STATUS_PAUSED = 3,
STATUS_EXHAUSTED = 4,
STATUS_CRACKED = 5,
STATUS_ABORTED = 6,
STATUS_QUIT = 7,
STATUS_BYPASS = 8,
STATUS_STOP_AT_CHECKPOINT = 9,
STATUS_AUTOTUNE = 10
2015-12-04 15:47:52 +01:00
} status_rc_t;
2015-12-04 15:47:52 +01:00
typedef struct
{
uint salt_buf[16];
uint salt_buf_pc[8];
2015-12-04 15:47:52 +01:00
uint salt_len;
uint salt_iter;
uint salt_sign[2];
2015-12-04 15:47:52 +01:00
uint keccak_mdlen;
uint truecrypt_mdlen;
2016-03-01 18:56:46 +01:00
uint digests_cnt;
uint digests_done;
uint digests_offset;
uint scrypt_N;
uint scrypt_r;
uint scrypt_p;
} salt_t;
2015-12-04 15:47:52 +01:00
typedef struct
{
char *user_name;
uint user_len;
} user_t;
typedef struct
{
user_t *user;
char *orighash;
} hashinfo_t;
typedef struct
{
void *digest;
salt_t *salt;
void *esalt;
int cracked;
hashinfo_t *hash_info;
} hash_t;
typedef struct
{
char plain_buf[256];
int plain_len;
hash_t hash;
} pot_t;
typedef struct
{
2016-01-25 12:28:06 +01:00
u64 cnt;
2015-12-04 15:47:52 +01:00
#ifdef _POSIX
struct stat stat;
#endif
#ifdef _WIN
struct __stat64 stat;
#endif
} dictstat_t;
typedef struct
{
u32 i[16];
2015-12-04 15:47:52 +01:00
u32 pw_len;
2015-12-04 15:47:52 +01:00
u32 alignment_placeholder_1;
u32 alignment_placeholder_2;
u32 alignment_placeholder_3;
2015-12-04 15:47:52 +01:00
} pw_t;
typedef struct
{
uint i;
} bf_t;
typedef struct
{
uint b[32];
} bs_word_t;
typedef struct
{
uint i[8];
uint pw_len;
} comb_t;
typedef struct
{
2016-01-25 12:28:06 +01:00
u32 version_bin;
char cwd[256];
2016-01-25 12:28:06 +01:00
u32 pid;
2015-12-04 15:47:52 +01:00
2016-01-25 12:28:06 +01:00
u32 dictpos;
u32 maskpos;
2015-12-04 15:47:52 +01:00
2016-01-25 12:28:06 +01:00
u64 words_cur;
2015-12-04 15:47:52 +01:00
2016-01-25 12:28:06 +01:00
u32 argc;
char **argv;
2015-12-04 15:47:52 +01:00
} restore_data_t;
typedef struct
{
2016-01-25 12:28:06 +01:00
char *file_name;
long seek;
time_t ctime;
2015-12-04 15:47:52 +01:00
} outfile_data_t;
typedef struct
{
2016-01-25 12:28:06 +01:00
char *buf;
2016-01-15 17:16:43 +01:00
u32 incr;
u32 avail;
u32 cnt;
u32 pos;
2015-12-04 15:47:52 +01:00
} wl_data_t;
typedef struct
{
uint bitmap_shift;
uint collisions;
} bitmap_result_t;
#define CPT_BUF 0x20000
typedef struct
{
uint cracked;
time_t timestamp;
} cpt_t;
/*
typedef struct
{
uint plain_buf[16];
uint plain_len;
} plain_t;
*/
typedef struct
{
uint salt_pos;
uint digest_pos;
uint hash_pos;
2015-12-04 15:47:52 +01:00
uint gidvid;
uint il_pos;
} plain_t;
typedef struct
{
uint word_buf[16];
} wordl_t;
typedef struct
{
uint word_buf[1];
} wordr_t;
typedef struct
{
char *device_name;
char *alias_name;
} tuning_db_alias_t;
typedef struct
{
char *device_name;
int attack_mode;
int hash_type;
int workload_profile;
int vector_width;
int kernel_accel;
int kernel_loops;
} tuning_db_entry_t;
typedef struct
{
tuning_db_alias_t *alias_buf;
int alias_cnt;
tuning_db_entry_t *entry_buf;
int entry_cnt;
} tuning_db_t;
#define RULES_MAX 256
2015-12-04 15:47:52 +01:00
#define PW_MIN 0
#define PW_MAX 54
#define PW_MAX1 (PW_MAX + 1)
#define PW_DICTMAX 31
#define PW_DICTMAX1 (PW_DICTMAX + 1)
#define PARAMCNT 64
2015-12-04 15:47:52 +01:00
struct __hc_device_param
{
2016-01-15 17:23:07 +01:00
cl_device_id device;
cl_device_type device_type;
2016-01-25 12:28:06 +01:00
uint device_id;
uint platform_devices_id; // for mapping with hms devices
2016-02-07 21:20:10 +01:00
bool skipped;
2016-01-15 17:23:07 +01:00
2016-01-25 12:28:06 +01:00
uint sm_major;
uint sm_minor;
uint kernel_exec_timeout;
2015-12-04 15:47:52 +01:00
2016-01-25 12:28:06 +01:00
uint device_processors;
u64 device_maxmem_alloc;
u64 device_global_mem;
u32 device_maxclock_frequency;
2016-05-04 00:52:53 +02:00
size_t device_maxworkgroup_size;
2016-01-25 12:28:06 +01:00
uint vector_width;
2016-01-25 12:28:06 +01:00
uint kernel_threads;
2016-02-05 15:27:09 +01:00
uint kernel_loops;
2016-01-25 12:28:06 +01:00
uint kernel_accel;
uint kernel_loops_min;
uint kernel_loops_max;
uint kernel_accel_min;
uint kernel_accel_max;
uint kernel_power;
2016-06-06 21:39:11 +02:00
uint hardware_power;
2016-05-04 00:52:53 +02:00
size_t size_pws;
size_t size_tmps;
size_t size_hooks;
size_t size_bfs;
size_t size_combs;
size_t size_rules;
size_t size_rules_c;
size_t size_root_css;
size_t size_markov_css;
size_t size_digests;
size_t size_salts;
size_t size_shown;
size_t size_results;
size_t size_plains;
2015-12-04 15:47:52 +01:00
2016-01-25 12:28:06 +01:00
FILE *combs_fp;
comb_t *combs_buf;
2015-12-04 15:47:52 +01:00
2016-01-25 12:28:06 +01:00
void *hooks_buf;
2015-12-04 15:47:52 +01:00
2016-01-25 12:28:06 +01:00
pw_t *pws_buf;
uint pws_cnt;
2015-12-04 15:47:52 +01:00
2016-01-25 12:28:06 +01:00
u64 words_off;
u64 words_done;
2015-12-04 15:47:52 +01:00
2016-01-25 12:28:06 +01:00
uint outerloop_pos;
uint outerloop_left;
2015-12-04 15:47:52 +01:00
2016-01-25 12:28:06 +01:00
uint innerloop_pos;
uint innerloop_left;
2015-12-04 15:47:52 +01:00
uint exec_pos;
double exec_ms[EXEC_CACHE];
// workaround cpu spinning
2016-06-14 10:18:42 +02:00
double exec_us_prev1[EXPECTED_ITERATIONS];
double exec_us_prev2[EXPECTED_ITERATIONS];
double exec_us_prev3[EXPECTED_ITERATIONS];
// this is "current" speed
2016-01-25 12:28:06 +01:00
uint speed_pos;
u64 speed_cnt[SPEED_CACHE];
double speed_ms[SPEED_CACHE];
2016-01-25 12:28:06 +01:00
hc_timer_t timer_speed;
2015-12-04 15:47:52 +01:00
// device specific attributes starting
2016-01-25 12:28:06 +01:00
char *device_name;
char *device_vendor;
2016-01-25 12:28:06 +01:00
char *device_name_chksum;
char *device_version;
char *driver_version;
bool opencl_v12;
double nvidia_spin_damp;
cl_platform_id platform;
cl_uint device_vendor_id;
cl_uint platform_vendor_id;
2016-01-25 12:28:06 +01:00
cl_kernel kernel1;
cl_kernel kernel12;
cl_kernel kernel2;
cl_kernel kernel23;
cl_kernel kernel3;
cl_kernel kernel_mp;
cl_kernel kernel_mp_l;
cl_kernel kernel_mp_r;
cl_kernel kernel_amp;
cl_kernel kernel_tm;
cl_kernel kernel_weak;
cl_kernel kernel_memset;
2016-01-25 12:28:06 +01:00
cl_context context;
cl_program program;
cl_program program_mp;
cl_program program_amp;
cl_command_queue command_queue;
cl_mem d_pws_buf;
cl_mem d_pws_amp_buf;
cl_mem d_words_buf_l;
cl_mem d_words_buf_r;
cl_mem d_rules;
cl_mem d_rules_c;
cl_mem d_combs;
cl_mem d_combs_c;
cl_mem d_bfs;
cl_mem d_bfs_c;
cl_mem d_tm_c;
cl_mem d_bitmap_s1_a;
cl_mem d_bitmap_s1_b;
cl_mem d_bitmap_s1_c;
cl_mem d_bitmap_s1_d;
cl_mem d_bitmap_s2_a;
cl_mem d_bitmap_s2_b;
cl_mem d_bitmap_s2_c;
cl_mem d_bitmap_s2_d;
cl_mem d_plain_bufs;
cl_mem d_digests_buf;
cl_mem d_digests_shown;
cl_mem d_salt_bufs;
cl_mem d_esalt_bufs;
cl_mem d_bcrypt_bufs;
cl_mem d_tmps;
cl_mem d_hooks;
cl_mem d_result;
cl_mem d_scryptV0_buf;
cl_mem d_scryptV1_buf;
cl_mem d_scryptV2_buf;
cl_mem d_scryptV3_buf;
2016-01-25 12:28:06 +01:00
cl_mem d_root_css_buf;
cl_mem d_markov_css_buf;
void *kernel_params[PARAMCNT];
void *kernel_params_mp[PARAMCNT];
void *kernel_params_mp_r[PARAMCNT];
void *kernel_params_mp_l[PARAMCNT];
void *kernel_params_amp[PARAMCNT];
void *kernel_params_tm[PARAMCNT];
void *kernel_params_memset[PARAMCNT];
2016-01-25 12:28:06 +01:00
u32 kernel_params_buf32[PARAMCNT];
u32 kernel_params_mp_buf32[PARAMCNT];
u64 kernel_params_mp_buf64[PARAMCNT];
u32 kernel_params_mp_r_buf32[PARAMCNT];
u64 kernel_params_mp_r_buf64[PARAMCNT];
u32 kernel_params_mp_l_buf32[PARAMCNT];
u64 kernel_params_mp_l_buf64[PARAMCNT];
u32 kernel_params_amp_buf32[PARAMCNT];
u32 kernel_params_memset_buf32[PARAMCNT];
2015-12-04 15:47:52 +01:00
};
typedef struct __hc_device_param hc_device_param_t;