Fix cross-compiled binaries and modules

pull/1872/head
jsteube 5 years ago
parent 083d6e1fb2
commit 79c8618025

@ -34,6 +34,10 @@ typedef enum kernel_workload
int ascii_digest (const hashconfig_t *hashconfig, const hashes_t *hashes, const module_ctx_t *module_ctx, char *out_buf, const int out_size, const u32 salt_pos, const u32 digest_pos);
int module_filename (const folder_config_t *folder_config, const int hash_mode, char *out_buf, const size_t out_size);
bool module_load (hashcat_ctx_t *hashcat_ctx, module_ctx_t *module_ctx, const u32 hash_mode);
void module_unload (module_ctx_t *module_ctx);
bool initialize_keyboard_layout_mapping (hashcat_ctx_t *hashcat_ctx, const char *filename, keyboard_layout_mapping_t *keyboard_layout_mapping, int *keyboard_layout_mapping_cnt);
int find_keyboard_layout_map (const u32 search, const int search_len, keyboard_layout_mapping_t *s_keyboard_layout_mapping, const int keyboard_layout_mapping_cnt);
int execute_keyboard_layout_mapping (u32 plain_buf[64], const int plain_len, keyboard_layout_mapping_t *s_keyboard_layout_mapping, const int keyboard_layout_mapping_cnt);

