Browse Source

add final tests for SMBLoris

Jens Keim 6 years ago
parent
commit
fb1a3f2acd
2 changed files with 11 additions and 2 deletions
  1. 1 1
      code/Attack/BaseAttack.py
  2. 10 1
      code/Test/test_SMBLoris.py

+ 1 - 1
code/Attack/BaseAttack.py

@@ -475,7 +475,7 @@ class BaseAttack(metaclass=ABCMeta):
             if ip_source == ip_destination:
                 equal = True
         if equal:
-            print("\nERROR: Invalid IP addresses; source IP is the same as destination IP: " + ip_source + ".")
+            print("\nERROR: Invalid IP addresses; source IP is the same as destination IP: " + ip_destination + ".")
             sys.exit(0)
 
 

+ 10 - 1
code/Test/test_SMBLoris.py

@@ -14,7 +14,7 @@ sha_ips_in_pcap = 'bb54c042f870467021958d5f6947d21876b1fa5cda5f27da41adebac8cd44
 CURRENT COVERAGE
 Name                             Stmts   Miss  Cover   Missing (lines)
 ---------------------------------------------------------------------------
-Attack/SMBLorisAttack.py           128      5    96%   60, 73, 78, 155, 188
+Attack/SMBLorisAttack.py           128      4    97%   67, 72, 149, 182
 """
 # TODO: get 100% coverage
 
@@ -36,6 +36,15 @@ class UnitTestSMBLoris(GenericTest):
     def test_sixteen_attackers(self):
         self.generic_test([['SMBLorisAttack', 'ip.dst=192.168.1.210', 'attackers.count=16']], sha_sixteen_attackers)
 
+    @mock.patch('ID2TLib.Statistics.Statistics.get_most_used_ip_address')
+    def test_two_most_used_ips(self, mock_most_used_ip_address):
+        mock_most_used_ip_address.return_value = test_pcap_ips
+        self.generic_test([['SMBLorisAttack']], sha_default)
+
+    def test_same_ip_src_dst(self):
+        with self.assertRaises(SystemExit):
+            self.generic_test([['SMBLorisAttack', 'ip.src=192.168.1.240', 'ip.dst=192.168.1.240']], sha_default)
+
 
 if __name__ == '__main__':
     unittest.main()