Created
August 1, 2011 11:06
-
-
Save djromero/1117941 to your computer and use it in GitHub Desktop.
Fake in-URL-bar-search à la Chrome replacing ISP DNS redirect.
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
/* | |
* Fake in-URL-bar-search à la Chrome replacing hijacked DNS redirects | |
* | |
* /etc/hosts | |
* 127.0.0.1 dnssearch.jazztel.com # where your DNS redirects | |
* | |
* Should run as root to be able to use port 80: | |
* sudo node url-bar-search.js | |
*/ | |
var http = require("http"); | |
var util = require("util"); | |
var qs = require("querystring"); | |
var url = require("url"); | |
var server = http.createServer(function(request, response) { | |
var u = url.parse(request.url, true /* parse qs */) | |
// url=www.the original text.com | |
var q = u.query.url.replace('www.', '').replace('.com', ''); | |
util.log(qs.unescape(q)); | |
response.writeHead(302, { | |
'Location': 'http://www.google.com/search?sourceid=hack&ie=UTF-8&q=' + q | |
}); | |
response.end(); | |
}); | |
server.listen(80); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment