forked from elastic/detection-rules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exec_scripting_persistence_locations.py
62 lines (51 loc) · 1.82 KB
/
exec_scripting_persistence_locations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 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.
from . import common
from . import RtaMetadata
metadata = RtaMetadata(
uuid="537de67d-8ba8-4df8-a965-75ca564d0846",
platforms=["windows"],
endpoint=[
{
"rule_name": "Script Interpreter Process Writing to Commonly Abused Persistence Locations",
"rule_id": "be42f9fc-bdca-41cd-b125-f223d09eef69",
},
{
"rule_name": "Startup Persistence via Windows Script Interpreter",
"rule_id": "a85000c8-3eac-413b-8353-079343c2b6f0",
},
],
siem=[],
techniques=["T1547", "T1059"],
)
@common.requires_os(metadata.platforms)
def main():
powershell = "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
common.log("Dropping executable to Startup Folder using powershell")
common.execute(
[
powershell,
"-C",
"Copy-Item",
"C:\\Windows\\System32\\cmd.exe",
"'C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\'",
]
)
common.log("Dropping executable to Startup Folder using powershell")
common.execute(
[
powershell,
"-C",
"Copy-Item",
"C:\\Windows\\System32\\cmd.exe",
"'C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\cmd2.exe'",
]
)
common.remove_files(
"C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\cmd2.exe",
"C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\cmd.exe",
)
if __name__ == "__main__":
exit(main())