コード例 #1
0
ファイル: swabberd.py プロジェクト: nosmo/swabber
def runThreads(configpath):

    config = getConfig(configpath)
    #TODO make iptables_lock optional
    iptables_lock = threading.Lock()

    cleaner = None
    if config["bantime"] != 0:
        cleaner = BanCleaner(config["bantime"], config["backend"],
                             iptables_lock, config["interface"])
    banner = BanFetcher(config["bindstrings"],
                        config["interface"], config["backend"],
                        iptables_lock)

    def handleSignal(signum, frame):
        if signum == 15 or signum == 16:
            banner.stopIt()
            if config["bantime"]:
                cleaner.stopIt()
            logging.warning("Closing on SIGTERM")
    signal.signal(signal.SIGTERM, handleSignal)

    try:
        if config["bantime"] != 0:
            cleaner.start()
            logging.warning("Started running cleaner")
        banner.start()
        logging.warning("Started running banner")
    except Exception as e:
        print "Exception %s" % e
        logging.error("Swabber exiting on exception %s!", str(e))
        if config["bantime"]:
            cleaner.stopIt()
        banner.stopIt()
コード例 #2
0
ファイル: testing.py プロジェクト: nosmo/swabber
    def run(self): 

        bfetcher = BanFetcher(DB_CONN, BINDSTRING, False)
        bfetcher.start()

        print "Starting attacks"

        for i in range(self.hit_times): 
            if i % 1000 == 0:
                print "Attacked %d times" % i

            a = Attacker(self.testip)
            a.start()
            del(a)