Skip to content

msimon96/RT-MASK

Repository files navigation

RT-MASK: Red Team Mask for IPv4 to IPv6 Obfuscation

CI/CD Python 3.8+ License: MIT Code Quality

RT-MASK is a powerful, secure, and performant tool that converts IPv4 addresses to IPv6 addresses for the purpose of IPv4 obfuscation. Version 2.1 introduces comprehensive security improvements, performance optimizations (253x faster with caching, 10x faster CIDR processing), and enterprise-grade testing infrastructure.

🚀 What's New in v2.1.0

  • Critical Bug Fix: IPv6 conversion algorithm corrected (192.168.1.1 now properly converts to ::ffff:c0a8:0101)
  • Security Hardening: Input validation, command injection prevention, timeout protection, HTTPS enforcement
  • Performance Boost: 253x faster with caching, 10x faster parallel CIDR processing
  • Testing Infrastructure: 15 unit tests, CI/CD pipeline, security scanning
  • Quality Improvements: Type hints, proper error handling, pre-commit hooks

See IMPROVEMENTS.md for detailed changelog of 72 improvements!

Features

  • Multiple Input Methods:

    • Single IPv4 address
    • Domain name resolution (with caching)
    • CIDR notation support (with parallel processing)
    • Batch processing from file
    • Interactive mode
  • Rich Information:

    • IPv4 to IPv6 conversion (corrected algorithm)
    • URL generation (HTTP/HTTPS)
    • Geolocation information (cached, HTTPS)
    • WHOIS lookup (cached)
    • Network information (ping, reverse DNS)
    • QR code generation
  • Security Features (New in v2.1):

    • Input validation prevents command injection
    • Path traversal protection
    • Timeout protection on all network operations
    • HTTPS with SSL verification for API calls
    • Safe file handling with proper error messages
  • Performance Optimizations (New in v2.1):

    • Time-based caching (1 hour TTL) for DNS, WHOIS, geolocation
    • Parallel CIDR processing with ThreadPoolExecutor (configurable workers)
    • Large network warnings (>1024 hosts)
  • Multiple Output Formats:

    • Text (console with rich formatting)
    • JSON (with proper encoding)
    • CSV (with proper escaping)
    • HTML (modern, responsive design)
  • Cross-Platform Support:

    • Python implementation (recommended, fully tested)
    • PowerShell implementation (Windows-optimized using native APIs)
    • Bash implementation
  • Development Features (New in v2.1):

    • 15 unit tests with pytest
    • CI/CD pipeline (GitHub Actions)
    • Pre-commit hooks
    • Code quality tools (black, flake8, mypy)
    • Security scanning (bandit, safety)

Installation

Prerequisites

  • Python 3.9 or higher
  • pip package manager

Quick Install (Python - Recommended)

```bash

Clone the repository

git clone https://github.com/msimon96/RT-MASK.git cd RT-MASK

Install as package (includes all dependencies)

pip install -e .

Or install dependencies manually

pip install -r requirements.txt ```

Development Setup

```bash

Install with development dependencies

pip install -r requirements.txt

Install pre-commit hooks

pre-commit install

Run tests

pytest tests/

Run with coverage

pytest --cov=rtmask tests/ ```

Bash Version (Linux/macOS)

```bash

Install required utilities

macOS

brew install whois jq

Ubuntu/Debian

sudo apt-get install whois curl dnsutils jq ```

PowerShell Version (Windows)

PowerShell is pre-installed on Windows. The script uses native Windows APIs for enhanced performance and stealth.

Usage

Python Version

```bash

Single IP conversion

python RT-MASK.py -i 192.168.1.1

Domain name resolution

python RT-MASK.py -d example.com

CIDR range (parallel processing)

python RT-MASK.py -c 192.168.1.0/24

Process IPs from file

python RT-MASK.py -f input.txt

Save results in different formats

python RT-MASK.py -i 192.168.1.1 --format json -o results.json python RT-MASK.py -i 192.168.1.1 --format html -o report.html python RT-MASK.py -i 192.168.1.1 -o results.csv

Include additional information

python RT-MASK.py -i 192.168.1.1 --whois --geo --network

Generate QR codes

python RT-MASK.py -i 192.168.1.1 --qr

Interactive mode

python RT-MASK.py ```

