Files
sigma-rules/rta/reverse_shell.py
T

39 lines
1.1 KiB
Python
Raw Normal View History

2022-09-08 12:50:39 -04:00
# 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-06-06 14:42:37 -04:00
import sys
2022-09-08 12:50:39 -04:00
2024-06-06 14:42:37 -04:00
from . import RtaMetadata, common
2022-09-08 12:50:39 -04:00
metadata = RtaMetadata(
uuid="83b04be5-ed0f-4efd-a7fd-d5db2b8ab62f",
platforms=["macos", "linux"],
endpoint=[
{
"rule_name": "Potential Reverse Shell Activity via Terminal",
"rule_id": "d0e45f6c-1f83-4d97-a8d9-c8f9eb61c15c",
2024-06-06 14:42:37 -04:00
},
2022-09-08 12:50:39 -04:00
],
siem=[],
techniques=["T1071", "T1059"],
)
2023-10-03 10:47:58 -04:00
@common.requires_os(*metadata.platforms)
2024-06-06 14:42:37 -04:00
def main() -> None:
masquerade = "/tmp/bash"
if common.CURRENT_OS == "linux":
source = common.get_path("bin", "linux.ditto_and_spawn")
common.copy_file(source, masquerade)
else:
common.create_macos_masquerade(masquerade)
2022-09-08 12:50:39 -04:00
common.log("Executing command to simulate reverse shell execution")
2024-06-06 14:42:37 -04:00
common.execute([masquerade, "/dev/tcp/127.0.0.1/4444"], timeout=5, kill=True, shell=True) # noqa: S604
2022-09-08 12:50:39 -04:00
if __name__ == "__main__":
2024-06-06 14:42:37 -04:00
sys.exit(main())