PTF (Pentesters Framework) aide-mémoire
Overview
The Pentesters Framework (PTF) is a Python-based tool management platform designed specifically for penetration testers and security professionals. Developed by TrustedSec, PTF serves as a centralized repository and Installation manager for tests de pénétration tools, providing automated Installation, updates, and management of security tools across different platforms. The framework addresses the common challenge faced by security professionals who need to maintain and update dozens of specialized tools across multiple systems and environments.
PTF operates on a modular architecture where each tool is defined by a configuration file that specifies Installation methods, dependencies, update procedures, and compatibility requirements. This approach ensures consistent tool deployment across different environments while maintaining the flexibility to customize Installations based on specific requirements. The framework supports various Installation methods including git repositories, package managers, custom scripts, and binary downloads, making it compatible with virtually any security tool regardless of its distribution method.
The framework's strength lies in its ability to automate the tedious processus of tool management that traditionally consumes significant time for security professionals. PTF can automatically detect when tools have updates available, handle dependency resolution, manage version conflicts, and provide rollback capabilities when needed. This automation allows penetration testers to focus on their core security testing activities rather than spending time on tool maintenance and configuration.
PTF also provides valuable features for team environments, including the ability to create standardized tool configurations that can be deployed across multiple team members' systems. This ensures consistency in testing environments and reduces the likelihood of issues arising from tool version mismatches or configuration differences. The framework's logging and reporting capabilities provide visibility into tool Installation status and update history, which is valuable for maintaining audit trails and dépannage issues.
Installation
Prerequisites
# Install Python and pip
sudo apt update
sudo apt install python3 python3-pip git
# Install required Python packages
pip3 install requests beautifulsoup4 lxml
# Install additional dependencies
sudo apt install build-essential libssl-dev libffi-dev python3-dev
# For CentOS/RHEL
sudo yum install python3 python3-pip git gcc openssl-devel libffi-devel python3-devel
# For macOS
brew install python3 git
pip3 install requests beautifulsoup4 lxml
Standard Installation
# Clone PTF repository
git clone https://github.com/trustedsec/ptf /opt/ptf
# Change to PTF directory
cd /opt/ptf
# Make PTF executable
chmod +x ptf
# Run initial setup
sudo python3 ptf
# Alternative: Install to user directory
git clone https://github.com/trustedsec/ptf ~/ptf
cd ~/ptf
python3 ptf
Docker Installation
# Pull PTF Docker image
docker pull trustedsec/ptf
# Run PTF in Docker
docker run -it --rm trustedsec/ptf
# Run with persistent storage
docker run -it --rm -v ptf_data:/root/.ptf trustedsec/ptf
# Build custom PTF image
cat << 'EOF' > Dockerfile
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y python3 python3-pip git
RUN git clone https://github.com/trustedsec/ptf /opt/ptf
WORKDIR /opt/ptf
RUN chmod +x ptf
ENTRYPOINT ["python3", "ptf"]
EOF
docker build -t custom-ptf .
docker run -it --rm custom-ptf
Virtual Environment Installation
# Create virtual environment
python3 -m venv ptf-env
source ptf-env/bin/activate
# Install dependencies
pip install requests beautifulsoup4 lxml
# Clone and setup PTF
git clone https://github.com/trustedsec/ptf
cd ptf
python3 ptf
# Create activation script
cat << 'EOF' > activate-ptf.sh
#!/bin/bash
source /path/to/ptf-env/bin/activate
cd /path/to/ptf
python3 ptf
EOF
chmod +x activate-ptf.sh
System-wide Installation
# Install PTF system-wide
sudo git clone https://github.com/trustedsec/ptf /opt/ptf
sudo chown -R $USER:$USER /opt/ptf
cd /opt/ptf
sudo python3 ptf
# Create symbolic link
sudo ln -s /opt/ptf/ptf /usr/local/bin/ptf
# Create desktop entry
cat << 'EOF' > ~/.local/share/applications/ptf.desktop
[Desktop Entry]
Name=Pentesters Framework
Comment=Tool management for penetration testers
Exec=/opt/ptf/ptf
Icon=terminal
Terminal=true
Type=Application
Categories=Security;
EOF
Basic utilisation
Starting PTF
# Start PTF
python3 ptf
./ptf
# Start with specific configuration
python3 ptf --config /path/to/config.txt
# Start in quiet mode
python3 ptf --quiet
# Start with debug output
python3 ptf --debug
# Show version
python3 ptf --version
Core commandes
# Show help
help
?
# List available modules
show modules
list
# Search for modules
search nmap
search web
search "ingénierie sociale"
# Show module information
info modules/exploitation/metasploit
show info modules/intelligence/theharvester
# Install module
use modules/exploitation/metasploit
install
# Update module
use modules/exploitation/metasploit
update
# Remove module
use modules/exploitation/metasploit
remove
Module Categories
# List modules by category
show modules/exploitation
show modules/intelligence
show modules/vulnérabilité-analysis
show modules/web-applications
show modules/wireless
show modules/forensics
show modules/reverse-engineering
# Show all categories
show categories
# Search within category
search modules/exploitation metasploit
search modules/web-applications burp
Module Management
Installing Tools
# Install single module
use modules/exploitation/metasploit
install
# Install multiple modules
use modules/exploitation/metasploit
use modules/intelligence/theharvester
use modules/web-applications/burpsuite
install
# Install all modules in category
use modules/exploitation/*
install
# Install with dependencies
use modules/exploitation/metasploit
set INSTALL_DEPS true
install
# Force reinstall
use modules/exploitation/metasploit
set FORCE_INSTALL true
install
Updating Tools
# Update single module
use modules/exploitation/metasploit
update
# Update all installed modules
update all
# Check for updates
use modules/exploitation/metasploit
check_update
# Update specific modules
use modules/exploitation/metasploit
use modules/intelligence/theharvester
update
# Scheduled updates
set AUTO_UPDATE true
set UPDATE_INTERVAL 7 # days
Removing Tools
# Remove single module
use modules/exploitation/metasploit
remove
# Remove multiple modules
use modules/exploitation/metasploit
use modules/intelligence/theharvester
remove
# Remove all modules
remove all
# Remove with cleanup
use modules/exploitation/metasploit
set CLEAN_REMOVE true
remove
# Backup before removal
use modules/exploitation/metasploit
set BACKUP_BEFORE_REMOVE true
remove
Module Information
# Show detailed module info
info modules/exploitation/metasploit
# Show Installation status
status modules/exploitation/metasploit
# Show module dependencies
deps modules/exploitation/metasploit
# Show module files
files modules/exploitation/metasploit
# Show module configuration
config modules/exploitation/metasploit
# Show module changelog
changelog modules/exploitation/metasploit
configuration Management
Global configuration
# Show current configuration
show config
config
# Set configuration options
set INSTALL_DIR /opt/tools
set AUTO_UPDATE true
set UPDATE_INTERVAL 7
set BACKUP_ENABLED true
set LOG_LEVEL debug
# Save configuration
save config
# Load configuration
load config /path/to/config.txt
# Reset configuration
reset config
# Export configuration
export config /path/to/backup_config.txt
Module-Specific configuration
# Configure module
use modules/exploitation/metasploit
set INSTALL_PATH /opt/metasploit
set UPDATE_METHOD git
set BRANCH master
set DEPENDENCIES true
# Show module configuration
show config
# Save module configuration
save module_config
# Load module configuration
load module_config /path/to/module_config.txt
# Reset module configuration
reset module_config
Environment configuration
# Set environment variables
set ENV_VAR PATH="/opt/tools/bin:$PATH"
set ENV_VAR METASPLOIT_HOME="/opt/metasploit"
# Configure proxy settings
set PROXY_hôte 127.0.0.1
set PROXY_port 8080
set PROXY_USER nom d'utilisateur
set PROXY_PASS mot de passe
# Configure SSL settings
set SSL_VERIFY false
set SSL_CERT /path/to/cert.pem
# Configure timeout settings
set TIMEOUT 300
set RETRY_COUNT 3
set RETRY_DELAY 5
Advanced Features
Custom Module Creation
# Create custom module configuration
cat << 'EOF' > modules/custom/mytool.py
#!/usr/bin/env python3
AUTHOR = "Your Name"
Description = "Custom tool Description"
INSTALL_TYPE = "GIT"
REPOSITORY_LOCATION = "https://github.com/user/mytool.git"
INSTALL_LOCATION = "mytool"
DEBIAN = "git build-essential"
BYPASS_UPDATE = "FALSE"
LAUNCHER = "mytool"
def install():
# Custom Installation logic
pass
def update():
# Custom update logic
pass
def remove():
# Custom removal logic
pass
EOF
Batch Operations
# Create batch Installation script
cat << 'EOF' > batch_install.txt
use modules/exploitation/metasploit
use modules/intelligence/theharvester
use modules/web-applications/burpsuite
use modules/vulnérabilité-analysis/nmap
use modules/wireless/aircrack-ng
install
EOF
# Execute batch script
python3 ptf --batch batch_install.txt
# Create update script
cat << 'EOF' > batch_update.txt
update all
EOF
python3 ptf --batch batch_update.txt
Automation Scripts
# Automated Installation script
#!/bin/bash
cat << 'EOF' > auto_install.sh
#!/bin/bash
# Start PTF and install essential tools
python3 /opt/ptf/ptf ``<< 'PTFEOF'
use modules/exploitation/metasploit
use modules/intelligence/theharvester
use modules/web-applications/burpsuite
use modules/vulnérabilité-analysis/nmap
use modules/wireless/aircrack-ng
use modules/forensics/volatility
install
exit
PTFEOF
echo "Installation complete"
EOF
chmod +x auto_install.sh
./auto_install.sh
Integration with CI/CD
# GitHub Actions workflow
name: PTF Tool Management
on:
schedule:
- cron: '0 2 * * 0' # Weekly updates
workflow_dispatch:
jobs:
update-tools:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install PTF
run: |
git clone https: //github.com/trustedsec/ptf
cd ptf
pip install -r requirements.txt
- name: Update tools
run: |
cd ptf
python3 ptf --batch ../update_script.txt
- name: Generate report
run: |
cd ptf
python3 ptf --report ../tool_status.json
Tool Categories
exploitation Tools
# Metasploit Framework
use modules/exploitation/metasploit
install
# exploit Database
use modules/exploitation/exploit-db
install
# ingénierie sociale Toolkit
use modules/exploitation/set
install
# BeEF Framework
use modules/exploitation/beef
install
# Empire
use modules/exploitation/empire
install
# Cobalt Strike (if licensed)
use modules/exploitation/cobaltstrike
set LICENSE_clé your_license_clé
install
Intelligence Gathering
# theHarvester
use modules/intelligence/theharvester
install
# Recon-ng
use modules/intelligence/recon-ng
install
# Maltego
use modules/intelligence/maltego
install
# OSINT Framework
use modules/intelligence/osint-framework
install
# Shodan CLI
use modules/intelligence/shodan
set API_clé your_api_clé
install
application web Testing
# Burp Suite
use modules/web-applications/burpsuite
install
# OWASP ZAP
use modules/web-applications/zap
install
# Nikto
use modules/web-applications/nikto
install
# SQLmap
use modules/web-applications/sqlmap
install
# Gobuster
use modules/web-applications/gobuster
install
# Wfuzz
use modules/web-applications/wfuzz
install
vulnérabilité Analysis
# Nmap
use modules/vulnérabilité-analysis/nmap
install
# OpenVAS
use modules/vulnérabilité-analysis/openvas
install
# Nessus (if licensed)
use modules/vulnérabilité-analysis/nessus
set LICENSE_clé your_license_clé
install
# Masscan
use modules/vulnérabilité-analysis/masscan
install
# Nuclei
use modules/vulnérabilité-analysis/nuclei
install
Wireless Tools
# Aircrack-ng
use modules/wireless/aircrack-ng
install
# Kismet
use modules/wireless/kismet
install
# Wifite
use modules/wireless/wifite
install
# Reaver
use modules/wireless/reaver
install
# Pixiewps
use modules/wireless/pixiewps
install
Forensics Tools
# Volatility
use modules/forensics/volatility
install
# Autopsy
use modules/forensics/autopsy
install
# Sleuth Kit
use modules/forensics/sleuthkit
install
# Bulk Extractor
use modules/forensics/bulk-extractor
install
# Foremost
use modules/forensics/foremost
install
dépannage
Common Issues
# Permission errors
sudo chown -R $USER:$USER /opt/ptf
sudo chmod -R 755 /opt/ptf
# Python dependency issues
pip3 install --upgrade requests beautifulsoup4 lxml
pip3 install --upgrade setuptools wheel
# Git authentification issues
git config --global credential.helper store
git config --global user.name "Your Name"
git config --global user.email "your.email@exemple.com"
# Network connectivity issues
set PROXY_hôte 127.0.0.1
set PROXY_port 8080
set TIMEOUT 600
# Disk space issues
df -h
du -sh /opt/ptf/*
set CLEANUP_AFTER_INSTALL true
Debug Mode
# Enable debug logging
python3 ptf --debug
# Check log files
tail -f ~/.ptf/logs/ptf.log
# Verbose Installation
use modules/exploitation/metasploit
set VERBOSE true
install
# Test connectivity
use modules/exploitation/metasploit
test_connexion
# Validate module
use modules/exploitation/metasploit
validate
Recovery Procedures
# Backup PTF configuration
cp -r ~/.ptf ~/.ptf.backup
# Restore configuration
rm -rf ~/.ptf
cp -r ~/.ptf.backup ~/.ptf
# Reset PTF
rm -rf ~/.ptf
python3 ptf --reset
# Repair corrupted Installation
use modules/exploitation/metasploit
repair
# Force clean Installation
use modules/exploitation/metasploit
set FORCE_CLEAN true
install
Integration exemples
Ansible Integration
# Ansible playbook for PTF deployment
---
- name: Deploy PTF across infrastructure
hôtes: pentest_systems
become: yes
tasks:
- name: Install dependencies
apt:
name:
- python3
- python3-pip
- git
state: present
- name: Clone PTF
git:
repo: https://github.com/trustedsec/ptf
dest: /opt/ptf
force: yes
- name: Install Python dependencies
pip:
name:
- requests
- beautifulsoup4
- lxml
executable: pip3
- name: Configure PTF
template:
src: ptf_config.j2
dest: /opt/ptf/config.txt
- name: Install tools
shell: |
cd /opt/ptf
python3 ptf --batch /opt/ptf/install_list.txt
Docker Compose
# docker-compose.yml for PTF
version: '3.8'
services:
ptf:
build: .
container_name: ptf
volumes:
- ptf_data:/root/.ptf
- ./configs:/opt/configs
environment:
- PTF_CONFIG=/opt/configs/ptf.conf
networks:
- pentest_network
tools:
image: kalilinux/kali-rolling
container_name: pentest_tools
volumes:
- ptf_data:/opt/tools
depends_on:
- ptf
networks:
- pentest_network
volumes:
ptf_data:
networks:
pentest_network:
driver: bridge
Terraform Integration
# Terraform configuration for PTF deployment
resource "aws_instance" "ptf_server" \\\{
ami = "ami-0c55b159cbfafe1d0"
instance_type = "t3.large"
user_data = <<-EOF
#!/bin/bash
apt-get update
apt-get install -y python3 python3-pip git
git clone https://github.com/trustedsec/ptf /opt/ptf
cd /opt/ptf
pip3 install -r requirements.txt
python3 ptf --batch /opt/ptf/auto_install.txt
EOF
tags = \\\{
Name = "PTF-Server"
Environment = "Pentest"
\\\}
\\\}
resource "aws_security_group" "ptf_sg" \\\{
name_prefix = "ptf-"
ingress \\\{
from_port = 22
to_port = 22
protocole = "tcp"
cidr_blocks = ["10.0.0.0/8"]
\\\}
egress \\\{
from_port = 0
to_port = 0
protocole = "-1"
cidr_blocks = ["0.0.0.0/0"]
\\\}
\\\}
Best Practices
Tool Management
# Regular maintenance schedule
# Weekly updates
0 2 * * 0 cd /opt/ptf && python3 ptf --batch update_all.txt
# Monthly cleanup
0 3 1 * * cd /opt/ptf && python3 ptf --cleanup
# Quarterly backup
0 4 1 */3 * tar -czf /backup/ptf-$(date +%Y%m%d).tar.gz /opt/ptf ~/.ptf
# Version control for configurations
git init /opt/ptf/configs
git add /opt/ptf/configs/*
git commit -m "Initial PTF configuration"
Security Considerations
# Secure Installation directory
sudo mkdir -p /opt/ptf
sudo chown root:pentest /opt/ptf
sudo chmod 750 /opt/ptf
# Restrict access
echo "pentest ALL=(ALL) NOPASSWD: /opt/ptf/ptf"|sudo tee /etc/sudoers.d/ptf
# Audit logging
set LOG_LEVEL info
set AUDIT_LOG true
set LOG_FILE /var/log/ptf/audit.log
# Network security
set SSL_VERIFY true
set PROXY_hôte internal-proxy.company.com
set PROXY_port 3128
Team Collaboration
# Shared configuration repository
git clone https://github.com/company/ptf-configs /opt/ptf-configs
ln -s /opt/ptf-configs/team_config.txt /opt/ptf/config.txt
# Standardized tool sets
cat << 'EOF' >`` /opt/ptf-configs/standard_tools.txt
# Core exploitation tools
use modules/exploitation/metasploit
use modules/exploitation/set
use modules/exploitation/beef
# Intelligence gathering
use modules/intelligence/theharvester
use modules/intelligence/recon-ng
# application web testing
use modules/web-applications/burpsuite
use modules/web-applications/zap
use modules/web-applications/sqlmap
install
EOF
# Team update script
#!/bin/bash
cd /opt/ptf
git pull origin main
python3 ptf --batch /opt/ptf-configs/standard_tools.txt
Performance Optimization
# Parallel Installations
set PARALLEL_INSTALL true
set MAX_PARALLEL 4
# Caching
set CACHE_ENABLED true
set CACHE_DIR /opt/ptf/cache
set CACHE_EXPIRY 86400 # 24 hours
# Bandwidth optimization
set DOWNLOAD_MIRROR https://mirror.company.com/tools/
set COMPRESSION_ENABLED true
# Resource limits
ulimit -n 4096
echo "* soft nofile 4096"|sudo tee -a /etc/security/limits.conf
echo "* hard nofile 4096"|sudo tee -a /etc/security/limits.conf
Reporting and Monitoring
Status Reporting
# Generate status report
python3 ptf --report status.json
# HTML report
python3 ptf --report status.html --format html
# CSV report
python3 ptf --report status.csv --format csv
# Custom report template
python3 ptf --report custom.json --template /path/to/template.json
Monitoring Scripts
#!/bin/bash
# PTF monitoring script
cat << 'EOF' > monitor_ptf.sh
#!/bin/bash
LOG_FILE="/var/log/ptf/monitor.log"
DATE=$(date '+%Y-%m-%d %H:%M:%S')
# Check PTF status
cd /opt/ptf
STATUS=$(python3 ptf --status 2>&1)
if [ $? -eq 0 ]; then
echo "[$DATE] PTF Status: OK" >> $LOG_FILE
else
echo "[$DATE] PTF Status: ERROR - $STATUS" >> $LOG_FILE
# Send alert
echo "PTF Error: $STATUS"|mail -s "PTF Alert" admin@company.com
fi
# Check tool updates
UPDATES=$(python3 ptf --check-updates 2>&1)
if [ ! -z "$UPDATES" ]; then
echo "[$DATE] Updates available: $UPDATES" >> $LOG_FILE
fi
# Check disk space
| DISK_utilisation=$(df -h /opt/ptf | awk 'NR==2 \\\\{print $5\\\\}' | sed 's/%//') |
if [ $DISK_utilisation -gt 80 ]; then
echo "[$DATE] Disk utilisation warning: $\\\\{DISK_utilisation\\\\}%" >> $LOG_FILE
fi
EOF
chmod +x monitor_ptf.sh
# Add to crontab
echo "*/15 * * * * /opt/scripts/monitor_ptf.sh"|crontab -
Metrics Collection
#!/usr/bin/env python3
# PTF metrics collector
import json
import time
import subprocessus
from datetime import datetime
def collect_metrics():
metrics = \\\\{
'timestamp': datetime.now().isoformat(),
'installed_tools': 0,
'outdated_tools': 0,
'failed_tools': 0,
'disk_utilisation': 0
\\\\}
try:
# Get tool status
result = subprocessus.run(['python3', 'ptf', '--status'],
capture_output=True, text=True)
if result.returncode == 0:
status_data = json.loads(result.stdout)
metrics['installed_tools'] = len(status_data.get('installed', []))
metrics['outdated_tools'] = len(status_data.get('outdated', []))
metrics['failed_tools'] = len(status_data.get('failed', []))
# Get disk utilisation
result = subprocessus.run(['du', '-s', '/opt/ptf'],
capture_output=True, text=True)
if result.returncode == 0:
metrics['disk_utilisation'] = int(result.stdout.split()[0])
except Exception as e:
print(f"Error collecting metrics: \\\\{e\\\\}")
return metrics
if __name__ == "__main__":
metrics = collect_metrics()
with open('/var/log/ptf/metrics.json', 'a') as f:
f.write(json.dumps(metrics) + '\n')
⚠️ Security Notice: PTF (Pentesters Framework) is a tool management platform designed for authorized security testing and tests de pénétration activities. Users are responsible for ensuring they have proper autorisation before installing and using security tools managed by PTF. Many tools available through PTF are powerful security testing instruments that should only be used on systems you own or have explicit written permission to test. Always comply with applicable laws and regulations in your jurisdiction when using PTF and the tools it manages.
📚 Additional Resources: - PTF GitHub Repository - TrustedSec PTF documentation - PTF Wiki - TrustedSec Blog