Skip to content

Instantly share code, notes, and snippets.

@rebrec
Created May 17, 2016 12:09
Show Gist options
  • Save rebrec/5e847b159e7a5a5adfc82ff5442f1df9 to your computer and use it in GitHub Desktop.
Save rebrec/5e847b159e7a5a5adfc82ff5442f1df9 to your computer and use it in GitHub Desktop.
const net = require('net');
// common proxy ports
var honeyPort = [ 8080, 3128, 3129, 80 ];
function FakeSrv(port){
this.port = port;
this.server = net.createServer((socket) => {
socket.end('Bye\n');
});
this.server.on('connection', (socket) => {
console.log('FaksSrv (port %s) <-- %s:%s', this.port, socket.remoteAddress, socket.remotePort);
});
this.server.on('listening', () => {
console.log('Listening on port %s ...', this.port);
});
this.server.on('error', () => {
console.log('Error binding port %s', this.port);
});
this.server.listen(this.port, '0.0.0.0');
}
for (var i=0; i<honeyPort.length; i++) {
try{
new FakeSrv(honeyPort[i]);
} catch(e) {
console.log('Error ' + e.message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment