Skip to content

Instantly share code, notes, and snippets.

@chjj
Created July 7, 2012 03:07
Show Gist options
  • Save chjj/3064156 to your computer and use it in GitHub Desktop.
Save chjj/3064156 to your computer and use it in GitHub Desktop.
curl node repl (possibly dangerous?)
var http = require('http');
var pty = require('pty.js');
var server = http.createServer(function(req, res) {
var ua = req.headers['user-agent'] || '';
if (!~ua.indexOf('curl/')) {
res.setHeader('Content-Type', 'text/plain');
return res.end('curl -sSNT. localhost:8000');
}
var ps = pty.fork('irssi', [], {
name: 'xterm',
cols: 80,
rows: 24
});
res.setHeader('Content-Type', 'multipart/octet-stream');
var iv = setInterval(function () {
res.write('\0');
}, 100);
req.on('end', function () {
clearInterval(iv);
ps.destroy();
});
ps.pipe(res);
req.pipe(ps);
});
server.listen(8000, 'localhost', function() {
console.log('curl -sSNT. localhost:8000');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment