1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-07-08 07:38:17 +00:00
Commit Graph

9793 Commits

Author SHA1 Message Date
Gabriele Gristina
baea7933a8
fix memory leaks (2) 2025-06-22 22:04:38 +02:00
Gabriele Gristina
0720d20cf3
fix memory leaks 2025-06-22 21:47:28 +02:00
Jens Steube
957f3b8ac9
Merge pull request #4262 from matrix/is_autotune_metal
fix is_autotune checks on Apple Metal
2025-06-22 21:14:02 +02:00
Gabriele Gristina
df30dfd5c4
fix is_autotune checks on Apple Metal 2025-06-22 21:06:31 +02:00
Jens Steube
13f48e563d
Merge pull request #4109 from matrix/makefile-clangIdentification
Fixed clang identification in src/Makefile
2025-06-22 20:29:50 +02:00
Jens Steube
ed10e6a913 Autotune and Benchmark refactoring
This change affects three key areas, each improving autotuning:

- Autotune refactoring itself

The main autotune algorithm had become too complex to maintain and has
now been rewritten from scratch. The engine is now closer to the old
v6.0.0 version, using a much more straightforward approach.

Additionally, the backend is now informed when the autotune engine runs
its operations and runs an extra invisible kernel invocation. This
significantly improves runtime accuracy because the same caching
mechanisms which kick in normal cracking sessions now also apply during
autotuning. This leads to more consistent and reliable automatic
workload tuning.

- Benchmarking and '--speed-only' accuracy bugs fixed

Benchmark runtimes had become too short, especially since the default
benchmark mask changed from '?b?b?b?b?b?b?b' to '?a?a?a?a?a?a?a?a'. For
very fast hashes like NTLM, benchmarks often stopped immediately when
base words needed to be regenerated, producing highly inaccurate
results.

This issue also misled users tuning '-n' values, as manually
oversubscribing kernels could mask the problem, creating the impression
that increasing '-n' had a larger impact on performance than it truly
does. While '-n' still has an effect, it’s not as significant. With this
fix, users achieve the same speed without needing to tune '-n' manually.

The bug was fixed by enforcing a minimum benchmark runtime of 4 seconds,
regardless of kernel runtime or kernel type. This ensures more stable
and realistic benchmark results, but typically increasing the benchmark
duration by up to 4 seconds.

- Kernel-Threads set to 32 and plugin configuration cleanup

Some plugin configurations existed solely to work around the old
benchmarking bug and can now be removed. For example,
'OPTS_TYPE_MAXIMUM_THREADS' is no longer required and has been removed
from all plugins, although the parameter itself remains to avoid
breaking custom plugins.

Because increasing threads beyond 32 no longer offers meaningful
performance gains, the default is now capped at 32 (unless overridden
with '-T'). This simplifies GPU memory management. Currently, work-item
counts are indirectly limited by buffer sizes (e.g., 'pws_buf[]'), which
must not exceed 4 GiB (a hard-coded limit). This buffer size depends on
the product of 'kernel-accel', 'kernel-threads', and the device’s
compute units. By reducing the default threads from 1024 to 32, there is
now more space available for base words.
2025-06-22 20:17:52 +02:00
Jens Steube
15ada5124e Further simplified the use of inc_hash_scrypt.cl without any speed regression, and updated all affected plugin kernels. Use m08900-pure.cl as a template.
Updated kernel declarations from "KERNEL_FQ void HC_ATTR_SEQ" to "KERNEL_FQ KERNEL_FA void". Please update your custom plugin kernels accordingly.
Added spilling size as a factor in calculating usable memory per device. This is based on undocumented variables and may not be 100% accurate, but it works well in practice.
Added a compiler hint to scrypt-based kernels indicating the guaranteed maximum thread count per kernel invocation.
Removed redundant kernel code 29800, as it is identical to 27700, and updated the plugin.
2025-06-21 17:41:26 +02:00
Jens Steube
b7c8fcf27c Removed shared-memory based optimization for SCRYPT on HIP, because the shared-memory buffer is incompatible with TMTO, which is limiting SCRYPT-R to a maximum of 8. This change also simplifies the code, allowing removal of large sections of duplicated code. Removed the section in scrypt_module_extra_tuningdb_block() that increased TMTO when there was insufficient shared memory, as this is no longer applicable.
Refactored inc_hash_scrypt.cl almost completely and improved macro names in inc_hash_scrypt.h. Adapted all existing SCRYPT-based plugins to the new standard. If you have custom SCRYPT based plugins use hash-mode 8900 as reference.
Fixed some compiler warnings in inc_platform.cl.
Cleaned up code paths in inc_vendor.h for finding values for HC_ATTR_SEQ and DECLSPEC.
Removed option --device-as-default-execution-space from nvrtc for hiprtc compatibility. As a result, added __device__ back to DECLSPEC.
Removed option --restrict from nvrtc compile options since we actually alias some buffers.
Added --gpu-max-threads-per-block to hiprtc options.
Added -D MAX_THREADS_PER_BLOCK to OpenCL options (currently unused).
Removed all OPTS_TYPE_MP_MULTI_DISABLE entries for SNMPv3-based plugins.
These plugins consume large amounts of memory and for this reason,limited kernel_accel max to 256. This may still be high, but hashcat will automatically tune down kernel_accel if insufficient memory is detected.
Removed command `rocm-smi --resetprofile --resetclocks --resetfans` from benchmark_deep.pl, since some AMD GPUs become artificially slow for a while after running these commands.
Replaced load_source() with file_to_buffer() from shared.c, which does the exact same operations.
Moved suppress_stderr() and restore_stderr() to shared.c and reused them in both Python bridges and opencl_test_instruction(), where the same type of code existed.
2025-06-21 07:09:20 +02:00
Jens Steube
f399c97db0
Merge pull request #4252 from visitorckw/fix-sort-pot-orig-line
Fix incorrect comparison result in sort_pot_orig_line()
2025-06-20 14:56:06 +02:00
Jens Steube
22e2384314
Merge pull request #4253 from visitorckw/fix-sort-by-src-len
Fix incorrect comparison result in sort_by_src_len()
2025-06-20 14:55:54 +02:00
Jens Steube
1f3247be77
Merge pull request #4256 from DhruvTheDev1/patch-1
Fix Typo: change 'generatic' to 'generic' in both hashcat-assimilation-bridge-development.md and usage.c
2025-06-20 14:54:26 +02:00
Dhruv
301dbe9bf3
Update usage.c
fix spaces
2025-06-20 13:16:43 +01:00
Jens Steube
1e9f71990d
Merge pull request #4257 from DhruvTheDev1/patch-2
Update hashcat-assimilation-bridge.md
2025-06-19 23:08:50 +02:00
Jens Steube
59ec58e3a2
Merge pull request #4258 from DhruvTheDev1/patch-3
Update hashcat-python-plugin-development-guide.md
2025-06-19 23:08:40 +02:00
Dhruv
ce17d5271c
Update usage.c
Fix typo: change 'generatic' to 'generic' in usage.c
2025-06-19 12:29:57 +01:00
Jens Steube
4ed91e430f Refactor Python bridge to load source files as scripts instead of modules.
Previously, the bridge loaded user source files as Python modules, which required stripping extensions and could lead to confusing name conflicts.
Now, it loads them as regular Python scripts, which is more intuitive and aligns better with user expectations.
2025-06-18 20:16:08 +02:00
Jens Steube
c033873e4b Update hipDeviceAttribute_t for ROCm 6.x
Add hipDeviceProp_t and bindings for hipGetDeviceProperties(), hipGetDeviceProperties is required to retrieve gcnArchName[].
Add gcnArchName[] to select the correct --gpu-architecture value for a specific device when using hiprtc.
Include sm_major and sm_minor for CUDA and gcnArchName for HIP in the kernel filename hash.
Update nvrtc_options[] and hiprtc_options[] to avoid unused variables, eliminating the use of --restrict as a placeholder and preventing nvrtc from aborting.
Add check_file_suffix() and remove_file_suffix() helper functions.
2025-06-18 18:29:47 +02:00
Dhruv
a472c572f6
Update hashcat-python-plugin-development-guide.md
- Changed some mistakes e.g. duplicates "the the" and improved some clarity too.
2025-06-18 15:23:43 +01:00
Dhruv
1a20e78131
Update hashcat-assimilation-bridge.md
- Fixed typos and improved clarity
2025-06-18 15:06:13 +01:00
Dhruv
40a2dbe5ec
Update hashcat-assimilation-bridge-development.md
I believe the generetic is a typo and should be generic in the help/documentation strings for bridge parameters in the bridge_init() function.
2025-06-18 15:01:27 +01:00
Jens Steube
13245b5563 Add HC_ATTR_SEQ macro to CUDA kernels. It is left empty so that users can optionally add __launch_bounds__ or other launch attributes if needed.
Add MAX_THREADS_PER_BLOCK macro to CUDA kernels. It defaults to 1024 or a lower value if limited by the plugin module or specified via the -T command line option.
For CUDA, lower the C++ dialect from C++17 to C++14 to reduce JIT compile time. Also add support for --split-compile and --minimal flags to further improve NVRTC compile performance.
Remove power-hungry NVIDIA settings and fix missing sudo calls in tools/benchmark_deep.pl.
Remove NEW_SIMD_CODE macro from kernels that do not support SIMD (no u32x).
2025-06-18 10:08:56 +02:00
Jens Steube
e9137e8405
Merge pull request #4255 from matrix/scrypt_metal
porting the new scrypt engine to Apple Metal
2025-06-17 22:26:31 +02:00
Gabriele Gristina
564c560dcb
porting the new scrypt engine to Apple Metal 2025-06-17 22:17:59 +02:00
Jens Steube
7fe091f4a3 Always use the low-level API to query used memory on a device and silently ignore if unavailable.
The workaround using EXTRA_SIZE should no longer be needed, so we disable it for now and monitor for any issues with memory allocation.
Fixed a bug where a scrypt-based algorithm on an API would require only a single work item, resulting in size_extra_buffer4 being zero, which fails on OpenCL since it does not allow zero-byte allocations.
Ignore TMTO increase on low scrypt configurations if the R value is higher than 1.
2025-06-17 19:09:53 +02:00
Kuan-Wei Chiu
4af26080b8 Fix incorrect comparison result in sort_by_src_len()
The original sort_by_src_len() function returned 0 even when a > b,
violating the C standard requirements for qsort() comparison functions.
Specifically, it broke antisymmetry and transitivity, which can result
in undefined behavior.

In some versions of glibc, this leads not only to incorrect sorting but
also potential memory corruption[1].

Fix the issue by returning -1 when a > b, restoring compliance with the
standard.

Link: https://www.qualys.com/2024/01/30/qsort.txt [1]
Fixes: 8eb2558a7 ("Add -m 6211 module and moved some code around")
2025-06-17 21:26:13 +08:00
Kuan-Wei Chiu
64dcf4e69d Fix incorrect comparison result in sort_pot_orig_line()
The original sort_pot_orig_line() function returned 0 even when a < b,
violating the C standard requirements for qsort() comparison functions.
Specifically, it broke antisymmetry and transitivity, which can result
in undefined behavior.

In some versions of glibc, this leads not only to incorrect sorting but
also potential memory corruption[1].

Fix the issue by returning -1 when a < b, restoring compliance with the
standard.

Link: https://www.qualys.com/2024/01/30/qsort.txt [1]
Fixes: 6adc217ba ("Keep output of --show and --left in the original ordering of the input hash file")
2025-06-17 21:13:35 +08:00
Jens Steube
4b93a6e93c Add support for detecting unified GPU memory on CUDA and HIP (previously available only for OpenCL and Metal).
Do not adjust kernel-accel or scrypt-tmto for GPUs with unified memory, typically integrated GPUs in CPUs (APUs).
Redesign the "4-buffer" strategy to avoid overallocation from naive division by four, which can significantly increase memory usage for high scrypt configurations (e.g., 256k:8:1).
Update the scrypt B[] access pattern to match the new "4-buffer" design.
Allow user-specified kernel-accel and scrypt-tmto values, individually or both, via command line and tuning database. Any unspecified parameters are adjusted automatically.
Permit user-defined combinations of scrypt-tmto and kernel-accel even if they may exceed available memory.
2025-06-17 13:32:57 +02:00
Jens Steube
1ac14903d0
Merge pull request #4242 from matrix/update_BUILD_MSYS2
update BUILD_MSYS2: add python3 to dependencies
2025-06-16 19:16:18 +02:00
Jens Steube
4289ba2a74
Merge pull request #4243 from matrix/update_BUILD_CYGWIN
update BUILD_CYGWIN: add python3.12 to dependencies
2025-06-16 19:16:03 +02:00
Gabriele Gristina
027a3a0b39
Modules: Updated module_unstable_warning for hash-mode 1500 2025-06-16 08:05:50 +02:00
Gabriele Gristina
619b4a3998
Modules: Updated module_unstable_warning for hash-mode 19200 2025-06-16 07:52:22 +02:00
Jens Steube
e134564a73 Increase default iteration count per kernel invocation from 1024 to 2048
Add support for lower iteration counts per kernel invocation than the default, enabling TMTO for low scrypt configurations, such as N=1024
Use TMTO 2 if it reaches 4 times the device processor count, instead of TMTO 1 always
Improve performance for low scrypt configurations (hash-mode 9300)
Fix unit test for 15700 with correct scrypt configurations
Disable CPU over subscription for SCRYPT based algorithms
2025-06-15 21:14:40 +02:00
Jens Steube
4d2485db0f Re-enable warmup on SCRYPT based algorithms for more accurate results.
Fix TMTO handling
2025-06-15 18:00:08 +02:00
Gabriele Gristina
c61c1f48c4
Modules: Updated module_unstable_warning for hash-mode 1500, 3000, 14000 2025-06-15 16:17:13 +02:00
Jens Steube
07395626fa Introduce hashes_init_stage5() and call module_extra_tmp_size() there. At this stage, the self-test hash is initialized and its values can be used.
Remove hard-coded SCRYPT N, R, and P values in modules, except where they are intentionally hardcoded.
Fix a bug that always caused a TMTO value of 1, even when it was not needed.
Respect device_available_mem and device_maxmem_alloc values even if a reliable low-level free memory API is present, and always select the lowest of all available limits.
Fix benchmark_deep.pl mask to avoid UTF-8 rejects.
Improve error messages when the check verifying that all SCRYPT configuration settings across all hashes are identical is triggered.
Also improve the error message shown when the SCRYPT configuration of the self-test hash does not match that of the target hash.
Fix a bug where a low-tuned SCRYPT hash combined with a TMTO could result in fewer than 1024 iterations, which breaks the hard-coded minimum of 1024 iterations in the SCRYPT kernel.
2025-06-15 14:13:48 +02:00
Jens Steube
681988ab8f
Merge pull request #3921 from roycewilliams/master
summarize invalid rule chains warnings
2025-06-14 22:39:51 +02:00
Jens Steube
cb7848f956 Change the default benchmark mask from ?b?b?b?b?b?b?b to ?a?a?a?a?a?a?a to avoid inconsistencies when converting between UTF-8 and UTF-16 2025-06-14 22:36:14 +02:00
Jens Steube
53186f0a7f Added OpenCL/inc_hash_scrypt.cl and src/modules/scrypt_common.c with the goal to reduce code duplication in scrypt based plugins.
Updated all scrypt based plugins.
Added condition in OpenCL/inc_hash_scrypt.cl to use local memory in case of HIP platform for a 10% speed boost.
2025-06-14 18:07:50 +02:00
Jens Steube
f9d33a5729
Merge pull request #4104 from matrix/tuningdb_memoryLeaks
Fixed memory leaks in tuning_db_init in tuningdb.c
2025-06-13 13:01:58 +02:00
Jens Steube
fc7b1c5e16
Merge pull request #4101 from matrix/pkzip_stack-buffer-overflow
Fixed stack buffer overflow in PKZIP modules (17200, 17210, 17220, 17225, 17230)
2025-06-13 12:59:46 +02:00
Jens Steube
8494116ded Added support for WBB4 (Woltlab Burning Board) Plugin [bcrypt(bcrypt($pass))]
Thanks for the contribution! You know who you are.
2025-06-13 12:38:06 +02:00
Jens Steube
2e640c4e9f Speed improvements for all QNX /etc/shadow
Speed improvements for all OpenSSH private key (by reducing max upported password length from 256 to 128)
2025-06-12 21:18:24 +02:00
Jens Steube
ac6891e754
Merge pull request #4115 from wizardsd/master
Fixed a host buffer overflow bug when copying rules from host to device
2025-06-12 09:20:58 +02:00
Jens Steube
4e0a728f8f Add HC_ATTR_SEQ as a workaround, since HIP no longer
supports compiler option --gpu-max-threads-per-block
2025-06-12 09:17:02 +02:00
Jens Steube
30ac079caf 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.
2025-06-11 11:15:44 +02:00
Jens Steube
4246345950
Merge pull request #4249 from matrix/metal_device_alias
Alias Devices: Prevents hashcat, when started with x86_64 emulation on Apple Silicon, from showing the Apple M1 OpenCL CPU as an alias for the Apple M1 Metal GPU
2025-06-11 11:02:08 +02:00
Jens Steube
30c7c90635
Merge pull request #4250 from matrix/update_chksum_format
Backend: Updated filename chksum format to prevent invalid cache on Apple Silicon when switching arch
2025-06-11 11:00:47 +02:00
Gabriele Gristina
1096d961a1
Backend: Updated filename chksum format to prevent invalid cache on Apple Silicon when switching arch 2025-06-10 23:19:12 +02:00
Gabriele Gristina
ef8223b17a
Alias Devices: Prevents hashcat, when started with x86_64 emulation on Apple Silicon, from showing the Apple M1 OpenCL CPU as an alias for the Apple M1 Metal GPU 2025-06-10 21:49:21 +02:00
Jens Steube
6aeb188b48 - Handle case where system does not offer any reliable method to query actual free memory
- Change package script source folder from $HOME/hashcat to .
- Revisited Apple OpenCL 2GiB Bug (still present)
2025-06-10 12:54:15 +02:00