mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #711] Implement Cisco type 8 (sha256) and 9 (scrypt) #356
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#356
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 @magnumripper on GitHub (Aug 12, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/711
Cisco type 9 is scrypt. I know nothing more but here's a sample (from CMIYC):
$9$cvWdfQlRRDKq/U$VFTPha5VHTCbSgSUAo.nPoh50ZiXOw1zmljEjXkaq1gPlaintext is
123456Base64 charset is likely same as Cisco type 4.
@jfoug commented on GitHub (Nov 1, 2014):
from http://www.cisco.com/c/en/us/td/docs/ios-xml/ios/security/d1/sec-d1-cr-book/sec-cr-e1.html
so
$9$nhEmQVczB7dqsO$X.HsgL6x1il0RxkOSSvyQYwucySCt7qFm4v7pqCxkKMis another example with plaintextcisco(NOTE, prior plaintext of secret was WRONG, it is cisco)@jfoug commented on GitHub (Nov 1, 2014):
hash cat has type 8 and 9 cisco hashes now: http://hashcat.net/forum/thread-3710.html
@jfoug commented on GitHub (Nov 3, 2014):
I think type 8 is 80 bit salt, 1000 iteration pbkdf2-hmac-sha256. I have been trying to get it to work in pass_gen, but have not gotten it yet. I was easily able to get cisco4 working, so I was hoping for ease on the type 8. No go so far. The salt is 14 bytes, which 'could' give 80 bits if the 14th byte was always one of the first 4 base-64 values. It is not. So it looks like you get 84 bits of salt? I am not quite sure what to do with that. I have tried 3 different things for salts. full raw 14 bytes, truncated to 80 bits (after base-64 decode), and 88 bits (padding with 0 bits). I have tried 64 to 50k (step 64) and 100 to 50k step 100 iterations for all of them. Nothing lines up yet. I sent an email to Atom, asking if he would point me in the right direction.
I also thought the last 4 bits might be 1<<bits. The value I am seeing is 0xA (10), so 2<<10 is 2048. That sounds like a normal iteration count, BUT that was one of them I tried (and did not get a match).
@jfoug commented on GitHub (Nov 3, 2014):
More examples: hashcat plaintext
$8$TnGX/fE4KGHOVU$pEhnEvxrvaynpi8j4f.EMHr6M.FzU8xnZnBr/tJdFWk
$9$2MJBozw/9R3UsU$2lFhcKvpghcyw8deP25GOfyZaagyUOGBymkryvOdfo6
@jfoug commented on GitHub (Nov 3, 2014):
This reply came from atom:
So hashcat will publish at some time. I have tried about all I can (withing pass_gen). I even fell back and tried the interleaved bytes, like cryptmd5. That did not help either. I am sure it is encoding problems, I just do not know how to do it yet.
@frank-dittrich commented on GitHub (Nov 3, 2014):
https://hashcat.net/forum/thread-3803-post-21661.html#pid21661
@jfoug commented on GitHub (Nov 3, 2014):
Finally got things working. Problem I was having was the wrong plaintext (cisco and not secret)
@jfoug commented on GitHub (Nov 3, 2014):
here is pass_gen on cisco8
@jfoug commented on GitHub (Nov 3, 2014):
Got cisco9 working also
@jfoug commented on GitHub (Nov 3, 2014):
I have made changes to pbkdf2_hmac_sha256_fmt.c (and base64,[ch]) to allow cisco8 to work. Pretty trivial. Just a small change to valid, a prepare (to convert from
8to cannonical), a change to get_salt, and 2 conversion functions in base-64.46869acAdds cisco8 to CPU side. GPU should be similar trivial to add.e1908adAdds cisco8 to GPU (fixes a static missed on prepare on CPU side)@magnumripper commented on GitHub (Nov 3, 2014):
Good stuff. Makes me want #816 again. Do you have any idea how to fix that one in a KISS matter?
@jfoug commented on GitHub (Nov 3, 2014):
I do not follow how #816 relates to this change.
Also, I am not 100% sure that cisco9 would fit into any of our existing scrypt formats, due to too many nuanced differences. I am not 100% sure that the way I did it is absolutely the best. I make an assumption, that a 20k iteration, 14 char salt is a cisco8 that has been prepared.
@magnumripper commented on GitHub (Nov 4, 2014):
For benchmarking the new test vectors, you'd run eg.
./john -test -format:pbkdf2-hmac-sha256 -cost=20000@magnumripper commented on GitHub (Nov 4, 2014):
Build bots alerted me of a segfault:
https://travis-ci.org/magnumripper/JohnTheRipper/builds
@jfoug commented on GitHub (Nov 4, 2014):
$ ../run/john -test -form=pbkdf2-hmac-sha256
Will run 4 OpenMP threads
Benchmarking: PBKDF2-HMAC-SHA256, rounds=12000 [PBKDF2-SHA256 128/128 XOP 4x]... (4xOMP) DONE
Raw: 814 c/s real, 206 c/s virtual
I also ran a
make checkand it processed with zero problems.@jfoug commented on GitHub (Nov 4, 2014):
I have just tested with linux64, and same result (works fine, pass). does this also do a make clean or start in a clean dir ?
The first time it failed, the clang build was fine, only the gcc failed. From that point on ,both fail. I am seeing NO failures, so can not replicate teh problem.
@frank-dittrich commented on GitHub (Nov 4, 2014):
@magnumripper
I wanted to have a look, but so far I just didn't have enough time.
@jfoug commented on GitHub (Nov 4, 2014):
@magnumripper can we do a make clean on travis ?
@magnumripper commented on GitHub (Nov 4, 2014):
They are virtual machines always starting from scratch. They even install libssl-dev and other things, each and every time.
@magnumripper commented on GitHub (Nov 4, 2014):
I too have yet to reproduce the Travis problem. I have tried to understand what difference there is. I see they use XOP, I'm not. Other than that, I run the same SSE_PARA, OMP_NUM_THREADS and so on.
@magnumripper commented on GitHub (Nov 4, 2014):
Oh, and I see you run XOP. So what could it be? Theoretically it could be a bug in the bot or the virtual hardware but I do not think so.
@magnumripper commented on GitHub (Nov 4, 2014):
I did add a make clean just to be 100.0% sure, but it did not help.
@magnumripper commented on GitHub (Nov 4, 2014):
Also, as you probably did yourself, I have audited your changes and I really can't see any problem.
@frank-dittrich commented on GitHub (Nov 4, 2014):
Which was the last commit that was successfully built by Travis? Apparently
github.com/magnumripper/JohnTheRipper@b309863b2b.Jim could revert all recent changes in a local repository and create a dummy pull request, just to check whether Travis builds that successfully?
(I'm too tired right now, so I'll probably fail even with such a simple task.)
If Travis can't build a version anymore that is the same as
github.com/magnumripper/JohnTheRipper@b309863b2b, then we know it is not our fault and can submit a bug report to Travis...@magnumripper commented on GitHub (Nov 4, 2014):
I can reproduce now. Fixed soon.
@jfoug commented on GitHub (Nov 4, 2014):
What did you do to reproduce? I am curious since I have run this on 4 OS's, 32 and 64 bit, and it is happy to run. I have also done tests (not just -test), finding passwords. It is happy to work for me, everywehere I tried it EXCEPT travis.
@magnumripper commented on GitHub (Nov 4, 2014):
Compiler version dependant. I get it with clang, or eg. gcc 4.6.3. In the latter case it vanishes when I compile with -O0 :-(
@magnumripper commented on GitHub (Nov 4, 2014):
Unfortunately I do not have Valgrind available atm. Trying to understand what happens.
This will be totally arch & compiler dependant but the first time I hit these lines in prepare():
Buf is already 0x04 (the pointer was overwritten prior to this).
@frank-dittrich commented on GitHub (Nov 4, 2014):
Can you make
gcc --versionandclang --versionpart of the Travis builds?@jfoug commented on GitHub (Nov 4, 2014):
I am hoping this may fix it
9a204b6If so, then I will get this into opencl version
@jfoug commented on GitHub (Nov 4, 2014):
Nope, no fix. I can see NO reason that var gets overwritten.
@jfoug commented on GitHub (Nov 4, 2014):
If my last change does not work, we might want to simply drop the static pointer and replace it with a static buffer BUT I would like to find out WHY this is failing. THERE HAS TO BE a overwrite somewhere. I simply can not see it.
@jfoug commented on GitHub (Nov 4, 2014):
I am done poking the hornet nest. @magnumripper you might try this prepare:
NOTE, this still does not show us where the overwrite is happening at.
@magnumripper commented on GitHub (Nov 4, 2014):
I have nailed it and I'm testing a canonical fix.
@jfoug commented on GitHub (Nov 4, 2014):
I am really interested in this fix. It escapes me. I just do not see the bug.
@magnumripper commented on GitHub (Nov 4, 2014):
I thought I had it but it still escapes me. I set a hardware breakpoint on that static variable so I know the overwrite happens during base64_decode() but I am not sure why yet.
For a while I was sure the problem was that crypt64_to_mime64() does not add MIME "=" padding but that was not it. It's taken care of elsewhere.
Actually the bug might well be prior to your Cisco changes (and just triggered by them): If I drop all test vectors but the Cisco ones, problem goes away!
@magnumripper commented on GitHub (Nov 4, 2014):
Please do not commit anything unless you are SURE you have found a specific bug. You might end up just hiding the bug and we do NOT want that!!
@magnumripper commented on GitHub (Nov 4, 2014):
Aw man, this was a lot easier than we thought:
base64_decode() added a null termination beyond BINARY_SIZE
@magnumripper commented on GitHub (Nov 4, 2014):
And yes, this is an OLD bug. This overwrite happened with the very first test vector!
@magnumripper commented on GitHub (Nov 4, 2014):
Travis is good
@magnumripper commented on GitHub (Nov 4, 2014):
Reopen for cisco9
@kholia commented on GitHub (Nov 5, 2014):
Why does this looks very familiar?
This is why my buffers have weird sizes when I do base64 decoding ;)
@magnumripper commented on GitHub (Nov 5, 2014):
I overhauled every format that included base64.h in
c4574d0. I might have added some redundant extra but many of them had this bug for sure. Also, many formats included base64.h although they did not need to.@frank-dittrich commented on GitHub (Nov 5, 2014):
Wouldn't it be better to adjust the definition of
BINARY_SIZEinstead of usingBINARY_SIZE + 1and define a BINARY_SIZE for formats that don't have thist definition?@magnumripper commented on GitHub (Nov 5, 2014):
No, because BINARY_SIZE is reported to core. Core will copy that many bytes to an aligned buffer in the db.
Imagine loading a million hashes with BINARY_SIZE of 33 and BINARY_ALIGN of 4. Thats a lot of wasted memory and cache.
@jfoug commented on GitHub (Nov 6, 2014):
Got cisco9. It is in scrypt_fmt.c Simple EXCEPT for that DAMN CRAPPY base-64 stuff.
@jfoug commented on GitHub (Nov 6, 2014):
Cisco9:
7216d2cWe could probably also handle django in prepare() also, since it really is only the way N/r/p are in the salt, and the base-64 encoding. Yes, all 3 scrypts use DIFFERENT base-64, hence why I DESPISE that encoding method
@videgro commented on GitHub (Jun 17, 2017):
I would like to inform you that I used the discussion in this issue to make a Java implementation of the Type 8 and Type 9 hash calculations. Thanks!
See: https://github.com/videgro/cisco-password-hashes