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

396 Commits

Author SHA1 Message Date
Gabriele Gristina
df30dfd5c4
fix is_autotune checks on Apple Metal 2025-06-22 21:06:31 +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
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
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
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
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
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
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
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
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
Jens Steube
c87a87f992 Improvements to SCRYPT autotuning strategy
General:

The logic for calculating the SCRYPT workload has been moved
from module_extra_buffer_size() to module_extra_tuningdb_block().
Previously, this function just returned values from a static
tuning file. Now, it actually computes tuning values on the fly
based on the device's resources and SCRYPT parameters. This
was always possible, it just wasn't used that way until now.

After running the calculation, the calculated kernel_accel value
is injected into the tuning database as if it had come from a
file. The tmto value is stored internally.

Users can still override kernel-threads, kernel-accel, and
scrypt-tmto via the command line or via tuningdb file.

module_extra_tuningdb_block():

This is now where kernel_accel and tmto are automatically
calculated.

The logic for accel and tmto is now separated and more
flexible. Whether the user is using defaults, tuningdb entries, or
manual command line overrides, the code logic will try to make
smart choices based on what's actually available on the device.

First, it tries to find a kernel_accel value that fits into
available memory. It starts with a base value and simulates
tmto=1 or 2 (which is typical good on GPU).

It also leaves room for other buffers (like pws[], tmps[], etc.).
If the result is close to the actual processor count,
it gets clamped.

This value is then added to the tuning database, so hashcat can pick
it up during startup.

Once that's set, it derives tmto using available memory, thread
count, and the actual SCRYPT parameters.

module_extra_buffer_size():

This function now just returns the size of the SCRYPT B[] buffer,
based on the tmto that was already calculated.

kernel_threads:

Defaults are now set to 32 threads in most cases. On AMD GPUs,
64 threads might give a slight performance bump, but 32 is more
consistent and reliable.

For very memory-heavy algorithms (like Ethereum Wallet), it
scales down the thread count.

Here's a rough reference for other SCRYPT-based modes:

- 64 MiB: 16 threads
- 256 MiB: 4 threads

Tuning files:

All built-in tuningdb entries have been removed, because they
shouldn’t be needed anymore. But you can still add custom entries
if needed. There’s even a commented-out example in the tuningdb
file for mode 22700.

Free memory handling:

Getting the actual amount of free GPU memory is critical for
this to work right. Unfortunately, none of the common GPGPU APIs
give reliable numbers. We now query low-level interfaces like
SYSFS (AMD) and NVML (NVIDIA). Support for those APIs is in
place already, except for ADL, which still needs to be added.

Because of this, hwmon support (which handles those low-level
queries) can no longer be disabled.
2025-06-09 11:02:34 +02:00
Jens Steube
ed6e967425 Add experimental SCRYPT N-parameter auto-discovery
Remove existing tuningdb entries due to salsa_r() core
refactor. Update tuningdb engine to prefer file entries,
when available, over automatic discovery.

Improve memory-free detection per device, default
--backend-device-keepfree is now set to 0.

Old brute-force OpenCL behavior can be restored using
--backend-device-keepfree 100.
2025-06-08 07:32:32 +02:00
Gabriele Gristina
12f1fe56aa OpenCL Backend: added workaround to set device_available_memory from CUDA/HIP alias device 2025-06-07 20:22:01 +02:00
Gabriele Gristina
378abf6957 Metal Backend: added workaround to set the true Processor value in Metal devices on Apple Intel 2025-06-07 17:52:34 +02:00
Jens Steube
d60658102b Added option --backend-devices-keepfree to configure X percentage of device memory available to keep free 2025-06-04 10:13:29 +02:00
Jens Steube
bf110ee10f
Merge branch 'master' into asahi-fix 2025-06-03 14:59:04 +02:00
Jens Steube
b02b1b5033 - Add code to recognize Microsofts OpenCL D3D12 platform
- Skip memory-free detection on MS OpenCL platform to avoid crashes
- Improve salt usage of 70100/70200, use decoder/kernels from 8900
- Add REPLACE bridge type support (eg. BRIDGE_TYPE_REPLACE_LOOP)
- Switch 70000, 70100 and 70200 to BRIDGE_TYPE_REPLACE_LOOP
- Add synchronization barriers on d2h copy when using bridges
- Improve speed status display updates when using bridges
- Set AMD_DIRECT_DISPATCH=0 to reduce CPU burning loop on AMD backends
- Set benchmark/selftest hash on 70100/70200 to 16:8:1
2025-06-02 06:59:36 +02:00
Jens Steube
22c25b3ea1 Fix cross-compiler target in makefiles
Do not show timeout patch warnings in virtualized mode
2025-06-01 06:39:55 +02:00
Jens Steube
ceb5ff5641 The Assimilation Bridge (Framework) 2025-05-29 15:38:13 +02:00
Jens Steube
f9822fe569
Merge pull request #4185 from matrix/deep_comp_aux_workaround
workaround for issue #3914
2025-05-25 08:14:23 +02:00
Jens Steube
b0c7765e88 - Backport code from hipDllPath to hiprtcDllPath
- Fix some compiler warning
- Remove some unused code
- We will add changes to docs/ and user-notifications on versioning later
2025-05-11 14:08:04 +02:00
Jens Steube
d10ffbb461 Change amdhip64.dll installation path detection strategy 2025-05-10 12:11:40 +00:00
Gabriele Gristina
6568c5988b fix #3914 2025-04-18 14:17:21 +02:00
Code Curiously
5b26392adb Fix RAM usage bug for Linux Apple Silicon #4125 2024-12-01 19:20:26 +00:00
wizardsd
0ba76629c0 Fixed a host buffer overflow bug when copying rules from host to device 2024-11-07 12:47:36 +03:00
Mathias
d756a6617c
Update backend.c
Fixes hiprtcCompileProgram(): HIPRTC_ERROR_COMPILATION on AMD 6900XT.

```bash
hiprtcCompileProgram(): HIPRTC_ERROR_COMPILATION

ld.lld: error: undefined hidden symbol: __ockl_get_group_id
>>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_decompress)
>>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_decompress)
>>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_memset)
>>> referenced 7 more times

ld.lld: error: undefined hidden symbol: __ockl_get_local_size
>>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_decompress)
>>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_decompress)
>>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_memset)
>>> referenced 7 more times

ld.lld: error: undefined hidden symbol: __ockl_get_local_id
>>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_decompress)
>>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_decompress)
>>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_memset)
>>> referenced 7 more times

* Device #1: Kernel /usr/local/share/hashcat/OpenCL/shared.cl build failed.

* Device #1: Kernel /usr/local/share/hashcat/OpenCL/shared.cl build failed.
```
2024-10-29 15:35:10 +01:00
fse-a
f8c0899670 Increased-virtual-backend-limit
Increased the virtual backend limit.
2024-01-25 10:27:38 +01:00
Sergey Popov
c7923fe8ba Fix RAM usage for Intel iGPUs 2023-11-24 23:03:00 +02:00
jsteube
c59b4bffd5 Add note on how to get CUDA running on WSL2 2023-09-27 08:14:51 +00:00
jsteube
0d0a07012c Do not show HIPRTC notice if HIP is not installed. In that case we can assume the system doesn't have an AMD GPU 2023-09-26 08:52:46 +00:00
Rosen Penev
ae07d65f34 clang-tidy: remove useless casts
Now that const was fixed, pointless casts can be removed.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-08-20 21:10:34 -07:00
Rosen Penev
795674c939 fix some const-qual warnings
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-08-20 20:55:54 -07:00
Rosen Penev
a59e030d7f
fix MinGW compilation
HC_API_CALL needs to be placed not just on the declaration.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2023-08-11 23:16:27 -07:00
jsteube
96b05b2630 AMD Driver: Updated requirements for AMD Windows drivers to "AMD Adrenalin Edition" (23.7.2 or later) and "AMD HIP SDK" (23.Q3 or later) 2023-08-05 15:58:22 +00:00
justpretending
b2f14f2f5d Fix some typos 2023-07-27 23:11:55 +07:00
jsteube
ab932815ea Fixed out-of-boundary read in autotune.c when a fast hash defines a kernel_loops_min value that is higher than the actual number of amplifiers provided by the user 2023-07-04 09:40:39 +00:00
Gabriele Gristina
ef81520158 Metal Backend: disable Metal devices only if at least one OpenCL device is active 2023-06-14 21:11:42 +02:00
Jens Steube
32517211a5
Merge pull request #3760 from matrix/check_invalid_kern_type
do not allow negative kern_type
2023-06-14 03:25:35 +02:00
Gabriele Gristina
eb276f12f6 do not allow negative kern_type 2023-06-07 21:06:57 +02:00
Gabriele Gristina
737989b7cf Metal Backend: allow use of devices with Metal if runtime version is >= 200 2023-06-07 01:17:30 +02:00
Gabriele Gristina
36606addac Help: show supported hash-modes only with -hh 2023-05-01 17:38:42 +02:00
jsteube
6785a32e7a Added new feature (-Y) that creates N virtual instances for each device in your system at the cost of N times the device memory consumption 2023-04-16 12:04:34 +00:00
Jens Steube
b1ca2ca539 Only try to allocate memory on a opencl device if it actually has memory 2023-04-11 10:17:32 +00:00
jsteube
6ad36db9ba Add some detailed information/warnings about dropped HIPRTC symbols in the current AMD Adrenalin driver 2023-03-29 20:16:36 +00:00
Dávid Bolvanský
29a461cb51
Respect quiet flag when printing Metal API warning
Fixes https://github.com/hashcat/hashcat/issues/3624
2023-03-28 00:05:46 +02:00