[GH-ISSUE #1990] SIP format in legacy clang build FAILED: (Could not find salt in db - salt() return inconsistent?) #1333

Closed
opened 2026-10-14 03:44:38 +07:00 by bsakaguchi · 24 comments
Owner

Originally created by @frank-dittrich on GitHub (Jan 12, 2016).
Original GitHub issue: https://github.com/openwall/john/issues/1990

Originally assigned to: @frank-dittrich on GitHub.

Not that legacy clang builds are top priority, but nevertheless:

SIP format is the only one which fails in a legacy clang build using

make -s -f Makefile.legacy linux-x86-64-clang
Testing: SIP [MD5 32/64]... FAILED (Could not find salt in db - salt() return inconsistent?)

1 out of 342 tests have FAILED

Any idea what could be wrong here?
With a gcc legacy build, SIP format doesn't fail self test.

Is clang to blame? Should I test with a more recent clang version (3.7 instead of 3.5)?
But on the same system, with an autoconf clang build, SIP format passes self test.

Originally created by @frank-dittrich on GitHub (Jan 12, 2016). Original GitHub issue: https://github.com/openwall/john/issues/1990 Originally assigned to: @frank-dittrich on GitHub. Not that legacy clang builds are top priority, but nevertheless: SIP format is the only one which fails in a legacy clang build using ``` make -s -f Makefile.legacy linux-x86-64-clang ``` ``` Testing: SIP [MD5 32/64]... FAILED (Could not find salt in db - salt() return inconsistent?) 1 out of 342 tests have FAILED ``` Any idea what could be wrong here? With a gcc legacy build, SIP format doesn't fail self test. Is clang to blame? Should I test with a more recent clang version (3.7 instead of 3.5)? But on the same system, with an autoconf clang build, SIP format passes self test.
bsakaguchi 2026-10-14 03:44:38 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@magnumripper commented on GitHub (Jan 12, 2016):

Probably a bug in get_salt()... but I can't spot it.

<!-- gh-comment-id:171083046 --> @magnumripper commented on GitHub (Jan 12, 2016): Probably a bug in get_salt()... but I can't spot it.
Author
Owner

@frank-dittrich commented on GitHub (Jan 16, 2016):

I commented out all except the first self test, confirmed that the error still exists,
added a dump_stuff_msg() at the end of get_salt() and inside fmt_self_test_body().

Turns out that the value returned by get_salt() is exactly the same as the value of salt in dump_stuff_msg().
But for the only db entry, dbsalt->salt has some extra bytes filled that are 0x00 in salt.

So for me it doesn't look as if SIP format's get_salt() is to blame.
Instead, somehow a mangled salt has been stored in the db.

<!-- gh-comment-id:172240356 --> @frank-dittrich commented on GitHub (Jan 16, 2016): I commented out all except the first self test, confirmed that the error still exists, added a dump_stuff_msg() at the end of get_salt() and inside fmt_self_test_body(). Turns out that the value returned by get_salt() is exactly the same as the value of salt in dump_stuff_msg(). But for the only db entry, dbsalt->salt has some extra bytes filled that are 0x00 in salt. So for me it doesn't look as if SIP format's get_salt() is to blame. Instead, somehow a mangled salt has been stored in the db.
Author
Owner

@magnumripper commented on GitHub (Jan 29, 2016):

I still think it's a bug in the format.

Turns out that the value returned by get_salt() is exactly the same as the value of salt in dump_stuff_msg().
But for the only db entry, dbsalt->salt has some extra bytes filled that are 0x00 in salt.

This makes no sense. What do you mean "extra"? Are those bytes within format->params.salt_size or not?

<!-- gh-comment-id:176494012 --> @magnumripper commented on GitHub (Jan 29, 2016): I still think it's a bug in the format. > Turns out that the value returned by get_salt() is exactly the same as the value of salt in dump_stuff_msg(). > But for the only db entry, dbsalt->salt has some extra bytes filled that are 0x00 in salt. This makes no sense. What do you mean "extra"? Are those bytes within format->params.salt_size or not?
Author
Owner

@frank-dittrich commented on GitHub (Jan 29, 2016):

Yes, those bytes are within the format's salt size.
But within the salt size, the hash has lots of 0x00 bytes.

<!-- gh-comment-id:176647753 --> @frank-dittrich commented on GitHub (Jan 29, 2016): Yes, those bytes are within the format's salt size. But within the salt size, the hash has lots of 0x00 bytes.
Author
Owner

@frank-dittrich commented on GitHub (Jan 29, 2016):

The first line is the salt at the end of get_salt, the second one is the "same" salt stored in the db:

2a000000 01234567 89abcdef fedcba98 76543210 0d000000 00000000 3230303a 61737465 7269736b 3a313932 2e313638 2e312e31 30348000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 d0000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 3a343663 63653835 373a3061 38346637 38666465 36366262 31353139 37656162 39363134 36326463 32660000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
2a000000 01234567 89abcdef fedcba98 76543210 0d000000 00000000 3230303a 61737465 7269736b 3a313932 2e313638 2e312e31 30348000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 d0000000 00000000 48cddf55 367f0000 01000000 00000000 00000000 00000000 01000000 00000000 48f1e155 367f0000 18cddf55 367f0000 b06fc055 367f0000 09000000 00000000 3a343663 63653835 373a3061 38346637 38666465 36366262 31353139 37656162 39363134 36326463 32660000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<!-- gh-comment-id:176665778 --> @frank-dittrich commented on GitHub (Jan 29, 2016): The first line is the salt at the end of get_salt, the second one is the "same" salt stored in the db: ``` 2a000000 01234567 89abcdef fedcba98 76543210 0d000000 00000000 3230303a 61737465 7269736b 3a313932 2e313638 2e312e31 30348000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 d0000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 3a343663 63653835 373a3061 38346637 38666465 36366262 31353139 37656162 39363134 36326463 32660000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 2a000000 01234567 89abcdef fedcba98 76543210 0d000000 00000000 3230303a 61737465 7269736b 3a313932 2e313638 2e312e31 30348000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 d0000000 00000000 48cddf55 367f0000 01000000 00000000 00000000 00000000 01000000 00000000 48f1e155 367f0000 18cddf55 367f0000 b06fc055 367f0000 09000000 00000000 3a343663 63653835 373a3061 38346637 38666465 36366262 31353139 37656162 39363134 36326463 32660000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ```
Author
Owner

@frank-dittrich commented on GitHub (Jan 29, 2016):

BTW: for some reason, the clang legacy linux-x86-64 build is just using SSE2, not SSE4.1, not AVX:

$ ./john --list=build-info 
Version: 1.8.0.6-jumbo-1-1931-gc07e539+
Build: linux-x86-64-clang
SIMD: SSE2, interleaving: MD4:4 MD5:5 SHA1:2 SHA256:1 SHA512:1
$JOHN is ./
Format interface version: 13
Max. number of reported tunable costs: 3
Rec file version: REC4
Charset file version: CHR3
CHARSET_MIN: 1 (0x01)
CHARSET_MAX: 255 (0xff)
CHARSET_LENGTH: 24
SALT_HASH_SIZE: 1048576
Max. Markov mode level: 400
Max. Markov mode password length: 30
clang version: 3.5.0 (tags/RELEASE_350/final) (gcc 4.3.0 compatibility)
GNU libc version: 2.21 (loaded: 2.21)
OpenSSL library version: 0100010bf
OpenSSL 1.0.1k-fips 8 Jan 2015
GMP library version: 6.0.0
File locking: fcntl()
fseek(): fseek
ftell(): ftell
fopen(): fopen
memmem(): JtR internal
<!-- gh-comment-id:176684405 --> @frank-dittrich commented on GitHub (Jan 29, 2016): BTW: for some reason, the clang legacy linux-x86-64 build is just using SSE2, not SSE4.1, not AVX: ``` $ ./john --list=build-info Version: 1.8.0.6-jumbo-1-1931-gc07e539+ Build: linux-x86-64-clang SIMD: SSE2, interleaving: MD4:4 MD5:5 SHA1:2 SHA256:1 SHA512:1 $JOHN is ./ Format interface version: 13 Max. number of reported tunable costs: 3 Rec file version: REC4 Charset file version: CHR3 CHARSET_MIN: 1 (0x01) CHARSET_MAX: 255 (0xff) CHARSET_LENGTH: 24 SALT_HASH_SIZE: 1048576 Max. Markov mode level: 400 Max. Markov mode password length: 30 clang version: 3.5.0 (tags/RELEASE_350/final) (gcc 4.3.0 compatibility) GNU libc version: 2.21 (loaded: 2.21) OpenSSL library version: 0100010bf OpenSSL 1.0.1k-fips 8 Jan 2015 GMP library version: 6.0.0 File locking: fcntl() fseek(): fseek ftell(): ftell fopen(): fopen memmem(): JtR internal ```
Author
Owner

@magnumripper commented on GitHub (Jan 29, 2016):

The first line is the salt at the end of get_salt, the second one is the "same" salt stored in the db:

So they differ a whole lot. Well the db isn't going to change itself. It copies params.salt_size bytes starting at the address returned by get_salt(). Just put more dump_stuff calls all over the place.

<!-- gh-comment-id:176826760 --> @magnumripper commented on GitHub (Jan 29, 2016): > The first line is the salt at the end of get_salt, the second one is the "same" salt stored in the db: So they differ a whole lot. Well the db isn't going to change itself. It copies _params.salt_size_ bytes starting at the address returned by get_salt(). Just put more dump_stuff calls all over the place.
Author
Owner

@frank-dittrich commented on GitHub (Feb 15, 2016):

BTW: Here (1st line) is what that same hash looks like for an autoconf clang build:

2a000000 01234567 89abcdef fedcba98 76543210 68000000 00000000 3230303a 61737465 7269736b 3a000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0d000000 3a343663 63653835 373a3061 38346637 38666465 36366262 31353139 37656162 39363134 36326463 32660000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
2a000000 01234567 89abcdef fedcba98 76543210 0d000000 00000000 3230303a 61737465 7269736b 3a313932 2e313638 2e312e31 30348000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 d0000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 3a343663 63653835 373a3061 38346637 38666465 36366262 31353139 37656162 39363134 36326463 32660000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
2a000000 01234567 89abcdef fedcba98 76543210 0d000000 00000000 3230303a 61737465 7269736b 3a313932 2e313638 2e312e31 30348000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 d0000000 00000000 48cddf55 367f0000 01000000 00000000 00000000 00000000 01000000 00000000 48f1e155 367f0000 18cddf55 367f0000 b06fc055 367f0000 09000000 00000000 3a343663 63653835 373a3061 38346637 38666465 36366262 31353139 37656162 39363134 36326463 32660000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

Lines 2 and 3 are from the legacy clang build output.
The first bytes that are initial in the clang autoconf build, but filled in the clang legacy build, are 313932 2e313638 2e312e31
Translated to ascii, that's 192.168.1.104, which is the IP address stored in the first self test:

{"$sip$*192.168.1.111*192.168.1.104*200*asterisk*REGISTER*sip*192.168.1.104**46cce857****MD5*4dfc7515936a667565228dbaa0293dfc", "123456"}

Why is it that clang legacy still has that information, but clang autoconf doesn't?.

OTOH, the clang autoconf build has some bytes filled which are initial in the clang legacy build:
These are: a343663 63653835 373a3061 38346637 38666465 36366262 31353139.
The 63 63653835 37 part corresponds to cce857 which is part of the first self test sample hash.

Furthermore, the clang autoconf build has 37656162 39363134 36326463 3266 where the clang legacy build's get_salt() has 0x00 bytes.

Quite confusing.

Any idea where adding more dump_stuff_msg() could be added?

<!-- gh-comment-id:184167381 --> @frank-dittrich commented on GitHub (Feb 15, 2016): BTW: Here (1st line) is what that same hash looks like for an autoconf clang build: ``` 2a000000 01234567 89abcdef fedcba98 76543210 68000000 00000000 3230303a 61737465 7269736b 3a000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0d000000 3a343663 63653835 373a3061 38346637 38666465 36366262 31353139 37656162 39363134 36326463 32660000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 2a000000 01234567 89abcdef fedcba98 76543210 0d000000 00000000 3230303a 61737465 7269736b 3a313932 2e313638 2e312e31 30348000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 d0000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 3a343663 63653835 373a3061 38346637 38666465 36366262 31353139 37656162 39363134 36326463 32660000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 2a000000 01234567 89abcdef fedcba98 76543210 0d000000 00000000 3230303a 61737465 7269736b 3a313932 2e313638 2e312e31 30348000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 d0000000 00000000 48cddf55 367f0000 01000000 00000000 00000000 00000000 01000000 00000000 48f1e155 367f0000 18cddf55 367f0000 b06fc055 367f0000 09000000 00000000 3a343663 63653835 373a3061 38346637 38666465 36366262 31353139 37656162 39363134 36326463 32660000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ``` Lines 2 and 3 are from the legacy clang build output. The first bytes that are initial in the clang autoconf build, but filled in the clang legacy build, are `313932 2e313638 2e312e31` Translated to ascii, that's `192.168.1.104`, which is the IP address stored in the first self test: ``` {"$sip$*192.168.1.111*192.168.1.104*200*asterisk*REGISTER*sip*192.168.1.104**46cce857****MD5*4dfc7515936a667565228dbaa0293dfc", "123456"} ``` Why is it that clang legacy still has that information, but clang autoconf doesn't?. OTOH, the clang autoconf build has some bytes filled which are initial in the clang legacy build: These are: `a343663 63653835 373a3061 38346637 38666465 36366262 31353139`. The `63 63653835 37` part corresponds to `cce857` which is part of the first self test sample hash. Furthermore, the clang autoconf build has `37656162 39363134 36326463 3266` where the clang legacy build's get_salt() has 0x00 bytes. Quite confusing. Any idea where adding more dump_stuff_msg() could be added?
Author
Owner

@frank-dittrich commented on GitHub (Feb 15, 2016):

I just noticed that in a legacy clang build SIP has salt size 472, while for other builds (legacy linux-x86-64 (gcc), autoconf gcc and clang) the salt size is 412.
Also, a legacy gcc build has exactly the same salt as the autoconf clang build.

<!-- gh-comment-id:184181142 --> @frank-dittrich commented on GitHub (Feb 15, 2016): I just noticed that in a legacy clang build SIP has salt size 472, while for other builds (legacy linux-x86-64 (gcc), autoconf gcc and clang) the salt size is 412. Also, a legacy gcc build has exactly the same salt as the autoconf clang build.
Author
Owner

@frank-dittrich commented on GitHub (Feb 15, 2016):

BTW: Now that we have clang on well, this error can be reproduced on well:

make -s clean
make -s -f Makefile.legacy linux-x86-64-clang
../run/john --test=0 --format=sip
Testing: SIP [MD5 32/64]... FAILED (Could not find salt in db - salt() return inconsistent?)

<!-- gh-comment-id:184182324 --> @frank-dittrich commented on GitHub (Feb 15, 2016): BTW: Now that we have clang on well, this error can be reproduced on well: ``` make -s clean make -s -f Makefile.legacy linux-x86-64-clang ../run/john --test=0 --format=sip Testing: SIP [MD5 32/64]... FAILED (Could not find salt in db - salt() return inconsistent?) ```
Author
Owner

@jfoug commented on GitHub (Feb 15, 2016):

SIP has a MD5_CTX in the salt, that is pre-loaded up to a point. That easily explains the size difference (if not using oSSL, or something).

I also wonder if there is something allocated in a MD5_CTX happening on the legacy clang build? If so, then the salts are not going to match.

Adding a CTX to a salt structure is done to allow some of the work to be done 1 time, and then used later in crypt_all. I wonder if that is not always a valid thing to do?

<!-- gh-comment-id:184224932 --> @jfoug commented on GitHub (Feb 15, 2016): SIP has a MD5_CTX in the salt, that is pre-loaded up to a point. That easily explains the size difference (if not using oSSL, or something). I also wonder if there is something allocated in a MD5_CTX happening on the legacy clang build? If so, then the salts are not going to match. Adding a CTX to a salt structure is done to allow some of the work to be done 1 time, and then used later in crypt_all. I wonder if that is not always a valid thing to do?
Author
Owner

@magnumripper commented on GitHub (Feb 15, 2016):

The salt struct layout/size is not not an issue, a struct is essentially a black box because the compiler is free to pad and/or reorder stuff within it. What matters is the input format.

<!-- gh-comment-id:184250696 --> @magnumripper commented on GitHub (Feb 15, 2016): The salt struct layout/size is not not an issue, a struct is essentially a black box because the compiler is free to pad and/or reorder stuff within it. What matters is the input format.
Author
Owner

@magnumripper commented on GitHub (Feb 15, 2016):

That error is obviously an issue of course

<!-- gh-comment-id:184250784 --> @magnumripper commented on GitHub (Feb 15, 2016): That error is obviously an issue of course
Author
Owner

@buzzdeee commented on GitHub (Nov 24, 2020):

I've the same problem, with legacy buidl on OpenBSD:

john --list=build-info
Version: 1.9.0-jumbo-1
Build: openbsd-x86-64
SIMD: SSE2, interleaving: MD4:4 MD5:5 SHA1:2 SHA256:1 SHA512:1
System-wide exec: /usr/libexec/john
System-wide home: /etc/john
Private home: ~/.john
$JOHN is /etc/john/
Format interface version: 14
Max. number of reported tunable costs: 4
Rec file version: REC4
Charset file version: CHR3
CHARSET_MIN: 1 (0x01)
CHARSET_MAX: 255 (0xff)
CHARSET_LENGTH: 24
SALT_HASH_SIZE: 1048576
SINGLE_IDX_MAX: 32768
SINGLE_BUF_MAX: 65535
Effective limit: Max. KPC 4096 at length 16, down to 525 at length 125
Max. Markov mode level: 400
Max. Markov mode password length: 30
clang version: 10.0.1 (gcc 4.2.1 compatibility)
File locking: fcntl()
fseek(): fseek
ftell(): ftell
fopen(): fopen
memmem(): JtR internal

<!-- gh-comment-id:732857223 --> @buzzdeee commented on GitHub (Nov 24, 2020): I've the same problem, with legacy buidl on OpenBSD: john --list=build-info Version: 1.9.0-jumbo-1 Build: openbsd-x86-64 SIMD: SSE2, interleaving: MD4:4 MD5:5 SHA1:2 SHA256:1 SHA512:1 System-wide exec: /usr/libexec/john System-wide home: /etc/john Private home: ~/.john $JOHN is /etc/john/ Format interface version: 14 Max. number of reported tunable costs: 4 Rec file version: REC4 Charset file version: CHR3 CHARSET_MIN: 1 (0x01) CHARSET_MAX: 255 (0xff) CHARSET_LENGTH: 24 SALT_HASH_SIZE: 1048576 SINGLE_IDX_MAX: 32768 SINGLE_BUF_MAX: 65535 Effective limit: Max. KPC 4096 at length 16, down to 525 at length 125 Max. Markov mode level: 400 Max. Markov mode password length: 30 clang version: 10.0.1 (gcc 4.2.1 compatibility) File locking: fcntl() fseek(): fseek ftell(): ftell fopen(): fopen memmem(): JtR internal
Author
Owner

@solardiz commented on GitHub (Nov 24, 2020):

We should probably look into and fix the SIP format's issue.

@buzzdeee That said, why are you using a legacy build on OpenBSD? I'd expect ./configure && make to work on OpenBSD, doesn't it?

<!-- gh-comment-id:732939410 --> @solardiz commented on GitHub (Nov 24, 2020): We should probably look into and fix the SIP format's issue. @buzzdeee That said, why are you using a legacy build on OpenBSD? I'd expect `./configure && make` to work on OpenBSD, doesn't it?
Author
Owner

@solardiz commented on GitHub (Nov 24, 2020):

Reproduced in a make -f Makefile.legacy linux-x86-64-clang build:

Benchmarking: SIP [MD5 32/64]... Warning: Could not find salt in db
Warning: Could not find salt in db
Warning: Could not find salt in db
Warning: Could not find salt in db
DONE
Many salts:     2446K c/s real, 2458K c/s virtual
Only one salt:  2388K c/s real, 2388K c/s virtual

This fixes it:

+++ b/src/sip_fmt_plug.c
@@ -198,7 +198,14 @@ static void *get_salt(char *ciphertext)
        char static_hash[MD5_LEN_HEX+1];
        char *saltcopy = saltBuf;
 
+/*
+ * Zeroize both structs so that any padding gaps have defined values and thus
+ * salt comparisons work reliably.  Note that we memcpy() md5_ctx into
+ * salt.ctx_dyna_data, which copies md5_ctx's padding gaps too.
+ */
        memset(&salt, 0, sizeof(salt));
+       memset(&md5_ctx, 0, sizeof(md5_ctx));
+
        strcpy(saltBuf, ciphertext);
        saltcopy += FORMAT_TAG_LEN;     /* skip over "$sip$*" */
        memset(&login, 0, sizeof(login_t));
<!-- gh-comment-id:732954712 --> @solardiz commented on GitHub (Nov 24, 2020): Reproduced in a `make -f Makefile.legacy linux-x86-64-clang` build: ``` Benchmarking: SIP [MD5 32/64]... Warning: Could not find salt in db Warning: Could not find salt in db Warning: Could not find salt in db Warning: Could not find salt in db DONE Many salts: 2446K c/s real, 2458K c/s virtual Only one salt: 2388K c/s real, 2388K c/s virtual ``` This fixes it: ```diff +++ b/src/sip_fmt_plug.c @@ -198,7 +198,14 @@ static void *get_salt(char *ciphertext) char static_hash[MD5_LEN_HEX+1]; char *saltcopy = saltBuf; +/* + * Zeroize both structs so that any padding gaps have defined values and thus + * salt comparisons work reliably. Note that we memcpy() md5_ctx into + * salt.ctx_dyna_data, which copies md5_ctx's padding gaps too. + */ memset(&salt, 0, sizeof(salt)); + memset(&md5_ctx, 0, sizeof(md5_ctx)); + strcpy(saltBuf, ciphertext); saltcopy += FORMAT_TAG_LEN; /* skip over "$sip$*" */ memset(&login, 0, sizeof(login_t)); ```
Author
Owner

@solardiz commented on GitHub (Nov 24, 2020):

I identified 3 other formats that copy MD5 contexts: EIGRP, HSRP, and tacacs-plus. However, per code review these do not have the same issue. 2 of them do keep the MD5 context inside their salt structures, but they zeroize the structure and then MD5_Init the context right inside the structure, not via a memcpy.

<!-- gh-comment-id:732964237 --> @solardiz commented on GitHub (Nov 24, 2020): I identified 3 other formats that copy MD5 contexts: EIGRP, HSRP, and tacacs-plus. However, per code review these do not have the same issue. 2 of them do keep the MD5 context inside their salt structures, but they zeroize the structure and then `MD5_Init` the context right inside the structure, not via a `memcpy`.
Author
Owner

@buzzdeee commented on GitHub (Nov 24, 2020):

The current ports tree is at john-jumbo 1.8.0-1, and that uses the legacy build to create the package:
https://cvsweb.openbsd.org/ports/security/john-jumbo/
The Makefile is a bit messy. With the 1.8.0-1 all tests pass.

After reading the issue here, I actually tried configure && gmake however, that's why I then commented here.
Now tried to reproduce, and linking just works. maybe I had some other stuff around from prior build.

However, with ./configure && gmake compilation breaks:

CC=clang CFLAGS="-DJOHN_SYSTEMWIDE=1 -DJOHN_SYSTEMWIDE_HOME='"/etc/john"' -DHAVE_NSS `pkg-config --cflags nss`" LDFLAGS="-lssl -lcrypto -lm -lz `pkg-config --libs nss`" ./configure 
configure: WARNING: No recognized optimization option present in CFLAGS "-m64 -DJOHN_SYSTEMWIDE=1 -DJOHN_SYSTEMWIDE_HOME='"/etc/john"' -DHAVE_NSS -I/usr/local/include/nss -I/usr/local/include/nspr -I/usr/local/include -DARCH_LITTLE_ENDIAN=1"

Configured for building John the Ripper jumbo:

Target CPU ................................. x86_64 AVX, 64-bit LE
AES-NI support ............................. depends on OpenSSL
Target OS .................................. openbsd6.8
Cross compiling ............................ no
Legacy arch header ......................... x86-64.h

Optional libraries/features found:
Memory map (share/page large files) ........ yes
Fork support ............................... yes
OpenMP support ............................. no
OpenCL support ............................. no
Generic crypt(3) format .................... yes
libgmp (PRINCE mode and faster SRP formats)  yes
128-bit integer (faster PRINCE mode) ....... yes
libz (pkzip and some other formats) ........ yes
libbz2 (gpg2john extra decompression logic)  yes
libpcap (vncpcap2john and SIPdump) ......... yes
OpenMPI support (default disabled) ......... no
ZTEX USB-FPGA module 1.15y support ......... no

Install missing libraries to get any needed features that were omitted.

Configure finished.  Now "gmake -s clean && gmake -sj4" to compile.

however, then gmail fails:

CC=clang CFLAGS="-DJOHN_SYSTEMWIDE=1 -DJOHN_SYSTEMWIDE_HOME='\"/etc/john\"' -DHAVE_NSS `pkg-config --cflags nss`" LDFLAGS="-lssl -lcrypto -lm -lz `pkg-config --libs nss`" gmake
clang -DAC_BUILT -mavx -DJOHN_AVX -c -m64 -DJOHN_SYSTEMWIDE=1 -DJOHN_SYSTEMWIDE_HOME='"/etc/john"' -DHAVE_NSS -I/usr/local/include/nss -I/usr/local/include/nspr -I/usr/local/include -DARCH_LITTLE_ENDIAN=1  -Wall -Wno-tautological-constant-out-of-range-compare -fno-omit-frame-pointer --param allow-store-data-races=0 -Wno-deprecated-declarations -Wformat-extra-args -Qunused-arguments -std=gnu89 -Wdate-time    -pthread -I/usr/local/include -DCL_SILENCE_DEPRECATION -funroll-loops eapmd5tojohn.c -o eapmd5tojohn.o
eapmd5tojohn.c:1131:8: error: use of undeclared identifier 'DLT_TZSP'
                case DLT_TZSP:
                     ^
eapmd5tojohn.c:1135:8: error: use of undeclared identifier 'DLT_PRISM_HEADER'
                case DLT_PRISM_HEADER:
                     ^
2 errors generated.
gmake[1]: *** [Makefile:1596: eapmd5tojohn.o] Error 1

Then, running the tests, two tests fail:

Testing: skey, S/Key [MD4/MD5/SHA1/RMD160 32/64]... FAILED (cmp_all(1))
Testing: crypt, generic crypt(3) [?/64]... Warning: hash encoding string length 13, type id #1
appears to be unsupported on this system; will not load such hashes.
FAILED (valid (before init))

<!-- gh-comment-id:733019473 --> @buzzdeee commented on GitHub (Nov 24, 2020): The current ports tree is at john-jumbo 1.8.0-1, and that uses the legacy build to create the package: https://cvsweb.openbsd.org/ports/security/john-jumbo/ The Makefile is a bit messy. With the 1.8.0-1 all tests pass. After reading the issue here, I actually tried configure && gmake however, that's why I then commented here. Now tried to reproduce, and linking just works. maybe I had some other stuff around from prior build. However, with ./configure && gmake compilation breaks: ``` CC=clang CFLAGS="-DJOHN_SYSTEMWIDE=1 -DJOHN_SYSTEMWIDE_HOME='"/etc/john"' -DHAVE_NSS `pkg-config --cflags nss`" LDFLAGS="-lssl -lcrypto -lm -lz `pkg-config --libs nss`" ./configure ``` ``` configure: WARNING: No recognized optimization option present in CFLAGS "-m64 -DJOHN_SYSTEMWIDE=1 -DJOHN_SYSTEMWIDE_HOME='"/etc/john"' -DHAVE_NSS -I/usr/local/include/nss -I/usr/local/include/nspr -I/usr/local/include -DARCH_LITTLE_ENDIAN=1" Configured for building John the Ripper jumbo: Target CPU ................................. x86_64 AVX, 64-bit LE AES-NI support ............................. depends on OpenSSL Target OS .................................. openbsd6.8 Cross compiling ............................ no Legacy arch header ......................... x86-64.h Optional libraries/features found: Memory map (share/page large files) ........ yes Fork support ............................... yes OpenMP support ............................. no OpenCL support ............................. no Generic crypt(3) format .................... yes libgmp (PRINCE mode and faster SRP formats) yes 128-bit integer (faster PRINCE mode) ....... yes libz (pkzip and some other formats) ........ yes libbz2 (gpg2john extra decompression logic) yes libpcap (vncpcap2john and SIPdump) ......... yes OpenMPI support (default disabled) ......... no ZTEX USB-FPGA module 1.15y support ......... no Install missing libraries to get any needed features that were omitted. Configure finished. Now "gmake -s clean && gmake -sj4" to compile. ``` however, then gmail fails: ``` CC=clang CFLAGS="-DJOHN_SYSTEMWIDE=1 -DJOHN_SYSTEMWIDE_HOME='\"/etc/john\"' -DHAVE_NSS `pkg-config --cflags nss`" LDFLAGS="-lssl -lcrypto -lm -lz `pkg-config --libs nss`" gmake ``` ``` clang -DAC_BUILT -mavx -DJOHN_AVX -c -m64 -DJOHN_SYSTEMWIDE=1 -DJOHN_SYSTEMWIDE_HOME='"/etc/john"' -DHAVE_NSS -I/usr/local/include/nss -I/usr/local/include/nspr -I/usr/local/include -DARCH_LITTLE_ENDIAN=1 -Wall -Wno-tautological-constant-out-of-range-compare -fno-omit-frame-pointer --param allow-store-data-races=0 -Wno-deprecated-declarations -Wformat-extra-args -Qunused-arguments -std=gnu89 -Wdate-time -pthread -I/usr/local/include -DCL_SILENCE_DEPRECATION -funroll-loops eapmd5tojohn.c -o eapmd5tojohn.o eapmd5tojohn.c:1131:8: error: use of undeclared identifier 'DLT_TZSP' case DLT_TZSP: ^ eapmd5tojohn.c:1135:8: error: use of undeclared identifier 'DLT_PRISM_HEADER' case DLT_PRISM_HEADER: ^ 2 errors generated. gmake[1]: *** [Makefile:1596: eapmd5tojohn.o] Error 1 ``` Then, running the tests, two tests fail: Testing: skey, S/Key [MD4/MD5/SHA1/RMD160 32/64]... FAILED (cmp_all(1)) Testing: crypt, generic crypt(3) [?/64]... Warning: hash encoding string length 13, type id #1 appears to be unsupported on this system; will not load such hashes. FAILED (valid (before init))
Author
Owner

@solardiz commented on GitHub (Nov 24, 2020):

@buzzdeee Thanks. Is this with our latest code from this repo?

We don't recommend overriding CFLAGS as that drops our optimization options. You should probably use CPPFLAGS instead.

The eapmd5tojohn.c build errors suggest incompatibility of our code in there with the version of libpcap you have on the system. We should probably introduce some #ifdef logic in there to exclude the functionality unsupported by build system's libpcap (we'd welcome a pull request doing that), but meanwhile you should be able to build with --disable-pcap (thus, excluding entire tools).

We'll need to look into the skey format failure if it's indeed seen with our latest code - please confirm.

The crypt format failure is "correct" - as I understand, OpenBSD dropped support for those hashes. I don't know whether we should do anything about that in JtR. Maybe exclude those test vectors from that format when built for OpenBSD (again, a pull request is welcome).

<!-- gh-comment-id:733036919 --> @solardiz commented on GitHub (Nov 24, 2020): @buzzdeee Thanks. Is this with our latest code from this repo? We don't recommend overriding `CFLAGS` as that drops our optimization options. You should probably use `CPPFLAGS` instead. The `eapmd5tojohn.c` build errors suggest incompatibility of our code in there with the version of libpcap you have on the system. We should probably introduce some `#ifdef` logic in there to exclude the functionality unsupported by build system's libpcap (we'd welcome a pull request doing that), but meanwhile you should be able to build with `--disable-pcap` (thus, excluding entire tools). We'll need to look into the skey format failure if it's indeed seen with our latest code - please confirm. The crypt format failure is "correct" - as I understand, OpenBSD dropped support for those hashes. I don't know whether we should do anything about that in JtR. Maybe exclude those test vectors from that format when built for OpenBSD (again, a pull request is welcome).
Author
Owner

@solardiz commented on GitHub (Nov 24, 2020):

We should probably introduce some #ifdef logic in there to exclude the functionality unsupported by build system's libpcap (we'd welcome a pull request doing that)

I just took care of this myself, it's #4488 now.

<!-- gh-comment-id:733044000 --> @solardiz commented on GitHub (Nov 24, 2020): > We should probably introduce some `#ifdef` logic in there to exclude the functionality unsupported by build system's libpcap (we'd welcome a pull request doing that) I just took care of this myself, it's #4488 now.
Author
Owner

@buzzdeee commented on GitHub (Nov 24, 2020):

the meset patch makes all tests pass in legacy build mode:
All 705 formats passed self-tests!

<!-- gh-comment-id:733052616 --> @buzzdeee commented on GitHub (Nov 24, 2020): the meset patch makes all tests pass in legacy build mode: All 705 formats passed self-tests!
Author
Owner

@solardiz commented on GitHub (Nov 24, 2020):

@buzzdeee What "meset patch"? Also, perhaps your build somehow fails to read its john.conf. There should be a little over 400 formats tested with our default settings.

<!-- gh-comment-id:733058724 --> @solardiz commented on GitHub (Nov 24, 2020): @buzzdeee What "meset patch"? Also, perhaps your build somehow fails to read its `john.conf`. There should be a little over 400 formats tested with our default settings.
Author
Owner

@buzzdeee commented on GitHub (Nov 24, 2020):

sorry, typo, just wanted to confirm, the added memset in the sip_fmt_plug.c works for me.

I'm currently with the latest release 1.9.0-jumbo-1

I'll see to find a clean system for testing, then I'll look at current code regarding the skey test, and the number of tests.

<!-- gh-comment-id:733105503 --> @buzzdeee commented on GitHub (Nov 24, 2020): sorry, typo, just wanted to confirm, the added memset in the sip_fmt_plug.c works for me. I'm currently with the latest release 1.9.0-jumbo-1 I'll see to find a clean system for testing, then I'll look at current code regarding the skey test, and the number of tests.
Author
Owner

@solardiz commented on GitHub (Nov 24, 2020):

@buzzdeee I'd appreciate it if you also review the patches in the OpenBSD port for relevance to our current code, and send us PR(s) accordingly. At a glance, perhaps at least the patches having to do with getopt() return value type are still relevant. Thanks!

<!-- gh-comment-id:733187787 --> @solardiz commented on GitHub (Nov 24, 2020): @buzzdeee I'd appreciate it if you also review the patches in the OpenBSD port for relevance to our current code, and send us PR(s) accordingly. At a glance, perhaps at least the patches having to do with `getopt()` return value type are still relevant. Thanks!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#1333
No description provided.