I am trying to brute force a RAR archive which is protected by a password with 3 characters:
import os
Alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for a in range(0,26):
for b in range(0,26):
for c in range(0,26):
Brute = Alphabets[a] + Alphabets[b] + Alphabets[c]
os.popen4("Rar.exe x -p" + Brute + " Protected.rar")
# raw_input()
raw_input("Done !")
The code works fine, except: it is very slow !!
i think what makes it slow is the multi-opening by "popen4". because i tried to stored the generated words in a txt file, and the program finished in less than 5 seconds.
Any ideas to increase the performance?
You could use (or learn from) rarcrack. It is written in C and compiles without problems on Linux (Windows with lots of changes).
In general, opening a process for every single tested password is very expensive. You should try and open the archive yourself, and then test against all passwords. Anyway you need to test the return value of rar.exe to find out whether extraction succeeded.
For best performance, you should write the program in C (or similar). There's a Linux package called "libunrar" that might help you with opening RAR files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With