Browse Source

add SQLiAttack test

Jens Keim 6 years ago
parent
commit
d3b14b396d
2 changed files with 29 additions and 1 deletions
  1. 2 1
      code/Attack/SQLiAttack.py
  2. 27 0
      code/Test/test_SQLi.py

+ 2 - 1
code/Attack/SQLiAttack.py

@@ -6,6 +6,7 @@ from scapy.utils import RawPcapReader
 from scapy.layers.inet import Ether
 from ID2TLib.Utility import update_timestamp, get_interval_pps
 
+from definitions import ROOT_DIR
 from Attack import BaseAttack
 from Attack.AttackParameters import Parameter as Param
 from Attack.AttackParameters import ParameterTypes
@@ -15,7 +16,7 @@ logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
 
 
 class SQLiAttack(BaseAttack.BaseAttack):
-    template_attack_pcap_path = "resources/ATutorSQLi.pcap"
+    template_attack_pcap_path = ROOT_DIR + "/../resources/ATutorSQLi.pcap"
     # HTTP port
     http_port = 80
     # Metasploit experiments show this range of ports

+ 27 - 0
code/Test/test_SQLi.py

@@ -0,0 +1,27 @@
+import unittest
+import unittest.mock as mock
+
+from Test.GenericTest import GenericTest
+from Test.Lib import test_pcap_ips
+
+# FIXME: create new hashes if new test.pcap is used
+sha_default = 'fa9a43a8b6eb959f25cf3306c9b94b0957027d91b61edd2c9906a135b814f148'
+
+"""
+CURRENT COVERAGE
+Name                             Stmts   Miss  Cover   Missing (lines)
+---------------------------------------------------------------------------
+Attack/SQLiAttack.py               159      5    97%   62, 71, 113, 120, 245
+"""
+# TODO: get 100% coverage
+
+
+class UnitTestSQLi(GenericTest):
+
+    def test_default(self):
+        # FIXME: maybe use another seed
+        self.generic_test([['SQLiAttack']], sha_default)
+
+
+if __name__ == '__main__':
+    unittest.main()