Parent : [[INDEX-CYBERSECU]]
Génération d'URLs tracker pour amplification DDoS
Problème
L'archive Ygg contient un générateur d'URLs tracker (generate-tracker-url.js) qui crée des URLs de tracker BitTorrent. Cette technique peut être détournée pour générer des URLs de trackers qui amplifient le trafic ou redirigent vers des endpoints malveillants.
Contexte archive Ygg
- Fichier :
06a_ddos/generate-tracker-url.js - Fichier :
06a_ddos/tracker-urls.log - Tracker : XBT Tracker (
02f_xbt_tracker) - Logs d'abus :
06f_blacklist/xbt_abuse.log
Technique d'amplification
1. Génération d'URLs tracker
Les URLs de tracker BitTorrent contiennent :
http://tracker.example.com:8080/announce?info_hash=...&peer_id=...&port=...&uploaded=...&downloaded=...&left=...&event=started
Amplification : Un seul announce génère une réponse avec la liste des peers (50-200 peers). Envoyer des announces spoofés = amplification du trafic.
2. Logs d'abus (xbt_abuse.log)
Le fichier xbt_abuse.log contient les tentatives d'abus détectées sur le tracker.
Solution protectif — Protection tracker BitTorrent
1. Rate limiting sur le tracker
# tracker_protection.py — Rate limiting et validation
from flask import Flask, request, jsonify
from redis import Redis
import hashlib
import time
app = Flask(__name__)
redis = Redis(host='localhost', port=6379)
# Rate limit par IP : 10 announces / 60 sec
RATE_LIMIT = 10
RATE_WINDOW = 60
@app.route('/announce')
def announce():
client_ip = request.headers.get('X-Forwarded-For', request.remote_addr)
info_hash = request.args.get('info_hash')
# Validation info_hash
if not info_hash or len(info_hash) != 40:
return jsonify({'error': 'Invalid info_hash'}), 400
# Rate limiting
key = f"tracker:{client_ip}:{info_hash}"
current = redis.get(key)
if current and int(current) >= RATE_LIMIT:
return jsonify({'warning': 'Rate limit exceeded'}), 429
pipe = redis.pipeline()
pipe.incr(key)
pipe.expire(key, RATE_WINDOW)
pipe.execute()
# Logging
log_announce(client_ip, info_hash, request.args)
return jsonify({'peers': get_peers(info_hash)})
def log_announce(ip, info_hash, params):
# Log pour détection d'abus
print(f"[TRACKER] {time.time()} | IP={ip} | hash={info_hash[:16]}...")
2. Détection d'annonces spoofés
# detect_spoofing.py — Détection d'annonces malveillantes
import re
from collections import defaultdict
class TrackerAbuseDetector:
def __init__(self):
self.ip_stats = defaultdict(lambda: {'count': 0, 'hashes': set(), 'ports': set()})
def check_announce(self, ip, info_hash, port, peer_id):
stats = self.ip_stats[ip]
stats['count'] += 1
stats['hashes'].add(info_hash)
stats['ports'].add(port)
# Alertes
alerts = []
# 1. Trop de hashes différents
if len(stats['hashes']) > 50:
alerts.append(f"Multi-hash abuse: {len(stats['hashes'])} torrents")
# 2. Trop de ports différents
if len(stats['ports']) > 20:
alerts.append(f"Multi-port abuse: {len(stats['ports'])} ports")
# 3. Peer ID suspicieux (pattern connu de bots)
if re.match(r'^-UT[0-9]{4}-', peer_id):
alerts.append("Suspicious peer ID pattern")
# 4. Volume anormal
if stats['count'] > 100:
alerts.append(f"High frequency: {stats['count']} announces")
return alerts
3. Hardening du tracker XBT
; xbt_tracker.conf — Configuration sécurisée
announce_interval = 1800 ; 30 min minimum entre announces
peer_limit = 50 ; Max 50 peers par réponse
require_key = true ; Clé d'accès requise
whitelist_only = true ; Uniquement torrents whitelistés
log_abuse = true ; Logger les abus
block_tor = false ; Autoriser Tor (mais loguer)
Checklist de validation
- Rate limiting par IP + info_hash
- Validation info_hash (40 caractères hex)
- Limite de peers par réponse (≤50)
- Intervalle announce minimum (≥30 min)
- Détection multi-hash / multi-port
- Logging de tous les announces
- Blacklist automatique des abus répétés
- Clé d'accès pour trackers privés
Comment se prot[ée]ger
- Rate limiting sur la g[ée]n[ée]ration d'URLs
- CAPTCHA ou proof-of-work avant g[ée]n[ée]ration
- Cache des r[ée]sultats (pas de r[ée]g[ée]n[ée]ration [a] chaque requ[ê]te)
- Monitoring du volume d'URLs g[ée]n[ée]r[ée]es par IP
Références
- Archive Ygg :
06a_ddos/,02f_xbt_tracker/,06f_blacklist/xbt_abuse.log - BitTorrent Protocol : BEP-15 (UDP Tracker)
- OWASP : DDoS Protection