Created
April 25, 2012 04:28
-
-
Save ruturajv/2486354 to your computer and use it in GitHub Desktop.
node.js web beacon (web bug) serving
This file contains 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
http = require('http'); | |
url = require('url'); | |
http.createServer(function(req, res){ | |
var requestURL = url.parse(req.url, true)['pathname']; | |
if (requestURL == '/log.gif') { | |
var imgHex = '47494638396101000100800000dbdfef00000021f90401000000002c00000000010001000002024401003b'; | |
var imgBinary = new Buffer(imgHex, 'hex'); | |
res.writeHead(200, {'Content-Type': 'image/gif' }); | |
res.end(imgBinary, 'binary'); | |
// Do MySQL/Redis/MongoDB logging | |
} else { | |
res.writeHead(200, {'Content-Type': 'text/plain' }); | |
res.end(''); | |
} | |
}).listen(8080); // Ofcourse u can use whatever IP/port combination you want |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment