Files
hanger/index.mjs

42 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-07-24 16:40:40 +02:00
import { createServer } from 'node:http';
import { clearInterval, setInterval } from 'node:timers';
const server = createServer((req, res) => {
2024-07-24 19:15:07 +02:00
const connOpenDate = new Date();
const attacker = req.headers['x-forwarded-for'];
const host = req.headers['X-Targeted-Host'];
2024-07-24 19:15:07 +02:00
2024-07-24 19:19:39 +02:00
console.log(req.headers);
2024-07-24 16:40:40 +02:00
console.log(
2024-07-24 19:15:07 +02:00
`[${connOpenDate.toLocaleString()}] ${attacker} targeted ${host} on ${
req.method
} ${req.url}`
2024-07-24 16:40:40 +02:00
);
2024-07-24 19:15:07 +02:00
const msg = ':) you are an idiot hahahahaha :)';
2024-07-24 16:40:40 +02:00
let charIdx = 0;
2024-07-24 19:15:07 +02:00
const intervalId = setInterval(() => {
2024-07-24 16:40:40 +02:00
if (charIdx === msg.length) {
charIdx = 0;
res.write('\n');
} else {
res.write(msg[charIdx++]);
}
}, 3000);
2024-07-24 19:15:07 +02:00
res.once('close', () => {
const connCloseDate = new Date();
const timeDiff = connCloseDate.getTime() - connOpenDate.getTime();
const diffText = new Date(timeDiff).toISOString().substring(11, 19);
clearInterval(intervalId);
console.log(
`[${connCloseDate.toLocaleString()}] ${attacker} aborted connection after ${diffText}`
);
});
2024-07-24 16:40:40 +02:00
});
server.listen(3000);