@ -332,13 +332,11 @@ LFLAGS_CROSS_LINUX64 += -lm
LFLAGS_CROSS_WIN32 := $(LFLAGS)
LFLAGS_CROSS_WIN32 += -Wl,--dynamicbase
LFLAGS_CROSS_WIN32 += -Wl,--nxcompat
LFLAGS_CROSS_WIN32 += -Wl,--export-all-symbols
LFLAGS_CROSS_WIN32 += -lpsapi
LFLAGS_CROSS_WIN32 += -lws2_32
LFLAGS_CROSS_WIN64 := $(LFLAGS)
LFLAGS_CROSS_WIN64 += -Wl,--dynamicbase
LFLAGS_CROSS_WIN64 += -Wl,--nxcompat
LFLAGS_CROSS_WIN64 += -Wl,--export-all-symbols
LFLAGS_CROSS_WIN64 += -lpsapi
LFLAGS_CROSS_WIN64 += -lws2_32
@ -420,11 +418,15 @@ distclean: clean
binaries: linux32 linux64 win32 win64
linux32: hashcat32.bin
linux64: hashcat64.bin
host_linux32: hashcat32.bin
host_linux64: hashcat64.bin
host_win32: hashcat32.exe
host_win64: hashcat64.exe
win32: hashcat32.exe
win64: hashcat64.exe
linux32: host_linux32 modules_linux32
linux64: host_linux64 modules_linux64
win32: host_win32 modules_win32
win64: host_win64 modules_win64
##
## Targets: Linux install
@ -568,25 +570,40 @@ endif
##
MODULES_SRC := $(wildcard src/modules/*.c)
MODULES_LIB := $(patsubst src/modules/%.c, modules/%.so, $(MODULES_SRC))
MODULES_LIB := $(patsubst src/modules/module_%.c, modules/module_%.so, $(MODULES_SRC))
modules/module_%.so: src/modules/module_%.c
$(CC) $(CFLAGS_NATIVE) $< -o $@ -shared -fPIC -D MODULE_INTERFACE_VERSION_CURRENT=$(MODULE_INTERFACE_VERSION)
$(CC) $(CFLAGS_NATIVE) $< -o $@ $(LFLAGS_NATIVE) -shared -fPIC -D MODULE_INTERFACE_VERSION_CURRENT=$(MODULE_INTERFACE_VERSION)
modules: $(MODULES_LIB)
##
## cross compiled modules
##
MODULES_LIB_LINUX32 := $(patsubst src/modules/module_%.c, modules/module32_%.so, $(MODULES_SRC))
MODULES_LIB_LINUX64 := $(patsubst src/modules/module_%.c, modules/module64_%.so, $(MODULES_SRC))
MODULES_LIB_WIN32 := $(patsubst src/modules/module_%.c, modules/module32_%.dll, $(MODULES_SRC))
MODULES_LIB_WIN64 := $(patsubst src/modules/module_%.c, modules/module64_%.dll, $(MODULES_SRC))
modules_linux32: $(MODULES_LIB_LINUX32)
modules_linux64: $(MODULES_LIB_LINUX64)
modules_win32: $(MODULES_LIB_WIN32)
modules_win64: $(MODULES_LIB_WIN64)
MODULES_LIB_WIN64 := $(patsubst src/modules/%.c, modules/%.dll, $(MODULES_SRC))
modules/module_%.dll: src/modules/module_%.c
$(CC_WIN_64) $(CFLAGS_CROSS_WIN64) $< -o $@ -shared -fPIC -D MODULE_INTERFACE_VERSION_CURRENT=$(MODULE_INTERFACE_VERSION)
MODULE_DEPEND := src/bitops.c src/convert.c src/memory.c src/shared.c src/cpu_aes.c
modules_win64: $(MODULES_LIB_WIN64)
modules/module32_%.so: src/modules/module_%.c
$(CC_LINUX_32) $(CFLAGS_CROSS_LINUX32) $< -o $@ $(LFLAGS_CROSS_LINUX32) -shared -fPIC -D MODULE_INTERFACE_VERSION_CURRENT=$(MODULE_INTERFACE_VERSION)
modules/module64_%.so: src/modules/module_%.c
$(CC_LINUX_64) $(CFLAGS_CROSS_LINUX64) $< -o $@ $(LFLAGS_CROSS_LINUX64) -shared -fPIC -D MODULE_INTERFACE_VERSION_CURRENT=$(MODULE_INTERFACE_VERSION)
modules/module32_%.dll: src/modules/module_%.c
$(CC_WIN_32) $(CFLAGS_CROSS_WIN32) $< -o $@ $(LFLAGS_CROSS_WIN32) -shared -fPIC -D MODULE_INTERFACE_VERSION_CURRENT=$(MODULE_INTERFACE_VERSION) $(MODULE_DEPEND)
modules/module64_%.dll: src/modules/module_%.c
$(CC_WIN_64) $(CFLAGS_CROSS_WIN64) $< -o $@ $(LFLAGS_CROSS_WIN64) -shared -fPIC -D MODULE_INTERFACE_VERSION_CURRENT=$(MODULE_INTERFACE_VERSION) $(MODULE_DEPEND)
##
## cross compiled hashcat
@ -641,13 +658,13 @@ 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) $(WIN_ICONV_32)/lib/libiconv.a
$(CC_WIN_32) $(CFLAGS_CROSS_WIN32) -o $@ $^ $(LFLAGS_CROSS_WIN32) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -Wl,--output-def,host32.def
$(CC_WIN_32) $(CFLAGS_CROSS_WIN32) -o $@ $^ $(LFLAGS_CROSS_WIN32) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\"
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)\" -Wl,--output-def,host64.def
$(CC_WIN_64) $(CFLAGS_CROSS_WIN64) -o $@ $^ $(LFLAGS_CROSS_WIN64) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\"
hashcat32.dll: src/main.c $(WIN_32_OBJS)
hashcat32.dll: 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)\" -shared
hashcat64.dll: src/main.c $(WIN_64_OBJS)
hashcat64.dll: 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)\" -shared

@ -43,6 +43,7 @@ static const int DEFAULT_BENCHMARK_ALGORITHMS_BUF[] =
int benchmark_next (hashcat_ctx_t *hashcat_ctx)
{
const folder_config_t *folder_config = hashcat_ctx->folder_config;
const module_ctx_t *module_ctx = hashcat_ctx->module_ctx;
const user_options_t *user_options = hashcat_ctx->user_options;
static int cur = 0;
@ -63,11 +64,7 @@ int benchmark_next (hashcat_ctx_t *hashcat_ctx)
for (int i = cur; i < MODULE_HASH_MODES_MAXIMUM; i++)
{
#if defined (_WIN)
snprintf (modulefile, HCBUFSIZ_TINY, "%s/modules/module_%05d.dll", folder_config->shared_dir, i);
#else
snprintf (modulefile, HCBUFSIZ_TINY, "%s/modules/module_%05d.so", folder_config->shared_dir, i);
#endif
module_filename (folder_config, i, modulefile, HCBUFSIZ_TINY);
if (hc_path_exist (modulefile) == true)
{

@ -370,7 +370,34 @@ int ascii_digest (const hashconfig_t *hashconfig, const hashes_t *hashes, const
return out_len;
}
static bool module_load (hashcat_ctx_t *hashcat_ctx, module_ctx_t *module_ctx, const u32 hash_mode)
int module_filename (const folder_config_t *folder_config, const int hash_mode, char *out_buf, const size_t out_size)
{
// cross compiled
#if defined (__x86_64__)
#if defined (_WIN)
const int out_len = snprintf (out_buf, out_size, "%s/modules/module64_%05d.dll", folder_config->shared_dir, hash_mode);
#else
const int out_len = snprintf (out_buf, out_size, "%s/modules/module64_%05d.so", folder_config->shared_dir, hash_mode);
#endif
#else
#if defined (_WIN)
const int out_len = snprintf (out_buf, out_size, "%s/modules/module32_%05d.dll", folder_config->shared_dir, hash_mode);
#else
const int out_len = snprintf (out_buf, out_size, "%s/modules/module32_%05d.so", folder_config->shared_dir, hash_mode);
#endif
#endif
if (hc_path_exist (out_buf) == true) return out_len;
// native compiled
#if defined (_WIN)
return snprintf (out_buf, out_size, "%s/modules/module_%05d.dll", folder_config->shared_dir, hash_mode);
#else
return snprintf (out_buf, out_size, "%s/modules/module_%05d.so", folder_config->shared_dir, hash_mode);
#endif
}
bool module_load (hashcat_ctx_t *hashcat_ctx, module_ctx_t *module_ctx, const u32 hash_mode)
{
const folder_config_t *folder_config = hashcat_ctx->folder_config;
@ -378,11 +405,7 @@ static bool module_load (hashcat_ctx_t *hashcat_ctx, module_ctx_t *module_ctx, c
char *module_file = (char *) hcmalloc (HCBUFSIZ_TINY);
#if defined (_WIN)
snprintf (module_file, HCBUFSIZ_TINY, "%s/modules/module_%05d.dll", folder_config->shared_dir, hash_mode);
#else
snprintf (module_file, HCBUFSIZ_TINY, "%s/modules/module_%05d.so", folder_config->shared_dir, hash_mode);
#endif
module_filename (folder_config, hash_mode, module_file, HCBUFSIZ_TINY);
module_ctx->module_handle = hc_dlopen (module_file);
@ -411,7 +434,7 @@ static bool module_load (hashcat_ctx_t *hashcat_ctx, module_ctx_t *module_ctx, c
return true;
}
static void module_unload (module_ctx_t *module_ctx)
void module_unload (module_ctx_t *module_ctx)
{
if (module_ctx->module_handle)
{
@ -477,25 +500,77 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx)
// check for missing pointer assignements
const size_t ptr_sz = sizeof (void *);
char *zbuf = (char *) hcmalloc (ptr_sz);
char *mpa_check = (char *) module_ctx;
for (size_t i = 0; i < sizeof (module_ctx_t) - ptr_sz; i++)
{
if (memcmp (mpa_check, zbuf, ptr_sz) == 0)
{
event_log_error (hashcat_ctx, "module context initialization is invalid, outdated template?");
return -1;
#define CHECK_DEFINED(func) \
if (func == NULL) \
{ \
event_log_error (hashcat_ctx, "module context initialization is invalid, outdated template?"); \
\
return -1; \
}
mpa_check++;
}
hcfree (zbuf);
CHECK_DEFINED (module_ctx->module_attack_exec);
CHECK_DEFINED (module_ctx->module_benchmark_esalt);
CHECK_DEFINED (module_ctx->module_benchmark_hook_salt);
CHECK_DEFINED (module_ctx->module_benchmark_mask);
CHECK_DEFINED (module_ctx->module_benchmark_salt);
CHECK_DEFINED (module_ctx->module_dictstat_disable);
CHECK_DEFINED (module_ctx->module_dgst_pos0);
CHECK_DEFINED (module_ctx->module_dgst_pos1);
CHECK_DEFINED (module_ctx->module_dgst_pos2);
CHECK_DEFINED (module_ctx->module_dgst_pos3);
CHECK_DEFINED (module_ctx->module_dgst_size);
CHECK_DEFINED (module_ctx->module_esalt_size);
CHECK_DEFINED (module_ctx->module_forced_outfile_format);
CHECK_DEFINED (module_ctx->module_hash_category);
CHECK_DEFINED (module_ctx->module_hash_name);
CHECK_DEFINED (module_ctx->module_hash_mode);
CHECK_DEFINED (module_ctx->module_hash_type);
CHECK_DEFINED (module_ctx->module_hlfmt_disable);
CHECK_DEFINED (module_ctx->module_hook_salt_size);
CHECK_DEFINED (module_ctx->module_hook_size);
CHECK_DEFINED (module_ctx->module_kernel_accel_min);
CHECK_DEFINED (module_ctx->module_kernel_accel_max);
CHECK_DEFINED (module_ctx->module_kernel_loops_min);
CHECK_DEFINED (module_ctx->module_kernel_loops_max);
CHECK_DEFINED (module_ctx->module_kernel_threads_min);
CHECK_DEFINED (module_ctx->module_kernel_threads_max);
CHECK_DEFINED (module_ctx->module_kern_type);
CHECK_DEFINED (module_ctx->module_opti_type);
CHECK_DEFINED (module_ctx->module_opts_type);
CHECK_DEFINED (module_ctx->module_outfile_check_disable);
CHECK_DEFINED (module_ctx->module_outfile_check_nocomp);
CHECK_DEFINED (module_ctx->module_potfile_disable);
CHECK_DEFINED (module_ctx->module_potfile_keep_all_hashes);
CHECK_DEFINED (module_ctx->module_pwdump_column);
CHECK_DEFINED (module_ctx->module_pw_min);
CHECK_DEFINED (module_ctx->module_pw_max);
CHECK_DEFINED (module_ctx->module_salt_min);
CHECK_DEFINED (module_ctx->module_salt_max);
CHECK_DEFINED (module_ctx->module_salt_type);
CHECK_DEFINED (module_ctx->module_separator);
CHECK_DEFINED (module_ctx->module_st_hash);
CHECK_DEFINED (module_ctx->module_st_pass);
CHECK_DEFINED (module_ctx->module_tmp_size);
CHECK_DEFINED (module_ctx->module_unstable_warning);
CHECK_DEFINED (module_ctx->module_warmup_disable);
CHECK_DEFINED (module_ctx->module_hash_binary_count);
CHECK_DEFINED (module_ctx->module_hash_binary_parse);
CHECK_DEFINED (module_ctx->module_hash_binary_save);
CHECK_DEFINED (module_ctx->module_hash_binary_verify);
CHECK_DEFINED (module_ctx->module_hash_decode_outfile);
CHECK_DEFINED (module_ctx->module_hash_decode_zero_hash);
CHECK_DEFINED (module_ctx->module_hash_decode);
CHECK_DEFINED (module_ctx->module_hash_encode_status);
CHECK_DEFINED (module_ctx->module_hash_encode);
CHECK_DEFINED (module_ctx->module_extra_buffer_size);
CHECK_DEFINED (module_ctx->module_jit_build_options);
CHECK_DEFINED (module_ctx->module_deep_comp_kernel);
CHECK_DEFINED (module_ctx->module_hash_init_selftest);
CHECK_DEFINED (module_ctx->module_hook12);
CHECK_DEFINED (module_ctx->module_hook23);
CHECK_DEFINED (module_ctx->module_build_plain_postprocess);
#undef CHECK_DEFINED
// mandatory functions check

@ -598,11 +598,7 @@ void example_hashes (hashcat_ctx_t *hashcat_ctx)
{
user_options->hash_mode = i;
#if defined (_WIN)
snprintf (modulefile, HCBUFSIZ_TINY, "%s/modules/module_%05d.dll", folder_config->shared_dir, i);
#else
snprintf (modulefile, HCBUFSIZ_TINY, "%s/modules/module_%05d.so", folder_config->shared_dir, i);
#endif
module_filename (folder_config, i, modulefile, HCBUFSIZ_TINY);
if (hc_path_exist (modulefile) == false) continue;

@ -268,6 +268,7 @@ void usage_big_print (hashcat_ctx_t *hashcat_ctx)
{
folder_config_t *folder_config = hashcat_ctx->folder_config;
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
module_ctx_t *module_ctx = hashcat_ctx->module_ctx;
user_options_t *user_options = hashcat_ctx->user_options;
char *modulefile = (char *) hcmalloc (HCBUFSIZ_TINY);
@ -280,11 +281,7 @@ void usage_big_print (hashcat_ctx_t *hashcat_ctx)
{
user_options->hash_mode = i;
#if defined (_WIN)
snprintf (modulefile, HCBUFSIZ_TINY, "%s/modules/module_%05d.dll", folder_config->shared_dir, i);
#else
snprintf (modulefile, HCBUFSIZ_TINY, "%s/modules/module_%05d.so", folder_config->shared_dir, i);
#endif
module_filename (folder_config, i, modulefile, HCBUFSIZ_TINY);
if (hc_path_exist (modulefile) == false) continue;

Loading…
Cancel
Save