Esempio n. 1
0
	def testStop(self):
		path = os.path.join(modulePath(),'testexploits','Forever.py')
		attack = AttackTask(path,"127.0.0.1",10,None)
		attack.launch()
		time.sleep(0.3)
		self.assertTrue(attack.isAlive())
		attack.stop()
		time.sleep(0.3)
		self.assertFalse(attack.isAlive())
		attack.quit()
Esempio n. 2
0
	def testBasicAttack(self):
		path = os.path.join(modulePath(),'testexploits','Succesful.py')
		attack = AttackTask(path,"127.0.0.1",2,None)
		attack.launch()
		time.sleep(0.1)
		attack.processOutput()
		flags = attack.collectFlags()
		self.assertEquals(flags,["foobarbaz"])
		attack.quit()
Esempio n. 3
0
	def testInfiniteAttack(self):
		path = os.path.join(modulePath(),'testexploits','Infinite.py')
		attack = AttackTask(path,"127.0.0.1",1,None)
		attack.launch()
		time.sleep(0.5)
		attack.processOutput()
		time.sleep(2)
		self.assertTrue(attack.isAlive())
		attack.quit()
Esempio n. 4
0
	def testRestartAttack(self):
		path = os.path.join(modulePath(),'testexploits','Succesful.py')
		attack = AttackTask(path,"127.0.0.1",2,None)
	
		for i in range(5):	
			attack.launch()
			time.sleep(0.1)
			self.assertFalse(attack.isAlive())
		
		attack.processOutput()
		flags = attack.collectFlags()
		self.assertEquals(flags,["foobarbaz"]*5)
		attack.quit()
Esempio n. 5
0
	def testCookieAttack(self):
		path = os.path.join(modulePath(),'testexploits','Cookie.py')
		attack = AttackTask(path,"127.0.0.1",2,None)
	
		for i in range(5):	
			attack.launch()
			time.sleep(0.1)
			self.assertFalse(attack.isAlive())
			attack.processOutput()
		
		flags = attack.collectFlags()
		for i in range(len(flags)):
			self.assertEquals(flags[i],"COOKIEFLAG%d"%i)

		attack.quit()
Esempio n. 6
0
	def testTimeoutAttack(self):
		path = os.path.join(modulePath(),'testexploits','Timeout.py')
		attack = AttackTask(path,"127.0.0.1",5,None)
		attack.launch()
		time.sleep(0.5)
		attack.processOutput()
		count = 0
		while(attack.isAlive()):
			time.sleep(1)
			count += 1
			self.assertTrue(count < 5)

		attack.quit()
Esempio n. 7
0
	def testExpireTimeout(self):
		path = os.path.join(modulePath(),'testexploits','Timeout.py')
		attack = AttackTask(path,"127.0.0.1",1,None)
		attack.launch()
		time.sleep(1.5)
		self.assertFalse(attack.isAlive())
		attack.quit()
Esempio n. 8
0
 def __updateAttacks(self, exploit):
     exploit_dir = self.attack_conf.exploitDir()
     path = os.path.join(exploit_dir, exploit)
     logger = self.conf.buildLogger("Exploit-%s" % exploit)
     for team in self.conf.teams:
         attack = AttackTask(path, team.host,
                             self.attack_conf.exploitTimeout(), logger)
         key = (team.id, exploit)
         self.attack_tasks[key] = attack
Esempio n. 9
0
	def testStress(self):
		path = os.path.join(modulePath(),'testexploits','Forever.py')
	
		attacks = []
		for i in xrange(500):
			attacks.append(AttackTask(path,"127.0.0.1",10,None))
			attacks[i].launch()

		for i in xrange(500):
			attacks[i].processOutput()

		for i in xrange(500):
			attacks[i].quit()
			self.assertFalse(attacks[i].isAlive())