Phân tích binary Go khó hơn C/C++ vì nhiều lý do: runtime Go được bundle cùng binary, function name bị strip trong release build, và calling convention khác. Bài này sẽ đi qua quy trình phân tích một Remote Access Tool (RAT) viết bằng Go.
Tại sao Go phổ biến trong malware?
- Cross-compile dễ dàng cho Windows/Linux/macOS từ một codebase
- Static binary — không cần dependency
- Antivirus detection rate thấp hơn so với C
- Concurrency built-in với goroutines
Phân tích tĩnh với Ghidra
# Cài Ghidra extension cho Go
# https://github.com/ghidra-sre/GolangAnalyzerExtension
# Bước 1: Xác định version Go của binary
strings malware.bin | grep "go1\."
# go1.21.5
# Bước 2: Recover function names từ pclntab
# Ghidra tự làm việc này nếu dùng Go Analyzer extension
# Bước 3: Tìm main.main
# Window → Symbol Tree → Functions → main.main
Identify C2 Communication
Tìm kiếm các string liên quan đến network trong binary:
# strings + grep
strings malware.bin | grep -E "(http|tcp|connect|beacon|c2|cmd)"
# Trong Ghidra: Search → For Strings
# Filter: http, :443, /api/, /update/
# Kết quả tìm thấy:
# "https://update-service[.]com/api/beacon"
# "POST /api/cmd"
# "X-Session-Token"
Phân tích persistence mechanism
# Tìm registry operations trong Windows binary
strings malware.bin | grep -iE "(HKEY|SOFTWARE\\\\Microsoft|Run|Startup)"
# Kết quả:
# SOFTWARE\Microsoft\Windows\CurrentVersion\Run
# "WindowsUpdateHelper"
# Verify trong Ghidra bằng cách trace call graph từ main.main
# → main.install() → syscall.RegSetKeyValueW()
Dynamic analysis với x64dbg
# Chạy trong isolated VM (Windows)
# 1. Đặt breakpoint tại WS2_32.connect để bắt network calls
bp WS2_32.connect
# 2. Dump decrypted C2 config khi chạy
# Nhiều RAT decrypt config in-memory khi start
# Đặt bp sau hàm decrypt, dump memory tại địa chỉ buffer
# 3. Intercept traffic với FakeNet-NG
fakenet -c fakenet.ini
# Sẽ log toàn bộ network traffic kể cả encrypted
IOCs thu được
Network:
C2: update-service[.]com:443
URI: /api/beacon, /api/cmd, /api/upload
Header: X-Session-Token: {uuid}
Beacon interval: 30s
Host:
Registry: HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Value: WindowsUpdateHelper
Path: %APPDATA%\Microsoft\WindowsUpdateHelper.exe
Hashes:
MD5: a1b2c3d4e5f6...
SHA256: 0x1234abcd...