main
ba05324 ยท 1 year ago 2 commits
 1import express from 'express';
 2import path from 'path';
 3import fs from 'fs';
 4
 5const app = express();
 6const PORT = 3000;
 7const zipBombPath = path.join(__dirname,'10GB.gz');
 8
 9app.get('/', (req, res) => {
10  res.send('Welcome to the Zip Bomb Demo Server. Try hitting /trap as a bot would.');
11});
12
13app.get('/trap', (req, res) => {
14  console.log(`Bot caught! IP: ${req.ip}`);
15  res.setHeader('Content-Encoding', 'gzip');
16  res.setHeader('Content-Type', 'text/html');
17  res.setHeader('Content-Length', fs.statSync(zipBombPath).size.toString());
18  const stream = fs.createReadStream(zipBombPath);
19  stream.pipe(res);
20});
21
22app.listen(PORT, () => {
23  console.log(`Zip Bomb server running at http://localhost:${PORT}`);
24});