Example #1
0
def startPublic(init):
    cip = ConfigIniParser()
    cip.addHandler(ServiceBotConfigHandler())
    cip.addHandler(ServiceConfigHandler())
    cip.addHandler(UsenixConfigHandler())

    config_path = "config/usenix_public.ini"
    conf = cip.load(config_path)
    conf.setFlagPhrase("flags wave in the wind")

    assert (conf.isValid())

    #Create Game Logic
    usenixlogic = UsenixPublicLogic(conf, init)

    #Create GameStateBot
    game_state_bot = GameStateBot(conf, usenixlogic)
    game_state_bot.start()

    time.sleep(1)

    #Create ServiceBot
    servicebot = ServiceBot(conf, init)
    servicebot.start()

    #Create UsenixReportBot
    reportbot = UsenixReportBot(conf, 8081)
    reportbot.start()

    servicebot.join()
    reportbot.join()
    game_state_bot.join()
Example #2
0
	def testMissingSection(self):
		test_path = os.path.join(modulePath(),"testini","no_logging.ini")
		cip = ConfigIniParser(debug=True)
		try:
			cip.load(test_path)
			self.assert_(False,"ConfigParser should have thown exit execption")
		except SystemExit as e:
			self.assertEquals(type(e), type(SystemExit()))
	def testValidServiceScripts(self):
		test_path = os.path.join(modulePath(),"testini","test_service.ini")
		cip = ConfigIniParser()
		cip.addHandler(ServiceBotConfigHandler())
		cip.addHandler(ServiceConfigHandler())
		try:
			conf = cip.load(test_path)
			self.assert_(False,"ConfigParser should have thown exit execption")
		except SystemExit as e:
			self.assertEquals(type(e), type(SystemExit()))
Example #4
0
	def testGetTeams(self):
		test_path = os.path.join(modulePath(),"testini","test_config.ini")
		cip = ConfigIniParser(debug=True)
		conf = cip.load(test_path)
		team1 = conf.getTeamInfoById(0)
		team2 = conf.getTeamInfoById(1)
		
		#Order is not preserved
		self.assert_(team1.name == "Team1" or team1.name == "Team2")
		self.assert_(team2.name == "Team1" or team2.name == "Team2")
Example #5
0
def startAll(init):

    #Setup config
    cip = ConfigIniParser()
    cip.addHandler(ServiceBotConfigHandler())
    cip.addHandler(ServiceConfigHandler())
    cip.addHandler(UsenixConfigHandler())
    cip.addHandler(UsenixExploitConfigHandler())
    #cip.addHandler(AttackConfigHandler(False))

    #Load conf file
    config_path = "config/usenix.ini"
    conf = cip.load(config_path)

    #Temporary hack - this should be in config file..
    conf.setFlagPhrase("flags wave in the wind")

    assert (conf.isValid())

    #Create Game Logic
    usenixlogic = UsenixLogic(conf, init)

    #Create GameStateBot
    game_state_bot = GameStateBot(conf, usenixlogic)
    game_state_bot.start()

    time.sleep(1)

    #Create ServiceBot
    servicebot = ServiceBot(conf, init)
    servicebot.start()

    #Create Scoreboard

    #Create UsenixExploitBot
    usenix_exploit_bot = UsenixExploitBot(conf, init)
    usenix_exploit_bot.start()

    #Create UsenixReportBot
    reportbot = UsenixReportBot(conf, 8082)
    reportbot.start()

    reportbot.join()
    usenix_exploit_bot.join()
    servicebot.join()
    game_state_bot.join()
Example #6
0
def mainStandard():

	#Setup config
	cip = ConfigIniParser()
	cip.addHandler(ServiceBotConfigHandler())
	cip.addHandler(ServiceConfigHandler())

	#Load conf file
	test_config_path = "config/integration_test.ini"
	conf = cip.load(test_config_path)
	
	#Temporary hack - this should be in config file..
	conf.setFlagPhrase("flags wave in the wind")

	assert(conf.isValid())

	#Create Game Type
	gamelogic = StandardCTF(conf,True)

	try:
		#Create Game Server
		game_server_bot = GameServerBot(conf,gamelogic)
		game_server_bot.start()
		time.sleep(1)

		#Create ServiceBot
		service_bot = ServiceBot(conf,True)		
		service_bot.start()

		#Create SubmitBot
		submit_bot = SubmitBot(conf,True)
		submit_bot.start()

		#Create ScoreboardBot
		scoreboard_bot = ScoreboardBot(conf,True)
		scoreboard_bot.start()

		submit_bot.join()
		service_bot.join()
		game_server_bot.join()

	except KeyboardInterrupt:
		print "Integration test caught keyboard interrupt"

	finally:
		print "Finally.."
