forked from elastic/detection-rules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enum_commands.py
74 lines (61 loc) · 2.18 KB
/
enum_commands.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
63
64
65
66
67
68
69
70
71
72
73
74
# 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.
# Name: Common Enumeration Commands
# RTA: enum_commands.py
# ATT&CK: T1007, T1016, T1018, T1035, T1049, T1057, T1063, T1069, T1077, T1082, T1087, T1124, T1135
# Description: Executes a list of administration tools commonly used by attackers for enumeration.
import argparse
import random
from . import common
@common.requires_os(common.WINDOWS)
def main(args=None):
slow_commands = [
"gpresult.exe /z",
"systeminfo.exe"
]
commands = [
"ipconfig /all",
"net localgroup administrators",
"net user",
"net user administrator",
"net user /domain"
"tasklist",
"net view",
"net view /domain",
"net view \\\\%s" % common.get_ip(),
"netstat -nao",
"whoami",
"hostname",
"net start",
"tasklist /svc",
"net time \\\\%s" % common.get_ip(),
"net use",
"net view",
"net start",
"net accounts",
"net localgroup",
"net group",
"net group \"Domain Admins\" /domain",
"net share",
"net config workstation",
]
commands.extend(slow_commands)
parser = argparse.ArgumentParser()
parser.add_argument('-s', '--sample', dest="sample", default=len(commands), type=int,
help="Number of commands to run, chosen at random from the list of enumeration commands")
args = parser.parse_args(args)
sample = min(len(commands), args.sample)
if sample < len(commands):
random.shuffle(commands)
common.log("Running {} out of {} enumeration commands\n".format(sample, len(commands)))
for command in commands[0:sample]:
common.log("About to call {}".format(command))
if command in slow_commands:
common.execute(command, kill=True, timeout=15)
common.log("[output suppressed]", log_type='-')
else:
common.execute(command)
if __name__ == "__main__":
exit(main())