12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import unittest.mock as mock
- import ID2TLib.TestLibrary as Lib
- import Test.ID2TAttackTest as Test
- sha_basic_ddos = '33dfb7a6f4b32be3409cf088e5a2e179e98456637d192e7541a6f16c286c2bc2'
- sha_num_attackers_ddos = '64a76befad280dac48c39ba9e3258a7768c13aeea3203044900fd8ac49e1e6ea'
- sha_dest_mac_length_zero_ddos = '75c6aaf84f3ede7b740233f2e6e7f78a4d1887b1e3b5137942c3e2095abad5f6'
- sha_mss_none_ddos = '33dfb7a6f4b32be3409cf088e5a2e179e98456637d192e7541a6f16c286c2bc2'
- sha_one_attacker_ddos = '4e9dc3c4ff09f9fa52fb2f6cd6260dcfbe338dfdbf4df100c1170da913547dcb'
- sha_ip_range_ddos = '87639c6ecb652afdc393ed810efb0d6fee1032629d4f00d774589fba90e89204'
- sha_port_range_ddos = 'c141c32cb78755e20477518c1165eb4564af88b1a95025925f6c90039de35359'
- class UnitTestDDoS(Test.ID2TAttackTest):
- @mock.patch('ID2TLib.Utility.get_attacker_config', side_effect=Lib.get_attacker_config)
- def test_ddos_basic(self, mock_get_attacker_config):
- self.checksum_test([['DDoSAttack']],
- sha_basic_ddos)
- @mock.patch('ID2TLib.Utility.get_attacker_config', side_effect=Lib.get_attacker_config)
- def test_ddos_num_attackers(self, mock_get_attacker_config):
- self.checksum_test([['DDoSAttack', 'attackers.count=5']],
- sha_num_attackers_ddos)
- @mock.patch('ID2TLib.Utility.get_attacker_config', side_effect=Lib.get_attacker_config)
- @mock.patch('Core.Statistics.Statistics.get_mac_address', return_value=[])
- def test_ddos_dest_mac_length_zero(self, mock_dest_mac, mock_get_attacker_config):
- self.checksum_test([['DDoSAttack']], sha_dest_mac_length_zero_ddos)
- @mock.patch('ID2TLib.Utility.get_attacker_config', side_effect=Lib.get_attacker_config)
- @mock.patch('Core.Statistics.Statistics.get_most_used_mss', return_value=None)
- def test_ddos_mss_none(self, mock_mss, mock_get_attacker_config):
- self.checksum_test([['DDoSAttack']], sha_mss_none_ddos)
- @mock.patch('ID2TLib.Utility.get_attacker_config', side_effect=Lib.get_attacker_config)
- def test_ddos_one_attacker(self, mock_get_attacker_config):
- self.checksum_test([['DDoSAttack', 'ip.src=1.1.1.1']],
- sha_one_attacker_ddos)
- @mock.patch('ID2TLib.Utility.get_attacker_config', side_effect=Lib.get_attacker_config)
- def test_ddos_ip_range(self, mock_get_attacker_config):
- self.checksum_test([['DDoSAttack', 'ip.src=1.1.1.1-1.1.1.10']],
- sha_ip_range_ddos)
- @mock.patch('ID2TLib.Utility.get_attacker_config', side_effect=Lib.get_attacker_config)
- def test_ddos_port_range(self, mock_get_attacker_config):
- self.checksum_test([['DDoSAttack', 'attackers.count=5', 'port.src=1000-2000']],
- sha_port_range_ddos)
- def test_ddos_order(self):
- self.order_test([['DDoSAttack', 'attackers.count=5']])
|