Last active
August 29, 2015 14:23
-
-
Save alibo/c5052e68f66c0c473ff2 to your computer and use it in GitHub Desktop.
Bypass filternet (Node.js version!) [PHP version: https://gist.github.com/alibo/22ed0cf12d8398703335]
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
/** | |
* There is a bug in filternet (filtering system of Iran). | |
* if you wait 3 seconds or more | |
* before sending http request headers, you can bypass | |
* filternet! Also you should use LF | |
* instead of CRLF (like netcat). | |
* | |
* | |
* How to run: | |
* $ node filternet_bypass_bug.js <domain-address> <http-host-value> <wait-time> <path> | |
* | |
* - <domain-address> : connecting via tcp | |
* - <http-host-value> : [optional] [default: <domain-address>] value of header `Host` | |
* - <wait-time> : [optional] [default: 2] waiting time before requesting | |
* - <path> : [optional] [default: '/'] GET <path> HTTP/1.1 | |
*/ | |
var net = require('net'); | |
var client = new net.Socket(); | |
var domain = process.argv[2]; | |
var host = process.argv[3]? process.argv[3]: domain; | |
var waitTime = process.argv[4]? process.argv[4]: 3; | |
var path = process.argv[5]? process.argv[5]: '/'; | |
client.connect(80, domain, function() { | |
console.log('Connected to ' + domain); | |
setTimeout(function(){ | |
console.log('Requesting GET ' + path + ' HTTP/1.1'); | |
console.log('Host: ' + host); | |
console.log('==================='); | |
client.write('GET ' + path + ' HTTP/1.1\n'); | |
client.write('Host: ' + host + '\n\n'); | |
}, waitTime * 1000); | |
}); | |
client.on('data', function(data) { | |
console.log("Response: "); | |
console.log('==================='); | |
console.log(data.toString()); | |
client.destroy(); // kill client after server's response | |
}); | |
client.on('close', function() { | |
console.log('Connection closed'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment