Skip to content

Commit dd02267

Browse files
committed
Automatic downtune problem:
In the automatic downtune routine, hashcat prepares a fixed 512MiB host buffer that is known to be allocated by the compute runtimes (CUDA, HIP, OpenCL, Metal), and over which hashcat has no control. However, hashcat still divides the maximum available host memory by the active device count to automatically as a preparation to later downtune the -n and -T parameters when memory is limited. Hashcat reserves 512MiB per active device. With bridges, the active devices become bridge units, which for modes 70000, 70100, and 70200 equals the CPU core count. On a 32-core CPU, this multiplies to 16GiB, even though the memory is actually shared because of threading. This leads to an overestimation of memory usage. A simple fix is to divide the 512MiB buffer by the active device count. This keeps the full 512MiB for a single GPU but avoids overestimating memory usage with many virtual devices. Fix code handling kernel-accel value in argon2_common.c for CPU, which was accidentally removed during previous refactoring. Set thread count to 1 for hash-mode 70000. Oversubscribing the CPU isn't useful here. This allows to keep the wordlist count low, which is very welcome for slow hashes like Argon2id. Fix unit test for 20011/20012/20013 (DiskCryptor) by adding setuptools to install_modules.sh and replacing AES.MODE_XTS with python_AES.MODE_XTS. Fix false negative for kernel 32800, which only occurred if all conditions were true: multihash, -a 3, optimized mode, and password length between 16 and 31. Fix Python package name in BUILD_WSL.md command line example.
1 parent 28c486f commit dd02267

11 files changed

Lines changed: 46 additions & 21 deletions

File tree

BUILD_WSL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ sudo make install
2121
cd ../
2222
wget https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-python-3.12.11-1-any.pkg.tar.zst
2323
sudo mkdir /opt/win-python
24-
sudo tar --zstd -xf mingw-w64-x86_64-python-3.12.10-1-any.pkg.tar.zst -C /opt/win-python
24+
sudo tar --zstd -xf mingw-w64-x86_64-python-3.12.11-1-any.pkg.tar.zst -C /opt/win-python
2525
```
2626

2727
### Building ###

OpenCL/m32800_a3-optimized.cl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -917,8 +917,8 @@ KERNEL_FQ KERNEL_FA void m32800_m08 (KERN_ATTR_BASIC ())
917917

918918
w3[0] = 0;
919919
w3[1] = 0;
920-
w3[2] = 0;
921-
w3[3] = pws[gid].i[15];
920+
w3[2] = pws[gid].i[14];
921+
w3[3] = 0;
922922

923923
const u32 pw_len = pws[gid].pw_len & 63;
924924

src/backend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16425,7 +16425,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
1642516425

1642616426
if (size_total > device_param->device_available_mem) memory_limit_hit = 1;
1642716427

16428-
const u64 size_host_extra = (512 * 1024 * 1024);
16428+
const u64 size_host_extra = (512 * 1024 * 1024) / backend_ctx->backend_devices_active;
1642916429

1643016430
const u64 size_total_host
1643116431
= size_pws_comp

src/bridges/bridge_argon2id_reference.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
// and therefore it's easier for hashcat to parallelize if this multiplier is low.
2626
// in the end, it's a trade-off.
2727

28-
#define N_ACCEL 8
28+
#define N_ACCEL 32
2929

3030
typedef struct
3131
{

src/modules/argon2_common.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,17 @@ const char *argon2_module_extra_tuningdb_block (MAYBE_UNUSED const hashconfig_t
7171
}
7272
else
7373
{
74-
kernel_accel_new = kernel_accel_max;
74+
if (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)
75+
{
76+
kernel_accel_new = MIN (device_processors, kernel_accel_max);
77+
}
78+
else
79+
{
80+
kernel_accel_new = kernel_accel_max;
81+
}
7582
}
7683

84+
7785
char *new_device_name = hcstrdup (device_param->device_name);
7886

7987
for (size_t i = 0; i < strlen (new_device_name); i++)

src/modules/module_70000.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ typedef struct
7777

7878
static const char *SIGNATURE_ARGON2ID= "$argon2id$";
7979

80+
u32 module_kernel_threads_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
81+
{
82+
const u32 kernel_threads_min = 1;
83+
84+
return kernel_threads_min;
85+
}
86+
87+
u32 module_kernel_threads_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
88+
{
89+
const u32 kernel_threads_max = 1;
90+
91+
return kernel_threads_max;
92+
}
93+
8094
u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
8195
{
8296
const u64 esalt_size = (const u64) sizeof (argon2_t);
@@ -300,8 +314,8 @@ void module_init (module_ctx_t *module_ctx)
300314
module_ctx->module_kernel_accel_min = MODULE_DEFAULT;
301315
module_ctx->module_kernel_loops_max = MODULE_DEFAULT;
302316
module_ctx->module_kernel_loops_min = MODULE_DEFAULT;
303-
module_ctx->module_kernel_threads_max = MODULE_DEFAULT;
304-
module_ctx->module_kernel_threads_min = MODULE_DEFAULT;
317+
module_ctx->module_kernel_threads_max = module_kernel_threads_max;
318+
module_ctx->module_kernel_threads_min = module_kernel_threads_min;
305319
module_ctx->module_kern_type = module_kern_type;
306320
module_ctx->module_kern_type_dynamic = MODULE_DEFAULT;
307321
module_ctx->module_opti_type = module_opti_type;

tools/install_modules.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ else
164164
pip3 install cryptography
165165
ERRORS=$((ERRORS+$?))
166166

167+
pip3 install setuptools
168+
ERRORS=$((ERRORS+$?))
169+
167170
fi
168171

169172
echo

tools/test_modules/m13600.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ sub module_generate_hash
8686

8787
my $key = $pbkdf2->PBKDF2_hex ($salt_bin, $word);
8888

89-
my $verify_bytes = substr ($key, -4); $verify_bytes =~ s/^0+//; #lol
89+
my $verify_bytes = substr ($key, -4); #$verify_bytes =~ s/^0+//; #lol
9090

9191
$key = substr ($key, $key_len, $key_len);
9292

tools/test_modules/m20011.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ sub aes_encrypt
2424

2525
my $python_code = <<'END_CODE';
2626
27-
from CryptoPlus.Cipher import AES
27+
from CryptoPlus.Cipher import python_AES
2828
import base64
2929
3030
key1 = base64.b64decode (key_main)
3131
key2 = base64.b64decode (key_tweak)
3232
3333
key = (key1, key2)
3434
35-
cipher = AES.new (key, AES.MODE_XTS)
35+
cipher = python_AES.new (key, python_AES.MODE_XTS)
3636
3737
sequence = b"\x01"
3838
@@ -67,15 +67,15 @@ sub aes_decrypt
6767

6868
my $python_code = <<'END_CODE';
6969
70-
from CryptoPlus.Cipher import AES
70+
from CryptoPlus.Cipher import python_AES
7171
import base64
7272
7373
key1 = base64.b64decode (key_main)
7474
key2 = base64.b64decode (key_tweak)
7575
7676
key = (key1, key2)
7777
78-
cipher = AES.new (key, AES.MODE_XTS)
78+
cipher = python_AES.new (key, python_AES.MODE_XTS)
7979
8080
sequence = b"\x01"
8181

tools/test_modules/m20012.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ sub aes_encrypt
2424

2525
my $python_code = <<'END_CODE';
2626
27-
from CryptoPlus.Cipher import AES
27+
from CryptoPlus.Cipher import python_AES
2828
import base64
2929
3030
key1 = base64.b64decode (key_main)
3131
key2 = base64.b64decode (key_tweak)
3232
3333
key = (key1, key2)
3434
35-
cipher = AES.new (key, AES.MODE_XTS)
35+
cipher = python_AES.new (key, python_AES.MODE_XTS)
3636
3737
sequence = b"\x01"
3838
@@ -67,15 +67,15 @@ sub aes_decrypt
6767

6868
my $python_code = <<'END_CODE';
6969
70-
from CryptoPlus.Cipher import AES
70+
from CryptoPlus.Cipher import python_AES
7171
import base64
7272
7373
key1 = base64.b64decode (key_main)
7474
key2 = base64.b64decode (key_tweak)
7575
7676
key = (key1, key2)
7777
78-
cipher = AES.new (key, AES.MODE_XTS)
78+
cipher = python_AES.new (key, python_AES.MODE_XTS)
7979
8080
sequence = b"\x01"
8181

0 commit comments

Comments
 (0)