mufeedvh / pdfrip

A multi-threaded PDF password cracking utility equipped with commonly encountered password format builders and dictionary attacks.
MIT License
589 stars 67 forks source link

Inline bits of pdf crate for better performance #36

Closed jorpic closed 2 months ago

jorpic commented 4 months ago

Hello and thank you for this project, it helped me A LOT recently.

I was in a need to restore passwords for multiple PDF documents, so performance was really important. It occurs that sharing single pdf::file::Storage between attempts in a single thread results in a noticeable speedup.

Cracking one of the example files on my machine:

Single thread

user@zen ~/t/pdfrip (inline-pdf-storage)> cargo run --release -- -n 1 -f examples/default-query-1.pdf range 1 1000000
 2024-04-22T17:23:26.430Z INFO  engine > Starting password cracking job...
  [00:02:43] [████████████████████████████████████████]  999999/999999  100% 6113/s ETA: 0s
 2024-04-22T17:26:10.043Z INFO  cli_interface > Failed to crack file...
user@zen ~/t/pdfrip (main) [1]> cargo run --release -- -n 1 -f examples/default-query-1.pdf range 1 1000000
 2024-04-22T17:36:11.308Z INFO  engine > Starting password cracking job...
  [00:07:20] [████████████████████████████████████████]  999999/999999  100% 2269/s ETA: 0s
 2024-04-22T17:43:32.091Z INFO  cli_interface > Failed to crack file...

Four threads

user@zen ~/t/pdfrip (inline-pdf-storage) [1]> cargo run --release -- -n 4 -f examples/default-query-1.pdf range 1 1000000
 2024-04-22T17:28:08.219Z INFO  engine > Starting password cracking job...
  [00:01:09] [████████████████████████████████████████]  999999/999999  100% 14315/s ETA: 0s
 2024-04-22T17:29:18.090Z INFO  cli_interface > Failed to crack file...
user@zen ~/t/pdfrip (main) [1]> cargo run --release -- -n 4 -f examples/default-query-1.pdf range 1 1000000
 2024-04-22T17:32:44.111Z INFO  engine > Starting password cracking job...
  [00:02:44] [████████████████████████████████████████]  999999/999999  100% 6095/s ETA: 0s
 2024-04-22T17:35:28.198Z INFO  cli_interface > Failed to crack file...
mufeedvh commented 2 months ago

Thank you, LGTM! Merging this now! 🚀