From 910a7562bc3b59eb2e5dfc2d2af77358838883bf Mon Sep 17 00:00:00 2001 From: Simon Morgan Date: Mon, 13 Aug 2007 15:50:10 +0100 Subject: [PATCH] Initial import. --- check.cgi | 21 +++++++++++++++++++++ ppcheck.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100755 check.cgi create mode 100755 ppcheck.py diff --git a/check.cgi b/check.cgi new file mode 100755 index 0000000..57b469c --- /dev/null +++ b/check.cgi @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +import cgi +from os import environ as env + +myip = "127.0.0.1" + +if __name__ == "__main__": + form = cgi.FieldStorage() + + print 'Content-type: text/plain\n' + + if env['REMOTE_ADDR'] == myip: + print "junk" + elif env.has_key('HTTP_X_FORWARDED_FOR') and env['HTTP_X_FORWARDED_FOR'] == myip: + print "junk" + else: + if form.has_key("ppcheck"): + print "ok" + else: + print "junk" diff --git a/ppcheck.py b/ppcheck.py new file mode 100755 index 0000000..0b88adc --- /dev/null +++ b/ppcheck.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +import socket +import sys +import threading +import time +import urllib + +class ProxyScanner(threading.Thread): + def __init__(self, proxy): + threading.Thread.__init__(self) + self.proxy = proxy + def run(self): + try: + d = urllib.urlencode({ "ppcheck": "ppcheck"}) # Check for POST support. + u = urllib.urlopen(checker, d, { "http": "http://" + self.proxy}) + except KeyboardInterrupt: + raise + except: + return + else: + result = u.readline().strip() + if result == "ok": + print self.proxy + +checker = "http://www.example.net/check.cgi" # Use a hostname as some proxies don't do DNS. +numthreads = 100 + +if len(sys.argv) < 2: + sys.exit() + +try: + f = open(sys.argv[1]) +except: + print "Couldn't open %s." % sys.argv[1] + sys.exit() + +socket.setdefaulttimeout(20) + +try: + for l in f: + while threading.activeCount() == numthreads: + time.sleep(2) + thread = ProxyScanner(l.strip()) + thread.start() +except KeyboardInterrupt: + sys.exit() + +f.close() -- 2.11.4.GIT