Skip to content

Instantly share code, notes, and snippets.

@djromero
Created August 1, 2011 11:06
Show Gist options
  • Save djromero/1117941 to your computer and use it in GitHub Desktop.
Save djromero/1117941 to your computer and use it in GitHub Desktop.
Fake in-URL-bar-search à la Chrome replacing ISP DNS redirect.
/*
* 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