Skip to content

amir-aghajani/pentest-toolbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pentest Toolbox

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.

Project Structure

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

Installation

  1. Clone the Repository: Clone this project or create the directory structure as shown above.

  2. Create a Virtual Environment:

    python -m venv .venv
  3. Activate the Virtual Environment:

    • On Windows:
      .venv\Scripts\activate
    • On MacOS/Linux:
      source .venv/bin/activate
  4. Install Dependencies: Make sure to install the required libraries.

    pip install cryptography python-nmap

Usage Instructions

Each tool can be run as a standalone module. This requires running each script from the root directory (pentest-toolbox) with python -m.


Tools Overview

1. Key Generation Tool (keygen/run.py)

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.

Usage

Run from the root directory (pentest-toolbox):

python -m keygen.run --method <random|password> --key-path <path/to/keyfile.key>

Options

  • --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 is secret.key). The filename must end with .key.

Example Commands

  1. Generate a random key and save it to secret.key:

    python -m keygen.run --method random
  2. Generate a key from a password and save it to mykey.key:

    python -m keygen.run --method password --key-path mykey.key

2. File Encryption/Decryption Tool (crypto/run.py)

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.

Usage

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>

Options

  • --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.

Example Commands

  1. Encrypt a file named plaintext.txt and save it as ciphertext.enc:

    python -m crypto.run --key-path secret.key --file plaintext.txt --mode encrypt --output ciphertext.enc
  2. Decrypt ciphertext.enc back to plaintext_decrypted.txt:

    python -m crypto.run --key-path secret.key --file ciphertext.enc --mode decrypt --output plaintext_decrypted.txt

3. Nmap Network Scanner Tool (nmap_scan/run.py)

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.

Usage

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>

Options

  • --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.

Example Commands

  1. 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
  2. Scan multiple IP addresses from a file ips.txt with an intense scan, saving the results in JSON format to scan_results.json:

    python -m nmap_scan.run --file ips.txt --scan-type intense --format json --output scan_results.json

Logging

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.


Notes

  1. Ensure you have nmap installed on your system for the nmap_tool to function correctly.

    • Windows: Download Nmap
    • Linux/macOS: Install via your package manager, e.g., sudo apt install nmap on Ubuntu.
  2. All tools must be run from the root directory (pentest-toolbox) with the python -m command to ensure proper imports.


License

This project is open source and available for use under the MIT License.


Contact

For any questions or feedback, please contact Amir Aghajani at amir.aghajani@iths.se

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages