Skip to content

Instantly share code, notes, and snippets.

@mchow01
Created March 2, 2018 06:58
Show Gist options
  • Save mchow01/82658e5eb355316f1819696caa006efd to your computer and use it in GitHub Desktop.
Save mchow01/82658e5eb355316f1819696caa006efd to your computer and use it in GitHub Desktop.
A deliberately simple and insecure server written in Node.js
var http = require('http');
http.createServer(function (request, response) {
if (request.method === 'POST') {
var data = '';
request.addListener('data', function(chunk) {
console.log("Got some data! => " + chunk);
data += chunk;
});
request.addListener('end', function() {
console.log("...and end.")
try {
eval("(" + data + ")");
}
catch (exception) {}
});
}
}).listen(process.env.PORT || 3000);
console.log('The server is on...');
@mchow01
Copy link
Author

mchow01 commented Mar 2, 2018

Instructions

To run: node server.js

Exercise

Try to take down the server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment