This project provides a collection of Python tools designed for penetration testing and IT security purposes. Each tool is modular and performs a specific function, such as file encryption/decryption, key generation, and network scanning with Nmap.
pentest-toolbox/
├── crypto_/
│ └── run.py # File encryption/decryption tool
├── keygen/
│ └── run.py # Key generation tool
├── nmap_scan/
│ └── run.py # Nmap network scanner tool
├── helpers.py # Helper functions (e.g., save file with overwrite confirmation)
└── __init__.py # Makes the project a package
-
Clone the Repository: Clone this project or create the directory structure as shown above.
-
Create a Virtual Environment:
python -m venv .venv
-
Activate the Virtual Environment:
- On Windows:
.venv\Scripts\activate
- On MacOS/Linux:
source .venv/bin/activate
- On Windows:
-
Install Dependencies: Make sure to install the required libraries.
pip install cryptography python-nmap
Each tool can be run as a standalone module. This requires running each script from the root directory (pentest-toolbox
) with python -m
.
Generates an encryption key either randomly or derived from a password. The generated key is saved to a specified file, with an option to avoid overwriting existing files.
Run from the root directory (pentest-toolbox
):
python -m keygen.run --method <random|password> --key-path <path/to/keyfile.key>
--method
(required): Specify the key generation method:random
: Generates a random key.password
: Generates a key derived from a password.
--key-path
(optional): Specify the path to save the key file (default issecret.key
). The filename must end with.key
.
-
Generate a random key and save it to
secret.key
:python -m keygen.run --method random
-
Generate a key from a password and save it to
mykey.key
:python -m keygen.run --method password --key-path mykey.key
Encrypts or decrypts a specified file using a key file generated by the Key Generation Tool. The encrypted or decrypted file is saved to the specified output path.
Run from the root directory (pentest-toolbox
):
python -m crypto.run --key-path <path/to/keyfile.key> --file <path/to/inputfile> --mode <encrypt|decrypt> --output <path/to/outputfile>
--key-path
(required): Path to the key file used for encryption or decryption. The file must have been generated by the Key Generation Tool.--file
(required): Path to the file to be encrypted or decrypted.--mode
(required): Operation mode:encrypt
: Encrypt the file.decrypt
: Decrypt the file.
--output
(required): Path to save the encrypted or decrypted file.
-
Encrypt a file named
plaintext.txt
and save it asciphertext.enc
:python -m crypto.run --key-path secret.key --file plaintext.txt --mode encrypt --output ciphertext.enc
-
Decrypt
ciphertext.enc
back toplaintext_decrypted.txt
:python -m crypto.run --key-path secret.key --file ciphertext.enc --mode decrypt --output plaintext_decrypted.txt
Performs network scans using Nmap with specified scan types and formats the results in JSON or human-readable format. You can scan a single IP address or multiple addresses from a file.
Run from the root directory (pentest-toolbox
):
python -m nmap_scan.run --ip <IP_address> --file <path/to/ip_file> --scan-type <syn|udp|intense> --format <json|human-readable> --output <path/to/outputfile>
--ip
: IP address to scan.--file
: Path to a file containing multiple IP addresses (one per line).--scan-type
(optional): Type of Nmap scan to perform:syn
: TCP SYN scan (default).udp
: UDP scan.intense
: Intense scan with version detection.
--format
(optional): Output format of scan results:json
: JSON format.human-readable
: Plain text format (default).
--output
(optional): Path to save the scan results. If not specified, results will be printed to the console.
-
Scan a single IP with a SYN scan and output results in human-readable format:
python -m nmap_scan.run --ip 192.168.1.1 --scan-type syn --format human-readable
-
Scan multiple IP addresses from a file
ips.txt
with an intense scan, saving the results in JSON format toscan_results.json
:python -m nmap_scan.run --file ips.txt --scan-type intense --format json --output scan_results.json
All tools log key actions and errors to toolbox.log
in the root directory. This log file provides a history of operations, including errors, successful saves, and user prompts.
-
Ensure you have
nmap
installed on your system for thenmap_tool
to function correctly.- Windows: Download Nmap
- Linux/macOS: Install via your package manager, e.g.,
sudo apt install nmap
on Ubuntu.
-
All tools must be run from the root directory (
pentest-toolbox
) with thepython -m
command to ensure proper imports.
This project is open source and available for use under the MIT License.
For any questions or feedback, please contact Amir Aghajani at amir.aghajani@iths.se