efficiency_testing.py 2.8 KB

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