Created
March 2, 2018 06:58
-
-
Save mchow01/82658e5eb355316f1819696caa006efd to your computer and use it in GitHub Desktop.
A deliberately simple and insecure server written in Node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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...'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instructions
To run:
node server.js
Exercise
Try to take down the server