Files
sigma-rules/rta/linux_execution_gsocket_activity.py
T
2024-10-23 13:21:33 +05:30

41 lines
1.1 KiB
Python

# 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.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
uuid="b6dde7bc-4408-4a29-9c23-3c72cab3548c",
platforms=["linux"],
endpoint=[
{
"rule_name": "Potential Gsocket Activity",
"rule_id": "9015e5ec-a68d-4539-923d-a96d2c6227d3",
},
],
techniques=["T1059", "T1071"],
)
@common.requires_os(*metadata.platforms)
def main() -> None:
common.log("Creating a fake executable..")
masquerade = "/tmp/sh"
source = common.get_path("bin", "linux.ditto_and_spawn")
common.copy_file(source, masquerade)
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade])
commands = [masquerade, 'gs-netcat']
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
common.log("Simulation successfull!")
if __name__ == "__main__":
sys.exit(main())