APT Package Manager Command Execution Sync RTA (#3940)
Co-authored-by: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
e277ecd230
commit
ec1f617fdc
@@ -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())
|
||||
Reference in New Issue
Block a user