mirror of
https://github.com/openwall/john.git
synced 2026-12-03 20:43:49 +07:00
[GH-ISSUE #2261] Format as400-ssha1 has max. password length of 90, dynamic_1590 uses 125 #1515
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#1515
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 (Sep 5, 2016).
Original GitHub issue: https://github.com/openwall/john/issues/2261
Which one is correct?
Is that limit of 90 the max. AS/400 password length in bytes, or is it in characters and will be larger if passwords with non-ASCII characters in UTF-8 are used?
If AS/400 only supports 90, can dynamic_1590 be adjusted? Should dynamic_1590 it be adjusted, or should it keep 125, just in case the same algorithm is used somewhere else?
@magnumripper commented on GitHub (Sep 7, 2016):
The max is 128 (depending on settings):
https://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm?info/rzakz/rzakzqpwdmaxlen.htm
https://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm?info/rzakz/rzakzpasswordoverview.htm
@jfoug commented on GitHub (Sep 13, 2016):
I am not sure where the 125 'comes' from. Dyna, by default tries to stay to 110 bytes 'max' length for password and salt. Since this format has a fixed 20 byte size. That is why as400-ssha1 is showing 90 bytes (and actually the 'right' value for dynamic).
Now, since this is unicode, the 125 max length listed in dyna_1590, there is NO way it will work. So that has to be looked at (along with other unicode dyna formats).
@jfoug commented on GitHub (Sep 13, 2016):
I see several dynamic formats with 125 byte max length (1032, 1033, 1400, 1507, 1590 and as400-ssha1 if you list all details for -form=dynamic). There should be no formats with length that long. There is a bug somewhere.
So all of them are sha1 with utf16 So likely there is something with 1 or the other of those characteristics.
@jfoug commented on GitHub (Sep 13, 2016):
We have this logic. I think this is very wrong
@magnumripper commented on GitHub (Sep 13, 2016):
Most UTF-16 formats has something like this in init
What is wrong with that?
@magnumripper commented on GitHub (Sep 13, 2016):
Hmm in that dynamic snippet I guess the "else" should be removed?
@jfoug commented on GitHub (Sep 13, 2016):
dyna is different. There are several fixed limits, AND it is much more difficult to put the 'real' logic in needed to provide buffers that are TOO large, to later properly convert and see if things fit.
@jfoug commented on GitHub (Sep 13, 2016):
no the else copies the 'prototype data into the runtime object. That else block simply says that what was compiled is what should be used.
@jfoug commented on GitHub (Sep 13, 2016):
I have to think about this one a bit. There are no buffer overflow checks. That was all being done with plaintext-length being done properly.
@magnumripper commented on GitHub (Sep 13, 2016):
The actual limit is the UTF-16 buffer, no? If it can hold
ncharacters of UTF-16, theMIN(125, 3 * n)logic should be correct.@jfoug commented on GitHub (Sep 13, 2016):
because, we can have plaintexts that end up being 256 bytes. That IS the buffer size for dyna. ALso, if this is anything other than a 'raw' format, then there will 100% be overflows.
@magnumripper commented on GitHub (Sep 13, 2016):
Yes but if the Unicode '3xsize' was applied, the resulting bigger number is never "used"? But I'm not seeing all code here.
@jfoug commented on GitHub (Sep 13, 2016):
Those lengths
min(125,3*n)is ONLY correct if there is additional logic that at run time converts and counts utf characters. Dyna has nothing like that, nor no way to really do that at all.@jfoug commented on GitHub (Sep 13, 2016):
John talks in bytes. So if 125 bytes of ASCII data are provided, at runtime that will balloon to 256 bytes. Hence the problem.
@magnumripper commented on GitHub (Sep 13, 2016):
Yes but all UTF-16 formats has logic for truncating in set_key simply because that's the only place we can know. I'm pretty sure dyna has (had) that logic too.
@jfoug commented on GitHub (Sep 13, 2016):
Not dyna. Dyna has NO idea what extra logic will get done. Trust me, it is NOT a garden variety format, it has some constraints put on just what can be done. There is no way it can protect itself with overflows, other than to get the text lengths 'right'.
@magnumripper commented on GitHub (Sep 13, 2016):
Actually the same goes for the other formats. NT can take 27 characters of UTF-16. If running UTF-8 we announce a maxlen of 81. However, if fed eg. 81 bytes of ASCII, set-key will truncate that to 27 characters - and ensure get_key will return the same truncated plain.
@jfoug commented on GitHub (Sep 13, 2016):
ok, try to figure the length out for:
and do that generically within set key, and do that all without slowing down the format. It simply can not be done.
@magnumripper commented on GitHub (Sep 13, 2016):
Well dyna has things like this
just like the other formats (that was __append_string() but similar code is all over the place)
@jfoug commented on GitHub (Sep 13, 2016):
Right now, the way the code is written, I can not even 'force' a plain text length, if I know the max. NOTE, if the user does provide 3 byte utf-8 input, then dyna will only be able to do 1/3 the length that it possibly could do, BECAUSE it has to be able to handle the worst case situation (which is the most common), which is pure ASCII data.
@magnumripper commented on GitHub (Sep 13, 2016):
That may be true for some formats, like dynamic compiler or whatever. But it's not generally true. You are saying that dynamic_33 can only do a max of 9 in UTF-8 mode? That is simply not true. It announces 81 and can handle up to 27 characters just like the plain NT formats.
@jfoug commented on GitHub (Sep 13, 2016):
That was due to putting in special code just for that format. I avoid specialization as much as possible. I need to dig deep into dyna, and will do so just to make sure things are being handled.
@jfoug commented on GitHub (Sep 14, 2016):
Ok, I made some changes to dyna (not checked in, still testing), removing that *=3 and /=3 crap. This is just with ascii values. I will retest with 2byte utf-8 and 3byte utf-8 dictionary, to see just where we are at. I was almost 100% sure that 90 characters were going to be correct, and they were. There is a LOT of code in dyna that limits the password (and salt) to 110 characters. That would be either 110 characters OR 110 utf16 characters (this was the reason for 110, they both 'fit' into the 2 limb 64 bit MD hash buffers, which is the MAX we can use in a generic manner.
Note, this was with ascii. I will repost with the 2 and 3 character utf-8 wordlists.
@jfoug commented on GitHub (Sep 14, 2016):
Ok, in 'current' form, here is what the utf8 dictionaries do for dyna. NOTE, this is 90 'text' characters, not 90 utf8-characters. So I do need to see why this is happening. BUT this may be done this way to 'guard' dyna, but is done wrong.
@jfoug commented on GitHub (Sep 14, 2016):
Ok, I have made a couple changes, and I think this is the best that can get in dynamic, due to dynamic constraints (110 characters) and overall john constraints (125 bytes).
All of these for dyna_1590 (the unicode as400-ssha1)
ascii was 90, still 90
utf8-2 was 45, now 62 (trunc: 1/2 of 125)
utf8-3 was 30, now 41 (trunc: 1/3 of 125)
I believe this is the 'best' we can do. So knowing the 'exact' length of a password for these type formats in dyna will be nuanced. It is a combination of 110 bytes vs the number of characters that can be produced with that. Also, salt it taken into account, and word+salt can not be > 110 characters (if 'auto-detect length logic used).
There will still be issues that we need to address. There will likely need to be a 'new' length, that is max characters for password. Up to this point, almost all computations have been max bytes, BUT it has been used for both bytes and characters. Up to this point, it has 'worked', and not bitten us. But I think we may need to address the distinction.
@jfoug commented on GitHub (Sep 14, 2016):
Ok, here is where the problem comes in. Using the ascii only dictionary. 1 to 140 byte passwords, shuffled around randomly. This is the same run that if -enc:utf8 is NOT used, gets 1500 until 90 byte max input. So something is being overwritten, or something is being truncated. I think dynamic is 'safe' for true data in ascii format, OR in utf8 encoding (as long as the -enc:utf8 is used) BUT if we have characters that are not multi-byte, then we either get overflow or truncations even when the code 'should' work.
@jfoug commented on GitHub (Sep 14, 2016):
I am almost 100% sure that we have an overwrite problem. I did dynamic_1590_ascii_dic_80.in with -enc:utf8 and got 1354 found. re-running against same pot (with same input dict file), and it still shows the 146 uncracked hashes, but nothing new cracks. If pulled 1 unfound hash out and made a dic file of just the correct value, it cracks just fine. If I shuffle the ascii.dic file, then I found 129 of them. Rerunning finds no more. If I shuffle that dic, and re-run, I find 15, etc.
So there is something getting overwritten, not properly cleaned, etc.
(PS, Have I ever mentioned that I hate dynamic when it does not go right, lol)
@jfoug commented on GitHub (Sep 25, 2016):
Ok, back to original question:
The max length password the format will handle is 90 bytes (actually 90 2 byte unicode characters). However, the format accepts data up to 125 bytes. This is so that inputs which are entirely made up of 2 byte utf8, will handle up to 62 unicode characters (max that fits in 125 bytes). If the input line is made up entirely of 3 byte utf8, then 41 unicode characters will be the max length we can have. If the input is a mix of ascii, unt8 (2 and 3 byte chars), then the max sized data the format can handle will be the minimum of 90 unicode chars, or the number of unicode chars that are in the 125 bytes of data.
The dynamic format is working properly now, no overwrites. All data in the TS is working properly, as it should.