Files
sigma-rules/rta/linux_compress_sensitive_files.py
T
Ross Wolf a0d3b4bd23 Populate RTA directory.
Co-Authored-By: Brent Murphy <56412096+bm11100@users.noreply.github.com>
Co-Authored-By: Daniel Stepanic <57736958+dstepanic17@users.noreply.github.com>
Co-Authored-By: David French <56409778+threat-punter@users.noreply.github.com>
Co-Authored-By: Joe Desimone <56411054+joe-desimone@users.noreply.github.com>
Co-Authored-By: Justin Ibarra <brokensound77@users.noreply.github.com>
2020-06-29 23:07:18 -06:00

34 lines
1.3 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;
# you may not use this file except in compliance with the Elastic License.
# 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
@common.requires_os(common.LINUX)
def main():
common.log("Compressing sensitive files")
files = ['totally-legit.tar', 'official-business.zip', 'expense-reports.gz']
# we don't want/need these to actually work, since the rule is only looking for command line, so no need for sudo
commands = [
['tar', '-cvf', files[0], '/etc/shadow'],
['zip', files[1], '/etc/passwd'],
['gzip', '/etc/group', files[2]]
]
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))
if __name__ == '__main__':
main()