From eb10bdaa4ea8eb475bc9b946a9601cbe9bafdbef Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 10 Jan 2022 08:22:01 -0500 Subject: [PATCH] Agent: Add unit tests for log4shell ldap server tree --- .../exploit/log4shell_utils/test_ldap_server.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 monkey/tests/unit_tests/infection_monkey/exploit/log4shell_utils/test_ldap_server.py diff --git a/monkey/tests/unit_tests/infection_monkey/exploit/log4shell_utils/test_ldap_server.py b/monkey/tests/unit_tests/infection_monkey/exploit/log4shell_utils/test_ldap_server.py new file mode 100644 index 000000000..99f32eb18 --- /dev/null +++ b/monkey/tests/unit_tests/infection_monkey/exploit/log4shell_utils/test_ldap_server.py @@ -0,0 +1,13 @@ +from pathlib import Path + +from infection_monkey.exploit.log4shell_utils.ldap_server import EXPLOIT_RDN, Tree + + +def test_java_code_base_url(tmp_path): + ip = "172.10.20.30" + port = 9999 + + tree = Tree(ip, port, tmp_path) + ldif_path = Path(tree.path) / f"{EXPLOIT_RDN}.ldif" + with open(ldif_path, "r") as exploit_dit: + assert f"javaCodeBase: http://{ip}:{port}/" in exploit_dit.read()