Example #7
0
def main(argv):
    global flag_submission_bot

    if (len(argv) != 2):
        print "Usage: %s [all attack submission]" % argv[0]
        return

    #Load conf file
    config_path = "config/ructfe.ini"
    cip = ConfigIniParser()
    cip.addHandler(AttackConfigHandler(True))
    conf = cip.load(config_path)
    print conf
    assert (conf.isValid())

    #Create Game Type
    if (argv[1] == "all" or argv[1] == "attack"):
        attacklogic = AttackEngineLogic(conf)

        #Create GameStateBot
        game_state_bot = GameStateBot(conf, attacklogic)
        game_state_bot.start()

        time.sleep(1)

        #Create AttackBot
        attack_bot = AttackBot(conf, True)
        attack_bot.start()

        #Create WebBot
        web_bot = WebBot(conf, True)
        web_bot.start()
        print "All Started.."

    if (argv[1] == "all" or argv[1] == "submission"):
        #Create FlagSubmissionBot
        flag_submission_bot = FlagSubmissionBot(conf, True)
        print "Flag started"
        flag_submission_bot.start()
        flag_submission_bot.join()

    game_state_bot.join()
    attack_bot.join()
    web_bot.join()
Example #8
0
def mainAttack():
	#Load conf file
	test_config_path = "config/attack_test.ini"
	conf = ConfigIniParser().load(test_config_path)
	assert(conf.isValid())

	#Create Game Type
	attacklogic = AttackLogic(conf)

	#Create GameStateBot
	game_state_bot = GameStateBot(conf,attacklogic)
	game_state_bot.start()

	time.sleep(1)

	#Create AttackBot
	attack_bot = AttackBot(conf,True)
	attack_bot.start()

	attack_bot.join()
	game_state_bot.join()
	"""
Example #9
0
	def testValidConfig(self):
		test_path = os.path.join(modulePath(),"testini","test_config.ini")
		conf = ConfigIniParser(debug=True).load(test_path)
		self.assert_(conf.isValid())
Example #10
0
def main(argv):
    #Parse command line
    try:
        opts, args = getopt.gnu_getopt(argv[1:], "ic:")
    except getopt.GetoptError as err:
        print str(err)
        print "Usage: %s [-i] [-c <config file>]" % sys.argv[0]
        print "-i\t\t\tInitialize new game"
        print "-c <config file>\tPath to alternate config.ini"
        sys.exit(2)

    initialize = False
    default_config_path = "config/config.ini"
    config_path = default_config_path

    for o, a in opts:
        if o == "-i":
            initialize = True

        elif o == "-c":
            config_path = a

        else:
            assert False, "unhandled option"

    #Setup config
    cip = ConfigIniParser()
    cip.addHandler(FlagConfigHandler())
    cip.addHandler(ServiceBotConfigHandler())
    cip.addHandler(SubmitBotConfigHandler())
    cip.addHandler(ScoreboardBotConfigHandler())
    cip.addHandler(ServiceConfigHandler())

    #Load conf file
    if (config_path == default_config_path):
        print "Using default config file", config_path

    conf = cip.load(config_path)

    #Temporary hack - this should be in config file..
    #conf.setFlagPhrase("flags wave in the wind")
    required_sections = [
        "FLAG",
        "SUBMIT_BOT",
        "SCOREBOARD_BOT",
        "SUBMIT_BOT",
    ]
    assert (conf.isValid(required_sections)), "A required section is missing!"

    #Create Game Type
    gamelogic = StandardCTF(conf, initialize)

    try:
        #Create Game Server
        game_server_bot = GameServerBot(conf, gamelogic)
        game_server_bot.start()
        time.sleep(1)

        #Create ServiceBot
        service_bot = ServiceBot(conf, initialize)
        service_bot.start()

        #Create SubmitBot
        submit_bot = SubmitBot(conf, initialize)
        submit_bot.start()

        #Create ScoreboardBot
        scoreboard_bot = ScoreboardBot(conf, initialize)
        scoreboard_bot.start()

        scoreboard_bot.join()
        submit_bot.join()
        service_bot.join()
        game_server_bot.join()

    except KeyboardInterrupt:
        print "Main caught keyboard interrupt"

    finally:
        print "Finally.."
	def setUp(self):
		self.cip = ConfigIniParser(debug=True)
		self.cip.addHandler(ServiceBotConfigHandler())
		self.cip.addHandler(ServiceConfigHandler())