mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #2105] new command line switch to provide a rule to be run (RFC) #1408
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#1408
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 @jfoug on GitHub (Mar 29, 2016).
Original GitHub issue: https://github.com/openwall/john/issues/2105
I was wondering if there is interest or 'need' for adding a command line option to allow a rule to be provided on command line (like mask is) ?
@magnumripper commented on GitHub (Mar 30, 2016):
I have wanted it at times but I also agree with @solardiz we generally bloat Jumbo too much.
@jfoug commented on GitHub (Mar 30, 2016):
Agreed about bloat, but is this any more or less needed than having mask on command line? Just because rules have been in a config file does not mean that it 'has' to be that way. Adding another command line switch is pretty much a trivial thing, adds little to bloat, and when you understand what rules you want (especially with knowledge of rpp), then it is really useful. Also, it would be super useful when building rules, to be able to toss some samples at a rule you are building, making sure the result is what you want it to be. I have actually started to use the rule_tst.pl script to do that, since I added the command line switch to -dump the pp output. Helps to make sure what shows us is what I expect to show up from a rule.
I have not started on any switch like this, because I wanted to hear from others. I vote for it, but will listen.
@magnumripper commented on GitHub (Mar 30, 2016):
So with RPP also. Well, it sure could be handy. Perhaps give it a shot and see how intrusive (or not) the patch becomes. Use a topic branch, of course.
But you probably want to wait with this until #2087 is finished, or we'll end up with incompatible branches that rot from never being merged.
@jfoug commented on GitHub (Mar 30, 2016):
I might poke at this, even with #2087 still hanging on (which is also waiting on some of the other save/restore logic). This may be pretty easy. I am going to try to simply use the existing overloaded
That code is already jumbo only, so it should not matter if it can figure out if it is a conf section, OR a absolute rule line.
Jim.
@jfoug commented on GitHub (Mar 30, 2016):
This was trivial (I have not checked it in yet). There may be things we need to 'check', such as this properly saves/restores, but I am pretty sure it should.
@jfoug commented on GitHub (Mar 30, 2016):
Note, I tried to write it to only be line adds within rpp.c, even though I think this may be code where we already diverge from core (since we load the config section name).
I had a feeling the code would be just this trivial, once the magic 'spot' was found.
@jfoug commented on GitHub (Mar 30, 2016):
Note should we validate this:
or simply let the rules processor fail ?
The code as it is, does this:
(the E is invalid), so I think it is fine as it stands. However, if you try to type a section, and the section name is wrong, the code will now use it as a rule, and not return that the section was not found. That is really the only bad side effect.
That should have been section tst_cur and not cur_tst.. But note it 'does' list the rule 'section' of cmd_line_rule
@jfoug commented on GitHub (Mar 31, 2016):
If I add this, I think I will also allow multiple rules to be on command line. They will have to be in 1 switch (I think) since the getopt solar built does not do multipe of same. But it is still easy, just make a line separator (like \n). So
would be 3 rules (but after rpp, would be 23)
@jfoug commented on GitHub (Mar 31, 2016):
This change is pretty trivial, AND appears to be without major side effects (the only one I can think of is a mis spelled config section name will now be treated as a rule). I think this adds some power for power users. I know you mentioned to put this in a branch, but I simply can not see problems with it.
@jfoug commented on GitHub (Mar 31, 2016):
@magnumripper do you have any heartburn about me putting this directly into jimbo-bleed ?
I just tested restore, and like I thought, it woks just fine.
I reran and ended up with a 100% same .pot file as I did on a prior run where I let the program simply run to completion. I also did 4 stop/starts, and same result.
I see no reason to not put this into bleeding, even though it is new logic.
@solardiz commented on GitHub (Mar 31, 2016):
I think we should use ';' instead of "\n" as rule separator on the command-line. This character is already somewhat special: it can be used to comment out a john.conf line, just like '#'. And we should communicate to @hashcat that we're starting to use this character as rule separator, in case they want to do the same instead of using it for some new command (it's still unused in hashcat now, right?)
@jfoug commented on GitHub (Mar 31, 2016):
;does appear to be unused in HC (looking at their wiki). Making the change from \n to ; is trivial , and I can actually use a strtok vs the strstr();*p=0;p+=2; which I am doing with a \nHmm, I do see an issue here (and even with \n)
--rule=$[;]
now becomes 2 rule: $[ and ]
I am pretty sure there are things which would also cause \n to split things incorrectly :(
@jfoug commented on GitHub (Apr 1, 2016):
I believe that the only way a \n can be in a rule, is if it is in a range, or AN"STR" block. But it is less likely than a ';' char being in either of those parts of data.
I really think the \n may be the better way to go. I can do it either way, but if it is a ':', then there will likely have to be more \xHH work arounds for it.
@frank-dittrich commented on GitHub (Apr 1, 2016):
The rules parser should be able to tell the difference between a
;which is part of a rule definition and a;which must be a separator.@solardiz commented on GitHub (Apr 1, 2016):
I think we don't want any heuristics like what Frank suggests. Rather, we want something simple and consistent. This means we need another level of escaping.
\;is for literal semicolon,\\is for literal backslash (at this level; in practice, more backslashes will need to be written in a row to pass literal backslashes to deeper layers). This might not be pretty, but it is consistent with approach taken by other command-line tools, such as Unix shell and sed.@solardiz commented on GitHub (Apr 1, 2016):
We also want a more reliable way to specify a section name vs. rule(s) on the command-line. Jim's patch is not robust in that the same command-line will be understood very differently depending on john.conf contents. A valid section name from another system may well end up being misinterpreted as a valid rule on a system lacking the section. Any suggestions on command-line syntax to distinguish section names from rules? Unfortunately, nothing good comes to my mind right now. We could use a new option name, but
--rulesfits both purposes well. Maybe we'll just accept the non-robustness of Jim's patch, if we fail to come up with anything good.@frank-dittrich commented on GitHub (Apr 1, 2016):
If
;needs to be escaped, I'd rather suggest to keep\nas a rule separator instead.To distinguish rules from sections, we could require a rule (or list of rules) to be started with a
:which gets dropped...@jfoug commented on GitHub (Apr 1, 2016):
We can easily state that a ; char which should be in the rule set needs an escape. The rpp already handles this just fine:
The logic which would split the rules data into multiple rules would NOT be de escaping, so there is no reason to worry about 'multiple levels' of escaping. It will simply search for the next ; char, and use it as a line separator (eating the character also), as long as there is no \ proceeding the ; byte.
The only item left, is a better / smarter way of determining if a user wants a section or has supplied a rule on the command line. We could add something like this:
what shows up in rpp_init() is R=$a$b and we use the R= as an indication that someone is wanting an inlined rule. I personally like the simplicity of simply having the data processed as an inline rule vs having to remember new syntax, but it is trivial to code either way. Another option is also a choice, but I thought re-use of the existing one would be ideal, as in the solution I have provided, there was almost NO change to any logic at all.
@jfoug commented on GitHub (Apr 1, 2016):
Ok, here is a new 'version'. It uses ; as the line separator. This means that ANY ; used in a rule that should be used as a ; must be escaped (this rule ONLY applies to command line). Also, the command line rules MUST start with the 2 letters R=. This keeps the current logic (as per error messages, etc) working 100% the same. The only stipulation is there could not be a section that starts with R= IF there were a section like that (say R=BIGGER), then simply using the section name of r=BIGGER would allow that section to be used. The R= is just that, case sensitive. NOTE, I do not personally like having the extended syntax for the command arg, but I can live with it. It is MUCH easier to just use the existing plumbing for the --rule switch, than trying to impelement all the other logic needed for another argument.
Here is an example. It shows multi line, there are 3 instances where ';' are used in rules (one showing that ; used twice in a group, still gets reduced to 1 instance), and one of them is the LAST character of the rule. Things work like a champ.
@jfoug commented on GitHub (Apr 1, 2016):
This is the entire patch as it stands against the current jumbo.
@jfoug commented on GitHub (Apr 1, 2016):
Note, the code as it stands even handles this properly (i.e. 'null' rule). I had not tested this before now, and was worried that there would be some problem (I will ASAN test it also just to be sure).
edit: ASAN run had no problems with this either.
@solardiz commented on GitHub (Apr 1, 2016):
I like Jim's idea to reuse rpp's escaping without introducing a new level of escaping.
I also like Frank's idea to require the command-line rule(s) list to start with
:. I think this is better thanR=. BTW, since we support not only=, but also:as separator between option name and parameter, it will be valid to use e.g.-ru::c(requesting the rulec) or-ru::;c(requesting the no-op rule and rulec). These are hackish, but are quick to type. And the non-hackish syntax will be the full--rules=:c, etc.@jfoug commented on GitHub (Apr 1, 2016):
I can do this with a ':' leading. That can NOT be the first char of a section name (I think). I had to test to make sure it was valid within command line parsing (it is)l
NOTE, that was before any change, so my code is still looking for R=, so the :$a was used as a section name, and shows that the ':' char was properly put through.
I will change my code to handle a leading : char, and it will be removed. It is ONLY used to state the user IS providing inline rules.
Pretty easy.
This is null rule, followed by $a. Works as expected. Same thing would have been
../run/john '--rules:::;$a' -w=tst-.in -stdothat does the same thing but now instead of a null rule, we have : which I think becomes the null rule.I have updated the patch above with the changed R= now being :
I want to keep the line splitting logic as brain dead as possible. I certainly do not want it to process or validate rules, looking for separators. The : and skipping that is all that is needed, and rpp is only too happy to undo that escape for us, with no penalty.
@jfoug commented on GitHub (Apr 1, 2016):
Is everyone happy with the new changes?
I think all stated issues are addressed, and I agree that all in all, it is better syntax, and certainly much better than blindly treating any rule where there was a section search failure as an inline rule.
@solardiz commented on GitHub (Apr 1, 2016):
Jim, your changes look good to me, to the extent jumbo can look good. As usual, there's a spelling error: "proceeded" should be replaced with "preceded". ;-) Thanks!
@jfoug commented on GitHub (Apr 1, 2016):
but it wouldn't be my code without speeling errers, lol. Just my little easter eggs.
@frank-dittrich commented on GitHub (Apr 2, 2016):
Did anybody contact hashcat, to ask about their opinion/possible concerns?
@magnumripper commented on GitHub (Apr 2, 2016):
Obviously as long as Solar is fine with this, I am too. Hit it!
😆
@frank-dittrich commented on GitHub (Apr 2, 2016):
I was just looking into extending bash completion support, and then I noticed that we might want to extend the --single logic as well.
@magnumripper commented on GitHub (Jun 29, 2016):
Wow, I forgot this was committed. Good stuff!
@magnumripper commented on GitHub (Jun 29, 2016):
It works fine. Perhaps just tweak the usage blurb and the docs.
@jfoug commented on GitHub (Jun 29, 2016):
I use this functionality all the time. When the idea hit me that morning in the shower, I simply could not believe that we had not added it a LONG time ago.
i had no idea about --single, BUT since it really is a 'special' alias for --rules that in the end, when it gets down to computing which rule section to use, that it simply works. Yes, good stuff.