()
Zarp entry point
Zarp entry point
Zarp entry point
def main():
    """ Zarp entry point
    """

    # set up configuration
    config.initialize()

    # set up database
    database.initialize()

    # load modules
    loader = LoadedModules()
    loader.load()
    util.Msg('Loaded %d modules.' % loader.total)

    # handle command line options first
    if len(argv) > 1:
        parse_cmd.parse(argv, loader)

    # menus
    main_menu = ['Poisoners', 'DoS Attacks', 'Sniffers', 'Scanners',
                     'Parameter', 'Services', 'Attacks', 'Sessions']

    running = True
    choice = -1
    while running:
        util.header()
        choice = util.print_menu(main_menu)
        if choice == 0:
            # check if they've got running sessions!
            cnt = stream.get_session_count()
            if cnt > 0:
                display = color.B_YELLOW + 'You have %d sessions running. ' + \
                          'Are you sure? ' + color.B_GREEN + '[' + color.B_YELLOW + \
                          'Y' + color.B_GREEN + '/' + color.B_YELLOW + 'n' + \
                          color.B_GREEN + '] ' + color.END
                choice = raw_input(display % cnt)
                if 'y' in choice.lower() or choice == '':
                    util.Msg('Shutting all sessions down...')
                    stream.stop_session('all', -1)
                    running = False

            else:
                util.debug("Exiting with session count: %d" % (cnt))
                util.Msg("Exiting...")
                running = False

            # remove zarp temporary directory
            util.init_app('rm -fr /tmp/.zarp/')
             
            # recheck that all sessions are down
            cnt = stream.get_session_count()
            if cnt <= 0:
               # some libs dont clean up their own threads, so
               # we need to hard quit those to avoid hanging; FIXME
               _exit(1)
        elif choice == 1:
            while True:
                choice = util.print_menu([x().which for x in loader.poison])
                if choice == 0:
                    break
                elif choice == -1:
                    pass
                elif choice > len(loader.poison):
                    continue
                else:
                    stream.initialize(loader.poison[choice - 1])
        elif choice == 2:
            while True:
                choice = util.print_menu([x().which for x in loader.dos])
                if choice == 0:
                    break
                elif choice == -1:
                    pass
                elif choice > len(loader.dos):
                    continue
                else:
                    stream.initialize(loader.dos[choice - 1])
        elif choice == 3:
            while True:
                choice = util.print_menu([x().which for x in loader.sniffers])
                if choice == 0:
                    break
                elif choice == -1:
                    pass
                elif choice > len(loader.sniffers):
                    continue
                else:
                    stream.initialize(loader.sniffers[choice - 1])
        elif choice == 4:
            while True:
                choice = util.print_menu([x().which for x in loader.scanner])
                if choice == 0:
                    break
                elif choice == -1:
                    pass
                elif choice > len(loader.scanner):
                    continue
                else:
                    stream.initialize(loader.scanner[choice - 1])
        elif choice == 5:
            while True:
                choice = util.print_menu([x().which for x in loader.parameter])
                if choice == 0:
                    break
                elif choice == -1:
                    pass
                elif choice > len(loader.parameter):
                    continue
                else:
                    stream.initialize(loader.parameter[choice - 1])
        elif choice == 6:
            while True:
                choice = util.print_menu([x().which for x in loader.services])
                if choice == 0:
                    break
                elif choice == -1:
                    pass
                elif choice > len(loader.services):
                    continue
                else:
                    stream.initialize(loader.services[choice - 1])
        elif choice == 7:
            while True:
                choice = util.print_menu([x().which for x in loader.attacks])
                if choice == 0:
                    break
                elif choice == -1:
                    pass
                elif choice > len(loader.attacks):
                    continue
                else:
                    stream.initialize(loader.attacks[choice - 1])
        elif choice == 8:
            session_manager.menu()
        elif choice == -1:
            pass
def main ( ) : # set up configuration config . initialize ( ) # set up database database . initialize ( ) # load modules loader = LoadedModules ( ) loader . load ( ) util . Msg ( 'Loaded %d modules.' % loader . total ) # handle command line options first if len ( argv ) > 1 : parse_cmd . parse ( argv , loader ) # menus main_menu = [ 'Poisoners' , 'DoS Attacks' , 'Sniffers' , 'Scanners' , 'Parameter' , 'Services' , 'Attacks' , 'Sessions' ] running = True choice = - 1 while running : util . header ( ) choice = util . print_menu ( main_menu ) if choice == 0 : # check if they've got running sessions! cnt = stream . get_session_count ( ) if cnt > 0 : display = color . B_YELLOW + 'You have %d sessions running. ' + 'Are you sure? ' + color . B_GREEN + '[' + color . B_YELLOW + 'Y' + color . B_GREEN + '/' + color . B_YELLOW + 'n' + color . B_GREEN + '] ' + color . END choice = raw_input ( display % cnt ) if 'y' in choice . lower ( ) or choice == '' : util . Msg ( 'Shutting all sessions down...' ) stream . stop_session ( 'all' , - 1 ) running = False else : util . debug ( "Exiting with session count: %d" % ( cnt ) ) util . Msg ( "Exiting..." ) running = False # remove zarp temporary directory util . init_app ( 'rm -fr /tmp/.zarp/' ) # recheck that all sessions are down cnt = stream . get_session_count ( ) if cnt <= 0 : # some libs dont clean up their own threads, so # we need to hard quit those to avoid hanging; FIXME _exit ( 1 ) elif choice == 1 : while True : choice = util . print_menu ( [ x ( ) . which for x in loader . poison ] ) if choice == 0 : break elif choice == - 1 : pass elif choice > len ( loader . poison ) : continue else : stream . initialize ( loader . poison [ choice - 1 ] ) elif choice == 2 : while True : choice = util . print_menu ( [ x ( ) . which for x in loader . dos ] ) if choice == 0 : break elif choice == - 1 : pass elif choice > len ( loader . dos ) : continue else : stream . initialize ( loader . dos [ choice - 1 ] ) elif choice == 3 : while True : choice = util . print_menu ( [ x ( ) . which for x in loader . sniffers ] ) if choice == 0 : break elif choice == - 1 : pass elif choice > len ( loader . sniffers ) : continue else : stream . initialize ( loader . sniffers [ choice - 1 ] ) elif choice == 4 : while True : choice = util . print_menu ( [ x ( ) . which for x in loader . scanner ] ) if choice == 0 : break elif choice == - 1 : pass elif choice > len ( loader . scanner ) : continue else : stream . initialize ( loader . scanner [ choice - 1 ] ) elif choice == 5 : while True : choice = util . print_menu ( [ x ( ) . which for x in loader . parameter ] ) if choice == 0 : break elif choice == - 1 : pass elif choice > len ( loader . parameter ) : continue else : stream . initialize ( loader . parameter [ choice - 1 ] ) elif choice == 6 : while True : choice = util . print_menu ( [ x ( ) . which for x in loader . services ] ) if choice == 0 : break elif choice == - 1 : pass elif choice > len ( loader . services ) : continue else : stream . initialize ( loader . services [ choice - 1 ] ) elif choice == 7 : while True : choice = util . print_menu ( [ x ( ) . which for x in loader . attacks ] ) if choice == 0 : break elif choice == - 1 : pass elif choice > len ( loader . attacks ) : continue else : stream . initialize ( loader . attacks [ choice - 1 ] ) elif choice == 8 : session_manager . menu ( ) elif choice == - 1 : pass