This Python script performs a brute-force attack to find the password of a password-protected RAR file. It generates all possible password combinations up to a specified length and attempts to extract the contents of the RAR file using 7-Zip. The script uses multiprocessing to speed up the process by running multiple password attempts in parallel.
- Brute-Force Attack: Attempts to crack a password-protected RAR file by testing all possible password combinations up to a specified length.
- 7-Zip Integration: Uses 7-Zip (
7z.exe
) to attempt password extraction from the RAR file. - Multiprocessing: Utilizes multiple CPU cores to accelerate the brute-force process.
- Logging: Logs successful and failed attempts, along with errors, into a log file for monitoring progress.
- Customizable Parameters: Set the maximum password length and the characters used for password generation.
- Python 3.x
- 7-Zip (
7z.exe
) installed on your system. Download 7-Zip - Windows OS or a system that supports 7-Zip command-line tool.
Install the required Python libraries with the following command:
pip install -r requirements.txt
The required dependencies are:
itertools
string
subprocess
multiprocessing
-
Download and Install 7-Zip:
Download and install 7-Zip if it is not already installed on your system. Make sure the executable7z.exe
is in your system's PATH or provide the absolute path to the7z.exe
file in the script. -
Configure the Script:
Modify the following variables in the script to point to your RAR file and 7-Zip executable:rar_file_path = "path/to/your/file.rar" seven_zip_path = r"C:\Program Files\7-Zip\7z.exe"
-
Run the Script:
Execute the script with the following command:python brute_force_rar.py
The script will start generating and testing password combinations, logging progress and results.
max_password_length
: Set the maximum password length to test.characters
: Define the character set to use for generating passwords. The default set includes uppercase and lowercase letters and digits.
- Logs are stored in a file named
bruteforce_rar.log
. - The log file records:
- Successful password attempts.
- Failed attempts.
- Any errors that occur during the brute-force process.
$ python brute_force_rar.py
2024-11-09 21:36:07,401 - INFO - Starting brute-force attack on RAR file.
Password found: abc123
2024-11-09 21:36:09,589 - INFO - Correct password found: abc123
- Performance: The script uses multiprocessing to utilize multiple CPU cores, speeding up the brute-force process. You can adjust the number of processes used by modifying the script.
- 7-Zip: The script uses 7-Zip’s command-line tool for extraction. Ensure that 7-Zip is correctly installed and accessible from your system’s PATH.
This project is licensed under the MIT License.
This README.md
provides an overview of the project, how to set it up, and its usage, along with installation instructions for any dependencies. Feel free to adapt and expand it based on your specific needs.