From ec1f617fdca8ef2dc481aeec19b3e3c24bf7f9ab Mon Sep 17 00:00:00 2001 From: protections machine <72879786+protectionsmachine@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:49:44 +1000 Subject: [PATCH] APT Package Manager Command Execution Sync RTA (#3940) Co-authored-by: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com> --- ...rsistence_apt_package_manager_execution.py | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 rta/linux_persistence_apt_package_manager_execution.py diff --git a/rta/linux_persistence_apt_package_manager_execution.py b/rta/linux_persistence_apt_package_manager_execution.py new file mode 100644 index 000000000..21944b7f4 --- /dev/null +++ b/rta/linux_persistence_apt_package_manager_execution.py @@ -0,0 +1,50 @@ +# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +# or more contributor license agreements. Licensed under the Elastic License +# 2.0; you may not use this file except in compliance with the Elastic License +# 2.0. + +from . import common +from . import RtaMetadata + +metadata = RtaMetadata( + uuid="305b2daa-2ef4-4cdd-8ed2-d751174cbdcc", + platforms=["linux"], + endpoint=[ + { + "rule_name": "APT Package Manager Command Execution", + "rule_id": "cd0844ea-6112-453f-a836-cc021a2b6afb" + } + ], + techniques=["T1543", "T1059", "T1546"], +) + + +@common.requires_os(*metadata.platforms) +def main(): + + common.log("Creating a fake apt executable..") + masquerade = "/tmp/apt" + source = common.get_path("bin", "netcon_exec_chain.elf") + common.copy_file(source, masquerade) + common.log("Granting execute permissions...") + common.execute(['chmod', '+x', masquerade]) + + common.log("Creating a fake openssl executable..") + masquerade2 = "/tmp/openssl" + source = common.get_path("bin", "linux.ditto_and_spawn") + common.copy_file(source, masquerade2) + common.log("Granting execute permissions...") + common.execute(['chmod', '+x', masquerade2]) + + commands = [masquerade, 'exec', '-c', '/tmp/openssl'] + common.execute([*commands], timeout=5, kill=True) + + common.log("Cleaning...") + common.remove_file(masquerade) + common.remove_file(masquerade2) + + common.log("Simulation successfull!") + + +if __name__ == "__main__": + exit(main())