kimci86 / bkcrack

Crack legacy zip encryption with Biham and Kocher's known plaintext attack.
zlib License
1.45k stars 151 forks source link

Ability to use more threads that the charsetSize #127

Open jgrahamc opened 3 days ago

jgrahamc commented 3 days ago

The code for multi-threading in password recovery contains the following line:

const auto threadCount = std::clamp(jobs, 1, charsetSize);

This means the maximum number of threads is the same as the charsetSize. The largest charset possible in the code is ?p which is 95 characters. This means that the maximum number of threads is 95 (and can be much smaller for other charsets). I have a machine with 192 cores and so it's not possible to max that machine out.

kimci86 commented 3 days ago

You are right, this is a mistake. Thank you for reporting this. I work on a machine with 8 threads so I didn't really saw the impact, but I noticed it reading code during the refactoring of bruteforce attack I did while starting the branch on mask attack.

It is better on the mask branch: there can be up to charsetSize * charsetSize threads.

It would be better to split work in some other way to allow taking advantage of so many threads, but for now using the version from the mask branch should be an improvement.

jgrahamc commented 3 days ago

Thanks. I'll switch to using that version.

EDIT: Thank you, I now have a machine with 128 cores running at roughly 98% utilization.