Files
sigma-rules/rta/linux_execution_interactive_shell_spawn_from_hidden_process.py
T

41 lines
1.2 KiB
Python
Raw Normal View History

# 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.
2024-08-27 04:27:42 +10:00
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
uuid="fd5fb7a8-398a-4322-ae28-8f88cce6aa88",
platforms=["linux"],
endpoint=[
{
"rule_name": "Interactive Shell Spawned via Hidden Process",
2024-08-27 04:27:42 +10:00
"rule_id": "52deef30-e633-49e1-9dd2-da1ad6cb5e43",
},
],
techniques=["T1059", "T1564"],
)
@common.requires_os(*metadata.platforms)
2024-08-27 04:27:42 +10:00
def main() -> None:
common.log("Creating a fake hidden executable..")
masquerade = "/tmp/.evil"
source = common.get_path("bin", "netcon_exec_chain.elf")
common.copy_file(source, masquerade)
common.log("Granting execute permissions...")
2024-08-27 04:27:42 +10:00
common.execute(["chmod", "+x", masquerade])
2024-08-27 04:27:42 +10:00
commands = [masquerade, "exec", "-c", "-i"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
common.log("Simulation successfull!")
if __name__ == "__main__":
2024-08-27 04:27:42 +10:00
sys.exit(main())