forked from elastic/detection-rules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmd_shell_via_word.py
38 lines (28 loc) · 985 Bytes
/
cmd_shell_via_word.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
# 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="6c399694-d21c-4a19-9e58-8fa24eb399b9",
platforms=["windows"],
endpoint=[
{
"rule_name": "Windows Command Shell Spawned via Microsoft Office",
"rule_id": "2a396a3c-b343-42a9-b74b-c5b9925b6ee2",
}
],
siem=[],
techniques=["T1566", "T1059"],
)
EXE_FILE = common.get_path("bin", "renamed.exe")
@common.requires_os(*metadata.platforms)
def main():
binary = "winword.exe"
common.copy_file(EXE_FILE, binary)
# Execute command
common.execute([binary, "/c", "cmd.exe /c 'echo comspec'"], timeout=5, kill=True)
common.remove_files(binary)
if __name__ == "__main__":
exit(main())