lakiw / pcfg_cracker

Probabilistic Context Free Grammar (PCFG) password guess generator
314 stars 68 forks source link

Add limit to all modes. #34

Closed Wineh closed 10 months ago

Wineh commented 10 months ago

Enables to set a predefined amount of words to be generated.

lakiw commented 10 months ago

Awesome! Thank you for this. I’ll try to review this either tonight or tomorrow!

lakiw commented 10 months ago

First of all, thank you again for this PR! I'm making some minor changes to it. Most of them fall into "nitpicky" level changes based on my own coding style, but the major change is to move where the limit check occurs. Some of the pre-terminals generated by the PCFG can create many different guesses, so checking the limit outside of pcfg.create_guesses() can result in generating thousands of extra guesses. For example if you do the following (using the Default Ruleset):

python3 pcfg_guesser.py -n 10000 | wc Loading Ruleset: Default Limit reached. Exiting... 14183 14182 114650

As you can see, 14k+ guesses were made when it should have stopped it at 10k guesses.

I want to stress again, I really appreciate you submitting this PR! This is a feature I've been procrastinating on forever so the fact that you did this really gave me a kick in the butt which I appreciate. I'm going to keep messing with this a bit but I'll probably merge everything in tomorrow.

ghost commented 10 months ago

I'm not sure it's necessary since you can always do | head -n 10000.