Bash Version

```bash

Make script executable

chmod +x RT-MASK.sh

Single IP conversion

./RT-MASK.sh -i 192.168.1.1

Domain name resolution with WHOIS and geolocation

./RT-MASK.sh -d google.com --whois --geo

CIDR range with JSON output

./RT-MASK.sh -c 192.168.1.0/24 --format json

Process IPs from file with CSV output

./RT-MASK.sh -f input.txt -o results.csv ```

PowerShell Version

```powershell

Single IP conversion

./RT-MASK.ps1 -IP 192.168.1.1

Domain name resolution with WHOIS and geolocation

./RT-MASK.ps1 -Domain google.com -Whois -Geo

CIDR range with JSON output

./RT-MASK.ps1 -CIDR 192.168.1.0/24 -Format json

Process IPs from file with CSV output

./RT-MASK.ps1 -InputFile input.txt -OutputFile results.csv ```

Command Line Options

Python Version

``` usage: RT-MASK.py [-h] [-i IP | -d DOMAIN | -c CIDR | -f FILE] [-o OUTPUT] [--format {text,json,csv,html}] [--output-dir OUTPUT_DIR] [--qr] [--whois] [--geo] [--network] [--no-banner]

options: -h, --help show this help message -i IP, --ip IP Single IPv4 address to convert -d DOMAIN, --domain DOMAIN Domain name to resolve and convert -c CIDR, --cidr CIDR CIDR notation (e.g., 192.168.1.0/24) -f FILE, --file FILE File containing IPv4 addresses or CIDR ranges -o OUTPUT, --output OUTPUT Output file (format determined by extension) --format {text,json,csv,html} Output format (default: text) --output-dir OUTPUT_DIR Directory for output files --qr Generate QR codes for URLs --whois Include WHOIS information --geo Include geolocation information --network Include network information --no-banner Disable banner display ```

Performance Considerations

Caching (New in v2.1)

RT-MASK implements intelligent caching with a 1-hour TTL:

  • DNS lookups: Cached to avoid repeated resolution
  • WHOIS queries: Cached to reduce external requests
  • Geolocation: Cached to minimize API calls

Performance Gain: Processing the same /24 network 253x faster on subsequent runs!

Parallel Processing (New in v2.1)

CIDR ranges are processed in parallel using ThreadPoolExecutor: ```bash

Sequential mode (1 IP at a time)

python RT-MASK.py -c 192.168.1.0/24

Parallel mode is automatic for CIDR ranges

Processes 10 IPs concurrently by default

```

Performance Gain: ~10x faster for large CIDR ranges!

Rate Limiting

The tool respects API rate limits:

  • ipapi.co: 45 requests/minute (free tier)
  • WHOIS servers: Varies by server
  • Automatic warnings for large networks (>1024 hosts)

Security Considerations

Input Validation (New in v2.1)

  • All inputs validated before processing
  • Command injection prevention
  • Path traversal protection
  • CIDR size limits to prevent DoS

Network Security (New in v2.1)

  • HTTPS enforced for all API calls
  • SSL certificate verification enabled
  • Timeout protection (10s for HTTP, 5s for subprocess)
  • No credentials or sensitive data transmitted

Safe File Operations (New in v2.1)

  • File existence and permission checks
  • UTF-8 encoding validation
  • File size limits (10MB max for input files)
  • Proper error handling

PowerShell Stealth Features

  • Direct Windows API calls bypass monitored cmdlets
  • No external process creation
  • Reduced detection footprint

API Services Used

