From 7cabb848d2c2ba675bae6efd6890443a221857e2 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Fri, 14 Apr 2017 16:36:28 +0200 Subject: [PATCH 1/9] Wordlist encoding: Support added for internal convert from and to user-defined encoding during runtime Wordlist encoding: Added parameters --encoding-from and --encoding-to to configure wordlist encoding handling Dictstat: Structure for dictstat file changed as it has to include --encoding-from and --encoding-to parameter now --- deps/OpenCL-Headers/CL | 2 +- docs/changes.txt | 8 +++ extra/tab_completion/hashcat.sh | 6 +- include/types.h | 120 ++++++++++++++++++-------------- src/Makefile | 28 ++++++-- src/dictstat.c | 8 +++ src/dispatch.c | 50 ++++++++++++- src/usage.c | 2 + src/user_options.c | 11 +++ src/wordlist.c | 80 ++++++++++++++++++++- 10 files changed, 249 insertions(+), 66 deletions(-) diff --git a/deps/OpenCL-Headers/CL b/deps/OpenCL-Headers/CL index bf0f43b76..42e7afe06 160000 --- a/deps/OpenCL-Headers/CL +++ b/deps/OpenCL-Headers/CL @@ -1 +1 @@ -Subproject commit bf0f43b76f4556c3d5717f8ba8a01216b27f4af7 +Subproject commit 42e7afe066a67107c2236b86c9864a472f8eead8 diff --git a/docs/changes.txt b/docs/changes.txt index 05e42dd31..0829bdca5 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -1,5 +1,12 @@ * changes v3.40 -> 3.5.x: +## +## Features +## + +- Wordlist encoding: Support added for internal convert from and to user-defined encoding during runtime +- Wordlist encoding: Added parameters --encoding-from and --encoding-to to configure wordlist encoding handling + ## ## Improvements ## @@ -10,6 +17,7 @@ ## Technical ## +- Dictstat: Structure for dictstat file changed as it has to include --encoding-from and --encoding-to parameter now - OpenCL Runtime: Updated AMDGPU-Pro driver version check, do warn if version 17.10 is detected which is known to be broken - WPA cracking: Reduced --nonce-error-corrections default from 16 to 8 to compensate speed drop caused due to Big-Endian fixes diff --git a/extra/tab_completion/hashcat.sh b/extra/tab_completion/hashcat.sh index e0dfbbd89..2044d2ccf 100644 --- a/extra/tab_completion/hashcat.sh +++ b/extra/tab_completion/hashcat.sh @@ -189,8 +189,8 @@ _hashcat () local BUILD_IN_CHARSETS='?l ?u ?d ?a ?b ?s ?h ?H' local SHORT_OPTS="-m -a -V -v -h -b -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -i -I -s -l" - local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --hex-salt --hex-wordlist --hex-charset --force --status --status-timer --machine-readable --loopback --weak-hash-threshold --markov-hcstat --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-info --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --nvidia-spin-damp --gpu-temp-disable --gpu-temp-abort --gpu-temp-retain --powertune-enable --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --truecrypt-keyfiles --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections" - local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --status-timer --weak-hash-threshold --markov-hcstat --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-path --restore-file-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --nvidia-spin-damp --gpu-temp-abort --gpu-temp-retain -disable --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment-min --increment-max --scrypt-tmto --truecrypt-keyfiles --hccapx-message-pair --nonce-error-corrections" + local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --hex-salt --hex-wordlist --hex-charset --force --status --status-timer --machine-readable --loopback --weak-hash-threshold --markov-hcstat --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-info --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --nvidia-spin-damp --gpu-temp-disable --gpu-temp-abort --gpu-temp-retain --powertune-enable --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --truecrypt-keyfiles --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to" + local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --status-timer --weak-hash-threshold --markov-hcstat --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-path --restore-file-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --nvidia-spin-damp --gpu-temp-abort --gpu-temp-retain -disable --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment-min --increment-max --scrypt-tmto --truecrypt-keyfiles --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to" COMPREPLY=() local cur="${COMP_WORDS[COMP_CWORD]}" @@ -363,7 +363,7 @@ _hashcat () --status-timer|--markov-threshold|--runtime|--session|--separator|--segment-size|--rule-left|--rule-right| \ --nvidia-spin-damp|--gpu-temp-abort|--gpu-temp-retain|--generate-rules|--generate-rules-func-min|--generate-rules-func-max| \ --increment-min|--increment-max|--remove-timer|--bitmap-min|--bitmap-max|--skip|--limit|--generate-rules-seed| \ - --weak-hash-threshold|--outfile-check-timer|--outfile-check-dir|--induction-dir|--scrypt-tmto) + --weak-hash-threshold|--outfile-check-timer|--outfile-check-dir|--induction-dir|--scrypt-tmto|--encoding-from|--encoding-to) return 0 ;; diff --git a/include/types.h b/include/types.h index e0b94dee6..6d8225e10 100644 --- a/include/types.h +++ b/include/types.h @@ -16,6 +16,7 @@ #include #include #include +#include #if defined (_WIN) #include @@ -573,80 +574,82 @@ typedef enum user_options_map IDX_CUSTOM_CHARSET_4 = '4', IDX_DEBUG_FILE = 0xff04, IDX_DEBUG_MODE = 0xff05, - IDX_FORCE = 0xff06, - IDX_GPU_TEMP_ABORT = 0xff07, - IDX_GPU_TEMP_DISABLE = 0xff08, - IDX_GPU_TEMP_RETAIN = 0xff09, + IDX_ENCODING_FROM = 0xff06, + IDX_ENCODING_TO = 0xff07, + IDX_FORCE = 0xff08, + IDX_GPU_TEMP_ABORT = 0xff09, + IDX_GPU_TEMP_DISABLE = 0xff0a, + IDX_GPU_TEMP_RETAIN = 0xff0b, IDX_HASH_MODE = 'm', - IDX_HCCAPX_MESSAGE_PAIR = 0xff0a, + IDX_HCCAPX_MESSAGE_PAIR = 0xff0c, IDX_HELP = 'h', - IDX_HEX_CHARSET = 0xff0b, - IDX_HEX_SALT = 0xff0c, - IDX_HEX_WORDLIST = 0xff0d, + IDX_HEX_CHARSET = 0xff0d, + IDX_HEX_SALT = 0xff0e, + IDX_HEX_WORDLIST = 0xff0f, IDX_INCREMENT = 'i', - IDX_INCREMENT_MAX = 0xff0e, - IDX_INCREMENT_MIN = 0xff0f, - IDX_INDUCTION_DIR = 0xff10, - IDX_KEEP_GUESSING = 0xff11, + IDX_INCREMENT_MAX = 0xff10, + IDX_INCREMENT_MIN = 0xff11, + IDX_INDUCTION_DIR = 0xff12, + IDX_KEEP_GUESSING = 0xff13, IDX_KERNEL_ACCEL = 'n', IDX_KERNEL_LOOPS = 'u', - IDX_KEYSPACE = 0xff12, - IDX_LEFT = 0xff13, + IDX_KEYSPACE = 0xff14, + IDX_LEFT = 0xff15, IDX_LIMIT = 'l', - IDX_LOGFILE_DISABLE = 0xff14, - IDX_LOOPBACK = 0xff15, - IDX_MACHINE_READABLE = 0xff16, - IDX_MARKOV_CLASSIC = 0xff17, - IDX_MARKOV_DISABLE = 0xff18, - IDX_MARKOV_HCSTAT = 0xff19, + IDX_LOGFILE_DISABLE = 0xff16, + IDX_LOOPBACK = 0xff17, + IDX_MACHINE_READABLE = 0xff18, + IDX_MARKOV_CLASSIC = 0xff19, + IDX_MARKOV_DISABLE = 0xff1a, + IDX_MARKOV_HCSTAT = 0xff1b, IDX_MARKOV_THRESHOLD = 't', - IDX_NONCE_ERROR_CORRECTIONS = 0xff1a, - IDX_NVIDIA_SPIN_DAMP = 0xff1b, + IDX_NONCE_ERROR_CORRECTIONS = 0xff1c, + IDX_NVIDIA_SPIN_DAMP = 0xff1d, IDX_OPENCL_DEVICES = 'd', IDX_OPENCL_DEVICE_TYPES = 'D', IDX_OPENCL_INFO = 'I', - IDX_OPENCL_PLATFORMS = 0xff1c, - IDX_OPENCL_VECTOR_WIDTH = 0xff1d, - IDX_OUTFILE_AUTOHEX_DISABLE = 0xff1e, - IDX_OUTFILE_CHECK_DIR = 0xff1f, - IDX_OUTFILE_CHECK_TIMER = 0xff20, - IDX_OUTFILE_FORMAT = 0xff21, + IDX_OPENCL_PLATFORMS = 0xff1e, + IDX_OPENCL_VECTOR_WIDTH = 0xff1f, + IDX_OUTFILE_AUTOHEX_DISABLE = 0xff20, + IDX_OUTFILE_CHECK_DIR = 0xff21, + IDX_OUTFILE_CHECK_TIMER = 0xff22, + IDX_OUTFILE_FORMAT = 0xff23, IDX_OUTFILE = 'o', - IDX_POTFILE_DISABLE = 0xff22, - IDX_POTFILE_PATH = 0xff23, - IDX_POWERTUNE_ENABLE = 0xff24, - IDX_QUIET = 0xff25, - IDX_REMOVE = 0xff26, - IDX_REMOVE_TIMER = 0xff27, - IDX_RESTORE = 0xff28, - IDX_RESTORE_DISABLE = 0xff29, - IDX_RESTORE_FILE_PATH = 0xff2a, + IDX_POTFILE_DISABLE = 0xff24, + IDX_POTFILE_PATH = 0xff25, + IDX_POWERTUNE_ENABLE = 0xff26, + IDX_QUIET = 0xff27, + IDX_REMOVE = 0xff28, + IDX_REMOVE_TIMER = 0xff29, + IDX_RESTORE = 0xff2a, + IDX_RESTORE_DISABLE = 0xff2b, + IDX_RESTORE_FILE_PATH = 0xff2c, IDX_RP_FILE = 'r', - IDX_RP_GEN_FUNC_MAX = 0xff2b, - IDX_RP_GEN_FUNC_MIN = 0xff2c, + IDX_RP_GEN_FUNC_MAX = 0xff2d, + IDX_RP_GEN_FUNC_MIN = 0xff2e, IDX_RP_GEN = 'g', - IDX_RP_GEN_SEED = 0xff2d, + IDX_RP_GEN_SEED = 0xff2f, IDX_RULE_BUF_L = 'j', IDX_RULE_BUF_R = 'k', - IDX_RUNTIME = 0xff2e, - IDX_SCRYPT_TMTO = 0xff2f, + IDX_RUNTIME = 0xff30, + IDX_SCRYPT_TMTO = 0xff31, IDX_SEGMENT_SIZE = 'c', IDX_SEPARATOR = 'p', - IDX_SESSION = 0xff30, - IDX_SHOW = 0xff31, + IDX_SESSION = 0xff32, + IDX_SHOW = 0xff33, IDX_SKIP = 's', - IDX_STATUS = 0xff32, - IDX_STATUS_TIMER = 0xff33, - IDX_STDOUT_FLAG = 0xff34, - IDX_SPEED_ONLY = 0xff35, - IDX_PROGRESS_ONLY = 0xff36, - IDX_TRUECRYPT_KEYFILES = 0xff37, - IDX_USERNAME = 0xff38, - IDX_VERACRYPT_KEYFILES = 0xff39, - IDX_VERACRYPT_PIM = 0xff3a, + IDX_STATUS = 0xff34, + IDX_STATUS_TIMER = 0xff35, + IDX_STDOUT_FLAG = 0xff36, + IDX_SPEED_ONLY = 0xff37, + IDX_PROGRESS_ONLY = 0xff38, + IDX_TRUECRYPT_KEYFILES = 0xff39, + IDX_USERNAME = 0xff3a, + IDX_VERACRYPT_KEYFILES = 0xff3b, + IDX_VERACRYPT_PIM = 0xff3c, IDX_VERSION_LOWER = 'v', IDX_VERSION = 'V', - IDX_WEAK_HASH_THRESHOLD = 0xff3b, + IDX_WEAK_HASH_THRESHOLD = 0xff3d, IDX_WORKLOAD_PROFILE = 'w' } user_options_map_t; @@ -1203,6 +1206,9 @@ typedef struct dictstat hc_stat_t stat; + char encoding_from[64]; + char encoding_to[64]; + } dictstat_t; typedef struct dictstat_ctx @@ -1388,6 +1394,10 @@ typedef struct wl_data u64 cnt; u64 pos; + bool iconv_enabled; + iconv_t iconv_ctx; + char *iconv_tmp; + void (*func) (char *, u64, u64 *, u64 *); } wl_data_t; @@ -1453,6 +1463,8 @@ typedef struct user_options char *custom_charset_3; char *custom_charset_4; char *debug_file; + char *encoding_from; + char *encoding_to; char *induction_dir; char *markov_hcstat; char *opencl_devices; diff --git a/src/Makefile b/src/Makefile index b572e771d..e3d921ccd 100644 --- a/src/Makefile +++ b/src/Makefile @@ -108,6 +108,15 @@ CC_LINUX_64 := gcc CC_WIN_32 := i686-w64-mingw32-gcc CC_WIN_64 := x86_64-w64-mingw32-gcc +## To compile mingw iconv: +## +## ./configure --host=i686-w64-mingw32 --prefix=/opt/iconv-w32 && make install +## ./configure --host=x86_64-w64-mingw32 --prefix=/opt/iconv-w64 && make install +## + +ICONV_WIN_32 := /opt/iconv-w32 +ICONV_WIN_64 := /opt/iconv-w64 + ## ## Misc stuff ## @@ -184,7 +193,8 @@ CFLAGS_NATIVE := $(CFLAGS) CFLAGS_NATIVE += -I$(OPENCL_HEADERS_KHRONOS)/ CFLAGS_NATIVE += -DWITH_HWMON LFLAGS_NATIVE := $(LFLAGS) -LFLAGS_NATIVE += -lpthread -ldl +LFLAGS_NATIVE += -lpthread +LFLAGS_NATIVE += -ldl endif # Linux ifeq ($(UNAME),FreeBSD) @@ -192,7 +202,7 @@ ifndef PORTNAME CFLAGS_NATIVE := $(CFLAGS) CFLAGS_NATIVE += -I$(OPENCL_HEADERS_KHRONOS)/ LFLAGS_NATIVE := $(LFLAGS) -LFLAGS_NATIVE += -lpthread +LFLAGS_NATIVE += -lpthread endif endif # FreeBSD @@ -211,6 +221,7 @@ CFLAGS_NATIVE += -DWITH_HWMON LFLAGS_NATIVE := $(LFLAGS) LFLAGS_NATIVE += -Wl,--dynamicbase -Wl,--nxcompat LFLAGS_NATIVE += -lpsapi +LFLAGS_NATIVE += -liconv endif # CYGWIN ifeq ($(UNAME),MSYS2) @@ -220,6 +231,7 @@ CFLAGS_NATIVE += -DWITH_HWMON LFLAGS_NATIVE := $(LFLAGS) LFLAGS_NATIVE += -Wl,--dynamicbase -Wl,--nxcompat LFLAGS_NATIVE += -lpsapi +LFLAGS_NATIVE += -liconv endif # MSYS2 ## @@ -236,23 +248,31 @@ CFLAGS_CROSS_LINUX64 += -m64 CFLAGS_CROSS_LINUX64 += -DWITH_HWMON CFLAGS_CROSS_WIN32 := $(CFLAGS) CFLAGS_CROSS_WIN32 += -I$(OPENCL_HEADERS_KHRONOS)/ +CFLAGS_CROSS_WIN32 += -I$(ICONV_WIN_32)/include/ CFLAGS_CROSS_WIN32 += -m32 CFLAGS_CROSS_WIN32 += -DWITH_HWMON CFLAGS_CROSS_WIN64 := $(CFLAGS) CFLAGS_CROSS_WIN64 += -I$(OPENCL_HEADERS_KHRONOS)/ +CFLAGS_CROSS_WIN64 += -I$(ICONV_WIN_64)/include/ CFLAGS_CROSS_WIN64 += -m64 CFLAGS_CROSS_WIN64 += -DWITH_HWMON LFLAGS_CROSS_LINUX32 := $(LFLAGS) -LFLAGS_CROSS_LINUX32 += -lpthread -ldl +LFLAGS_CROSS_LINUX32 += -lpthread +LFLAGS_CROSS_LINUX32 += -ldl LFLAGS_CROSS_LINUX64 := $(LFLAGS) -LFLAGS_CROSS_LINUX64 += -lpthread -ldl +LFLAGS_CROSS_LINUX64 += -lpthread +LFLAGS_CROSS_LINUX64 += -ldl LFLAGS_CROSS_WIN32 := $(LFLAGS) LFLAGS_CROSS_WIN32 += -Wl,--dynamicbase -Wl,--nxcompat +LFLAGS_CROSS_WIN32 += -L$(ICONV_WIN_32)/lib/ LFLAGS_CROSS_WIN32 += -lpsapi +LFLAGS_CROSS_WIN32 += -liconv LFLAGS_CROSS_WIN64 := $(LFLAGS) LFLAGS_CROSS_WIN64 += -Wl,--dynamicbase -Wl,--nxcompat +LFLAGS_CROSS_WIN64 += -L$(ICONV_WIN_64)/lib/ LFLAGS_CROSS_WIN64 += -lpsapi +LFLAGS_CROSS_WIN64 += -liconv ## ## Objects diff --git a/src/dictstat.c b/src/dictstat.c index 47c8f4274..bec2defbd 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -18,6 +18,14 @@ int sort_by_dictstat (const void *s1, const void *s2) d2->stat.st_atime = d1->stat.st_atime; + const int rc_from = strcmp (d1->encoding_from, d2->encoding_from); + + if (rc_from != 0) return rc_from; + + const int rc_to = strcmp (d1->encoding_to, d2->encoding_to); + + if (rc_to != 0) return rc_to; + return memcmp (&d1->stat, &d2->stat, sizeof (struct stat)); } diff --git a/src/dispatch.c b/src/dispatch.c index c869c6672..71bd1f871 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -123,7 +123,22 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par char *buf = (char *) hcmalloc (HCBUFSIZ_LARGE); - const u32 attack_kern = user_options_extra->attack_kern; + bool iconv_enabled = false; + + iconv_t iconv_ctx; + + char *iconv_tmp = NULL; + + if (strcmp (user_options->encoding_from, user_options->encoding_to)) + { + iconv_enabled = true; + + iconv_ctx = iconv_open (user_options->encoding_to, user_options->encoding_from); + + if (iconv_ctx == (iconv_t) -1) return -1; + + iconv_tmp = (char *) hcmalloc (HCBUFSIZ_TINY); + } while (status_ctx->run_thread_level1 == true) { @@ -144,10 +159,30 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par if (line_buf == NULL) break; - u32 line_len = (u32) in_superchop (line_buf); + size_t line_len = in_superchop (line_buf); line_len = convert_from_hex (hashcat_ctx, line_buf, line_len); + // do the on-the-fly encoding + + if (iconv_enabled == true) + { + char *iconv_ptr = iconv_tmp; + size_t iconv_sz = HCBUFSIZ_TINY; + + const size_t iconv_rc = iconv (iconv_ctx, &line_buf, &line_len, &iconv_ptr, &iconv_sz); + + if (iconv_rc == (size_t) -1) + { + line_len = PW_MAX1; + } + else + { + line_buf = iconv_tmp; + line_len = HCBUFSIZ_TINY - iconv_sz; + } + } + // post-process rule engine char rule_buf_out[BLOCK_SIZE]; @@ -176,6 +211,8 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par // hmm that's always the case, or? + const u32 attack_kern = user_options_extra->attack_kern; + if (attack_kern == ATTACK_KERN_STRAIGHT) { if ((line_len < hashconfig->pw_min) || (line_len > hashconfig->pw_max)) @@ -241,6 +278,15 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par device_param->kernel_accel = 0; device_param->kernel_loops = 0; + if (iconv_enabled == true) + { + iconv_close (iconv_ctx); + + iconv_enabled = false; + + hcfree (iconv_tmp); + } + hcfree (buf); return 0; diff --git a/src/usage.c b/src/usage.c index 407807216..dd923b454 100644 --- a/src/usage.c +++ b/src/usage.c @@ -61,6 +61,8 @@ static const char *USAGE_BIG[] = " --remove-timer | Num | Update input hash file each X seconds | --remove-timer=30", " --potfile-disable | | Do not write potfile |", " --potfile-path | Dir | Specific path to potfile | --potfile-path=my.pot", + " --encoding-from | Code | Force internal wordlist encoding from X | --encoding-from=iso-8859-15", + " --encoding-from | Code | Force internal wordlist encoding to X | --encoding-to=utf-32le", " --debug-mode | Num | Defines the debug mode (hybrid only by using rules) | --debug-mode=4", " --debug-file | File | Output file for debugging rules | --debug-file=good.log", " --induction-dir | Dir | Specify the induction directory to use for loopback | --induction=inducts", diff --git a/src/user_options.c b/src/user_options.c index e198f9e9b..17c5ddc6e 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -30,6 +30,8 @@ static const struct option long_options[] = {"custom-charset4", required_argument, 0, IDX_CUSTOM_CHARSET_4}, {"debug-file", required_argument, 0, IDX_DEBUG_FILE}, {"debug-mode", required_argument, 0, IDX_DEBUG_MODE}, + {"encoding-from", required_argument, 0, IDX_ENCODING_FROM}, + {"encoding-to", required_argument, 0, IDX_ENCODING_TO}, {"force", no_argument, 0, IDX_FORCE}, {"generate-rules-func-max", required_argument, 0, IDX_RP_GEN_FUNC_MAX}, {"generate-rules-func-min", required_argument, 0, IDX_RP_GEN_FUNC_MIN}, @@ -108,6 +110,9 @@ static const struct option long_options[] = {0, 0, 0, 0} }; +static char ENCODING_FROM[] = "utf-8"; +static char ENCODING_TO[] = "utf-8"; + static char RULE_BUF_R[] = ":"; static char RULE_BUF_L[] = ":"; @@ -131,6 +136,8 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->custom_charset_4 = NULL; user_options->debug_file = NULL; user_options->debug_mode = DEBUG_MODE; + user_options->encoding_from = ENCODING_FROM; + user_options->encoding_to = ENCODING_TO; user_options->force = FORCE; user_options->gpu_temp_abort = GPU_TEMP_ABORT; user_options->gpu_temp_disable = GPU_TEMP_DISABLE; @@ -314,6 +321,8 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_POTFILE_PATH: user_options->potfile_path = optarg; break; case IDX_DEBUG_MODE: user_options->debug_mode = atoi (optarg); break; case IDX_DEBUG_FILE: user_options->debug_file = optarg; break; + case IDX_ENCODING_FROM: user_options->encoding_from = optarg; break; + case IDX_ENCODING_TO: user_options->encoding_to = optarg; break; case IDX_INDUCTION_DIR: user_options->induction_dir = optarg; break; case IDX_OUTFILE_CHECK_DIR: user_options->outfile_check_dir = optarg; break; case IDX_FORCE: user_options->force = true; break; @@ -2072,6 +2081,8 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx) logfile_top_string (user_options->custom_charset_3); logfile_top_string (user_options->custom_charset_4); logfile_top_string (user_options->debug_file); + logfile_top_string (user_options->encoding_from); + logfile_top_string (user_options->encoding_to); logfile_top_string (user_options->induction_dir); logfile_top_string (user_options->markov_hcstat); logfile_top_string (user_options->opencl_devices); diff --git a/src/wordlist.c b/src/wordlist.c index ef2f46a45..bbb70fc97 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -184,6 +184,28 @@ void get_next_word (hashcat_ctx_t *hashcat_ctx, FILE *fd, char **out_buf, u32 *o wl_data->pos += off; + // do the on-the-fly encoding + + if (wl_data->iconv_enabled == true) + { + char *iconv_ptr = wl_data->iconv_tmp; + size_t iconv_sz = HCBUFSIZ_TINY; + + size_t ptr_len = len; + + const size_t iconv_rc = iconv (wl_data->iconv_ctx, &ptr, &ptr_len, &iconv_ptr, &iconv_sz); + + if (iconv_rc == (size_t) -1) + { + len = PW_MAX1; + } + else + { + ptr = wl_data->iconv_tmp; + len = HCBUFSIZ_TINY - iconv_sz; + } + } + if (run_rule_engine (user_options_extra->rule_len_l, user_options->rule_buf_l)) { int rule_len_out = -1; @@ -288,6 +310,12 @@ int count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile, u64 d.stat.st_blocks = 0; #endif + memset (d.encoding_from, 0, sizeof (d.encoding_from)); + memset (d.encoding_to, 0, sizeof (d.encoding_to)); + + strncpy (d.encoding_from, user_options->encoding_from, sizeof (d.encoding_from)); + strncpy (d.encoding_to, user_options->encoding_to, sizeof (d.encoding_to)); + if (d.stat.st_size == 0) { *result = 0; @@ -351,7 +379,31 @@ int count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile, u64 u64 len; u64 off; - wl_data->func (wl_data->buf + i, wl_data->cnt - i, &len, &off); + char *ptr = wl_data->buf + i; + + wl_data->func (ptr, wl_data->cnt - i, &len, &off); + + // do the on-the-fly encoding + + if (wl_data->iconv_enabled == true) + { + char *iconv_ptr = wl_data->iconv_tmp; + size_t iconv_sz = HCBUFSIZ_TINY; + + size_t ptr_len = len; + + const size_t iconv_rc = iconv (wl_data->iconv_ctx, &ptr, &ptr_len, &iconv_ptr, &iconv_sz); + + if (iconv_rc == (size_t) -1) + { + len = PW_MAX1; + } + else + { + ptr = wl_data->iconv_tmp; + len = HCBUFSIZ_TINY - iconv_sz; + } + } if (run_rule_engine (user_options_extra->rule_len_l, user_options->rule_buf_l)) { @@ -361,7 +413,7 @@ int count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile, u64 { char unused[BLOCK_SIZE] = { 0 }; - rule_len_out = _old_apply_rule (user_options->rule_buf_l, user_options_extra->rule_len_l, wl_data->buf + i, len, unused); + rule_len_out = _old_apply_rule (user_options->rule_buf_l, user_options_extra->rule_len_l, ptr, len, unused); } if (rule_len_out < 0) @@ -476,6 +528,21 @@ int wl_data_init (hashcat_ctx_t *hashcat_ctx) wl_data->func = get_next_word_lm; } + /** + * iconv + */ + + if (strcmp (user_options->encoding_from, user_options->encoding_to)) + { + wl_data->iconv_enabled = true; + + wl_data->iconv_ctx = iconv_open (user_options->encoding_to, user_options->encoding_from); + + if (wl_data->iconv_ctx == (iconv_t) -1) return -1; + + wl_data->iconv_tmp = (char *) hcmalloc (HCBUFSIZ_TINY); + } + return 0; } @@ -487,5 +554,14 @@ void wl_data_destroy (hashcat_ctx_t *hashcat_ctx) hcfree (wl_data->buf); + if (wl_data->iconv_enabled == true) + { + iconv_close (wl_data->iconv_ctx); + + wl_data->iconv_enabled = false; + + hcfree (wl_data->iconv_tmp); + } + memset (wl_data, 0, sizeof (wl_data_t)); } From 54aaa1597ef2dff9eb2b07389a9b3c81093eeb36 Mon Sep 17 00:00:00 2001 From: Royce Williams Date: Fri, 14 Apr 2017 06:41:32 -0800 Subject: [PATCH 2/9] fix usage for encoding-to --- src/usage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/usage.c b/src/usage.c index dd923b454..b699f5bbe 100644 --- a/src/usage.c +++ b/src/usage.c @@ -62,7 +62,7 @@ static const char *USAGE_BIG[] = " --potfile-disable | | Do not write potfile |", " --potfile-path | Dir | Specific path to potfile | --potfile-path=my.pot", " --encoding-from | Code | Force internal wordlist encoding from X | --encoding-from=iso-8859-15", - " --encoding-from | Code | Force internal wordlist encoding to X | --encoding-to=utf-32le", + " --encoding-to | Code | Force internal wordlist encoding to X | --encoding-to=utf-32le", " --debug-mode | Num | Defines the debug mode (hybrid only by using rules) | --debug-mode=4", " --debug-file | File | Output file for debugging rules | --debug-file=good.log", " --induction-dir | Dir | Specify the induction directory to use for loopback | --induction=inducts", From 4e30ec5489f5214e2124229d8283269dc5e39f90 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Haidar-Bachminska Date: Fri, 14 Apr 2017 18:54:34 +0200 Subject: [PATCH 3/9] Fix compilation error on macOs (missing iconv linking) --- src/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile b/src/Makefile index e3d921ccd..864f53658 100644 --- a/src/Makefile +++ b/src/Makefile @@ -212,6 +212,7 @@ CFLAGS_NATIVE := $(CFLAGS) LFLAGS_NATIVE := $(LFLAGS) LFLAGS_NATIVE += -framework OpenCL LFLAGS_NATIVE += -lpthread +LFLAGS_NATIVE += -liconv endif # Darwin ifeq ($(UNAME),CYGWIN) From 5cc3b7807f2145bef0d2a966f467b577ca0ca3b0 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sat, 15 Apr 2017 17:33:59 +0200 Subject: [PATCH 4/9] Test for target Endianness and abort if it's big-endian --- include/common.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/common.h b/include/common.h index 64958a1ee..7291f749c 100644 --- a/include/common.h +++ b/include/common.h @@ -16,6 +16,10 @@ #error Your Operating System is not supported or detected #endif +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +#error "compiling for big-endian architecture not supported" +#endif + #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif From e3cef832be3e0a29e09caeebb3180e1fa0cbff86 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sun, 16 Apr 2017 12:47:14 +0200 Subject: [PATCH 5/9] Use the ROUNDS_MYWALLET instead of a hard-coded value --- src/interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interface.c b/src/interface.c index 65b99a602..3a2a29fa6 100644 --- a/src/interface.c +++ b/src/interface.c @@ -13059,7 +13059,7 @@ int mywallet_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U salt->salt_len = 32; // note we need to fix this to 16 in kernel - salt->salt_iter = 10 - 1; + salt->salt_iter = ROUNDS_MYWALLET - 1; /** * digest buf From 26a345334f22d8f3faa92c4a54a01ced467a3727 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sun, 16 Apr 2017 13:19:23 +0200 Subject: [PATCH 6/9] Added hash-mode 15200 = Blockchain, My Wallet, V2 Fixes https://github.com/hashcat/hashcat/issues/109 --- docs/changes.txt | 8 ++- docs/readme.txt | 1 + extra/tab_completion/hashcat.sh | 2 +- hashcat.hctune | 1 + include/interface.h | 4 ++ src/benchmark.c | 3 +- src/interface.c | 124 ++++++++++++++++++++++++++++++++ src/usage.c | 1 + tools/test.pl | 116 +++++++++++++++++++++++++++++- tools/test.sh | 4 +- 10 files changed, 258 insertions(+), 6 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 0829bdca5..5092d1917 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -1,4 +1,10 @@ -* changes v3.40 -> 3.5.x: +* changes v3.5.0 -> 3.x.x: + +## +## Algorithms +## + +- Added hash-mode 15200 = Blockchain, My Wallet, V2 ## ## Features diff --git a/docs/readme.txt b/docs/readme.txt index b9d603092..505959c6f 100644 --- a/docs/readme.txt +++ b/docs/readme.txt @@ -212,6 +212,7 @@ NVIDIA GPUs require "NVIDIA Driver" (367.x or later) - Lotus Notes/Domino 8 - Bitcoin/Litecoin wallet.dat - Blockchain, My Wallet +- Blockchain, My Wallet, V2 - 1Password, agilekeychain - 1Password, cloudkeychain - LastPass diff --git a/extra/tab_completion/hashcat.sh b/extra/tab_completion/hashcat.sh index 2044d2ccf..04eab7d4f 100644 --- a/extra/tab_completion/hashcat.sh +++ b/extra/tab_completion/hashcat.sh @@ -176,7 +176,7 @@ _hashcat () { local VERSION=3.5.0 - local HASH_MODES="0 10 11 12 20 21 22 23 30 40 50 60 100 101 110 111 112 120 121 122 124 130 131 132 133 140 141 150 160 200 300 400 500 501 900 1000 1100 1400 1410 1411 1420 1421 1430 1440 1441 1450 1460 1500 1600 1700 1710 1711 1720 1722 1730 1731 1740 1750 1760 1800 2100 2400 2410 2500 2600 2611 2612 2711 2811 3000 3100 3200 3710 3711 3800 3910 4010 4110 4300 4400 4500 4520 4521 4522 4700 4800 4900 5000 5100 5200 5300 5400 5500 5600 5700 5800 6000 6100 6211 6212 6213 6221 6222 6223 6231 6232 6233 6241 6242 6243 6300 6400 6500 6600 6700 6800 6900 7000 7100 7200 7300 7400 7500 7700 7800 7900 8000 8100 8200 8300 8400 8500 8600 8700 8800 8900 9000 9100 9200 9300 9400 9500 9600 9700 9710 9720 9800 9810 9820 9900 10000 10100 10200 10300 10400 10410 10420 10500 10600 10700 10800 10900 11000 11100 11200 11300 11400 11500 11600 11700 11800 11900 12000 12001 12100 12200 12300 12400 12500 12600 12700 12800 12900 13000 13100 13200 13300 13400 13500 13600 13800 13900 14000 14100 14700 14800 14900 15000 15100" + local HASH_MODES="0 10 11 12 20 21 22 23 30 40 50 60 100 101 110 111 112 120 121 122 124 130 131 132 133 140 141 150 160 200 300 400 500 501 900 1000 1100 1400 1410 1411 1420 1421 1430 1440 1441 1450 1460 1500 1600 1700 1710 1711 1720 1722 1730 1731 1740 1750 1760 1800 2100 2400 2410 2500 2600 2611 2612 2711 2811 3000 3100 3200 3710 3711 3800 3910 4010 4110 4300 4400 4500 4520 4521 4522 4700 4800 4900 5000 5100 5200 5300 5400 5500 5600 5700 5800 6000 6100 6211 6212 6213 6221 6222 6223 6231 6232 6233 6241 6242 6243 6300 6400 6500 6600 6700 6800 6900 7000 7100 7200 7300 7400 7500 7700 7800 7900 8000 8100 8200 8300 8400 8500 8600 8700 8800 8900 9000 9100 9200 9300 9400 9500 9600 9700 9710 9720 9800 9810 9820 9900 10000 10100 10200 10300 10400 10410 10420 10500 10600 10700 10800 10900 11000 11100 11200 11300 11400 11500 11600 11700 11800 11900 12000 12001 12100 12200 12300 12400 12500 12600 12700 12800 12900 13000 13100 13200 13300 13400 13500 13600 13800 13900 14000 14100 14700 14800 14900 15000 15100 15200" local ATTACK_MODES="0 1 3 6 7" local HCCAPX_MESSAGE_PAIR="0 1 2 3 4 5" local OUTFILE_FORMATS="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15" diff --git a/hashcat.hctune b/hashcat.hctune index aac71eee4..06be69726 100644 --- a/hashcat.hctune +++ b/hashcat.hctune @@ -445,6 +445,7 @@ ALIAS_Apple_Iris * 13000 1 1 ALIAS_Apple_Iris * 13200 1 1 1 ALIAS_Apple_Iris * 14700 1 1 1 ALIAS_Apple_Iris * 14800 1 1 1 +ALIAS_Apple_Iris * 15200 1 1 10 ALIAS_Apple_Iris_Pro * 5000 1 8 8 ALIAS_Apple_Iris_Pro * 6100 1 4 16 diff --git a/include/interface.h b/include/interface.h index e824aa34d..8632dde4c 100644 --- a/include/interface.h +++ b/include/interface.h @@ -1186,6 +1186,8 @@ typedef enum display_len DISPLAY_LEN_MAX_15000 = 128 + 1 + 64, DISPLAY_LEN_MIN_15100 = 6 + 3 + 1 + 8 + 1 + 28, DISPLAY_LEN_MAX_15100 = 6 + 6 + 1 + 8 + 1 + 28, + DISPLAY_LEN_MIN_15200 = 1 + 10 + 1 + 2 + 1 + 1 + 1 + 1 + 1 + 64, + DISPLAY_LEN_MAX_15200 = 1 + 10 + 1 + 2 + 1 + 8 + 1 + 5 + 1 + 20000, DISPLAY_LEN_MIN_99999 = 1, DISPLAY_LEN_MAX_99999 = 55, @@ -1569,6 +1571,7 @@ typedef enum rounds_count ROUNDS_BSDICRYPT = 2900, ROUNDS_RAR3 = 262144, ROUNDS_MYWALLET = 10, + ROUNDS_MYWALLETV2 = 5000, ROUNDS_MS_DRSR = 100, ROUNDS_ANDROIDFDE_SAMSUNG = 4096, ROUNDS_RAR5 = (1 << 15), @@ -1734,6 +1737,7 @@ int rar3hp_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_bu int rar5_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); int cf10_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); int mywallet_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int mywalletv2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); int ms_drsr_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); int androidfde_samsung_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); int axcrypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); diff --git a/src/benchmark.c b/src/benchmark.c index d2581d34e..fd85e023b 100644 --- a/src/benchmark.c +++ b/src/benchmark.c @@ -6,7 +6,7 @@ #include "common.h" #include "benchmark.h" -const unsigned int DEFAULT_BENCHMARK_ALGORITHMS_CNT = 149; +const unsigned int DEFAULT_BENCHMARK_ALGORITHMS_CNT = 150; const unsigned int DEFAULT_BENCHMARK_ALGORITHMS_BUF[] = { @@ -157,6 +157,7 @@ const unsigned int DEFAULT_BENCHMARK_ALGORITHMS_BUF[] = 8200, 11300, 12700, + 15200, 13400, 125 }; diff --git a/src/interface.c b/src/interface.c index 3a2a29fa6..cb408fd34 100644 --- a/src/interface.c +++ b/src/interface.c @@ -238,6 +238,7 @@ static const char HT_14800[] = "iTunes backup >= 10.0"; static const char HT_14900[] = "Skip32 (PT = $salt, key = $pass)"; static const char HT_15000[] = "FileZilla Server >= 0.9.55"; static const char HT_15100[] = "Juniper/NetBSD sha1crypt"; +static const char HT_15200[] = "Blockchain, My Wallet, V2"; static const char HT_99999[] = "Plaintext"; static const char HT_00011[] = "Joomla < 2.5.18"; @@ -331,6 +332,7 @@ static const char SIGNATURE_MSSQL[] = "0x0100"; static const char SIGNATURE_MSSQL2012[] = "0x0200"; static const char SIGNATURE_MYSQL_AUTH[] = "$mysqlna$"; static const char SIGNATURE_MYWALLET[] = "$blockchain$"; +static const char SIGNATURE_MYWALLETV2[] = "$blockchain$v2$"; static const char SIGNATURE_NETSCALER[] = "1"; static const char SIGNATURE_OFFICE2007[] = "$office$"; static const char SIGNATURE_OFFICE2010[] = "$office$"; @@ -13073,6 +13075,102 @@ int mywallet_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U return (PARSER_OK); } +int mywalletv2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) +{ + if ((input_len < DISPLAY_LEN_MIN_15200) || (input_len > DISPLAY_LEN_MAX_15200)) return (PARSER_GLOBAL_LENGTH); + + if (memcmp (SIGNATURE_MYWALLETV2, input_buf, 15)) return (PARSER_SIGNATURE_UNMATCHED); + + u32 *digest = (u32 *) hash_buf->digest; + + salt_t *salt = hash_buf->salt; + + /** + * parse line + */ + + u8 *iter_pos = input_buf + 1 + 10 + 1 + 2 + 1; + + u8 *data_len_pos = (u8 *) strchr ((const char *) iter_pos, '$'); + + if (data_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); + + u32 iter_pos_len = data_len_pos - iter_pos; + + if (iter_pos_len < 1) return (PARSER_SALT_LENGTH); + if (iter_pos_len > 8) return (PARSER_SALT_LENGTH); + + data_len_pos++; + + u8 *data_buf_pos = (u8 *) strchr ((const char *) data_len_pos, '$'); + + if (data_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); + + u32 data_len_len = data_buf_pos - data_len_pos; + + if (data_len_len < 1) return (PARSER_SALT_LENGTH); + if (data_len_len > 5) return (PARSER_SALT_LENGTH); + + data_buf_pos++; + + u32 data_buf_len = input_len - 1 - 10 - 1 - 2 - 1 - iter_pos_len - 1 - data_len_len - 1; + + if (data_buf_len < 64) return (PARSER_HASH_LENGTH); + + if (data_buf_len % 16) return (PARSER_HASH_LENGTH); + + u32 data_len = atoll ((const char *) data_len_pos); + + if ((data_len * 2) != data_buf_len) return (PARSER_HASH_LENGTH); + + u32 iter = atoll ((const char *) iter_pos); + + /** + * salt + */ + + u8 *salt_pos = data_buf_pos; + + if (is_valid_hex_string (salt_pos, 64) == false) return (PARSER_SALT_ENCODING); + + salt->salt_buf[0] = hex_to_u32 ((const u8 *) &salt_pos[ 0]); + salt->salt_buf[1] = hex_to_u32 ((const u8 *) &salt_pos[ 8]); + salt->salt_buf[2] = hex_to_u32 ((const u8 *) &salt_pos[16]); + salt->salt_buf[3] = hex_to_u32 ((const u8 *) &salt_pos[24]); + + salt->salt_buf[0] = byte_swap_32 (salt->salt_buf[0]); + salt->salt_buf[1] = byte_swap_32 (salt->salt_buf[1]); + salt->salt_buf[2] = byte_swap_32 (salt->salt_buf[2]); + salt->salt_buf[3] = byte_swap_32 (salt->salt_buf[3]); + + // this is actually the CT, which is also the hash later (if matched) + + salt->salt_buf[4] = hex_to_u32 ((const u8 *) &salt_pos[32]); + salt->salt_buf[5] = hex_to_u32 ((const u8 *) &salt_pos[40]); + salt->salt_buf[6] = hex_to_u32 ((const u8 *) &salt_pos[48]); + salt->salt_buf[7] = hex_to_u32 ((const u8 *) &salt_pos[56]); + + salt->salt_buf[4] = byte_swap_32 (salt->salt_buf[4]); + salt->salt_buf[5] = byte_swap_32 (salt->salt_buf[5]); + salt->salt_buf[6] = byte_swap_32 (salt->salt_buf[6]); + salt->salt_buf[7] = byte_swap_32 (salt->salt_buf[7]); + + salt->salt_len = 32; // note we need to fix this to 16 in kernel + + salt->salt_iter = iter - 1; + + /** + * digest buf + */ + + digest[0] = salt->salt_buf[4]; + digest[1] = salt->salt_buf[5]; + digest[2] = salt->salt_buf[6]; + digest[3] = salt->salt_buf[7]; + + return (PARSER_OK); +} + int ms_drsr_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_12800) || (input_len > DISPLAY_LEN_MAX_12800)) return (PARSER_GLOBAL_LENGTH); @@ -15080,6 +15178,7 @@ char *strhashtype (const u32 hash_mode) case 14900: return ((char *) HT_14900); case 15000: return ((char *) HT_15000); case 15100: return ((char *) HT_15100); + case 15200: return ((char *) HT_15200); case 99999: return ((char *) HT_99999); } @@ -18177,6 +18276,13 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le (char *) salt.salt_buf, ptr_plain); } + else if (hash_mode == 15200) + { + hashinfo_t **hashinfo_ptr = hash_info; + char *hash_buf = hashinfo_ptr[digest_cur]->orighash; + + snprintf (out_buf, out_len - 1, "%s", hash_buf); + } else if (hash_mode == 99999) { char *ptr = (char *) digest_buf; @@ -22420,6 +22526,21 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) hashconfig->dgst_pos3 = 3; break; + case 15200: hashconfig->hash_type = HASH_TYPE_AES; + hashconfig->salt_type = SALT_TYPE_EMBEDDED; + hashconfig->attack_exec = ATTACK_EXEC_OUTSIDE_KERNEL; + hashconfig->opts_type = OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_HASH_COPY; + hashconfig->kern_type = KERN_TYPE_MYWALLET; + hashconfig->dgst_size = DGST_SIZE_4_5; // because kernel uses _SHA1_ + hashconfig->parse_func = mywalletv2_parse_hash; + hashconfig->opti_type = OPTI_TYPE_ZERO_BYTE; + hashconfig->dgst_pos0 = 0; + hashconfig->dgst_pos1 = 1; + hashconfig->dgst_pos2 = 2; + hashconfig->dgst_pos3 = 3; + break; + case 99999: hashconfig->hash_type = HASH_TYPE_PLAINTEXT; hashconfig->salt_type = SALT_TYPE_NONE; hashconfig->attack_exec = ATTACK_EXEC_INSIDE_KERNEL; @@ -22657,6 +22778,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) case 14700: hashconfig->tmp_size = sizeof (pbkdf2_sha1_tmp_t); break; case 14800: hashconfig->tmp_size = sizeof (pbkdf2_sha256_tmp_t); break; case 15100: hashconfig->tmp_size = sizeof (pbkdf1_sha1_tmp_t); break; + case 15200: hashconfig->tmp_size = sizeof (mywallet_tmp_t); break; }; // hook_size @@ -23253,6 +23375,8 @@ void hashconfig_benchmark_defaults (hashcat_ctx_t *hashcat_ctx, salt_t *salt, vo break; case 15100: salt->salt_iter = ROUNDS_NETBSD_SHA1CRYPT - 1; break; + case 15200: salt->salt_iter = ROUNDS_MYWALLETV2; + break; } } diff --git a/src/usage.c b/src/usage.c index b699f5bbe..7e34e7fa6 100644 --- a/src/usage.c +++ b/src/usage.c @@ -345,6 +345,7 @@ static const char *USAGE_BIG[] = " 8200 | 1Password, cloudkeychain | Password Managers", " 11300 | Bitcoin/Litecoin wallet.dat | Password Managers", " 12700 | Blockchain, My Wallet | Password Managers", + " 15200 | Blockchain, My Wallet, V2 | Password Managers", " 13400 | KeePass 1 (AES/Twofish) and KeePass 2 (AES) | Password Managers", " 99999 | Plaintext | Plaintext", "", diff --git a/tools/test.pl b/tools/test.pl index 6db4ebc76..fb5d7b2c5 100755 --- a/tools/test.pl +++ b/tools/test.pl @@ -46,7 +46,7 @@ my $hashcat = "./hashcat"; my $MAX_LEN = 55; -my @modes = (0, 10, 11, 12, 20, 21, 22, 23, 30, 40, 50, 60, 100, 101, 110, 111, 112, 120, 121, 122, 125, 130, 131, 132, 133, 140, 141, 150, 160, 200, 300, 400, 500, 900, 1000, 1100, 1300, 1400, 1410, 1411, 1420, 1430, 1440, 1441, 1450, 1460, 1500, 1600, 1700, 1710, 1711, 1720, 1730, 1740, 1722, 1731, 1750, 1760, 1800, 2100, 2400, 2410, 2500, 2600, 2611, 2612, 2711, 2811, 3000, 3100, 3200, 3710, 3711, 3300, 3500, 3610, 3720, 3800, 3910, 4010, 4110, 4210, 4300, 4400, 4500, 4520, 4521, 4522, 4600, 4700, 4800, 4900, 5000, 5100, 5300, 5400, 5500, 5600, 5700, 5800, 6000, 6100, 6300, 6400, 6500, 6600, 6700, 6800, 6900, 7000, 7100, 7200, 7300, 7400, 7500, 7700, 7800, 7900, 8000, 8100, 8200, 8300, 8400, 8500, 8600, 8700, 8900, 9100, 9200, 9300, 9400, 9500, 9600, 9700, 9800, 9900, 10000, 10100, 10200, 10300, 10400, 10500, 10600, 10700, 10800, 10900, 11000, 11100, 11200, 11300, 11400, 11500, 11600, 11900, 12000, 12001, 12100, 12200, 12300, 12400, 12600, 12700, 12800, 12900, 13000, 13100, 13200, 13300, 13400, 13500, 13600, 13800, 13900, 14000, 14100, 14400, 14700, 14800, 14900, 15000, 15100, 99999); +my @modes = (0, 10, 11, 12, 20, 21, 22, 23, 30, 40, 50, 60, 100, 101, 110, 111, 112, 120, 121, 122, 125, 130, 131, 132, 133, 140, 141, 150, 160, 200, 300, 400, 500, 900, 1000, 1100, 1300, 1400, 1410, 1411, 1420, 1430, 1440, 1441, 1450, 1460, 1500, 1600, 1700, 1710, 1711, 1720, 1730, 1740, 1722, 1731, 1750, 1760, 1800, 2100, 2400, 2410, 2500, 2600, 2611, 2612, 2711, 2811, 3000, 3100, 3200, 3710, 3711, 3300, 3500, 3610, 3720, 3800, 3910, 4010, 4110, 4210, 4300, 4400, 4500, 4520, 4521, 4522, 4600, 4700, 4800, 4900, 5000, 5100, 5300, 5400, 5500, 5600, 5700, 5800, 6000, 6100, 6300, 6400, 6500, 6600, 6700, 6800, 6900, 7000, 7100, 7200, 7300, 7400, 7500, 7700, 7800, 7900, 8000, 8100, 8200, 8300, 8400, 8500, 8600, 8700, 8900, 9100, 9200, 9300, 9400, 9500, 9600, 9700, 9800, 9900, 10000, 10100, 10200, 10300, 10400, 10500, 10600, 10700, 10800, 10900, 11000, 11100, 11200, 11300, 11400, 11500, 11600, 11900, 12000, 12001, 12100, 12200, 12300, 12400, 12600, 12700, 12800, 12900, 13000, 13100, 13200, 13300, 13400, 13500, 13600, 13800, 13900, 14000, 14100, 14400, 14700, 14800, 14900, 15000, 15100, 15200, 99999); my %is_unicode = map { $_ => 1 } qw(30 40 130 131 132 133 140 141 1000 1100 1430 1440 1441 1730 1740 1731 5500 5600 8000 9400 9500 9600 9700 9800 11600 13500 13800); my %less_fifteen = map { $_ => 1 } qw(500 1600 1800 2400 2410 3200 6300 7400 10500 10700); @@ -2597,6 +2597,29 @@ sub verify next unless (exists ($db->{$hash_in}) and (! defined ($db->{$hash_in}))); } + elsif ($mode == 15200) + { + my $index1 = index ($line, ':'); + + next if ($index1 < 0); + + $hash_in = substr ($line, 0, $index1); + $word = substr ($line, $index1 + 1); + + my (undef, $signature, $version, $iter_count, $data_len, $data_buf) = split '\$', $hash_in; + + next unless ($signature eq "blockchain"); + + next unless ($version eq "v2"); + + next unless (($data_len * 2) == length $data_buf); + + $iter = $iter_count; + $salt = substr ($data_buf, 0, 32); + $param = substr ($data_buf, 32); + + next unless (exists ($db->{$hash_in}) and (! defined ($db->{$hash_in}))); + } else { print "ERROR: hash mode is not supported\n"; @@ -2938,6 +2961,40 @@ sub verify return unless (substr ($line, 0, $len) eq $hash_out); } + elsif ($mode == 15200) + { + # this is very special, we can't call gen_hash () because the param part is not always the same + # we only know that it should contain the letters "guid" at the beginning of the decryted string + + my $pbkdf2 = Crypt::PBKDF2->new ( + hash_class => 'HMACSHA1', + iterations => 5000, + output_len => 32 + ); + + my $salt_bin = pack ("H*", $salt); + + my $key = $pbkdf2->PBKDF2 ($salt_bin, $word); + + my $cipher = Crypt::CBC->new ({ + key => $key, + cipher => "Crypt::Rijndael", + iv => $salt_bin, + literal_key => 1, + header => "none", + keysize => 32 + }); + + my $param_bin = pack ("H*", $param); + + my $decrypted = $cipher->decrypt ($param_bin); + + my $decrypted_part = substr ($decrypted, 1, 16); + + return unless ($decrypted_part =~ /"guid"/); + + $hash_out = $hash_in; + } else { $hash_out = gen_hash ($mode, $word, $salt, $iter); @@ -3448,6 +3505,10 @@ sub passthrough { $tmp_hash = gen_hash ($mode, $word_buf, substr ($salt_buf, 0, 8)); } + elsif ($mode == 15200) + { + $tmp_hash = gen_hash ($mode, $word_buf, substr ($salt_buf, 0, 32)); + } else { print "ERROR: Unsupported hash type\n"; @@ -4374,6 +4435,20 @@ sub single } } } + elsif ($mode == 15200) + { + for (my $i = 1; $i < 32; $i++) + { + if ($len != 0) + { + rnd ($mode, $len, 32); + } + else + { + rnd ($mode, $i, 32); + } + } + } } } @@ -8033,6 +8108,45 @@ END_CODE $tmp_hash = sprintf ("\$sha1\$%d\$%s\$%s", $iterations, $salt_buf, $hash_buf); } + elsif ($mode == 15200) + { + my $iterations = 5000; + + if (defined ($iter)) + { + $iterations = $iter; + } + + my $data = qq|{ + "guid" : "00000000-0000-0000-0000-000000000000", + "sharedKey" : "00000000-0000-0000-0000-000000000000", + "options" : {"pbkdf2_iterations":$iterations,"fee_policy":0,"html5_notifications":false,"logout_time":600000,"tx_display":0,"always_keep_local_backup":false}|; + + my $salt_buf_bin = pack ("H*", $salt_buf); + + my $hasher = Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA1'); + + my $pbkdf2 = Crypt::PBKDF2->new ( + hasher => $hasher, + iterations => $iterations, + output_len => 32 + ); + + my $key = $pbkdf2->PBKDF2 ($salt_buf_bin, $word_buf); + + my $cipher = Crypt::CBC->new ({ + key => $key, + cipher => "Crypt::Rijndael", + iv => $salt_buf_bin, + literal_key => 1, + header => "none", + keysize => 32 + }); + + my $encrypted = unpack ("H*", $cipher->encrypt ($data)); + + $tmp_hash = sprintf ("\$blockchain\$v2\$%d\$%s\$%s", $iterations, length ($salt_buf . $encrypted) / 2, $salt_buf . $encrypted); + } elsif ($mode == 99999) { $tmp_hash = sprintf ("%s", $word_buf); diff --git a/tools/test.sh b/tools/test.sh index 09d3cf13e..de9004469 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -9,7 +9,7 @@ TDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # missing hash types: 5200,6251,6261,6271,6281 -HASH_TYPES="0 10 11 12 20 21 22 23 30 40 50 60 100 101 110 111 112 120 121 122 125 130 131 132 133 140 141 150 160 200 300 400 500 900 1000 1100 1300 1400 1410 1411 1420 1430 1440 1441 1450 1460 1500 1600 1700 1710 1711 1720 1722 1730 1731 1740 1750 1760 1800 2100 2400 2410 2500 2600 2611 2612 2711 2811 3000 3100 3200 3710 3711 3800 3910 4010 4110 4300 4400 4500 4520 4521 4522 4700 4800 4900 5000 5100 5300 5400 5500 5600 5700 5800 6000 6100 6211 6212 6213 6221 6222 6223 6231 6232 6233 6241 6242 6243 6300 6400 6500 6600 6700 6800 6900 7000 7100 7200 7300 7400 7500 7700 7800 7900 8000 8100 8200 8300 8400 8500 8600 8700 8900 9100 9200 9300 9400 9500 9600 9700 9800 9900 10000 10100 10200 10300 10400 10500 10600 10700 10800 10900 11000 11100 11200 11300 11400 11500 11600 11900 12000 12001 12100 12200 12300 12400 12600 12800 12900 13000 13100 13200 13300 13400 13500 13600 13800 14000 14100 14400 14600 14700 14800 14900 15000 15100 99999" +HASH_TYPES="0 10 11 12 20 21 22 23 30 40 50 60 100 101 110 111 112 120 121 122 125 130 131 132 133 140 141 150 160 200 300 400 500 900 1000 1100 1300 1400 1410 1411 1420 1430 1440 1441 1450 1460 1500 1600 1700 1710 1711 1720 1722 1730 1731 1740 1750 1760 1800 2100 2400 2410 2500 2600 2611 2612 2711 2811 3000 3100 3200 3710 3711 3800 3910 4010 4110 4300 4400 4500 4520 4521 4522 4700 4800 4900 5000 5100 5300 5400 5500 5600 5700 5800 6000 6100 6211 6212 6213 6221 6222 6223 6231 6232 6233 6241 6242 6243 6300 6400 6500 6600 6700 6800 6900 7000 7100 7200 7300 7400 7500 7700 7800 7900 8000 8100 8200 8300 8400 8500 8600 8700 8900 9100 9200 9300 9400 9500 9600 9700 9800 9900 10000 10100 10200 10300 10400 10500 10600 10700 10800 10900 11000 11100 11200 11300 11400 11500 11600 11900 12000 12001 12100 12200 12300 12400 12600 12700 12800 12900 13000 13100 13200 13300 13400 13500 13600 13800 14000 14100 14400 14600 14700 14800 14900 15000 15100 15200 99999" #ATTACK_MODES="0 1 3 6 7" ATTACK_MODES="0 1 3 7" @@ -22,7 +22,7 @@ HASHFILE_ONLY="2500" NEVER_CRACK="11600 14900" -SLOW_ALGOS="400 500 501 1600 1800 2100 2500 3200 5200 5800 6211 6212 6213 6221 6222 6223 6231 6232 6233 6241 6242 6243 6251 6261 6271 6281 6300 6400 6500 6600 6700 6800 7100 7200 7400 7900 8200 8800 8900 9000 9100 9200 9300 9400 9500 9600 10000 10300 10500 10700 10900 11300 11600 11900 12000 12001 12100 12200 12300 12400 12500 12800 12900 13000 13200 13400 13600 14600 14700 14800 15100" +SLOW_ALGOS="400 500 501 1600 1800 2100 2500 3200 5200 5800 6211 6212 6213 6221 6222 6223 6231 6232 6233 6241 6242 6243 6251 6261 6271 6281 6300 6400 6500 6600 6700 6800 7100 7200 7400 7900 8200 8800 8900 9000 9100 9200 9300 9400 9500 9600 10000 10300 10500 10700 10900 11300 11600 11900 12000 12001 12100 12200 12300 12400 12500 12700 12800 12900 13000 13200 13400 13600 14600 14700 14800 15100 15200" OPTS="--quiet --force --potfile-disable --runtime 400 --gpu-temp-disable --weak-hash-threshold=0" From a93a143d1e2820e2fae5da11e4a9b3292d09e690 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Mon, 17 Apr 2017 17:46:27 +0200 Subject: [PATCH 7/9] Use scalar swap32() version for scalar variable --- OpenCL/m02500.cl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenCL/m02500.cl b/OpenCL/m02500.cl index 6dfd5f506..d4f27c901 100644 --- a/OpenCL/m02500.cl +++ b/OpenCL/m02500.cl @@ -891,11 +891,11 @@ __kernel void m02500_comp (__global pw_t *pws, __global const kernel_rule_t *rul { u32 t = to; - t = swap32 (t); + t = swap32_S (t); t += nonce_error_correction; - t = swap32 (t); + t = swap32_S (t); if (wpa->nonce_compare < 0) { From 79609e8a54bcd8b4d6cbe9dbb10e438a807ea371 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Wed, 19 Apr 2017 10:51:28 +0200 Subject: [PATCH 8/9] Building: On binary release package, link libiconv static for windows binaries --- docs/changes.txt | 1 + src/Makefile | 24 ++++++++++-------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 5092d1917..92cc45b1e 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -23,6 +23,7 @@ ## Technical ## +- Building: On binary release package, link libiconv static for windows binaries - Dictstat: Structure for dictstat file changed as it has to include --encoding-from and --encoding-to parameter now - OpenCL Runtime: Updated AMDGPU-Pro driver version check, do warn if version 17.10 is detected which is known to be broken - WPA cracking: Reduced --nonce-error-corrections default from 16 to 8 to compensate speed drop caused due to Big-Endian fixes diff --git a/src/Makefile b/src/Makefile index 864f53658..d0325ab53 100644 --- a/src/Makefile +++ b/src/Makefile @@ -110,8 +110,8 @@ CC_WIN_64 := x86_64-w64-mingw32-gcc ## To compile mingw iconv: ## -## ./configure --host=i686-w64-mingw32 --prefix=/opt/iconv-w32 && make install -## ./configure --host=x86_64-w64-mingw32 --prefix=/opt/iconv-w64 && make install +## ./configure --host=i686-w64-mingw32 --prefix=/opt/iconv-w32 --enable-static --disable-shared && make install +## ./configure --host=x86_64-w64-mingw32 --prefix=/opt/iconv-w64 --enable-static --disable-shared && make install ## ICONV_WIN_32 := /opt/iconv-w32 @@ -194,7 +194,7 @@ CFLAGS_NATIVE += -I$(OPENCL_HEADERS_KHRONOS)/ CFLAGS_NATIVE += -DWITH_HWMON LFLAGS_NATIVE := $(LFLAGS) LFLAGS_NATIVE += -lpthread -LFLAGS_NATIVE += -ldl +LFLAGS_NATIVE += -ldl endif # Linux ifeq ($(UNAME),FreeBSD) @@ -202,7 +202,7 @@ ifndef PORTNAME CFLAGS_NATIVE := $(CFLAGS) CFLAGS_NATIVE += -I$(OPENCL_HEADERS_KHRONOS)/ LFLAGS_NATIVE := $(LFLAGS) -LFLAGS_NATIVE += -lpthread +LFLAGS_NATIVE += -lpthread endif endif # FreeBSD @@ -259,21 +259,17 @@ CFLAGS_CROSS_WIN64 += -m64 CFLAGS_CROSS_WIN64 += -DWITH_HWMON LFLAGS_CROSS_LINUX32 := $(LFLAGS) -LFLAGS_CROSS_LINUX32 += -lpthread -LFLAGS_CROSS_LINUX32 += -ldl +LFLAGS_CROSS_LINUX32 += -lpthread +LFLAGS_CROSS_LINUX32 += -ldl LFLAGS_CROSS_LINUX64 := $(LFLAGS) -LFLAGS_CROSS_LINUX64 += -lpthread -LFLAGS_CROSS_LINUX64 += -ldl +LFLAGS_CROSS_LINUX64 += -lpthread +LFLAGS_CROSS_LINUX64 += -ldl LFLAGS_CROSS_WIN32 := $(LFLAGS) LFLAGS_CROSS_WIN32 += -Wl,--dynamicbase -Wl,--nxcompat -LFLAGS_CROSS_WIN32 += -L$(ICONV_WIN_32)/lib/ LFLAGS_CROSS_WIN32 += -lpsapi -LFLAGS_CROSS_WIN32 += -liconv LFLAGS_CROSS_WIN64 := $(LFLAGS) LFLAGS_CROSS_WIN64 += -Wl,--dynamicbase -Wl,--nxcompat -LFLAGS_CROSS_WIN64 += -L$(ICONV_WIN_64)/lib/ LFLAGS_CROSS_WIN64 += -lpsapi -LFLAGS_CROSS_WIN64 += -liconv ## ## Objects @@ -424,10 +420,10 @@ hashcat32.bin: src/main.c $(LINUX_32_OBJS) hashcat64.bin: src/main.c $(LINUX_64_OBJS) $(CC_LINUX_64) $(CFLAGS_CROSS_LINUX64) -o $@ $^ $(LFLAGS_CROSS_LINUX64) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" -hashcat32.exe: src/main.c $(WIN_32_OBJS) +hashcat32.exe: src/main.c $(WIN_32_OBJS) $(ICONV_WIN_32)/lib/libiconv.a $(CC_WIN_32) $(CFLAGS_CROSS_WIN32) -o $@ $^ $(LFLAGS_CROSS_WIN32) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -hashcat64.exe: src/main.c $(WIN_64_OBJS) +hashcat64.exe: src/main.c $(WIN_64_OBJS) $(ICONV_WIN_64)/lib/libiconv.a $(CC_WIN_64) $(CFLAGS_CROSS_WIN64) -o $@ $^ $(LFLAGS_CROSS_WIN64) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" hashcat32.dll: src/main.c $(WIN_32_OBJS) From 086a07264a25c9b778de05786ea480e9b8bd5375 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Wed, 19 Apr 2017 12:58:25 +0200 Subject: [PATCH 9/9] Switch from libiconv to win-iconv --- include/types.h | 5 +++++ src/Makefile | 17 ++++++++--------- tools/win-iconv-32.diff | 32 ++++++++++++++++++++++++++++++++ tools/win-iconv-64.diff | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 tools/win-iconv-32.diff create mode 100644 tools/win-iconv-64.diff diff --git a/include/types.h b/include/types.h index 6d8225e10..437e3bad0 100644 --- a/include/types.h +++ b/include/types.h @@ -16,6 +16,11 @@ #include #include #include + +#if defined (_WIN) +#define WINICONV_CONST +#endif + #include #if defined (_WIN) diff --git a/src/Makefile b/src/Makefile index d0325ab53..2b64c798e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -108,14 +108,13 @@ CC_LINUX_64 := gcc CC_WIN_32 := i686-w64-mingw32-gcc CC_WIN_64 := x86_64-w64-mingw32-gcc -## To compile mingw iconv: +## To compile win-iconv with mingw clone from here: https://github.com/win-iconv/win-iconv ## -## ./configure --host=i686-w64-mingw32 --prefix=/opt/iconv-w32 --enable-static --disable-shared && make install -## ./configure --host=x86_64-w64-mingw32 --prefix=/opt/iconv-w64 --enable-static --disable-shared && make install +## Then patch the makefile withe the patches from tools/win-iconv-*.diff and run make install ## -ICONV_WIN_32 := /opt/iconv-w32 -ICONV_WIN_64 := /opt/iconv-w64 +WIN_ICONV_32 := /opt/win-iconv-32 +WIN_ICONV_64 := /opt/win-iconv-64 ## ## Misc stuff @@ -249,12 +248,12 @@ CFLAGS_CROSS_LINUX64 += -m64 CFLAGS_CROSS_LINUX64 += -DWITH_HWMON CFLAGS_CROSS_WIN32 := $(CFLAGS) CFLAGS_CROSS_WIN32 += -I$(OPENCL_HEADERS_KHRONOS)/ -CFLAGS_CROSS_WIN32 += -I$(ICONV_WIN_32)/include/ +CFLAGS_CROSS_WIN32 += -I$(WIN_ICONV_32)/include/ CFLAGS_CROSS_WIN32 += -m32 CFLAGS_CROSS_WIN32 += -DWITH_HWMON CFLAGS_CROSS_WIN64 := $(CFLAGS) CFLAGS_CROSS_WIN64 += -I$(OPENCL_HEADERS_KHRONOS)/ -CFLAGS_CROSS_WIN64 += -I$(ICONV_WIN_64)/include/ +CFLAGS_CROSS_WIN64 += -I$(WIN_ICONV_64)/include/ CFLAGS_CROSS_WIN64 += -m64 CFLAGS_CROSS_WIN64 += -DWITH_HWMON @@ -420,10 +419,10 @@ hashcat32.bin: src/main.c $(LINUX_32_OBJS) hashcat64.bin: src/main.c $(LINUX_64_OBJS) $(CC_LINUX_64) $(CFLAGS_CROSS_LINUX64) -o $@ $^ $(LFLAGS_CROSS_LINUX64) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" -hashcat32.exe: src/main.c $(WIN_32_OBJS) $(ICONV_WIN_32)/lib/libiconv.a +hashcat32.exe: src/main.c $(WIN_32_OBJS) $(WIN_ICONV_32)/lib/libiconv.a $(CC_WIN_32) $(CFLAGS_CROSS_WIN32) -o $@ $^ $(LFLAGS_CROSS_WIN32) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -hashcat64.exe: src/main.c $(WIN_64_OBJS) $(ICONV_WIN_64)/lib/libiconv.a +hashcat64.exe: src/main.c $(WIN_64_OBJS) $(WIN_ICONV_64)/lib/libiconv.a $(CC_WIN_64) $(CFLAGS_CROSS_WIN64) -o $@ $^ $(LFLAGS_CROSS_WIN64) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" hashcat32.dll: src/main.c $(WIN_32_OBJS) diff --git a/tools/win-iconv-32.diff b/tools/win-iconv-32.diff new file mode 100644 index 000000000..7dc17e3a6 --- /dev/null +++ b/tools/win-iconv-32.diff @@ -0,0 +1,32 @@ +diff --git a/Makefile b/Makefile +index 5937584..8777fad 100644 +--- a/Makefile ++++ b/Makefile +@@ -6,10 +6,10 @@ + # MKDIR_P, INSTALL, RM + # prefix, BINARY_PATH, INCLUDE_PATH, LIBRARY_PATH + +-CC ?= gcc +-AR ?= ar +-RANLIB ?= ranlib +-DLLTOOL ?= dlltool ++CC := i686-w64-mingw32-gcc ++AR := i686-w64-mingw32-ar ++RANLIB := i686-w64-mingw32-ranlib ++DLLTOOL := i686-w64-mingw32-dlltool + + MKDIR_P = mkdir -p + INSTALL = install -c +@@ -19,10 +19,10 @@ RM = rm -f + DEFAULT_LIBICONV_DLL ?= \"\" + + CFLAGS += -pedantic -Wall +-CFLAGS += -DUSE_LIBICONV_DLL ++#CFLAGS += -DUSE_LIBICONV_DLL + CFLAGS += -DDEFAULT_LIBICONV_DLL=$(DEFAULT_LIBICONV_DLL) + +-prefix ?= /usr/local ++prefix ?= /opt/win-iconv-32 + BINARY_PATH = $(prefix)/bin + INCLUDE_PATH = $(prefix)/include + LIBRARY_PATH = $(prefix)/lib diff --git a/tools/win-iconv-64.diff b/tools/win-iconv-64.diff new file mode 100644 index 000000000..2c658d8c1 --- /dev/null +++ b/tools/win-iconv-64.diff @@ -0,0 +1,32 @@ +diff --git a/Makefile b/Makefile +index 5937584..c4742a3 100644 +--- a/Makefile ++++ b/Makefile +@@ -6,10 +6,10 @@ + # MKDIR_P, INSTALL, RM + # prefix, BINARY_PATH, INCLUDE_PATH, LIBRARY_PATH + +-CC ?= gcc +-AR ?= ar +-RANLIB ?= ranlib +-DLLTOOL ?= dlltool ++CC := x86_64-w64-mingw32-gcc ++AR := x86_64-w64-mingw32-ar ++RANLIB := x86_64-w64-mingw32-ranlib ++DLLTOOL := x86_64-w64-mingw32-dlltool + + MKDIR_P = mkdir -p + INSTALL = install -c +@@ -19,10 +19,10 @@ RM = rm -f + DEFAULT_LIBICONV_DLL ?= \"\" + + CFLAGS += -pedantic -Wall +-CFLAGS += -DUSE_LIBICONV_DLL ++#CFLAGS += -DUSE_LIBICONV_DLL + CFLAGS += -DDEFAULT_LIBICONV_DLL=$(DEFAULT_LIBICONV_DLL) + +-prefix ?= /usr/local ++prefix ?= /opt/win-iconv-64 + BINARY_PATH = $(prefix)/bin + INCLUDE_PATH = $(prefix)/include + LIBRARY_PATH = $(prefix)/lib