-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwmi.cna
266 lines (215 loc) · 9.26 KB
/
wmi.cna
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
beacon_command_register("wmips", "[*] uses wmi and powershell to list processes",
"Synopsis: wmips [target] [DOMAIN\\user] [password]\n\n" .
"Uses PowerPick to run Get-WMIObject Win32_Process to list processes on a remote system. If creds are supplied, it will run as the user supplied.\n\n" .
"[target] IP address of hostname of the target system.");
alias wmips {
local('$beacon $target $user $password $domain $username');
$beacon = $1;
$target = $2;
$user = $3;
$password = $4;
($domain, $username) = split("\\\\", $user);
# if username is null, it means that only the target user was supplied
# in the user field. so have to juggle it.
if($username eq $null) {
$username = $domain;
$domain = $target;
}
if($target eq $null) {
$target = ".";
}
println("beacon:$beacon target:$target user:$user password:$password domain:$domain username:$username");
$command_base = "Get-WMIObject Win32_Process -computername \"$target\"";
# generate powershell credentials
if($password eq $null) {
$command = $command_base;
$command .= "| Select-Object ProcessID,Name,path,@{n='Owner';e={\$_.GetOwner().User}},commandline | fl";
}
else {
$command = "\$Password = ConvertTo-SecureString \"$password\" -asplaintext -force; \$Credential = New-Object -Typename System.Management.Automation.PSCredential -ArgumentList \"$domain\\$username\",\$Password;";
$command .= "$command_base -Credential \$Credential";
$command .= "| Select-Object ProcessID,Name,path,@{n='Owner';e={\$_.GetOwner().User}},commandline | fl";
}
binput($beacon,"powerpick $command");
bpowerpick($beacon,"$command");
}
beacon_command_register("wmiuptime", "[*] uses wmi and powershell to show uptime",
"Synopsis: wmiuptime [target] [DOMAIN\\user] [password]\n\n" .
"Uses PowerPick to run Get-WMIObject Win32_OperatingSystem to show uptime. If creds are supplied, it will run as the user supplied.\n\n" .
"[target] IP address of hostname of the target system.");
alias wmiuptime {
local('$beacon $target $user $password $domain $username');
$beacon = $1;
$target = $2;
$user = $3;
$password = $4;
($domain, $username) = split("\\\\", $user);
# if username is null, it means that only the target user was supplied
# in the user field. so have to juggle it.
if($username eq $null) {
$username = $domain;
$domain = $target;
}
if($target eq $null) {
$target = ".";
}
println("beacon:$beacon target:$target user:$user password:$password domain:$domain username:$username");
$command_base = "Get-WmiObject Win32_OperatingSystem -computername \"$target\"";
# generate powershell credentials
if($password eq $null) {
$command = $command_base;
$command .= "| select csname, @{LABEL='LastBootUpTime' ;EXPRESSION={\$_.ConverttoDateTime(\$_.lastbootuptime)}}";
}
else {
$command = "\$Password = ConvertTo-SecureString \"$password\" -asplaintext -force; \$Credential = New-Object -Typename System.Management.Automation.PSCredential -ArgumentList \"$domain\\$username\",\$Password;";
$command .= "$command_base -Credential \$Credential";
$command .= "| select csname, @{LABEL='LastBootUpTime' ;EXPRESSION={\$_.ConverttoDateTime(\$_.lastbootuptime)}}";
}
binput($beacon,"powerpick $command");
bpowerpick($beacon,"$command");
}
beacon_command_register("wmils", "[*] uses wmi and powerpick to list files",
"Synopsis: wmils [target] [path] [DOMAIN\\user] [password]\n\n" .
"Uses PowerPick to run Invoke-WMI and list processes on a remote system. If creds are supplied, it will run as the user supplied.\n\n" .
"[target] IP address of hostname of the target system.");
alias wmils {
$beacon = $1;
$target = $2;
$location = $3;
$user = $4;
$password = $5;
($domain, $username) = split("\\\\", $user);
# if username is null, it means that only the target user was supplied
# in the user field. so have to juggle it.
if($username eq $null) {
$username = $domain;
$domain = $target;
}
($drive, $path) = split(":",$location);
println($drive);
if($drive is $null) {
$drive = "C";
}
#println("$drive $path");
if($target is $null) {
$target = ".";
}
# -Filter $filter
$path_1 = "$path\\";
$path_2 = strrep("$path_1", "\\", "\\\\");
$path_exp = strrep("$path_2", "\\\\\\", "\\");
$command_base = "Get-WmiObject -Class Win32_Directory -ComputerName \"$target\" -Filter \"Drive=\'$drive".":"."\' and Path=\'$path_exp\'\"";
# generate powershell credentials
if($password eq $null) {
$command = $command_base;
$command .= "| select-object name | ft";
}
else {
$command = "\$Password = ConvertTo-SecureString \"$password\" -asplaintext -force; \$Credential = New-Object -Typename System.Management.Automation.PSCredential -ArgumentList \"$username\",\$Password;";
$command .= "$command_base -Credential \$Credential";
$command .= "| select-object name | ft";
}
binput($beacon,"powerpick $command");
bpowerpick($beacon,"$command");
}
beacon_command_register("wmicomputer", "[*] uses wmi and powerpick to get computer info",
"Synopsis: wmicomputer [target] [DOMAIN\\user] [password]\n\n" .
"Uses PowerPick to run Invoke-WMI and list processes on a remote system. If creds are supplied, it will run as the user supplied.\n\n" .
"[target] IP address of hostname of the target system.");
alias wmicomputer {
$beacon = $1;
$target = $2;
$user = $3;
$password = $4;
($domain, $username) = split("\\\\", $user);
# if username is null, it means that only the target user was supplied
# in the user field. so have to juggle it.
if($username eq $null) {
$username = $domain;
$domain = $target;
}
if($target is $null) {
$target = ".";
}
$command_base = "Get-WmiObject -Class win32_operatingsystem -ComputerName \"$target\"";
# generate powershell credentials
if($password eq $null) {
$command = $command_base;
$command .= " | fl";
}
else {
$command = "\$Password = ConvertTo-SecureString \"$password\" -asplaintext -force; \$Credential = New-Object -Typename System.Management.Automation.PSCredential -ArgumentList \"$username\",\$Password;";
$command .= "$command_base -Credential \$Credential";
$command .= " | fl";
}
binput($beacon,"powerpick $command");
bpowerpick($beacon,"$command");
}
beacon_command_register("wmishare", "[*] uses wmi and powerpick to list shares on a system",
"Synopsis: wmishare [target] [DOMAIN\\user] [password]\n\n" .
"Uses PowerPick to run Get-WMIObject Win32_Share to list shares on a system. If creds are supplied, it will run as the user supplied.\n\n" .
"[target] IP address of hostname of the target system.");
alias wmishare {
local('$beacon $target $user $password $domain $username');
$beacon = $1;
$target = $2;
$user = $3;
$password = $4;
($domain, $username) = split("\\\\", $user);
# if username is null, it means that only the target user was supplied
# in the user field. so have to juggle it.
if($username eq $null) {
$username = $domain;
$domain = $target;
}
if($target is $null) {
$target = ".";
}
$command_base = "Get-WMIObject Win32_Share -computername \"$target\"";
# generate powershell credentials
if($password eq $null) {
$command = $command_base;
$command .= "| ft";
}
else {
$command = "\$Password = ConvertTo-SecureString \"$password\" -asplaintext -force; \$Credential = New-Object -Typename System.Management.Automation.PSCredential -ArgumentList \"$username\",\$Password;";
$command .= "$command_base -Credential \$Credential";
$command .= "| ft";
}
binput($beacon,"powerpick $command");
bpowerpick($beacon,"$command");
}
beacon_command_register("wmiclass", "[*] uses wmi and powershell to run a wmi class",
"Synopsis: wmiclass [class] [target] [DOMAIN\\user] [password]\n\n" .
"Uses PowerPick to run Get-WMIObject with generic class. If creds are supplied, it will run as the user supplied.\n\n" .
"[target] IP address of hostname of the target system.");
alias wmiclass {
$beacon = $1;
$class = $2;
$target = $3;
$user = $4;
$password = $5;
($domain, $username) = split("\\\\", $user);
# if username is null, it means that only the target user was supplied
# in the user field. so have to juggle it.
if($username eq $null) {
$username = $domain;
$domain = $target;
}
if($target is $null) {
$target = ".";
}
$command_base = "Get-WMIObject $class -computername \"$target\"";
# generate powershell credentials
if($password eq $null) {
$command = $command_base;
$command .= "| ft";
}
else {
$command = "\$Password = ConvertTo-SecureString \"$password\" -asplaintext -force; \$Credential = New-Object -Typename System.Management.Automation.PSCredential -ArgumentList \"$username\",\$Password;";
$command .= "$command_base -Credential \$Credential";
$command .= "| ft";
}
binput($beacon,"powerpick $command");
bpowerpick($beacon,"$command");
}