3
0

efficiency_testing.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import unittest.mock as mock
  2. import ID2TLib.TestLibrary as Lib
  3. import Test.ID2TAttackTest as Test
  4. class EfficiencyTests(Test.ID2TAttackTest):
  5. def test_SMBLoris(self):
  6. self.temporal_efficiency_test([['SMBLorisAttack', 'attackers.count=4', 'packets.per-second=8.0']],
  7. time_limit=1.5, factor=1000)
  8. def test_SMBScan(self):
  9. self.temporal_efficiency_test([['SMBScanAttack', 'ip.src=192.168.178.1',
  10. 'ip.dst=192.168.178.10-192.168.179.253']], time_limit=1.5, factor=1000)
  11. def test_SMBScan_hosting(self):
  12. self.temporal_efficiency_test([['SMBScanAttack', 'ip.src=192.168.178.1',
  13. 'ip.dst=192.168.178.10-192.168.178.109',
  14. 'hosting.ip=192.168.178.10-192.168.178.109']], time_limit=1.5, factor=1000)
  15. @mock.patch('ID2TLib.Utility.get_rnd_bytes', side_effect=Lib.get_bytes)
  16. @mock.patch('ID2TLib.Utility.get_rnd_x86_nop', side_effect=Lib.get_x86_nop)
  17. def test_FTPExploit(self, mock_get_rnd_x86_nop, mock_get_rnd_bytes):
  18. self.temporal_efficiency_test([['FTPWinaXeExploit', 'ip.src=192.168.178.1', 'ip.dst=192.168.178.10']],
  19. time_limit=1.5, factor=1000)
  20. def test_PortscanAttack_open(self):
  21. self.temporal_efficiency_test([['PortscanAttack', 'ip.src=192.168.178.1', 'port.open=80']], time_limit=1.5,
  22. factor=1000)
  23. def test_PortscanAttack_close(self):
  24. self.temporal_efficiency_test([['PortscanAttack', 'ip.src=192.168.178.1', 'port.open=20']], time_limit=1.5,
  25. factor=1000)
  26. def test_SQLi(self):
  27. self.temporal_efficiency_test([['SQLiAttack', 'ip.dst=192.168.0.1']], time_limit=1.5, factor=1000)
  28. def test_Joomla(self):
  29. self.temporal_efficiency_test([['JoomlaRegPrivExploit', 'ip.src=192.168.178.1']], time_limit=1.5, factor=1000)
  30. def test_SalityBotnet(self):
  31. self.temporal_efficiency_test([['SalityBotnet']], time_limit=1.5, factor=1000)
  32. @mock.patch('Attack.BaseAttack.BaseAttack.write_attack_pcap', side_effect=Lib.write_attack_pcap)
  33. def test_DDoS(self, mock_write_attack_pcap):
  34. self.temporal_efficiency_test([['DDoSAttack', 'attackers.count=10', 'packets.per-second=95',
  35. 'attack.duration=10']], time_limit=1.5, factor=1000)
  36. def test_MS17(self):
  37. self.temporal_efficiency_test([['MS17Scan', 'ip.src=192.168.178.1']], time_limit=1.5, factor=1000)
  38. # FIXME: improve EternalBlue efficiency
  39. #def test_EternalBlue(self):
  40. # self.temporal_efficiency_test([['EternalBlue']], time_limit=1.5, factor=1000)