commit 7b7ed0b26ff31d32c945e1ea6b5750978534683c Author: Arturo Filastò hellais@gmail.com Date: Wed Feb 29 15:04:05 2012 -0800
Fix warning messages on status and add random logo --- logo.py | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++ ooniprobe.py | 61 ++++++++++++++++++---- tests/bridget.py | 3 + tests/dnstamper.py | 3 + tests/traceroute.py | 3 + 5 files changed, 201 insertions(+), 11 deletions(-)
diff --git a/logo.py b/logo.py new file mode 100644 index 0000000..dcdf119 --- /dev/null +++ b/logo.py @@ -0,0 +1,142 @@ +import random +def getlogo(): + logo = [] + logo.append(""" + _____ _____ __ _ _____ _____ ______ _____ ______ _______ + | | | | | \ | | |_____] |_____/ | | |_____] |______ + |_____| |_____| | _| __|__ | | _ |_____| |_____] |______""") + + logo.append(""" + _ _ + (_) | | + ___ ___ _ __ _ _ __ _ __ ___ | |__ ___ + / _ \ / _ | '_ | | '_ | '__/ _ | '_ \ / _ \ +| (_) | (_) | | | | | |_) | | | (_) | |_) | __/ + ___/ ___/|_| |_|_| .__/|_| ___/|_.__/ ___| + | | + |_|""") + + + logo.append(""" + .__ ___. + ____ ____ ____ |__|_____________ _____ |__ ____ + / _ \ / _ \ / | |____ _ __ / _ | __ _/ __ \ +( <_> | <_> ) | \ || |_> > | ( <_> ) _\ \ ___/ + ____/ ____/|___| /__|| __/|__| ____/|___ /___ > + / |__| / /""") + + + logo.append(""" + __ __ __ __ __ __ ___ +/ \ / \ |\ | | |__) |__) / \ |__) |__ +__/ __/ | | | | | \ __/ |__) |___ """) + + + logo.append(""" + _ _ ._ o ._ ._ _ |_ _ + (_) (_) | | | |_) | (_) |_) (/_ + | +""") + + logo.append(""" + _______ _______ __ _ ___ _______ ______ _______ _______ _______ +| || || | | || | | || _ | | || _ || | +| _ || _ || |_| || | | _ || | || | _ || |_| || ___| +| | | || | | || || | | |_| || |_|| | | | || || |___ +| |_| || |_| || _ || | | ___|| __ || |_| || _ | | ___| +| || || | | || | | | | | ||| || |_| || |___ +|_______||_______||_| |__||___| |___| |___| |||_______||_______||_______| +""") + + + logo.append(""" + _ _ + ___ ___ _ __ (_)_ __ _ __ ___ | |__ ___ + / _ \ / _ | '_ | | '_ | '__/ _ | '_ \ / _ \ +| (_) | (_) | | | | | |_) | | | (_) | |_) | __/ + ___/ ___/|_| |_|_| .__/|_| ___/|_.__/ ___| + |_| +""") + + logo.append(""" + o + o O + O + o +.oOo. .oOo. 'OoOo. O .oOo. `OoOo. .oOo. OoOo. .oOo. +O o O o o O o O o o O o O o OooO' +o O o O O o O o O O o O o O O +`OoO' `OoO' o O o' oOoO' o `OoO' `OoO' `OoO' + O + o' +""") + + + logo.append(""" + _____ _____ ____ _ ____ _____ _____ _____ ______ ______ + / / | \ | || || || | / | >| ___| + | || || | || || _|| \ | || < | ___| + _____/_____/|__/____||____||___| |__|__\\_____/|______>|______| +""") + + logo.append(""" + _ _ + ___ ___ ___|_|___ ___ ___| |_ ___ +| . | . | | | . | _| . | . | -_| +|___|___|_|_|_| _|_| |___|___|___| + |_| +""") + + logo.append(""" + _ _ + (_) | | + ___ ___ ____ _ ____ ____ ___ | |__ _____ + / _ \ / _ | _ | | _ \ / ___) _ | _ | ___ | +| |_| | |_| | | | | | |_| | | | |_| | |_) ) ____| + ___/ ___/|_| |_|_| __/|_| ___/|____/|_____) + |_| +""") + logo.append(""" + _ __ + ____ ____ ____ (_)____ _________ / /_ ___ + / __ / __ / __ / // __ / ___/ __ / __ / _ \ +/ /_/ / /_/ / / / / // /_/ / / / /_/ / /_/ / __/ +____/____/_/ /_/_// .___/_/ ____/_.___/___/ + /_/ +""") + logo.append(""" + _) | + _ \ _ \ \ | _ \ _| _ \ _ \ -_) + ___/ ___/ _| _| _| .__/ _| ___/ _.__/ ___| + _| +""") + logo.append(""" + _ _ + ___ ___ _ __ (_)_ __ _ __ ___ | |__ ___ + / _ \ / _ | '_ | | '_ | '__/ _ | '_ \ / _ \ + | (_) | (_) | | | | | |_) | | | (_) | |_) | __/ + ___/ ___/|_| |_|_| .__/|_| ___/|_.__/ ___| + |_| +""") + logo.append(""" + .-. ( ) + .--. .--. ___ .-. ( __) .-.. ___ .-. .--. | |.-. .--. + / \ / \ ( ) \ (''") / \ ( ) \ / \ | / \ / \ +| .-. ; | .-. ; | .-. . | | ' .-, ; | ' .-. ; | .-. ; | .-. | | .-. ; +| | | | | | | | | | | | | | | | . | | / (___) | | | | | | | | | | | | +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | |/ | +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | ' _.' +| ' | | | ' | | | | | | | | | | ' | | | | ' | | | ' | | | .'.-. +' `-' / ' `-' / | | | | | | | `-' ' | | ' `-' / ' `-' ; ' `-' / + `.__.' `.__.' (___)(___) (___) | __.' (___) `.__.' `.__. `.__.' + | | + (___) +""") + logo.append(""" + o | +,---.,---.,---..,---.,---.,---.|---.,---. +| || || ||| || | || ||---' +`---'`---'` '`|---'` `---'`---'`---' + | +""") + return random.choice(logo) diff --git a/ooniprobe.py b/ooniprobe.py old mode 100644 new mode 100755 index 64d35f5..958c9b1 --- a/ooniprobe.py +++ b/ooniprobe.py @@ -1,5 +1,5 @@ -# -*- coding: UTF-8 #!/usr/bin/env python +# -*- coding: UTF-8 """ ooni-probe ********** @@ -19,15 +19,18 @@ import imp import os import sys +import argparse
from pprint import pprint
import plugoo from utils import Storage, parse_asset, import_test, get_logger from config import Config +from logo import getlogo
class ooni(object): - """ooni-probe is a suite designed to run tests on your + """ + ooni-probe is a suite designed to run tests on your network to detect censorship. This is the main class that is used to start ooni probe select the assets and run tests. @@ -46,13 +49,14 @@ class ooni(object): self.get_assets()
self.tests = Storage() - self.load_tests() + #self.load_tests()
self.runtests = self.config.tests.run.split(",")
def get_assets(self): - """Parse all the assets in the asset directory. + """ + Parse all the assets in the asset directory. Assets can optionaly contain the ooni-probe asset file format: #:<something> <something_else>, that will then be used to render the asset details to the user. @@ -65,7 +69,8 @@ class ooni(object): self.assets.append(parse_asset(asset))
def list_assets(self): - """Enumerate all the assets in the directory specified + """ + Enumerate all the assets in the directory specified in the config file """ print "[-] There are a total of %s assets loaded" % len(self.assets) @@ -80,7 +85,8 @@ class ooni(object): print ""
def load_tests(self): - """Iterate through the plugoos insite the folder specified by the + """ + Iterate through the plugoos insite the folder specified by the config file and instantiate them. """ pluginfiles = [fname[:-3] for fname in os.listdir(self.config.main.testdir)\ @@ -108,8 +114,10 @@ class ooni(object): print "Failed to load the test %s %s" % (name, e)
def list_tests(self): - """Print the loaded plugoonis to screen """ + Print the loaded plugoonis to screen + """ + self.load_tests() print "[-] There are a total of %s tests available" % len(self.tests) for name, test in self.tests.items(): print " name: %s" % name @@ -121,8 +129,10 @@ class ooni(object):
def run_tests(self): - """Run all the tests that have been loaded """ + Run all the tests that have been loaded + """ + self.load_tests() for name in self.runtests: print "running %s" % name try: @@ -131,12 +141,41 @@ class ooni(object): print "ERR: %s" % e
def run_test(self, test): - """Run a single test """ + Run a single test + """ + self.load_tests() self.tests[test].module.run(self)
if __name__ == "__main__": + o = ooni() - o.list_tests() - o.run_test("bridget") + + parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, + description=getlogo()+'\n\n Open Observatory of Network Interference.') + parser.add_argument('-t', '--list-tests', help='List all the available tests', + action='store_true', dest='list_tests') + + parser.add_argument('-l', '--list-assets', help='List all the assets', + action='store_true', dest='list_assets') + + parser.add_argument('-r', '--run', help='Run a certain test', action='store') + + parser.add_argument('-a', '--asset', help='Use this asset for the test', action='store') + + parser.add_argument('--runall', help='Run all the tests in the config', action='store_true') + + args = parser.parse_args() + + if args.list_tests: + o.list_tests() + + if args.list_assets: + o.list_assets() + + if args.run: + o.run_test(args.run) + + elif args.runall: + o.run_tests()
diff --git a/tests/bridget.py b/tests/bridget.py index 59d7800..c4515aa 100644 --- a/tests/bridget.py +++ b/tests/bridget.py @@ -36,6 +36,9 @@ try: except: print "Error TorCtl not installed!"
+__plugoo__ = "BridgeT" +__desc__ = "BridgeT, for testing Tor Bridge reachability" + class SocksiPyConnection(httplib.HTTPConnection): def __init__(self, proxytype, proxyaddr, proxyport = None, rdns = True, username = None, password = None, *args, **kwargs): diff --git a/tests/dnstamper.py b/tests/dnstamper.py index 987a948..06b3551 100644 --- a/tests/dnstamper.py +++ b/tests/dnstamper.py @@ -7,6 +7,9 @@ import os import plugoo from plugoo import Plugoo, Asset
+__plugoo__ = "DNST" +__desc__ = "DNS censorship detection test" + class DNSTAsset(Asset): def __init__(self, file=None): self = Asset.__init__(self, file) diff --git a/tests/traceroute.py b/tests/traceroute.py index d7e722a..f2272c9 100644 --- a/tests/traceroute.py +++ b/tests/traceroute.py @@ -15,6 +15,9 @@ from plugoo import Plugoo, Asset
import socket
+__plugoo__ = "Traceroute" +__desc__ = "Performs TTL walking tests" + class TracerouteAsset(Asset): def __init__(self, file=None): self = Asset.__init__(self, file)
tor-commits@lists.torproject.org