1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-22 22:58:30 +00:00

More preparation for easier integration of:

* https://github.com/hashcat/hashcat/pull/485
* https://github.com/hashcat/hashcat/pull/486
This commit is contained in:
jsteube 2016-09-06 11:49:26 +02:00
parent 238b3e4401
commit 3dc77ced14
13 changed files with 18636 additions and 18523 deletions

43
include/convert.h Normal file
View File

@ -0,0 +1,43 @@
/**
* Author......: Jens Steube <jens.steube@gmail.com>
* License.....: MIT
*/
#pragma once
#include <ctype.h>
int is_valid_hex_char (const u8 c);
u8 hex_convert (const u8 c);
u8 hex_to_u8 (const u8 hex[2]);
u32 hex_to_u32 (const u8 hex[8]);
u64 hex_to_u64 (const u8 hex[16]);
void bin_to_hex_lower (const u32 v, u8 hex[8]);
u8 int_to_base32 (const u8 c);
u8 base32_to_int (const u8 c);
u8 int_to_base64 (const u8 c);
u8 base64_to_int (const u8 c);
u8 int_to_itoa32 (const u8 c);
u8 itoa32_to_int (const u8 c);
u8 int_to_itoa64 (const u8 c);
u8 itoa64_to_int (const u8 c);
u8 int_to_bf64 (const u8 c);
u8 bf64_to_int (const u8 c);
u8 int_to_lotus64 (const u8 c);
u8 lotus64_to_int (const u8 c);
int base32_decode (u8 (*f) (const u8), const u8 *in_buf, int in_len, u8 *out_buf);
int base32_encode (u8 (*f) (const u8), const u8 *in_buf, int in_len, u8 *out_buf);
int base64_decode (u8 (*f) (const u8), const u8 *in_buf, int in_len, u8 *out_buf);
int base64_encode (u8 (*f) (const u8), const u8 *in_buf, int in_len, u8 *out_buf);
void lowercase (u8 *buf, int len);
void uppercase (u8 *buf, int len);

View File

@ -709,3 +709,5 @@ void AES_set_encrypt_key (const u8 *key, int keysize, AES_KEY *aes_key);
void AES_set_decrypt_key (const u8 *key, int keysize, AES_KEY *aes_key);
void AES_encrypt (AES_KEY *aes_key, const u8 *input, u8 *output);
void AES_decrypt (AES_KEY *aes_key, const u8 *input, u8 *output);
void AES128_decrypt_cbc (const u32 key[4], const u32 iv[4], const u32 in[16], u32 out[16]);

254
include/data.h Normal file
View File

@ -0,0 +1,254 @@
/**
* Author......: Jens Steube <jens.steube@gmail.com>
* License.....: MIT
*/
#pragma once
typedef struct
{
/**
* threads
*/
uint devices_status;
uint devices_cnt;
uint devices_active;
hc_device_param_t *devices_param;
uint shutdown_inner;
uint shutdown_outer;
/**
* workload specific
*/
uint hardware_power_all;
uint kernel_power_all;
u64 kernel_power_final; // we save that so that all divisions are done from the same base
/**
* attack specific
*/
uint wordlist_mode;
uint hashlist_mode;
uint hashlist_format;
uint attack_mode;
uint attack_kern;
uint attack_exec;
uint kernel_rules_cnt;
kernel_rule_t *kernel_rules_buf;
uint combs_mode;
uint combs_cnt;
uint bfs_cnt;
uint css_cnt;
cs_t *css_buf;
cs_t *root_css_buf;
cs_t *markov_css_buf;
char *rule_buf_l;
char *rule_buf_r;
int rule_len_l;
int rule_len_r;
/**
* opencl library stuff
*/
void *ocl;
/**
* hardware watchdog
*/
#ifdef HAVE_HWMON
void *hm_adl;
void *hm_nvml;
void *hm_nvapi;
void *hm_xnvctrl;
hm_attrs_t hm_device[DEVICES_MAX];
#endif
/**
* hashes
*/
uint digests_cnt;
uint digests_done;
uint digests_saved;
void *digests_buf;
uint *digests_shown;
uint *digests_shown_tmp;
uint salts_cnt;
uint salts_done;
salt_t *salts_buf;
uint *salts_shown;
void *esalts_buf;
uint scrypt_tmp_size;
uint scrypt_tmto_final;
/**
* logging
*/
uint logfile_disable;
char *logfile;
char *topid;
char *subid;
/**
* crack-per-time
*/
cpt_t cpt_buf[CPT_BUF];
int cpt_pos;
time_t cpt_start;
u64 cpt_total;
/**
* user
*/
char *dictfile;
char *dictfile2;
char *mask;
uint maskcnt;
uint maskpos;
char *session;
char separator;
char *hashfile;
char *homedir;
char *install_dir;
char *profile_dir;
char *session_dir;
char *shared_dir;
char *outfile;
uint outfile_format;
uint outfile_autohex;
uint outfile_check_timer;
char *eff_restore_file;
char *new_restore_file;
char *induction_directory;
char *outfile_check_directory;
uint loopback;
char *loopback_file;
uint restore;
uint restore_timer;
uint restore_disable;
uint status;
uint status_timer;
uint machine_readable;
uint quiet;
uint force;
uint benchmark;
uint runtime;
uint remove;
uint remove_timer;
uint debug_mode;
char *debug_file;
uint hex_charset;
uint hex_salt;
uint hex_wordlist;
uint pw_min;
uint pw_max;
uint powertune_enable;
uint scrypt_tmto;
uint segment_size;
char *truecrypt_keyfiles;
char *veracrypt_keyfiles;
uint veracrypt_pim;
uint workload_profile;
char *custom_charset_1;
char *custom_charset_2;
char *custom_charset_3;
char *custom_charset_4;
uint hash_mode;
uint hash_type;
uint kern_type;
uint opts_type;
uint salt_type;
uint esalt_size;
uint isSalted;
uint dgst_size;
uint opti_type;
uint dgst_pos0;
uint dgst_pos1;
uint dgst_pos2;
uint dgst_pos3;
#ifdef HAVE_HWMON
uint gpu_temp_disable;
uint gpu_temp_abort;
uint gpu_temp_retain;
#endif
char **rp_files;
uint rp_files_cnt;
uint rp_gen;
uint rp_gen_seed;
FILE *pot_fp;
/**
* used for restore
*/
u64 skip;
u64 limit;
restore_data_t *rd;
u64 checkpoint_cur_words; // used for the "stop at next checkpoint" feature
/**
* status, timer
*/
time_t runtime_start;
time_t runtime_stop;
time_t prepare_time;
time_t proc_start;
time_t proc_stop;
u64 words_cnt;
u64 words_cur;
u64 words_base;
u64 *words_progress_done; // progress number of words done per salt
u64 *words_progress_rejected; // progress number of words rejected per salt
u64 *words_progress_restored; // progress number of words restored per salt
hc_timer_t timer_running; // timer on current dict
hc_timer_t timer_paused; // timer on current dict
double ms_paused; // timer on current dict
/**
* hash_info and username
*/
hashinfo_t **hash_info;
uint username;
int (*sort_by_digest) (const void *, const void *);
int (*parse_func) (char *, uint, hash_t *);
} hc_global_data_t;

1834
include/interface.h Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -165,7 +165,7 @@ LFLAGS_CROSS_WIN := -lpsapi
## Objects
##
NATIVE_OBJS := obj/memory.NATIVE.o obj/logging.NATIVE.o obj/cpu_aes.NATIVE.o obj/cpu_des.NATIVE.o obj/cpu_md5.NATIVE.o obj/cpu_sha1.NATIVE.o obj/cpu_sha256.NATIVE.o obj/bitops.NATIVE.o obj/bitops.NATIVE.o obj/ext_OpenCL.NATIVE.o obj/shared.NATIVE.o obj/rp_kernel_on_cpu.NATIVE.o
NATIVE_OBJS := obj/data.NATIVE.o obj/convert.NATIVE.o obj/memory.NATIVE.o obj/logging.NATIVE.o obj/cpu_aes.NATIVE.o obj/cpu_des.NATIVE.o obj/cpu_md5.NATIVE.o obj/cpu_sha1.NATIVE.o obj/cpu_sha256.NATIVE.o obj/bitops.NATIVE.o obj/bitops.NATIVE.o obj/ext_OpenCL.NATIVE.o obj/shared.NATIVE.o obj/rp_kernel_on_cpu.NATIVE.o obj/interface.NATIVE.o
ifeq ($(UNAME),Linux)
NATIVE_OBJS += obj/ext_ADL.NATIVE.o
@ -174,8 +174,8 @@ NATIVE_OBJS += obj/ext_nvml.NATIVE.o
NATIVE_OBJS += obj/ext_xnvctrl.NATIVE.o
endif
LINUX_32_OBJS := obj/memory.LINUX.32.o obj/logging.LINUX.32.o obj/cpu_aes.LINUX.32.o obj/cpu_des.LINUX.32.o obj/cpu_md5.LINUX.32.o obj/cpu_sha1.LINUX.32.o obj/cpu_sha256.LINUX.32.o obj/bitops.LINUX.32.o obj/ext_OpenCL.LINUX.32.o obj/shared.LINUX.32.o obj/rp_kernel_on_cpu.LINUX.32.o obj/ext_ADL.LINUX.32.o obj/ext_nvml.LINUX.32.o obj/ext_nvapi.LINUX.32.o obj/ext_xnvctrl.LINUX.32.o
LINUX_64_OBJS := obj/memory.LINUX.64.o obj/logging.LINUX.64.o obj/cpu_aes.LINUX.64.o obj/cpu_des.LINUX.64.o obj/cpu_md5.LINUX.64.o obj/cpu_sha1.LINUX.64.o obj/cpu_sha256.LINUX.64.o obj/bitops.LINUX.64.o obj/ext_OpenCL.LINUX.64.o obj/shared.LINUX.64.o obj/rp_kernel_on_cpu.LINUX.64.o obj/ext_ADL.LINUX.64.o obj/ext_nvml.LINUX.64.o obj/ext_nvapi.LINUX.64.o obj/ext_xnvctrl.LINUX.64.o
LINUX_32_OBJS := obj/data.LINUX.32.o obj/convert.LINUX.32.o obj/memory.LINUX.32.o obj/logging.LINUX.32.o obj/cpu_aes.LINUX.32.o obj/cpu_des.LINUX.32.o obj/cpu_md5.LINUX.32.o obj/cpu_sha1.LINUX.32.o obj/cpu_sha256.LINUX.32.o obj/bitops.LINUX.32.o obj/ext_OpenCL.LINUX.32.o obj/shared.LINUX.32.o obj/rp_kernel_on_cpu.LINUX.32.o obj/ext_ADL.LINUX.32.o obj/ext_nvml.LINUX.32.o obj/ext_nvapi.LINUX.32.o obj/ext_xnvctrl.LINUX.32.o obj/interface.LINUX.32.o
LINUX_64_OBJS := obj/data.LINUX.64.o obj/convert.LINUX.64.o obj/memory.LINUX.64.o obj/logging.LINUX.64.o obj/cpu_aes.LINUX.64.o obj/cpu_des.LINUX.64.o obj/cpu_md5.LINUX.64.o obj/cpu_sha1.LINUX.64.o obj/cpu_sha256.LINUX.64.o obj/bitops.LINUX.64.o obj/ext_OpenCL.LINUX.64.o obj/shared.LINUX.64.o obj/rp_kernel_on_cpu.LINUX.64.o obj/ext_ADL.LINUX.64.o obj/ext_nvml.LINUX.64.o obj/ext_nvapi.LINUX.64.o obj/ext_xnvctrl.LINUX.64.o obj/interface.LINUX.64.o
# Windows CRT file globbing:
@ -185,8 +185,8 @@ CRT_GLOB_INCLUDE_FOLDER := $(dir $(lastword $(MAKEFILE_LIST)))
include $(CRT_GLOB_INCLUDE_FOLDER)/win_file_globbing.mk
WIN_32_OBJS := obj/memory.WIN.32.o obj/logging.WIN.32.o obj/cpu_aes.WIN.32.o obj/cpu_des.WIN.32.o obj/cpu_md5.WIN.32.o obj/cpu_sha1.WIN.32.o obj/cpu_sha256.WIN.32.o obj/bitops.WIN.32.o obj/ext_OpenCL.WIN.32.o obj/shared.WIN.32.o obj/rp_kernel_on_cpu.WIN.32.o obj/ext_ADL.WIN.32.o obj/ext_nvml.WIN.32.o obj/ext_nvapi.WIN.32.o obj/ext_xnvctrl.WIN.32.o $(CRT_GLOB_32)
WIN_64_OBJS := obj/memory.WIN.64.o obj/logging.WIN.64.o obj/cpu_aes.WIN.64.o obj/cpu_des.WIN.64.o obj/cpu_md5.WIN.64.o obj/cpu_sha1.WIN.64.o obj/cpu_sha256.WIN.64.o obj/bitops.WIN.64.o obj/ext_OpenCL.WIN.64.o obj/shared.WIN.64.o obj/rp_kernel_on_cpu.WIN.64.o obj/ext_ADL.WIN.64.o obj/ext_nvml.WIN.64.o obj/ext_nvapi.WIN.64.o obj/ext_xnvctrl.WIN.64.o $(CRT_GLOB_64)
WIN_32_OBJS := obj/data.WIN.32.o obj/convert.WIN.32.o obj/memory.WIN.32.o obj/logging.WIN.32.o obj/cpu_aes.WIN.32.o obj/cpu_des.WIN.32.o obj/cpu_md5.WIN.32.o obj/cpu_sha1.WIN.32.o obj/cpu_sha256.WIN.32.o obj/bitops.WIN.32.o obj/ext_OpenCL.WIN.32.o obj/shared.WIN.32.o obj/rp_kernel_on_cpu.WIN.32.o obj/ext_ADL.WIN.32.o obj/ext_nvml.WIN.32.o obj/ext_nvapi.WIN.32.o obj/ext_xnvctrl.WIN.32.o obj/interface.WIN.32.o $(CRT_GLOB_32)
WIN_64_OBJS := obj/data.WIN.64.o obj/convert.WIN.64.o obj/memory.WIN.64.o obj/logging.WIN.64.o obj/cpu_aes.WIN.64.o obj/cpu_des.WIN.64.o obj/cpu_md5.WIN.64.o obj/cpu_sha1.WIN.64.o obj/cpu_sha256.WIN.64.o obj/bitops.WIN.64.o obj/ext_OpenCL.WIN.64.o obj/shared.WIN.64.o obj/rp_kernel_on_cpu.WIN.64.o obj/ext_ADL.WIN.64.o obj/ext_nvml.WIN.64.o obj/ext_nvapi.WIN.64.o obj/ext_xnvctrl.WIN.64.o obj/interface.WIN.64.o $(CRT_GLOB_64)
##
## Targets: Global

428
src/convert.c Normal file
View File

@ -0,0 +1,428 @@
/**
* Author......: Jens Steube <jens.steube@gmail.com>
* License.....: MIT
*/
#include "common.h"
#include "types_int.h"
#include "convert.h"
int is_valid_hex_char (const u8 c)
{
if ((c >= '0') && (c <= '9')) return 1;
if ((c >= 'A') && (c <= 'F')) return 1;
if ((c >= 'a') && (c <= 'f')) return 1;
return 0;
}
u8 hex_convert (const u8 c)
{
return (c & 15) + (c >> 6) * 9;
}
u8 hex_to_u8 (const u8 hex[2])
{
u8 v = 0;
v |= (hex_convert (hex[1]) << 0);
v |= (hex_convert (hex[0]) << 4);
return (v);
}
u32 hex_to_u32 (const u8 hex[8])
{
u32 v = 0;
v |= ((u32) hex_convert (hex[7])) << 0;
v |= ((u32) hex_convert (hex[6])) << 4;
v |= ((u32) hex_convert (hex[5])) << 8;
v |= ((u32) hex_convert (hex[4])) << 12;
v |= ((u32) hex_convert (hex[3])) << 16;
v |= ((u32) hex_convert (hex[2])) << 20;
v |= ((u32) hex_convert (hex[1])) << 24;
v |= ((u32) hex_convert (hex[0])) << 28;
return (v);
}
u64 hex_to_u64 (const u8 hex[16])
{
u64 v = 0;
v |= ((u64) hex_convert (hex[15]) << 0);
v |= ((u64) hex_convert (hex[14]) << 4);
v |= ((u64) hex_convert (hex[13]) << 8);
v |= ((u64) hex_convert (hex[12]) << 12);
v |= ((u64) hex_convert (hex[11]) << 16);
v |= ((u64) hex_convert (hex[10]) << 20);
v |= ((u64) hex_convert (hex[ 9]) << 24);
v |= ((u64) hex_convert (hex[ 8]) << 28);
v |= ((u64) hex_convert (hex[ 7]) << 32);
v |= ((u64) hex_convert (hex[ 6]) << 36);
v |= ((u64) hex_convert (hex[ 5]) << 40);
v |= ((u64) hex_convert (hex[ 4]) << 44);
v |= ((u64) hex_convert (hex[ 3]) << 48);
v |= ((u64) hex_convert (hex[ 2]) << 52);
v |= ((u64) hex_convert (hex[ 1]) << 56);
v |= ((u64) hex_convert (hex[ 0]) << 60);
return (v);
}
void bin_to_hex_lower (const u32 v, u8 hex[8])
{
hex[0] = v >> 28 & 15;
hex[1] = v >> 24 & 15;
hex[2] = v >> 20 & 15;
hex[3] = v >> 16 & 15;
hex[4] = v >> 12 & 15;
hex[5] = v >> 8 & 15;
hex[6] = v >> 4 & 15;
hex[7] = v >> 0 & 15;
u32 add;
hex[0] += 6; add = ((hex[0] & 0x10) >> 4) * 39; hex[0] += 42 + add;
hex[1] += 6; add = ((hex[1] & 0x10) >> 4) * 39; hex[1] += 42 + add;
hex[2] += 6; add = ((hex[2] & 0x10) >> 4) * 39; hex[2] += 42 + add;
hex[3] += 6; add = ((hex[3] & 0x10) >> 4) * 39; hex[3] += 42 + add;
hex[4] += 6; add = ((hex[4] & 0x10) >> 4) * 39; hex[4] += 42 + add;
hex[5] += 6; add = ((hex[5] & 0x10) >> 4) * 39; hex[5] += 42 + add;
hex[6] += 6; add = ((hex[6] & 0x10) >> 4) * 39; hex[6] += 42 + add;
hex[7] += 6; add = ((hex[7] & 0x10) >> 4) * 39; hex[7] += 42 + add;
}
u8 int_to_base32 (const u8 c)
{
const u8 tbl[0x20] =
{
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
};
return tbl[c];
}
u8 base32_to_int (const u8 c)
{
if ((c >= 'A') && (c <= 'Z')) return c - 'A';
else if ((c >= '2') && (c <= '7')) return c - '2' + 26;
return 0;
}
u8 int_to_itoa32 (const u8 c)
{
const u8 tbl[0x20] =
{
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
};
return tbl[c];
}
u8 itoa32_to_int (const u8 c)
{
if ((c >= '0') && (c <= '9')) return c - '0';
else if ((c >= 'a') && (c <= 'v')) return c - 'a' + 10;
return 0;
}
u8 int_to_itoa64 (const u8 c)
{
const u8 tbl[0x40] =
{
0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44,
0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a,
0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
};
return tbl[c];
}
u8 itoa64_to_int (const u8 c)
{
const u8 tbl[0x100] =
{
0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21,
0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x00, 0x01,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a,
0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x20, 0x21, 0x22, 0x23, 0x24,
0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34,
0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x00, 0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14,
0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24,
0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34,
0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x00, 0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14,
0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24,
0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34,
0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x00, 0x01, 0x02, 0x03, 0x04,
};
return tbl[c];
}
u8 int_to_base64 (const u8 c)
{
const u8 tbl[0x40] =
{
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2b, 0x2f,
};
return tbl[c];
}
u8 base64_to_int (const u8 c)
{
const u8 tbl[0x100] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3f,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
return tbl[c];
}
u8 int_to_bf64 (const u8 c)
{
const u8 tbl[0x40] =
{
0x2e, 0x2f, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64,
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
};
return tbl[c];
}
u8 bf64_to_int (const u8 c)
{
const u8 tbl[0x100] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
return tbl[c];
}
u8 int_to_lotus64 (const u8 c)
{
if (c < 10) return '0' + c;
else if (c < 36) return 'A' + c - 10;
else if (c < 62) return 'a' + c - 36;
else if (c == 62) return '+';
else if (c == 63) return '/';
return 0;
}
u8 lotus64_to_int (const u8 c)
{
if ((c >= '0') && (c <= '9')) return c - '0';
else if ((c >= 'A') && (c <= 'Z')) return c - 'A' + 10;
else if ((c >= 'a') && (c <= 'z')) return c - 'a' + 36;
else if (c == '+') return 62;
else if (c == '/') return 63;
else
return 0;
}
int base32_decode (u8 (*f) (const u8), const u8 *in_buf, int in_len, u8 *out_buf)
{
const u8 *in_ptr = in_buf;
u8 *out_ptr = out_buf;
for (int i = 0; i < in_len; i += 8)
{
const u8 out_val0 = f (in_ptr[0] & 0x7f);
const u8 out_val1 = f (in_ptr[1] & 0x7f);
const u8 out_val2 = f (in_ptr[2] & 0x7f);
const u8 out_val3 = f (in_ptr[3] & 0x7f);
const u8 out_val4 = f (in_ptr[4] & 0x7f);
const u8 out_val5 = f (in_ptr[5] & 0x7f);
const u8 out_val6 = f (in_ptr[6] & 0x7f);
const u8 out_val7 = f (in_ptr[7] & 0x7f);
out_ptr[0] = ((out_val0 << 3) & 0xf8) | ((out_val1 >> 2) & 0x07);
out_ptr[1] = ((out_val1 << 6) & 0xc0) | ((out_val2 << 1) & 0x3e) | ((out_val3 >> 4) & 0x01);
out_ptr[2] = ((out_val3 << 4) & 0xf0) | ((out_val4 >> 1) & 0x0f);
out_ptr[3] = ((out_val4 << 7) & 0x80) | ((out_val5 << 2) & 0x7c) | ((out_val6 >> 3) & 0x03);
out_ptr[4] = ((out_val6 << 5) & 0xe0) | ((out_val7 >> 0) & 0x1f);
in_ptr += 8;
out_ptr += 5;
}
for (int i = 0; i < in_len; i++)
{
if (in_buf[i] != '=') continue;
in_len = i;
}
int out_len = (in_len * 5) / 8;
return out_len;
}
int base32_encode (u8 (*f) (const u8), const u8 *in_buf, int in_len, u8 *out_buf)
{
const u8 *in_ptr = in_buf;
u8 *out_ptr = out_buf;
for (int i = 0; i < in_len; i += 5)
{
const u8 out_val0 = f ( ((in_ptr[0] >> 3) & 0x1f));
const u8 out_val1 = f (((in_ptr[0] << 2) & 0x1c) | ((in_ptr[1] >> 6) & 0x03));
const u8 out_val2 = f ( ((in_ptr[1] >> 1) & 0x1f));
const u8 out_val3 = f (((in_ptr[1] << 4) & 0x10) | ((in_ptr[2] >> 4) & 0x0f));
const u8 out_val4 = f (((in_ptr[2] << 1) & 0x1e) | ((in_ptr[3] >> 7) & 0x01));
const u8 out_val5 = f ( ((in_ptr[3] >> 2) & 0x1f));
const u8 out_val6 = f (((in_ptr[3] << 3) & 0x18) | ((in_ptr[4] >> 5) & 0x07));
const u8 out_val7 = f ( ((in_ptr[4] >> 0) & 0x1f));
out_ptr[0] = out_val0 & 0x7f;
out_ptr[1] = out_val1 & 0x7f;
out_ptr[2] = out_val2 & 0x7f;
out_ptr[3] = out_val3 & 0x7f;
out_ptr[4] = out_val4 & 0x7f;
out_ptr[5] = out_val5 & 0x7f;
out_ptr[6] = out_val6 & 0x7f;
out_ptr[7] = out_val7 & 0x7f;
in_ptr += 5;
out_ptr += 8;
}
int out_len = (int) (((0.5 + (double) in_len) * 8) / 5); // ceil (in_len * 8 / 5)
while (out_len % 8)
{
out_buf[out_len] = '=';
out_len++;
}
return out_len;
}
int base64_decode (u8 (*f) (const u8), const u8 *in_buf, int in_len, u8 *out_buf)
{
const u8 *in_ptr = in_buf;
u8 *out_ptr = out_buf;
for (int i = 0; i < in_len; i += 4)
{
const u8 out_val0 = f (in_ptr[0] & 0x7f);
const u8 out_val1 = f (in_ptr[1] & 0x7f);
const u8 out_val2 = f (in_ptr[2] & 0x7f);
const u8 out_val3 = f (in_ptr[3] & 0x7f);
out_ptr[0] = ((out_val0 << 2) & 0xfc) | ((out_val1 >> 4) & 0x03);
out_ptr[1] = ((out_val1 << 4) & 0xf0) | ((out_val2 >> 2) & 0x0f);
out_ptr[2] = ((out_val2 << 6) & 0xc0) | ((out_val3 >> 0) & 0x3f);
in_ptr += 4;
out_ptr += 3;
}
for (int i = 0; i < in_len; i++)
{
if (in_buf[i] != '=') continue;
in_len = i;
}
int out_len = (in_len * 6) / 8;
return out_len;
}
int base64_encode (u8 (*f) (const u8), const u8 *in_buf, int in_len, u8 *out_buf)
{
const u8 *in_ptr = in_buf;
u8 *out_ptr = out_buf;
for (int i = 0; i < in_len; i += 3)
{
const u8 out_val0 = f ( ((in_ptr[0] >> 2) & 0x3f));
const u8 out_val1 = f (((in_ptr[0] << 4) & 0x30) | ((in_ptr[1] >> 4) & 0x0f));
const u8 out_val2 = f (((in_ptr[1] << 2) & 0x3c) | ((in_ptr[2] >> 6) & 0x03));
const u8 out_val3 = f ( ((in_ptr[2] >> 0) & 0x3f));
out_ptr[0] = out_val0 & 0x7f;
out_ptr[1] = out_val1 & 0x7f;
out_ptr[2] = out_val2 & 0x7f;
out_ptr[3] = out_val3 & 0x7f;
in_ptr += 3;
out_ptr += 4;
}
int out_len = (int) (((0.5 + (double) in_len) * 8) / 6); // ceil (in_len * 8 / 6)
while (out_len % 4)
{
out_buf[out_len] = '=';
out_len++;
}
return out_len;
}
void lowercase (u8 *buf, int len)
{
for (int i = 0; i < len; i++) buf[i] = tolower (buf[i]);
}
void uppercase (u8 *buf, int len)
{
for (int i = 0; i < len; i++) buf[i] = toupper (buf[i]);
}

View File

@ -629,3 +629,47 @@ void AES_decrypt (AES_KEY *aes_key, const u8 *input, u8 *output)
AES256_decrypt ((const u32 *) input, (u32 *) output, aes_key->rdk);
}
}
// helper
void AES128_decrypt_cbc (const u32 key[4], const u32 iv[4], const u32 in[16], u32 out[16])
{
AES_KEY skey;
AES_set_decrypt_key ((const u8 *) key, 128, &skey);
u32 _iv[4] = { 0 };
_iv[0] = iv[0];
_iv[1] = iv[1];
_iv[2] = iv[2];
_iv[3] = iv[3];
for (int i = 0; i < 16; i += 4)
{
u32 _in[4] = { 0 };
u32 _out[4] = { 0 };
_in[0] = in[i + 0];
_in[1] = in[i + 1];
_in[2] = in[i + 2];
_in[3] = in[i + 3];
AES_decrypt (&skey, (const u8 *) _in, (u8 *) _out);
_out[0] ^= _iv[0];
_out[1] ^= _iv[1];
_out[2] ^= _iv[2];
_out[3] ^= _iv[3];
out[i + 0] = _out[0];
out[i + 1] = _out[1];
out[i + 2] = _out[2];
out[i + 3] = _out[3];
_iv[0] = _in[0];
_iv[1] = _in[1];
_iv[2] = _in[2];
_iv[3] = _in[3];
}
}

17
src/data.c Normal file
View File

@ -0,0 +1,17 @@
/**
* Author......: Jens Steube <jens.steube@gmail.com>
* License.....: MIT
*/
#include "common.h"
#include "types_int.h"
#include "ext_OpenCL.h"
#include "ext_ADL.h"
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "timer.h"
#include "types.h"
#include "data.h"
hc_global_data_t data;

View File

@ -10,6 +10,7 @@
#include "types_int.h"
#include "bitops.h"
#include "memory.h"
#include "convert.h"
#include "logging.h"
#include "ext_OpenCL.h"
#include "ext_ADL.h"
@ -28,7 +29,14 @@
#include "rp_cpu.h"
#include "rp_kernel_on_cpu.h"
#include "inc_hash_constants.h"
#include "interface.h"
#include "shared.h"
#include "data.h"
#include <search.h>
#include <getopt.h>
extern hc_global_data_t data;
static const char *PROGNAME = "hashcat";
@ -188,6 +196,23 @@ typedef enum combinator_mode
} combinator_mode_t;
typedef enum kern_run
{
KERN_RUN_1 = 1000,
KERN_RUN_12 = 1500,
KERN_RUN_2 = 2000,
KERN_RUN_23 = 2500,
KERN_RUN_3 = 3000
} kern_run_t;
typedef enum kern_run_mp
{
KERN_RUN_MP = 101,
KERN_RUN_MP_L = 102,
KERN_RUN_MP_R = 103
} kern_run_mp_t;
#ifdef _WIN
#define mkdir(name,mode) mkdir (name)

15846
src/interface.c Normal file

File diff suppressed because it is too large Load Diff

16290
src/shared.c

File diff suppressed because it is too large Load Diff