Browse Source

add Joomla tests

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

+ 2 - 1
code/Attack/JoomlaRegPrivExploit.py

@@ -5,6 +5,7 @@ from lea import Lea
 from scapy.utils import RawPcapReader
 from scapy.layers.inet import Ether
 
+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 JoomlaRegPrivExploit(BaseAttack.BaseAttack):
-    template_attack_pcap_path = "resources/joomla_registration_privesc.pcap"
+    template_attack_pcap_path = ROOT_DIR + "/../resources/joomla_registration_privesc.pcap"
     # HTTP port
     http_port = 80
     # Metasploit experiments show this range of ports

+ 27 - 0
code/Test/test_Joomla.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 = '27eb51f0b0bb417eb121a874174b09cf65240bf8895d984f3158817e48f9aba2'
+
+"""
+CURRENT COVERAGE
+Name                             Stmts   Miss  Cover   Missing (lines)
+---------------------------------------------------------------------------
+Attack/JoomlaRegPrivExploit.py     127      4    97%   62, 71, 116, 123
+"""
+# TODO: get 100% coverage
+
+
+class UnitTestJoomla(GenericTest):
+
+    def test_default(self):
+        # FIXME: maybe use another seed
+        self.generic_test([['JoomlaRegPrivExploit']], sha_default)
+
+
+if __name__ == '__main__':
+    unittest.main()