mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #967] crypt format: Self test failed (valid (before init)) #565
Labels
No labels
bug
core branch
documentation
enhancement
enhancement
fixed - pending verify
fuzz bug
good first issue
invalid
invalid
maintenance/cleanup
new cracking mode
new format
new tool
non-trivial
notes/external issues
portability
question
RFC / discussion
testing
WONTFIX
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openwall/john#565
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @frank-dittrich on GitHub (Dec 29, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/967
@jfoug commented on GitHub (Dec 29, 2014):
I do not get this. What system, @frank-dittrich ? I think it is your crypt lib, not able to handle something.
@jfoug commented on GitHub (Dec 29, 2014):
here is my cygwin run (it does not handle
6Here is the run on Ubuntu
@jfoug commented on GitHub (Dec 29, 2014):
Ok, I see the bug now:
the pw is not loaded with -w=pw, it is simply another input file.
Ok, now I can attack this.
@frank-dittrich commented on GitHub (Dec 29, 2014):
Yes, originally, I had a single input file with 2 lines, but
./base64conv -q -i raw -o hex < fail_crypt.pw > fail_crypt.hexignored the second line (see issue https://github.com/magnumripper/JohnTheRipper/issues/968), that's why I did split fail_crypt.pw into 2 files.@magnumripper commented on GitHub (Dec 29, 2014):
@frank-dittrich please add label (in this case bug) when you create issues.
@magnumripper commented on GitHub (Jan 4, 2015):
Doesn't happen under OSX
@jfoug commented on GitHub (Jan 4, 2015):
It will only happen on a system that handle
6I think. Cygwin does not show the problem either.@frank-dittrich commented on GitHub (Jan 4, 2015):
On a system that doesn't handle
6, you might be able ro reproduce this by combining a DES hash and a1hash.@magnumripper commented on GitHub (Jan 4, 2015):
https://github.com/magnumripper/JohnTheRipper/issues/967#issuecomment-68228739 seems to show the bug even though
6is not supported@magnumripper commented on GitHub (Jan 4, 2015):
No, wait, it's DES that is not handled in that case.
@magnumripper commented on GitHub (Jan 4, 2015):
So I reversed the order of input but it still does not trigger. I guess it's in the glibc-specific code.
@frank-dittrich commented on GitHub (Jan 4, 2015):
So we just enhance autoconfig to enable the use of an alternative libc.
Then I might try to build john with dietlibc, http://www.fefe.de/dietlibc/, and see if the bug disappears.
@magnumripper commented on GitHub (Jan 4, 2015):
Just squash the bug instead, that should be a lot easier...
@magnumripper commented on GitHub (Jan 4, 2015):
...or even better, add an
#undef __GLIBC__after the#include <stdio.h>line and see if bug disappears!@frank-dittrich commented on GitHub (Jan 4, 2015):
I just added a printf.
The format is failing on this ciphertext:
CCNf8Sbh3HDfQfrom the first self test.But what causes valid to fail here?
@frank-dittrich commented on GitHub (Jan 4, 2015):
The trouble is that this hash from the input file is considered invalid by libc's crypt_r:
+S/.8o.Wuph9..Later on, all descrypt hashes will be rejected as invalid here:
@frank-dittrich commented on GitHub (Jan 4, 2015):
That means, just because libc considered one has of length 13 as invalid and it considered one hash of ID 1 as invalid, we can't reject all the other hashes of id 1 and length 13. We'll have to let libc decide which of these hashes are valid.
The same applies for the other check:
Just because one of those hashes was valid doesn't mean libc can handle all of them.
@frank-dittrich commented on GitHub (Jan 4, 2015):
These are the ciphertexts valid() is checking when I run
./john --format=crypt fail_crypt.pw1 fail_crypt.pw2:In total, there are exactly 1500 garbage hashes tested in addition to the expected hashes.
@frank-dittrich commented on GitHub (Jan 4, 2015):
I just confirmed this.
I can reproduce the input file with
The only thing that matters is that the first line contains a hash of length 13 which libc considers to be invalid, and that there is at least one valid hash in it.
That means, the valid descrypt hash which comes second is now rejected as invalid.
When I change the sequence of these hashes in the input file, I get:
@magnumripper commented on GitHub (Jan 4, 2015):
Why is that? Is there something wrong with that hash? Did they drop support for DES?
@frank-dittrich commented on GitHub (Jan 4, 2015):
I just verified that the same problem exists in core:
@frank-dittrich commented on GitHub (Jan 4, 2015):
No, DES is still supported.
Apparently,
+S/.8o.Wuph9.is not a valid DES hash.@frank-dittrich commented on GitHub (Jan 4, 2015):
BTW:
+9F93o1OxwgK1is a valid BFegg hash from the BFegg self tests;)I can reproduce the error with these two hashes:
@frank-dittrich commented on GitHub (Jan 4, 2015):
+S/.8o.Wuph9.is a result of fuzzing+C/.8o.Wuph9.which also is a valid BFegg hash from the BFegg self tests.@frank-dittrich commented on GitHub (Jan 4, 2015):
I reported the core issue on john-users:
http://thread.gmane.org/gmane.comp.security.openwall.john.user/7815
http://openwall.com/lists/john-users/2015/01/04/1
@frank-dittrich commented on GitHub (Jan 4, 2015):
BTW:
@magnumripper commented on GitHub (Jan 4, 2015):
Bull does not show this behavior. It's valid in c3.
@magnumripper commented on GitHub (Jan 4, 2015):
OK, man page says salt is a two-character string chosen from the set [a–zA–Z0–9./] (for DES). This means we can probably work around this issue.
@frank-dittrich commented on GitHub (Jan 5, 2015):
But there are "broken" descrypt implementations that accept other salts, e.g. implementations using password[0] and password[1] as the salt!
You can't just drop supporting these hashes if libc's crypt() accepts them.
I think Solar will have an opinion about how to handle this in core.
OTOH, there's another difference between what libc's crypt() accepts as valid and what th descrypt format accepts as valid (only 1 out of 4 hashes in a sequence, see my comment from 5 hours ago.
@jfoug commented on GitHub (Jan 5, 2015):
Well, just use libc in valid()
@frank-dittrich commented on GitHub (Jan 5, 2015):
valid() does use libc's crypt() (or crypt_r() for OMP builds), but it tries to remember whether libc supports a particular hash type and hash length, and reuse this informaton.
May be Solar wants to change this for all hash types and lengths, may be he just finds a workaround for what looks like descrypt hashes.
@frank-dittrich commented on GitHub (Jan 5, 2015):
On my system, libc's crypt() is broken because it accepts all of these 4 hashes as valid, while just one of them is:
But at least, all these 4 hashes have the same salt, so the overhead is not that bad, compared to the overhead of calling libc's crypt() instead of using --format=descrypt.
EDIT:
No, this is not libc's fault.
crypt format should reject 3 of these hashes without calling libc's crypt().
@magnumripper commented on GitHub (Jan 5, 2015):
Note though that the generic crypt format is for systems that implement something we do not (yet). Like (initially) sha2crypt or sunmd5. I'd be perfectly fine with just closing this issue with no fix. Actually I really think we should leave this alone until Solar fixes it in core (if he ever cares to). We can leave the issue open forever, that is fine. This problem is not a problem in real life, or even semi real life.
@jfoug commented on GitHub (Jan 9, 2015):
Here is one thing that 'appears' to fix it. NOTE, if there are many of these 'bad' DES crypts they will all output. BUT this stops dropping ALL of them.
NOTE, I am pretty sure that the other ones would also be a problem, IF we have the first one found, that is right length, right 3 byte signature, but FAILS in the test load (for whatever reason). I do not know if any others have failure points. Possibly they do for invalid characters, in the salt or hash.
I really think these should be ignored (possibly warned about), but the rest of the file processed. Just because 1 fails, does not mean all of them from that point on should fail.
However, this is Solar's format. I pretty much refuse to make too many 'core' changes to it. IMHO, this whole short circuit should be removed, and the warning output only done in -verb=2 or more (but that does not exist in core, grrr).
With the patch:
Without the patch
the in file is 1 bad line. 2 'good' lines, one I know the password for, and one I do not.
@frank-dittrich commented on GitHub (Jan 9, 2015):
May be we should just warn if someone attempts to use
--format=cryptfor descrypt hashes.For other algorithms this can make sense, either because the algorithm is not supported otherwise, or because --format=crypt allows longer passwords to be tested.
@jfoug commented on GitHub (Jan 9, 2015):
I agree with the warning. Having c3_fmt around on jumbo is rather pointless. Especially since the c3_fmt is 'not' dynamic, pulling hashes that exist on some obscure system and handling them. It will ONLY handle hashes that we have coded for. So it's usefulness is very dubious, other than in Core.
@frank-dittrich commented on GitHub (Jan 9, 2015):
No, c3_fmt is not pointless.
We do restrict max. password length for performance reasons, so you can use --format=crypt even if it is much slower.
But for descrypt this is definitely pointless.
@magnumripper commented on GitHub (Jan 9, 2015):
Not true. You can only benchmark it for formats we have prepared test vectors for but you can use it for any future format as long as you run it on a host that supports it.
@magnumripper commented on GitHub (Jan 9, 2015):
Not sure what Solar would say (and we are not required to listen to him at all times) but we could definitely have it default as disabled in john.conf
@jfoug commented on GitHub (Feb 2, 2015):
Part of the problem with disabling descrypt for C3, is that there are some OS's (psuedo OS, like cygwin), which do have 'crypt' format, but only have descrypt. So if it is disabled, we may get into situation where we 'think' we have a crypt format, BUT it can do nothing.
@jfoug commented on GitHub (Feb 2, 2015):
I believe this corrects this issue. We simply never 'fully' disable length 13 hashes, since they are in the ST code. This may make input loading slower, for a TON of 13 byte busted hashes. But the format will now work properly, IF there are busted ones in there.
We really should look at this disable code more closely. If we find a hash that is not workable by the crypt engine, and IF that format really is in valid input syntax, then we could disable. BUT if it is some invalid syntax, then we should be very careful about disabling all of that length.
8fb75ddI have not closed this issue. I am waiting on others testing and feel about this patch.
@magnumripper commented on GitHub (Feb 2, 2015):
I did not test it, but the approach sounds AOK to me.
@jfoug commented on GitHub (Feb 2, 2015):
All it really does is to not use the disabled flags for length 13. I really wonder about the disabled all the way around, but I guess if crypt only looks at
1and figures if it can process it or not, then the disabled is probably the way to go. It looks like 'some' crypt() put much more effort into validation of descrypt than other implementations. So that appears to be why this bug was seen in the first place.If you are happy, I think we can close this. Should we push the diff file up to Solar as an issue for core?
@magnumripper commented on GitHub (Feb 3, 2015):
As far as I can recall, Solar hasn't ever used a single line of code I wrote :-)
@frank-dittrich commented on GitHub (May 6, 2015):
Since my old john-users mail from January got no response, I tried with a john-dev mail:
http://openwall.com/lists/john-dev/2015/05/06/5
@marcosrjalves commented on GitHub (Aug 27, 2015):
Hello there! I'm having that kind of trouble too. When I try to use john with mpiexec (with a cluster) I got a similar error.
"Generic crypt(3) module: hash encoding string lenght 98, type id $6
appears to be unsupported on this system; will not load such hashes"
When I try to run the same command, but without mpiexec (using just the master pc of the cluster) it appears to work.
Can someone help me? Thanks?
@magnumripper commented on GitHub (Aug 27, 2015):
You don't need the generic crypt format, just use the optimized formats instead. The generic one was created for situations where your system supports some format that JtR does not support natively. Right now I'm not aware of any such format existing.
@marcosrjalves commented on GitHub (Aug 27, 2015):
Which format can I use? I'm just doing some tests with john and the cluster, trying to crack my own passwords.
The command line i'm using is this:
mpiexec -f hosts -np 12 /home/cluster/john/run/./john /home/cluster/passwords.txt -users=teste
It returned the same thing (Generic crypt(3))
If I try to run it without "mpiexec", it runs ok.
If I try another app with mpiexec, it runs ok too
If i try the "./john -test", it runs ok too....
Thanks for the help! :)
@magnumripper commented on GitHub (Aug 27, 2015):
If the hashes start with
$6$you should use-format:sha512crypt.@jfoug commented on GitHub (Aug 27, 2015):
He is running non-jumbo.
@magnumripper commented on GitHub (Aug 27, 2015):
Non-jumbo with MPI? That won't work out very well...
@jfoug commented on GitHub (Aug 27, 2015):
Then why is it picking crypt when
6is the signature ?@magnumripper commented on GitHub (Aug 27, 2015):
I guess you are right. Or he's running a version of Jumbo older than my wife.
@marcosrjalves commented on GitHub (Aug 28, 2015):
Thanks magnumripper... i'll try that...
I'm running jumbo, ..1.7.9
Well.. thanks for the help!
:)
@magnumripper commented on GitHub (Aug 28, 2015):
That version is ancient and this bug tracker is the wrong forum for discussing this.