Files
sigma-rules/rta/linux_compress_sensitive_files.py
T

45 lines
1.6 KiB
Python
Raw Normal View History

2020-06-29 23:07:16 -06:00
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2021-03-03 22:12:11 -09:00
# 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.
2020-06-29 23:07:16 -06:00
# Name: Compression of sensitive files
# RTA: linux_compress_sensitive_files.py
# Description: Uses built-in commands for *nix operating systems to compress known sensitive
# files, such as etc/shadow and etc/passwd
from . import common
2022-09-08 12:50:39 -04:00
from . import RtaMetadata
2020-06-29 23:07:16 -06:00
2022-09-08 12:50:39 -04:00
metadata = RtaMetadata(
uuid="f3ffa89b-de47-4e17-ac8e-385e0e7f8253",
platforms=["linux"],
endpoint=[],
siem=[{"rule_id": "6b84d470-9036-4cc0-a27c-6d90bbfe81ab", "rule_name": "Sensitive Files Compression"}],
techniques=["T1560", "T1552"],
)
2023-10-03 10:47:58 -04:00
@common.requires_os(*metadata.platforms)
2020-06-29 23:07:16 -06:00
def main():
common.log("Compressing sensitive files")
2022-09-08 12:50:39 -04:00
files = ["totally-legit.tar", "official-business.zip", "expense-reports.gz"]
2020-06-29 23:07:16 -06:00
# we don't want/need these to actually work, since the rule is only looking for command line, so no need for sudo
commands = [
2022-09-08 12:50:39 -04:00
["tar", "-cvf", files[0], "/etc/shadow"],
["zip", files[1], "/etc/passwd"],
["gzip", "/etc/group", files[2]],
2020-06-29 23:07:16 -06:00
]
for command in commands:
try:
common.execute(command)
except OSError as exc:
# command doesn't exist on distro - the rule only needs one to trigger
# also means we will eventually need to explore per distro ground truth when we expand as counts will vary
common.log(str(exc))
2022-09-08 12:50:39 -04:00
if __name__ == "__main__":
2020-06-29 23:07:16 -06:00
main()