lakiw / pcfg_cracker

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

Problem restoring a saved session #29

Closed ghost closed 1 year ago

ghost commented 2 years ago

The session starts just fine, but when I stop it and then restore it —

Restoring saved progress...
Traceback (most recent call last):
  File "/home/xxx/pcfg_cracker/pcfg_guesser.py", line 386, in <module>
    main()
  File "/home/xxx/pcfg_cracker/pcfg_guesser.py", line 300, in main
    current_cracking_session.run(load_session = program_info['load_session'])
  File "/home/xxx/pcfg_cracker/lib_guesser/cracking_session.py", line 76, in run
    self.pqueue = PcfgQueue(self.pcfg, self.save_config)
  File "/home/xxx/pcfg_cracker/lib_guesser/priority_queue.py", line 207, in __init__
    self.restore_base_item(base_item)
  File "/home/xxx/pcfg_cracker/lib_guesser/priority_queue.py", line 268, in restore_base_item
    self.pcfg.restore_prob_order(
  File "/home/xxx/pcfg_cracker/lib_guesser/pcfg_grammar.py", line 647, in restore_prob_order
    self.restore_prob_order(child_item, max_prob, min_prob, save_function, left_index = pos)
  File "/home/xxx/pcfg_cracker/lib_guesser/pcfg_grammar.py", line 647, in restore_prob_order
    self.restore_prob_order(child_item, max_prob, min_prob, save_function, left_index = pos)
  File "/home/xxx/pcfg_cracker/lib_guesser/pcfg_grammar.py", line 647, in restore_prob_order
    self.restore_prob_order(child_item, max_prob, min_prob, save_function, left_index = pos)
  [Previous line repeated 986 more times]
  File "/home/xxx/pcfg_cracker/lib_guesser/pcfg_grammar.py", line 620, in restore_prob_order
    save_function(pt_item)
  File "/home/xxx/pcfg_cracker/lib_guesser/priority_queue.py", line 254, in insert_queue
    heapq.heappush(self.p_queue, QueueItem(queue_item))
  File "/home/xxx/pcfg_cracker/lib_guesser/priority_queue.py", line 63, in __lt__
    return self.pt_item['prob'] > other.pt_item['prob']
RecursionError: maximum recursion depth exceeded in comparison
ghost commented 2 years ago

Well, upping the recursion limit (sys.setrecursionlimit(10000)) helped.

lakiw commented 2 years ago

First of all, Thank you for reporting this!

I'm reopening the issue since I don't like having something this "weird" to fix to be a hanging problem for the next person (who may be me).

If you wouldn't mind, I'd appreciate if you could tell me more about your session. Aka how long were you running it, was it the default ruleset or a custom one, etc?

I suspect I took some shortcuts when it came to rebuilding the priority queue by using recursion so I should change this around to not rely on recursion so much. So I'll take a look again at this feature. But additional information might help me get to the bottom of this.

Once again thank you, and please don't hesitate to submit more feature and/or bug requests here as issues. I mean, I probably won't get to them super fast, but it'll help me prioritize things :)

ghost commented 2 years ago

It was a custom ruleset based on ~25M passwords. I wasn't running that session for long. Too many passwords, I guess.

ghost commented 2 years ago

I can share that ruleset with you, if you need it to reproduce the crash.

https://mega.nz/file/AkNWDaLJ#poVeO33NaSZpCzmPq95f3SpgBQD73d7omBkUgO7dxKY

lakiw commented 1 year ago

Thank you once again. My apologies for the nearly year turnaround in a fix, but Version 4.4 of the PCFG toolset should now solve this problem. I really appreciated the help and the example ruleset to help replicate the problem.