1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-07-30 10:28:41 +00:00

Use total memory as base if low-level free memory API is available.

Prefix device name in tuning-db with device ID to avoid collisions
between identically named devices.

Fix Python bridge Makefile to handle missing python3-config helper.
This commit is contained in:
Jens Steube 2025-06-11 11:15:44 +02:00
parent 4246345950
commit 30ac079caf
3 changed files with 146 additions and 30 deletions

View File

@ -9677,7 +9677,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
continue;
}
device_param->device_available_mem -= used_bytes;
device_param->device_available_mem = device_param->device_global_mem - used_bytes;
break;
}
@ -9730,7 +9730,13 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
if (next[0] == '#') continue;
tuning_db_process_line (hashcat_ctx, next, line_num);
char *search_name = NULL;
hc_asprintf (&search_name, "MODULE_%02d_%s", device_param->device_id, next);
tuning_db_process_line (hashcat_ctx, search_name, line_num);
hcfree (search_name);
} while ((next = strtok_r ((char *) NULL, "\n", &saveptr)) != NULL);
@ -9891,13 +9897,31 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
tuning_db_entry_t *tuningdb_entry = NULL;
if (user_options->slow_candidates == true)
for (int i = 0; i < 2; i++)
{
tuningdb_entry = tuning_db_search (hashcat_ctx, device_param->device_name, device_param->opencl_device_type, 0, hashconfig->hash_mode);
}
else
{
tuningdb_entry = tuning_db_search (hashcat_ctx, device_param->device_name, device_param->opencl_device_type, user_options->attack_mode, hashconfig->hash_mode);
char *search_name = NULL;
if (i == 0)
{
hc_asprintf (&search_name, "MODULE_%02d_%s", device_param->device_id, device_param->device_name);
}
else
{
search_name = device_param->device_name;
}
if (user_options->slow_candidates == true)
{
tuningdb_entry = tuning_db_search (hashcat_ctx, search_name, device_param->opencl_device_type, 0, hashconfig->hash_mode);
}
else
{
tuningdb_entry = tuning_db_search (hashcat_ctx, search_name, device_param->opencl_device_type, user_options->attack_mode, hashconfig->hash_mode);
}
if (i == 0) hcfree (search_name);
if (tuningdb_entry != NULL) break;
}
// user commandline option override tuning db

View File

@ -1,7 +1,39 @@
REPORT_MISSING_SO := false
REPORT_MISSING_DLL := false
PYTHON_CFLAGS := `python3-config --includes`
# See BUILD_WSL.md how to prepare $(WIN_PYTHON)
ifeq ($(BRIDGE_SUFFIX),so)
ifeq ($(REPORT_MISSING_SO),false)
PYTHON_CONFIG := $(shell command -v python3-config 2>/dev/null)
ifeq ($(PYTHON_CONFIG),)
REPORT_MISSING_SO := true
endif
endif
ifeq ($(REPORT_MISSING_SO),false)
PYTHON_CFLAGS := $(shell python3-config --includes 2>/dev/null)
ifeq ($(strip $(PYTHON_CFLAGS)),)
REPORT_MISSING_SO := true
endif
endif
endif
CHECK_DLL := false
ifeq ($(BRIDGE_SUFFIX),dll)
CHECK_DLL := true
endif
ifeq ($(BUILD_MODE),cross)
CHECK_DLL := true
endif
ifeq ($(CHECK_DLL),true)
ifeq ($(REPORT_MISSING_DLL),false)
PYTHON_CONFIG := $(shell ls $(WIN_PYTHON)/mingw64/include/python3.12/ 2>/dev/null)
ifeq ($(PYTHON_CONFIG),)
REPORT_MISSING_DLL := true
endif
endif
PYTHON_CFLAGS_WIN := -I$(WIN_PYTHON)/mingw64/include/python3.12/
endif
ifeq ($(BUILD_MODE),cross)
bridges/bridge_python_generic_hash_mp.so: src/bridges/bridge_python_generic_hash_mp.c src/cpu_features.c obj/combined.LINUX.a
@ -17,3 +49,26 @@ bridges/bridge_python_generic_hash_mp.$(BRIDGE_SUFFIX): src/bridges/bridge_pytho
$(CC) $(CCFLAGS) $(CFLAGS_NATIVE) $^ -o $@ $(LFLAGS_NATIVE) -shared -fPIC -D BRIDGE_INTERFACE_VERSION_CURRENT=$(BRIDGE_INTERFACE_VERSION) $(PYTHON_CFLAGS)
endif
endif
RED = \033[1;31m
RESET = \033[0m
ifeq ($(REPORT_MISSING_DLL),true)
bridges/bridge_python_generic_hash_mp.dll:
@echo ""
@echo "$(RED)WARNING$(RESET): Skipping regular plugin 70300: Python Windows headers not found."
@echo " To use -m 70300, you must install the required Python headers."
@echo " Otherwise, you can safely ignore this warning."
@echo " See BUILD_WSL.md how to prepare $(WIN_PYTHON)."
@echo ""
endif
ifeq ($(REPORT_MISSING_SO),true)
bridges/bridge_python_generic_hash_mp.so:
@echo ""
@echo "$(RED)WARNING$(RESET): Skipping regular plugin 70300: Python headers not found."
@echo " To use -m 70300, you must install the required Python headers."
@echo " Otherwise, you can safely ignore this warning."
@echo " For more information, see 'docs/hashcat-python-plugin-requirements.md'."
@echo ""
endif

View File

@ -1,7 +1,51 @@
REPORT_MISSING_SO := false
REPORT_MISSING_DLL := false
PYTHON_CFLAGS := `python3-config --includes`
# See BUILD_WSL.md how to prepare $(WIN_PYTHON)
ifeq ($(BRIDGE_SUFFIX),so)
ifeq ($(REPORT_MISSING_SO),false)
PYTHON_CONFIG := $(shell command -v python3-config 2>/dev/null)
ifeq ($(PYTHON_CONFIG),)
REPORT_MISSING_SO := true
endif
endif
ifeq ($(REPORT_MISSING_SO),false)
PYTHON_CFLAGS := $(shell python3-config --includes 2>/dev/null)
ifeq ($(strip $(PYTHON_CFLAGS)),)
REPORT_MISSING_SO := true
endif
endif
ifeq ($(REPORT_MISSING_SO),false)
PYTHON_INCLUDE_PATH := $(shell echo "$(PYTHON_CFLAGS)" | sed -n 's/-I\([^ ]*\).*/\1/p')
ifeq ($(PYTHON_INCLUDE_PATH),)
REPORT_MISSING_SO := true
endif
endif
ifeq ($(REPORT_MISSING_SO),false)
PYTHON_HAS_OWN_GIL := $(shell grep -r -q 'PyInterpreterConfig_OWN_GIL' "$(PYTHON_INCLUDE_PATH)" && echo true || echo false)
ifeq ($(PYTHON_HAS_OWN_GIL),false)
REPORT_MISSING_SO := true
endif
endif
endif
CHECK_DLL := false
ifeq ($(BRIDGE_SUFFIX),dll)
CHECK_DLL := true
endif
ifeq ($(BUILD_MODE),cross)
CHECK_DLL := true
endif
ifeq ($(CHECK_DLL),true)
ifeq ($(REPORT_MISSING_DLL),false)
PYTHON_CONFIG := $(shell ls $(WIN_PYTHON)/mingw64/include/python3.12/ 2>/dev/null)
ifeq ($(PYTHON_CONFIG),)
REPORT_MISSING_DLL := true
endif
endif
PYTHON_CFLAGS_WIN := -I$(WIN_PYTHON)/mingw64/include/python3.12/
endif
ifeq ($(BUILD_MODE),cross)
bridges/bridge_python_generic_hash_sp.so: src/bridges/bridge_python_generic_hash_sp.c src/cpu_features.c obj/combined.LINUX.a
@ -18,25 +62,20 @@ bridges/bridge_python_generic_hash_sp.$(BRIDGE_SUFFIX): src/bridges/bridge_pytho
endif
endif
ifeq ($(BRIDGE_SUFFIX),so)
PYTHON_INCLUDE_PATH := $(shell echo "$(PYTHON_CFLAGS)" | sed -n 's/-I\([^ ]*\).*/\1/p')
PYTHON_HAS_OWN_GIL := $(shell grep -r -q 'PyInterpreterConfig_OWN_GIL' "$(PYTHON_INCLUDE_PATH)" && echo true || echo false)
REPORTS_MISSING := false
ifeq ($(PYTHON_INCLUDE_PATH),)
REPORTS_MISSING := true
endif
ifeq ($(PYTHON_HAS_OWN_GIL),false)
REPORTS_MISSING := true
endif
RED = \033[1;31m
RESET = \033[0m
ifeq ($(REPORTS_MISSING),true)
ifeq ($(REPORT_MISSING_DLL),true)
bridges/bridge_python_generic_hash_sp.dll:
@echo ""
@echo "$(RED)WARNING$(RESET): Skipping freethreaded plugin 70200: Python Windows headers not found."
@echo " To use -m 70200, you must install the required Python headers."
@echo " Otherwise, you can safely ignore this warning."
@echo " See BUILD_WSL.md how to prepare $(WIN_PYTHON)."
@echo ""
endif
ifeq ($(REPORT_MISSING_SO),true)
bridges/bridge_python_generic_hash_sp.so:
@echo ""
@echo "$(RED)WARNING$(RESET): Skipping freethreaded plugin 70200: Python 3.12+ headers not found."
@ -45,5 +84,3 @@ bridges/bridge_python_generic_hash_sp.so:
@echo " For more information, see 'docs/hashcat-python-plugin-requirements.md'."
@echo ""
endif
endif