The tool uses the following free API services:

  1. ipapi.co (https://ipapi.co) - Changed in v2.1: Now uses HTTPS

    • Geolocation information
    • Rate limited to 45 requests per minute
    • No API key required
    • SSL verified
  2. WHOIS

    • Uses system's WHOIS command or Python library
    • Rate limits vary by WHOIS server
    • Results cached for 1 hour

Testing

Running Tests

```bash

Run all tests

pytest tests/

Run with coverage report

pytest --cov=rtmask tests/

Run specific test file

pytest tests/test_ip_converter.py

Run with verbose output

pytest -v tests/ ```

Test Coverage

  • 15 unit tests covering:
    • IPv6 conversion (including regression test for the bug fix)
    • Caching functionality
    • Input validation
    • Error handling
    • Parallel processing
    • Network operations (mocked)

CI/CD Pipeline

Automated testing runs on:

  • Operating Systems: Ubuntu, macOS, Windows
  • Python Versions: 3.9, 3.10, 3.11, 3.12
  • Checks: Tests, linting, type checking, security scanning

Development

Code Quality Tools

```bash

Format code

black rtmask/ tests/

Check code style

flake8 rtmask/ tests/

Type checking

mypy rtmask/

Security scanning

bandit -r rtmask/

Run all checks (via pre-commit)

pre-commit run --all-files ```

Project Structure

``` RT-MASK/ ├── rtmask/ │ ├── core/ │ │ └── ip_converter.py # Core conversion logic │ ├── utils/ │ │ ├── output_formatter.py # Output formatting │ │ └── validators.py # Input validation │ └── templates/ │ └── report.html # HTML report template ├── tests/ │ └── test_ip_converter.py # Unit tests ├── RT-MASK.py # Main CLI script ├── RT-MASK.sh # Bash implementation ├── RT-MASK.ps1 # PowerShell implementation ├── setup.py # Package setup ├── requirements.txt # Dependencies ├── pytest.ini # Test configuration ├── .pre-commit-config.yaml # Pre-commit hooks └── .github/workflows/ci.yml # CI/CD pipeline ```

Examples

Basic Usage

```bash

Convert single IP

$ python RT-MASK.py -i 192.168.1.1

IPv4: 192.168.1.1 IPv6: ::ffff:c0a8:0101 URL (HTTP): http://[::ffff:c0a8:0101] URL (HTTPS): https://[::ffff:c0a8:0101] ```

With Geolocation

```bash $ python RT-MASK.py -d google.com --geo

Domain: google.com IPv4: 142.250.80.46 IPv6: ::ffff:8efa:502e Location: Mountain View, United States Coordinates: 37.4056, -122.0775 Timezone: America/Los_Angeles ```

Processing Networks

```bash

Create input file

echo "192.168.1.0/24 10.0.0.0/24 172.16.0.0/24" > networks.txt

Process with parallel execution

python RT-MASK.py -f networks.txt --format html -o network_map.html ```

Contributing

We welcome contributions! Please see CONTRIBUTING.md for details.

Quick Start for Contributors

  1. Fork the repository
  2. Clone your fork: `git clone https://github.com/YOUR_USERNAME/RT-MASK.git\`
  3. Create a branch: `git checkout -b feature/amazing-feature`
  4. Install dev dependencies: `pip install -r requirements.txt`
  5. Install pre-commit hooks: `pre-commit install`
  6. Make your changes
  7. Run tests: `pytest tests/`
  8. Commit with descriptive message
  9. Push and create a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

See CHANGELOG.md for version history and IMPROVEMENTS.md for detailed v2.1.0 improvements.

Acknowledgments

  • Thanks to ipapi.co for providing free geolocation services
  • Thanks to all contributors who have helped improve RT-MASK
  • Special thanks to the open-source community for the various tools and libraries used in this project

Support

Statistics (v2.1.0)

  • 72 improvements across security, performance, and code quality
  • 15 unit tests with pytest
  • 5 critical bug fixes
  • 11 security improvements
  • 253x faster with caching
  • 10x faster parallel CIDR processing
  • 100% type-hinted Python code
  • CI/CD pipeline with multi-OS, multi-Python testing

Version: 2.1.0
Last Updated: 2026-01-25
Status: Production Ready ✅

About

RT-MASK: Red Team Mask for IPv4 to IPv6 Obfuscation

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •