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

9902 Commits

Author SHA1 Message Date
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
Jens Steube
5ce7e9ec2a
Merge pull request #4248 from matrix/MSONLINEACCOUNT_v2
Module 33700: limit data len to 32 bytes, based on the extraction tool
2025-06-10 09:23:07 +02:00
Jens Steube
0a8793fe71
Merge pull request #4247 from Banaanhangwagen/master
Create cachedata2hashcat.py
2025-06-10 09:22:55 +02:00
Gabriele Gristina
2485c1fcb5 Module 33700: limit data len to 32 bytes, based on the extraction tool 2025-06-10 00:35:35 +02:00
Banaanhangwagen
ffa3626c60
Create cachedata2hashcat.py 2025-06-09 16:26:13 +02:00
Jens Steube
8143839d99
Merge pull request #4241 from matrix/update_gitignore
add .so/.dll from bridges directory in .gitignore
2025-06-09 13:35:53 +02:00
Jens Steube
c3ac9810c8
Merge pull request #4244 from matrix/fix_pythonBridge_cygwin
fix DEFAULT_SOURCE_FILENAME with CYGWIN
2025-06-09 13:29:52 +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
c7d96b40e9
Merge pull request #4246 from matrix/MSONLINEACCOUNT
Added hash-mode: Microsoft Online Account (PBKDF2-HMAC-SHA256 + AES256)
2025-06-08 23:06:33 +02:00
Gabriele Gristina
86c8323ae2 Added hash-mode: Microsoft Online Account (PBKDF2-HMAC-SHA256 + AES256) 2025-06-08 21:39:29 +02:00
Gabriele Gristina
839ea7c2c4 fix for CYGWIN also on bridge_python_generic_hash_sp.c 2025-06-08 18:09:18 +02:00
Gabriele Gristina
ae2c0f2a31 show warning on single-threaded mode also with CYGWIN 2025-06-08 18:06:03 +02:00
Gabriele Gristina
c2dfc5f007 fix DEFAULT_SOURCE_FILENAME with CYGWIN 2025-06-08 17:29:05 +02:00
Gabriele Gristina
a06cf1bf7d update BUILD_CYGWIN: add python3.12 to dependencies 2025-06-08 17:08:11 +02:00
Gabriele Gristina
14db95aabd update BUILD_MSYS2: add python3 to dependencies 2025-06-08 14:10:22 +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
Jens Steube
6b29911431
Merge pull request #4240 from matrix/hip_cuda_device_available_memory
OpenCL Backend: added workaround to set device_available_memory from CUDA/HIP alias device
2025-06-08 07:28:44 +02:00
Gabriele Gristina
48d405d9aa add .so/.dll from bridges directory in .gitignore 2025-06-07 22:52:11 +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
Jens Steube
2af580b448
Merge pull request #4238 from matrix/update_BUILD.md
Update BUILD.md
2025-06-07 18:47:42 +02:00
Jens Steube
547f06caab
Merge pull request #4239 from matrix/metal_processors_workaround
Metal Backend: added workaround to set the true Processor value in Metal devices on Apple Intel
2025-06-07 18:41:04 +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
Gabriele Gristina
27d6816e09
Update BUILD.md
graphic improvement
2025-06-07 13:21:31 +02:00