Closed jfoug closed 10 years ago
This comment brought over from a comment on thread #434
I added a dump_stuff to the end of rar's get_salt, and it appears the get_salt is only being called 5 times, so there is some other dupe removal logic that is also working. Rar 'appears' to have the same issue, where it if the same salt was given to rar multiple times, that it would have multiple salts (all the same). BUT jtr is only giving rar the proper amount, but pkzip (from a --list=format-tests replicated 4 times), gets 4x as many salts.
$ ../run/john -form=rar ../in2 -w=../pw
b109105f 5fe0b899 00000000 1c721980 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
42ff7e92 f24fb2f8 00000000 e8721980 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
56ce6de6 ddee17fb 00000000 b0731980 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
c47c5bef 0bbd1e98 01000000 78741980 965f1453 00000000 30000000 00000000 2f000000 00000000 00000000 00000000 30000000 00000000
b4eee1a4 8dc95d12 01000000 b4751980 69a0ebac 00000000 40000000 00000000 2f000000 00000000 00000000 00000000 33000000 00000000
Loaded 5 password hashes with 5 different salts (rar, RAR3 [SHA1 AES 32/32])
No password hashes left to crack (see FAQ)
This 'might' be a PEBCAK, I need to look more. I can not get pkzip format to salt fail now.
nope, certainly not PEBCAK.
Loaded 50 password hashes with 50 different salts (PKZIP [32/32])
Should be 10 of them (10 hashes, file concatenated 5 times).
I just tested rar format (against bug #692) and it appears to be getting 'native' JtR salt dupe removal. Yes, I see that it simply stores the pointer. NOTE, the pointer is pretty deep into the structure. Possibly dupe removal logic only checks so much of the salt, to see if it is a dupe? That in itself 'could' be a bug.
RAR has a cludge in cracker.c line 174. It sets a special "pot check salt size" to a lot lower than the real size. Actually it sets it so the REAL salt is checked but not the pointers and other stuff.
RAR has a cludge in cracker.c line 174. It sets a special "pot check salt size" to a lot lower than the real size.
I really dislike changing core functionality if at all possible, but we could add support for this in the format struct. Drop that cludge and announce two salt sizes - one for compare sizeof(saltstruct.salt)
and one for salt buffer copy sizeof(saltstruct)
(assuming the .salt member comes first in the struct). Normal formats would have them the same size.
For some formats that would be wonderful. 'most' probably should check the entire salt size. But some (whihc may allocate a buffer and store a unique pointer which of itself is NOT something that can be compared), BUT which does not play into the salt itself, this would be a benefit.
Ok, by what I saw, I would have assumed rar would FAIL dupe salt removal but it worked. Now that you state rar has 'unique help' in core to do this, it makes sense.
Yes, 2 salt sizes (which default to == to each other) might be something helpful for many formats, which need to allocate something to be 'used' but which is not really 'part' of the salt. IT would also allow a lot more pre-computation of 'crap', BUT not have that affect salt dupe removal, as long as it is at the tail end of the salt record, 'after' the part checked. This is not a trivial design issue, and one that developers would have to understand, BUT it is a very useful addition if used properly. My vote is to add this type enhancement.
As long as we discuss this on john-dev prior to implementing it, I could live with the core change.
Issue posted to john-dev. Also while typing that email, a (better) thought popped into my head. Instead of having 2 salt lengths, and keeping a dumb comparator WITHIN john core, why not simply make a 'smart' comparator, by making a salt_equal() method??? That way, the format (which KNOWS it's internal structure), could be in charge of saying, yes this is the same, or no something is different....... The fmt_default_salt_equal() is trivial also. It simply keeps the existing code from today, doing the memcmp call.
For formats that store pointers due to variable sized data, having the format do the compare allow it to simply compare the contents of what those pointers are referencing, vs simply skipping them because the actual bytes that make up the pointer(s) themselves are of no value. Also, the format would 'know' that some data may actually NOT be of any comparator value, but was for instance some pre-computed data. A dumb memcmp would not know this, but the format author would (should).
Got a script to test, and here are some 'results', showing the zip problems (script named tst, and I run in dir above jtr's run folder)
#!/bin/sh
CNT=`run/john --list=format-tests -format=$1 | wc -l`
TOT=`expr $SSS \* 5`
run/john --list=format-tests -format=$1 | cut -f 3 > in2
run/john --list=format-tests -format=$1 | cut -f 3 >> in2
run/john --list=format-tests -format=$1 | cut -f 3 >> in2
run/john --list=format-tests -format=$1 | cut -f 3 >> in2
run/john --list=format-tests -format=$1 | cut -f 3 >> in2
echo there are $CNT tests for a total of $TOT. Any salt count more than $CNT is wrong.
echo
run/john -format=$1 in2 --max-run=1
# end of script
$ ./tst zip there are 2 tests for a total of 10. Any salt count more than 2 is wrong.
Loaded 10 password hashes with 10 different salts (ZIP, WinZip [PBKDF2-SHA1 8x SSE2]) Note: This format may emit false positives, so it will keep trying even after finding a possible candidate. Press 'q' or Ctrl-C to abort, almost any other key for status 0g 0:00:00:01 2/3 0g/s 0p/s 3143c/s 3143C/s 123456..bigben Session stopped (max run-time reached)
Now to just make a for loop to do this, and then look over the resultant output for issues like seen above.
NOTE, if you add a -w=pw (and have a pw file) to the actual john test of the input 2, then zip (and many others) does salt dupe removal correctly ?!?!?!
Changed script to this: run/john -format=$1 in2 --max-run=1 -w=pw
Now ./tst zip
Testing 'zip' format 2 salts (or less) should be seen Loaded 2 password hashes with 2 different salts (ZIP, WinZip [PBKDF2-SHA1 8x SSE2]) Note: This format may emit false positives, so it will keep trying even after finding a possible candidate. Press 'q' or Ctrl-C to abort, almost any other key for status 0g 0:00:00:00 DONE (2014-07-05 08:30) 0g/s 62.50p/s 125.0c/s 125.0C/s x Session completed
So here, we can see that there are only 2 (the correct) hashes being tested. I am getting more and more confused with this.......
Oh you must not run batch mode because the dupe rejection is disabled for Single mode!
why is dupe removal removed for single mode?? This may be the entire issue I am having. If the -w=xxx flag is used, I think all formats are salt deduping (I still need to check things closely). Why on earth would we remove dupe detection?
Because if you remove a dupe hash you will lose username and GECOS information. Single mode is all about using username and GECOS fields. This is a core thing. Dupe hashes are same salt anyway so "no" speed is lost.
I am back to thinking this may be a PEBCAK, and the dupe problem is mostly in the 'if run in single mode'. I have not tested dyna yet, but I see no issues with other formats as long as they are in wordlist mode, or something other than single mode, it seems. I still think salt dupe removal SHOULD be part of single mode. Yes, you may not want to drop candidates, BUT duplicate salts should be dropped. Take for example 2 hashes, but duplicated in a file 1 million times. Even in single mode, that would crawl, 1 million times slower than it should, along with gaining no information.
Sure but that is a pretty extreme example. In real world use you'd have a couple of dupe NT hashes which were unsalted anyway. And above all, they share the same bitmap. I do not wish to poke around with Single mode, that is a core thing we should leave as-is IMHO.
For salted formats in real life, any dupe passwords are likely to have different salts.
BTW I'm not even sure they are not actually removed. It may be just that the figures shown doesn't account for removed hashes because they are still "used" in terms of GECOS etc.
But this is mostly a john-dev discussion with Solar as the only one who actually knows.
I too think this was a pebcak. The only formats I know of that may have the issue are rar and latest zip, and both now have cludges.
We should look for salted formats that do not remove dupe salts properly.
To do this, we can take a set of X unique salts. Dupe the file 5 times, run it and make sure that jtr ONLY sees X salts and not 5X, or any value > X. I know frank recently did some testing on the --list=format-tests Was this behavior 'looked' for when testing. In other words, if there were 4 unique salts, but 16 lines in the input file, are we sure that jtr only displays 4 salts?
I do not have time to do all of this myself, it was just something I thought about, when working on the new zip2 format. This can happen if a format designs a salt in a manner that an exact bit by bit salt value is returned for any identical hash. We did catch some cannonical failures, but did we catch all ?
NOPE. I just tested with pkzip (a format I was pretty sure does not do salt dupe removal properly). --list=format=tests returns 10 lines, but there are 9 hashes (one is a dupe). JtR shows 10 salts. I duplicated the file data 4 times, and it lists 40 salts. So pkzip format needs salt_dup fixed. Can someone carry this forward and at least list which formats are NOT properly salt dupe detecting. When you find Update findings in this message (both proper working and failures, so we known when we have covered them all). Also, could the logic be different on different builds (64 bit vs 32, SIMD vs non, etc? I do not have this answer).
Format's dupe salt removal logic: