3
0

efficiency_testing.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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_10_000(self):
  6. self.temporal_efficiency_test([['SMBLorisAttack', 'attackers.count=30', 'packets.per-second=8.0']],
  7. time_limit=15, factor=10000)
  8. def test_SMBLoris_100_000(self):
  9. self.temporal_efficiency_test([['SMBLorisAttack', 'attackers.count=30', 'packets.per-second=98']],
  10. time_limit=150, factor=100000)
  11. def test_SMBScan_10_000(self):
  12. self.temporal_efficiency_test([['SMBScanAttack', 'ip.src=192.168.178.1',
  13. 'ip.dst=192.168.178.10-192.168.197.145']], time_limit=15, factor=10000)
  14. def test_SMBScan_100_000(self):
  15. self.temporal_efficiency_test([['SMBScanAttack', 'ip.src=192.168.178.1', 'ip.dst=192.168.0.1-192.168.195.76']],
  16. time_limit=150, factor=100000)
  17. def test_SMBScan_hosting_10_000(self):
  18. self.temporal_efficiency_test([['SMBScanAttack', 'ip.src=192.168.178.1',
  19. 'ip.dst=192.168.178.10-192.168.181.241',
  20. 'hosting.ip=192.168.178.10-192.168.181.241']], time_limit=15, factor=10000)
  21. def test_SMBScan_hosting_100_000(self):
  22. self.temporal_efficiency_test([['SMBScanAttack', 'ip.src=192.168.178.1', 'ip.dst=192.168.178.10-192.168.217.25',
  23. 'hosting.ip=192.168.178.10-192.168.217.25']], time_limit=150, factor=100000)
  24. @mock.patch('ID2TLib.Utility.get_rnd_bytes', side_effect=Lib.get_bytes)
  25. @mock.patch('ID2TLib.Utility.get_rnd_x86_nop', side_effect=Lib.get_x86_nop)
  26. def test_FTPExploit(self, mock_get_rnd_x86_nop, mock_get_rnd_bytes):
  27. self.temporal_efficiency_test([['FTPWinaXeExploit', 'ip.src=192.168.178.1', 'ip.dst=192.168.178.10']],
  28. time_limit=15, factor=10000)
  29. def test_PortscanAttack_open_10_000(self):
  30. self.temporal_efficiency_test([['PortscanAttack', 'ip.src=192.168.178.1', 'port.open=80']], time_limit=15,
  31. factor=10000)
  32. def test_PortscanAttack_close_10_000(self):
  33. self.temporal_efficiency_test([['PortscanAttack', 'ip.src=192.168.178.1', 'port.open=20']], time_limit=15,
  34. factor=10000)
  35. def test_SQLi_10_000(self):
  36. # FIXME: sometimes it takes 15.34028493521018 instead of the normal 7.150923313737726 seconds
  37. self.temporal_efficiency_test([['SQLiAttack', 'ip.dst=192.168.0.1']], time_limit=15, factor=10000)
  38. def test_Joomla_10_000(self):
  39. self.temporal_efficiency_test([['JoomlaRegPrivExploit', 'ip.src=192.168.178.1']], time_limit=15, factor=10000)
  40. def test_SalityBotnet_10_000(self):
  41. self.temporal_efficiency_test([['SalityBotnet']], time_limit=15, factor=10000)
  42. @mock.patch('Attack.BaseAttack.BaseAttack.write_attack_pcap', side_effect=Lib.write_attack_pcap)
  43. def test_DDoS_10_000(self, mock_write_attack_pcap):
  44. # TODO: update attack args, when DDoS gets refactored
  45. self.temporal_efficiency_test([['DDoSAttack', 'attackers.count=100', 'packets.per-second=95',
  46. 'attack.duration=150']], time_limit=15, factor=10000)
  47. @mock.patch('Attack.BaseAttack.BaseAttack.write_attack_pcap', side_effect=Lib.write_attack_pcap)
  48. def test_DDoS_100_000(self, mock_write_attack_pcap):
  49. # TODO: update attack args, when DDoS gets refactored
  50. self.temporal_efficiency_test([['DDoSAttack', 'attackers.count=1000', 'packets.per-second=950',
  51. 'attack.duration=300']], time_limit=150, factor=100000)
  52. # TODO: add temporal efficiency test(s) for EternalBlue and MS17