-
Notifications
You must be signed in to change notification settings - Fork 201
/
Copy pathMachineAccounts.cna
79 lines (59 loc) · 2.32 KB
/
MachineAccounts.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
#author Cornelis de Plaa
#@outflank.nl
beacon_command_register("GetMachineAccountQuota", "Read the MachineAccountQuota value from the Active Directory domain.",
"Synopsis: GetMachineAccountQuota\n\n" .
"Use Active Directory Service Interfaces (ADSI) to read the ms-DS-MachineAccountQuota value from AD.\n");
beacon_command_register("AddMachineAccount", "Add a computer account to the Active Directory domain.",
"Synopsis: AddMachineAccount [Computername] [Password <Optional>]\n\n" .
"Use Active Directory Service Interfaces (ADSI) to add a computer account to AD.\n");
beacon_command_register("DelMachineAccount", "Remove a computer account from the Active Directory domain.",
"Synopsis: DelMachineAccount [Computername]\n\n" .
"Use Active Directory Service Interfaces (ADSI) to delete a computer account from AD.\n");
alias GetMachineAccountQuota {
$bid = $1;
# Read in the right BOF file
$handle = openf(script_resource("GetMachineAccountQuota." . barch($bid) . ".o"));
$data = readb($handle, -1);
closef($handle);
beacon_inline_execute($bid, $data, "go", $null);
}
alias AddMachineAccount {
$bid = $1;
$input = substr($0, 18);
@args = split(' ', $input);
$accountname = @args[0];
$password = @args[1];
if ($accountname eq "") {
berror($bid, "Specify a computeraccount name");
return;
}
# Read in the right BOF file
$handle = openf(script_resource("AddMachineAccount." . barch($bid) . ".o"));
$data = readb($handle, -1);
closef($handle);
# Pack our arguments
if ($password eq "") {
$arg_data = bof_pack($bid, "Z", $accountname);
}
else{
$arg_data = bof_pack($bid, "ZZ", $accountname, $password);
}
beacon_inline_execute($bid, $data, "go", $arg_data);
}
alias DelMachineAccount {
$bid = $1;
$input = substr($0, 18);
@args = split(' ', $input);
$accountname = @args[0];
if ($accountname eq "") {
berror($bid, "Specify a computeraccount name");
return;
}
# Read in the right BOF file
$handle = openf(script_resource("DelMachineAccount." . barch($bid) . ".o"));
$data = readb($handle, -1);
closef($handle);
# Pack our arguments
$arg_data = bof_pack($bid, "Z", $accountname);
beacon_inline_execute($bid, $data, "go", $arg_data);
}