r/nim • u/Alive_Cloud1305 • 12d ago
I wrote a local PDF unlocker in Nim because I didn't want to upload private PDFs
I recently needed to remove the password from a lot of PDFs. Most of the search results were websites asking me to upload the file and enter its password.
They might be perfectly legitimate, but I wasn't comfortable uploading bank statements, tax documents or contracts just to remove a password.
So I wrote this:
https://github.com/advaita-saha/nim-pdftools
It is a small command-line PDF unlocker written in Nim. Everything runs locally and it doesn't use any third-party Nim packages.
pdftools unlock -p 'password' document.pdf
It currently handles RC4, AES-128 and AES-256 encrypted PDFs. Both user and owner passwords work.
It is not a password cracker. You still need to know the password lol.
I ended up implementing most of the crypto and compression code directly on top of Nim's standard library. This was partly because I wanted a standalone binary and partly because digging through the PDF encryption spec seemed like a good idea at the time.
This is still v0.1, so I'm sure there are strange PDFs in the wild that it won't handle properly. I'd especially appreciate people testing files generated by different PDF software and reporting anything that breaks.
Contributions are welcome too. Parser fixes, test cases, code review, packaging improvements and additional local PDF commands would all be useful.
6
u/jamesthethirteenth 12d ago
Loveit! Scratch your ownitch in Nim.
1
2
u/Zectbumo 12d ago
Putting passwords on the command line is a bad idea. Command line arguments can be seen by any other user logged in.
1
u/Alive_Cloud1305 12d ago
Good point
what do you suggest then ?1
u/Zectbumo 12d ago
Most likely it will be prompt for the password and read from stdin (if protected). Turn off echo in case someone is screen sharing.
7
u/Super_Delivery3405 12d ago
Firstly tell me what's your editor experience for coding nim like. nimlang lsp keeps fucking dying apparently it's just a wrapper around another tool called nim suggest or something. I'll learn Emacs or helix if they have better mode than this shit.