From cdc4e21aac400e7d6d80bdec2c157ca375dfedf8 Mon Sep 17 00:00:00 2001 From: protections machine <72879786+protectionsmachine@users.noreply.github.com> Date: Thu, 8 Aug 2024 22:31:56 +1000 Subject: [PATCH] Scheduled Job Executing Binary in Unusual Location Sync RTA (#3952) Co-authored-by: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com> --- ...duled_task_executing_sus_located_binary.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 rta/linux_persistence_scheduled_task_executing_sus_located_binary.py diff --git a/rta/linux_persistence_scheduled_task_executing_sus_located_binary.py b/rta/linux_persistence_scheduled_task_executing_sus_located_binary.py new file mode 100644 index 000000000..f5aa6c5af --- /dev/null +++ b/rta/linux_persistence_scheduled_task_executing_sus_located_binary.py @@ -0,0 +1,40 @@ +# 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="5b9be46b-18f2-4b74-9003-36d763c5d887", + platforms=["linux"], + endpoint=[ + { + "rule_name": "Scheduled Job Executing Binary in Unusual Location", + "rule_id": "f2a52d42-2410-468b-9910-26823c6ef822" + } + ], + techniques=["T1543", "T1053", "T1543"], +) + + +@common.requires_os(*metadata.platforms) +def main(): + + common.log("Creating a fake cron executable..") + masquerade = "/tmp/cron" + source = common.get_path("bin", "netcon_exec_chain.elf") + common.copy_file(source, masquerade) + common.log("Granting execute permissions...") + common.execute(['chmod', '+x', masquerade]) + + commands = [masquerade, 'exec', '-c', '/dev/shm/foo'] + common.execute([*commands], timeout=5, kill=True) + common.log("Cleaning...") + common.remove_file(masquerade) + common.log("Simulation successfull!") + + +if __name__ == "__main__": + exit(main())