PTF (Pentesters Framework) Cheat Sheet¶
Überblick¶
Das Pentesters Framework (PTF) ist eine Python-basierte Werkzeugmanagement-Plattform, die speziell für Penetrationsprüfer und Sicherheitsexperten entwickelt wurde. Die PTF wurde von TrustedSec entwickelt und dient als zentralisierter Repository- und Installationsmanager für Penetrationstests, der automatisierten Installation, Aktualisierung und Verwaltung von Sicherheitswerkzeugen auf verschiedenen Plattformen. Der Rahmen befasst sich mit der gemeinsamen Herausforderung von Sicherheitsexperten, die Dutzende von spezialisierten Werkzeugen in verschiedenen Systemen und Umgebungen pflegen und aktualisieren müssen.
PTF arbeitet an einer modularen Architektur, in der jedes Werkzeug durch eine Konfigurationsdatei definiert wird, die Installationsmethoden, Abhängigkeiten, Update-Prozesse und Kompatibilitätsanforderungen angibt. Dieser Ansatz sorgt für eine konsequente Werkzeugausführung in unterschiedlichen Umgebungen und behält gleichzeitig die Flexibilität bei, Anlagen auf Basis spezifischer Anforderungen anzupassen. Das Framework unterstützt verschiedene Installationsmethoden wie Git Repositories, Paketmanager, benutzerdefinierte Skripte und binäre Downloads, so dass es mit nahezu jedem Sicherheitstool unabhängig von seiner Distributionsmethode kompatibel ist.
Die Stärke des Rahmens liegt in der Fähigkeit, den mühsamen Prozess des Werkzeugmanagements zu automatisieren, der traditionell erhebliche Zeit für Sicherheitsexperten verbraucht. PTF kann automatisch erkennen, wann Werkzeuge Updates verfügbar haben, Abhängigkeitsauflösung verwalten, Versionskonflikte verwalten und Rollback-Funktionen bei Bedarf bereitstellen. Diese Automatisierung ermöglicht Penetrationstests, sich auf ihre Kernsicherheitstests zu konzentrieren, anstatt Zeit für die Wartung und Konfiguration von Werkzeugen zu verbringen.
PTF bietet auch wertvolle Funktionen für Teamumgebungen, einschließlich der Fähigkeit, standardisierte Werkzeugkonfigurationen zu erstellen, die über mehrere Teammitglieder hinweg eingesetzt werden können. Dadurch wird die Konsistenz in Prüfumgebungen gewährleistet und die Wahrscheinlichkeit von Problemen reduziert, die sich aus Fehlern der Werkzeugversion oder Konfigurationsunterschieden ergeben. Die Protokollierungs- und Reporting-Funktionen des Frameworks bieten Sichtbarkeit in den Status der Werkzeuginstallation und die Aktualisierungshistorie, die für die Aufrechterhaltung von Audit-Strecken und Problembehebungen wertvoll ist.
Installation¶
Voraussetzungen¶
```bash
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 ```_
Standardinstallation¶
```bash
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¶
```bash
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 ```_
Installation der virtuellen Umgebung¶
```bash
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 ```_
Systembreite Installation¶
```bash
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 ```_
Basisnutzung¶
Beginn der PTF¶
```bash
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 ```_
Kernkommandos¶
```bash
Show help¶
help ?
List available modules¶
show modules list
Search for modules¶
search nmap search web search "social engineering"
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 ```_
Modulkategorien¶
```bash
List modules by category¶
show modules/exploitation show modules/intelligence show modules/vulnerability-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 ```_
Modulmanagement¶
Installation von Tools¶
```bash
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 ```_
Aufrüstwerkzeuge¶
```bash
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 ```_
Werkzeuge entfernen¶
```bash
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 ```_
Modul Information¶
```bash
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 ```_
Konfigurationsmanagement¶
Globale Konfiguration¶
```bash
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 ```_
Modul-spezifische Konfiguration¶
```bash
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 ```_
Umweltkonfiguration¶
```bash
Set environment variables¶
set ENV_VAR PATH="/opt/tools/bin:$PATH" set ENV_VAR METASPLOIT_HOME="/opt/metasploit"
Configure proxy settings¶
set PROXY_HOST 127.0.0.1 set PROXY_PORT 8080 set PROXY_USER username set PROXY_PASS password
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 ```_
Erweiterte Funktionen¶
Benutzerdefinierte Modul-Erstellung¶
```python
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 Operationen¶
```bash
Create batch installation script¶
cat << 'EOF' > batch_install.txt use modules/exploitation/metasploit use modules/intelligence/theharvester use modules/web-applications/burpsuite use modules/vulnerability-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 ```_
Automatisierungsskripte¶
```bash
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/vulnerability-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 von CI/CD¶
```yaml
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
```_
Werkzeugkategorien¶
Exploitationswerkzeuge¶
```bash
Metasploit Framework¶
use modules/exploitation/metasploit install
Exploit Database¶
use modules/exploitation/exploit-db install
Social Engineering 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_KEY your_license_key install ```_
Nachrichten sammeln¶
```bash
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_KEY your_api_key install ```_
Web Application Testing¶
```bash
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 ```_
Schwachstellenanalyse¶
```bash
Nmap¶
use modules/vulnerability-analysis/nmap install
OpenVAS¶
use modules/vulnerability-analysis/openvas install
Nessus (if licensed)¶
use modules/vulnerability-analysis/nessus set LICENSE_KEY your_license_key install
Masscan¶
use modules/vulnerability-analysis/masscan install
Nuclei¶
use modules/vulnerability-analysis/nuclei install ```_
Funkgeräte¶
```bash
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¶
```bash
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 ```_
Fehlerbehebung¶
Gemeinsame Themen¶
```bash
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 authentication issues¶
git config --global credential.helper store git config --global user.name "Your Name" git config --global user.email "your.email@example.com"
Network connectivity issues¶
set PROXY_HOST 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¶
```bash
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_connection
Validate module¶
use modules/exploitation/metasploit validate ```_
Rückforderungsverfahren¶
```bash
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 ```_
Integrationsbeispiele¶
Anwendbare Integration¶
```yaml
Ansible playbook for PTF deployment¶
-
name: Deploy PTF across infrastructure hosts: 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 komponiert¶
```yaml
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 ```_
Integration von Terrain¶
```hcl
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 protocol = "tcp" cidr_blocks = ["10.0.0.0/8"] \}
egress \{ from_port = 0 to_port = 0 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] \} \} ```_
Best Practices¶
Werkzeugverwaltung¶
```bash
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" ```_
Sicherheitsüberlegungen¶
```bash
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_HOST internal-proxy.company.com set PROXY_PORT 3128 ```_
Team Collaboration¶
```bash
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
Web application 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 ```_
Leistungsoptimierung¶
```bash
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 und Monitoring¶
Status Reporting¶
```bash
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 ```_
Überwachung von Skripten¶
```bash
!/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_USAGE=$(df -h /opt/ptf|awk 'NR==2 \\{print $5\\}'|sed 's/%//') if [ \(DISK_USAGE -gt 80 ]; then echo "[\)DATE] Disk usage warning: $\\{DISK_USAGE\\}%" >> $LOG_FILE fi EOF
chmod +x monitor_ptf.sh
Add to crontab¶
echo "*/15 * * * * /opt/scripts/monitor_ptf.sh"|crontab - ```_
Sammlung von Metriken¶
```python
!/usr/bin/env python3¶
PTF metrics collector¶
import json import time import subprocess from datetime import datetime
def collect_metrics(): metrics = \\{ 'timestamp': datetime.now().isoformat(), 'installed_tools': 0, 'outdated_tools': 0, 'failed_tools': 0, 'disk_usage': 0 \\}
try:
# Get tool status
result = subprocess.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 usage
result = subprocess.run(['du', '-s', '/opt/ptf'],
capture_output=True, text=True)
if result.returncode == 0:
metrics['disk_usage'] = 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') ```_
--
** Sicherheitshinweis**: PTF (Pentesters Framework) ist eine Tool-Management-Plattform für autorisierte Sicherheitstests und Penetrationstests. Die Benutzer sind dafür verantwortlich, dass sie vor der Installation und Nutzung von Sicherheitstools, die von PTF verwaltet werden, eine ordnungsgemäße Autorisierung haben. Viele Tools, die über PTF verfügbar sind, sind leistungsfähige Sicherheitsprüfgeräte, die nur auf Systemen verwendet werden sollten, die Sie besitzen oder eine ausdrückliche schriftliche Genehmigung zum Testen haben. Befolgen Sie immer geltende Gesetze und Vorschriften in Ihrer Gerichtsbarkeit, wenn Sie PTF und die von ihm verwalteten Werkzeuge verwenden.
📚 Zusätzliche Ressourcen: - PTF GitHub Repository - TrustedSec PTF Dokumentation - [PTF Wiki](LINK_4__ - TrustedSec Blog