mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #1631] Add FMT_UTF16 format flag #1078
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#1078
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 9, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1631
This flag indicates that set_key() is to take a
UTF32*UTF16*instead of achar*pointer to key. Formats like NT and Oracle will set it.For eg. Incremental mode using UTF-32 internally, this means we don't have to go through (slow) UTF-8 conversion just to satisfy the legacy set_key() prototype.
@magnumripper commented on GitHub (Aug 9, 2015):
See ML discussion: http://www.openwall.com/lists/john-dev/2015/08/09/4
@jfoug commented on GitHub (Aug 9, 2015):
I thought everything in jtr was UTF-16 (actually UCS2 in many places). Why the UTF-32 ?
@magnumripper commented on GitHub (Aug 9, 2015):
UTF-32 is the only sane choice. We definitely don't want to handle UTF-16 surrogates within incremental or rules, that's almost as bad as actually processing UTF-8.
The UTF-32 -> UTF-16 conversion (eg. in NT format) will be very easy and very fast. If we (optionally) just support UCS-2 for speed, it's merely an int->short downcast similar to the original char->short upcast in speed.
@frank-dittrich commented on GitHub (Aug 10, 2015):
Word lists which mostly contain ascii would also get 4 times as large
instead of just 2 times.
@jfoug commented on GitHub (Aug 10, 2015):
Only internally within the memory footprint of john. The external file would be the same.
I am still not 100% sold on everything runs as UTF-32. I find that to be wasteful overkill if the file really is just ascii 7 bit, or 99% ascii 7bit.
@magnumripper commented on GitHub (Aug 11, 2015):
We could try to fit both 32-bit and 8-bit code in there simultaneously but it will be significantly harder and a LOT messier. I think the current code stretches the "don't go 32-bit" as far as sensible but the next step is to bite the bullet and go all in.
@jfoug commented on GitHub (Aug 11, 2015):
We will still need some of the code page support, but hopefully it will be far less encompassing, and will be localized in the code for wordlist.c or loader. We will only need to have character mapping. NOT any of the classification / or casing logic. But adding mapping may be VERY easy, at least for code pages in perl. Here is some code I did to grab the utf8 bytes from code pages supported by perl.
and here are 'most' of the code pages handled by Perl (including epsidic, which are a bit ugly since \n is not where you think it should be, lol)
@magnumripper commented on GitHub (Aug 11, 2015):
I'm not quite following what you did with that perl script.
The code page support will be needed for reading files, and for any target encoding used. Example
UTF-8 wordlist -> rules -> filters -> crk_set_key() -> LM format set_key() (using cp)
The UTF-8 will be converted to UTF-32 in wordlist.c, then stay UTF-32 all the way until cracker.c is about to call format's set_key(). Just before that, it needs to convert to eg. CP850. Note that in this very case, the current code is probably much more efficient.
@frank-dittrich commented on GitHub (Aug 11, 2015):
We have to handle the case that the target code page doesn't include characters that might be read from a wordlist. OTOH, we do have that problem right now as well. How is that handled?
@magnumripper commented on GitHub (Aug 11, 2015):
That is an issue now and will be no matter how we re-write this. It does, and always will, result in garbage candidates.
If we at all support reading non-UTF-8 wordlists, the same applies there: What if it's written in a non-supported codepage like ArmSCII-8? Like today, we'd need to run transparent. A sensible way of handling it would be "convert assuming ISO-8859-1", "process as ASCII" [i.e. ignore non-ASCII when case-toggling and so on] and "convert back assuming ISO-8859-1". This will work pretty much the same as current
-enc=rawI think.@jfoug commented on GitHub (Aug 11, 2015):
?? I would think forcing users to use iconv to put their wordlists into utf8 would be one option, but I bet users would NOT like that much. The main problem is 'shit' wordlists, that are a hodge podge of mixed character sets. Those dirty wordlists still abound around the net, and people like to use them. Yes, if every word in there was properly converted to utf8, then wow, it would be SO much better. But how do we help get from point dirty to point utf8 clean ? Or do we simply not care, and tell users that the word lists need to be in utf8 so there is no ambiguity within JtR?
@magnumripper commented on GitHub (Aug 11, 2015):
I think we should support it, but we could opt to not supporting it.
For mixed-encodings wordlists, that "transparent mode" concept is mandatory. However, it won't work well for Unicode hashes like NT. I never has and never will, in any cracker - it simply can't.
BTW a problem with "transparent mode" is your pot file entries will not be UTF-8. Ideally we should have a field in the .pot file stating this is the case, and for such entries -show would print eg.
Administrator:M.ller [4d 81 6c 6c 65 72]That's "Müller" in CP850.
@magnumripper commented on GitHub (Aug 11, 2015):
I'm digressing now, but ideally the pot file format would always be
That would work with tabs, colons and whatever, and with any encoding including transparent [== raw == unknown] encoding. It would always be totally reproducible.
@jfoug commented on GitHub (Aug 11, 2015):
We may want to have the .pot file enhanced if we allow anything OTHER than utf8 to be stored in it. The enhancement would be to somehow deliver across information about the encoding.
Lol, you beat me to the punch
@magnumripper commented on GitHub (Aug 11, 2015):
I have considered various ideas over time:
@jfoug commented on GitHub (Aug 11, 2015):
I actually REALLY like that .pot (.pv2 ?) file layout. It is absolutely concise. If we changed it to this:
hash : \t
V2\t encoding \t plain-in-hex : plainThen we would not have to change the .pot file at all. We could still read the legacy stuff, but if the line contains
V2as the found password, and has \tsome-valid-encoding\t following that, then we know this is a V2 line, and handle it appropriately and THEN the .pot file actually could have 'mixed' cp data, have the "REAL" data in the file, etc. Actually, would we really 'need' the plain-in-hex ?@magnumripper commented on GitHub (Aug 11, 2015):
For transparent mode, the plain hex is the only thing that will
everalways be proper.@jfoug commented on GitHub (Aug 11, 2015):
I would really poo-poo XML. Yes it you can do anything with it, BUT it is slow, and is a nightmare for stuff like this, where quoting will have to be done all over the place.
CSV is no better (we already are CSV, but with 2 fields, and the separator being the 'first' ':' seen on the line.
@magnumripper commented on GitHub (Aug 11, 2015):
Also, consider the case where a user fed a CP123 wordlist but stated CP234, and by coincidence some LM hashes was cracked. That plaintext-as-hex will show what was ACTUALLY the password, no matter the encoding, as recorded, was incorrect (and as a result, a Unicode print from -show will be incorrect too).
Yes, I hate XML. And the current format is just a variation of CSV.
@jfoug commented on GitHub (Aug 11, 2015):
Should these last few comments be moved to it's own topic, Possibly as an RFC type ?
@magnumripper commented on GitHub (Aug 11, 2015):
We should probably have discussed all this on john-dev instead...
@magnumripper commented on GitHub (Aug 11, 2015):
I wish john-dev was a web forum, with GitHub markup 😄
@jfoug commented on GitHub (Aug 11, 2015):
It is not bad to get things pie in the sky talked about offline, then bring to john-dev, but usually only crickets chirp there.
@jfoug commented on GitHub (Aug 11, 2015):
I hate the email lists. So difficult to find anything. Yes, the github is also a cluster, trying to find old stuff, BUT for doing 'hot in the trenches' stuff, it makes following along very easy
@magnumripper commented on GitHub (Aug 11, 2015):
This new flag should be named FMT_UTF32 and not only
set_key()should be affected but alsoget_key().@magnumripper commented on GitHub (Aug 11, 2015):
I think this also obsoletes both FMT_UNICODE and FMT_UTF8 flags.
@magnumripper commented on GitHub (Aug 12, 2015):
So, if set_key can be either of
and
What is the canonical way to declare it? I see at least two solutions. One is to declare it as void pointer in formats.h:
and the other is to actually add a function to the struct,
If we go with the latter, any format will probably have one of them as NULL and the other one defined. Actually that would mean we don't strictly need the FMT_UTF32 flag, we could just test if
fmt->methods.set_key32is NULL or not.@magnumripper commented on GitHub (Aug 12, 2015):
On a second thought: With the proposed changes, we'd detect in cracker.c that the target encoding can't hold the needed characters - so we could reject the candidate and never send it to the format. This is a good thing.
@jfoug commented on GitHub (Aug 12, 2015):
I think we need to step back a bit. We might want to totally relook at the interface. It may be time to provide an interface that the conversion code dumps data right into the key space (on set_key). Get_key IMHO is not hot code. Finding a crack is NOT expected, it is an exception. But setting keys IS hot code.
Switch to a real language 😈 where issues like this are simply handled by the compiler.
@jfoug commented on GitHub (Aug 12, 2015):
For example:
within converter (that marshals data from the crack type into the format), the format during init() would simply make 'setter' type calls into the converter, providing it with all the information that is required to properly load the data (number of buffers, layout of buffers, size of buffers, byte ordering of buffers, whether to MD the buffers, provided alignment, buffer cleaning required, etc). We would likely have to still provide the existing interface, where 1 word at a time is sent to the format to have it load into its memory layout, for formats which have complex (or extremely simple) data layouts. Formats that simply work on a single password at a time, could likely keep the existing naive setkey() layout.
@magnumripper commented on GitHub (Aug 12, 2015):
No but it's logical to return a key in same format you got it. And it simplifies format code, the conversion back to UTF-8 would be in cracker.c instead of duplicated in all Unicode formats.
@magnumripper commented on GitHub (Aug 12, 2015):
BTW for putting code where most effective, we should actually have it as FMT_UTF16. This means set_key() and get_key() will set/get UTF-16 with surrogates - BUT all of core should still have it as UTF-32. This will mean really simple code in formats.
On another note, while doing all this we'll ensure the key delivered from cracker.c is aligned properly for any use (ie. aligned to 8) no matter if it's char* or UTF16*.
@magnumripper commented on GitHub (Aug 12, 2015):
Real code don't need a compiler, only an assembler 😈
@frank-dittrich commented on GitHub (Aug 12, 2015):
Why an assembler? http://www.catb.org/jargon/html/story-of-mel.html