Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Rar Brute Forcer

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?

like image 668
Mahmoud K. Avatar asked Nov 29 '22 19:11

Mahmoud K.


1 Answers

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.

like image 64
AndiDog Avatar answered Dec 06 '22 16:12

AndiDog