Kiến thức

K14 chia sẻ về cuộc thi CTF đầu tiên kỳ 3: Những bài tập làm quen với CTF mảng Forensics

  • Đây chỉ là những challenges đơn giản mà mình đã tổng hợp để các bạn có thể hiểu sơ qua những gì mà khi chơi mảng Forensics phải làm.
  • Và từ những cái cơ bản này các bạn có thể đi sâu hơn để trở thành Main Forensics nhé!
  • Con đường nào cũng phải cần kiên trì, kết quả bạn nhận lại được sẽ tỉ lệ thuận với số lượng mồ hôi, thời gian, công sức bạn làm việc đó. CHÚC CÁC BẠN THÀNH CÔNG!

Author: St1rr1ng

Forensics Concept: 

Có thể bao gồm phân tích định dạng tệp, ghi mật mã, phân tích kết xuất bộ nhớ hoặc phân tích thu thập gói mạng. Bất kỳ thách thức nào để kiểm tra và xử lý một phần thông tin ẩn trong các tệp dữ liệu tĩnh (trái ngược với các chương trình thực thi hoặc máy chủ từ xa) có thể được coi là một thách thức của Pháp chứng.

Tools

split, pdfinfo, pdfimages, pdfcrack, pdfdetach, Keepass, Magic Numbers, hexed.it, foremost, binwalk, Repair image online tool, photorec, TestDisk, pngcheck, pngcsum, Registry Dumper, Dnscat2, pefile, Wireshark, Network Miner, PCAPNG, tcpflow, PcapXray, qpdf, Audacity, sonic visualiser, ffmpeg strings, file, grep, scalpel, bgrep, hexdump, xxd, base64, xplico framework, zsteg, gimp, Memory dump - volatility, ethscan, and many more.

stego-toolkit

Sau đây mình sẽ chia sẽ một số EX cho các bạn chơi mảng Forensics theo từng dạng thông qua các challenges mình đã giải

1. Image file format analysis

screenshoot

  • Thông thường khi gặp những bài này ta sẽ dùng binwalk xem nó file gì bị nén trong đó hay không.

screenshoot

  • Sau khi kiểm tra ta thấy nó có chứa file PDF trong ảnh. Ta dùng lệnh binwalk --dd='.*' wallet.jpeg để extract file bị ẩn

screenshoot

  • Ta được file _wallet.jpg.extracted . Sau đó check file ta thấy có 2 file 0 và 2E11E
  • Ta sẽ đổi đuôi file 2E11E thành .pdf

screenshoot

  • Xem file PDF ta thấy ngay Flag ở trang 23 😀

screenshoot

Flag: flag(xxx)

2. Network Forensics

Challenge:

We found this packet capture Recover the flag. You can also find the file in /problems/shark-on-wire-1_0_13d709ec13952807e477ba1b5404e620.

  • Để làm các bài .pcap các bạn cần sử dụng WireShark. Các bạn có thể tìm hiểu công cụ WireShark ở đây

  • Đầu tiên ta mở file bằng WireShark

screenshoot

  • Theo dõi cấc luồng UDP bằng cách nhấn chuột phải vào UPD chọn Follow UDP Stream
  • Sau đó nâng mức Stream lên 6 ta sẽ có ngay Flag

screenshoot

Flag: picoCTF{xxx}

3. File header analysis

NaCTF Turnips 2

screenshoot

Link download challenges

HINT: File headers are important, aren't they?

  • Hint đã nói quá rõ việc ta cần làm, kiểm tra File headers bằng hexedit thôi

kali@kali:~/Desktop/CTF$ hexedit file.txt

screenshoot

  • Ta thấy 8 byte đầu header của file sai định dạng. Tham khảo trang này ta sửa 8 byte đầu thành PNG 89 50 4E 47 và đổi tên file thành .png

screenshoot

  • Nhiều khi điều ta nghĩ lại không như ta nghĩ 😀 Sau khi mở file.png để xem flag thì hiện lên dòng yêu thương Could not load image “file.png”
  • Sau khi check laị header và tham khảo trang thần thánh StackOverFlow thì mình phát hiện lại cái chunk IHDRnó cố ý làm sai nên sửa lại luôn.

screenshoot

  • Check lại file xem nào. Ohhh Flag đây rồi 😀

Flag: nactf{xxx}

4. Sound File

Can you find flag? sound.wav

  • Một bài đơn giản về âm thanh. Để tìm Flag ta chỉ cần cho file này vào Audacity

screenshoot

  • Sound đang ở đạng Waveform ta chỉnh sang Spectrogram là ra flag

5. Memory Forensics

Problem description

  • Flag is: FwordCTF{computername_user_password}
  • foren.raw
  • Đối với dạng này ta ta có tool Volatility để giải quyết

  • Làm gì thì làm extract file trước đã kkk 😀

  • Dùng Volatility để lấy thông tin file:

$ volatility -f foren.raw imageinfoVolatility Foundation Volatility Framework 2.6INFO    : volatility.debug    : Determining profile based on KDBG search...Suggested Profile(s) : Win7SP1x64, Win7SP0x64, Win2008R2SP0x64, Win2008R2SP1x64_23418, Win2008R2SP1x64, Win7SP1x64_23418AS Layer1 : WindowsAMD64PagedMemory (Kernel AS)AS Layer2 : FileAddressSpace (/home/jeanette/Downloads/foren.raw)
  • Để có thông tin về tên máy tính, chúng ta cần thông tin về REGISTRY \ MACHINE \ SYSTEM. Để lấy băm tên người dùng và mật khẩu, chúng tôi cần thông tin về REGISTRY \ MACHINE \ SYSTEM và \ SystemRoot \ System32 \ Config \ SAM.

  • Giờ ta bắt đầu tìm mảnh ghép Flag

    ComputerName

  • Để lấy ComputerName, chúng ta có thể sử dụng lệnh sau (đối số -o là một tham chiếu đến địa chỉ ảo của \ REGISTRY \ MACHINE \ SYSTEM):

$ volatility -f foren.raw --profile=Win7SP1x64 printkey -o 0xfffff8a000024010 -K 'ControlSet001\Control\ComputerName\ComputerName'   REG_SZ        ComputerName    : (S) ************

Ta có ngay Computername: ***********

User

  • Để biết user ta chỉ cần dùng lệnh envars và grep như sau:
$ volatility -f foren.raw --profile=Win7SP1x64 envars | grep 'C:\\Users'Volatility Foundation Volatility Framework 2.6Pid      Process              Block              Variable                       Value-------- -------------------- ------------------ ------------------------------ -----2516 chrome.exe           0x0000000000a31320 USERPROFILE                    C:\Users\***_**3992 chrome.exe           0x0000000000931320 APPDATA                        C:\Users\***_**\AppData\Roaming3992 chrome.exe           0x0000000000931320 LOCALAPPDATA                   C:\Users***_**\AppData\Local

Như vậy ta có User: ***_**

Password

  • Bước tiếp theo mình cũng làm theo hướng dẫn sau để thực hiện tìm password: Retrieve-password
volatility -f foren.raw --profile=Win7SP0x64 hivelistVolatility Foundation Volatility Framework 2.6Virtual            Physical           Name------------------ ------------------ ----0xfffff8a000b0f410 0x000000002720d410 \??\C:\Windows\ServiceProfiles\LocalService\NTUSER.DAT0xfffff8a000d00010 0x000000001ff75010 \??\C:\Windows\ServiceProfiles\NetworkService\NTUSER.DAT0xfffff8a000f8b410 0x00000000175e8410 \??\C:\Windows\System32\config\COMPONENTS0xfffff8a00145f010 0x0000000027d9b010 \SystemRoot\System32\Config\DEFAULT0xfffff8a0014da410 0x00000000275c0410 \SystemRoot\System32\Config\SAM0xfffff8a0033fe410 0x0000000069de6410 \??\C:\Users\SBA_AK\ntuser.dat0xfffff8a0036e7010 0x0000000069188010 \??\C:\Users\SBA_AK\AppData\Local\Microsoft\Windows\UsrClass.dat0xfffff8a0038fe280 0x0000000068390280 \??\C:\System Volume Information\Syscache.hve0xfffff8a00000f010 0x000000002cfef010 [no name]0xfffff8a000024010 0x000000002d07a010 \REGISTRY\MACHINE\SYSTEM0xfffff8a000058010 0x000000002d3ae010 \REGISTRY\MACHINE\HARDWARE0xfffff8a000846010 0x000000002a0e9010 \Device\HarddiskVolume1\Boot\BCD0xfffff8a000873010 0x0000000013880010 \SystemRoot\System32\Config\SOFTWARE0xfffff8a000ab8010 0x0000000027455010 \SystemRoot\System32\Config\SECURITY
  • Hàm băm của người dùng được lưu trữ trong \SystemRoot\System32\Config\SAM file.
volatility -f foren.raw --profile=Win7SP0x64 hashdump -y 0xfffff8a000024010 -s 0xfffff8a0014da410Volatility Foundation Volatility Framework 2.6Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::fwordCTF:1000:aad3b435b51404eeaad3b435b51404ee:a9fdfa038c4b75ebc76dc855dd74f0da:::HomeGroupUser$:1002:aad3b435b51404eeaad3b435b51404ee:514fab8ac8174851bfc79d9a205a939f:::SBA_AK:1004:aad3b435b51404eeaad3b435b51404ee:`a9fdfa038c4b75ebc76dc855dd74f0da`:::
  • Và đó là cách mình lấy tên người dùng và mã băm NTLM của mật khẩu của họ cần được bẻ khóa.

  • Mình đã bẻ khóa mật khẩu của anh ấy bằng https://crackstation.net/

screenshoot

Và mảnh ghép cuối cùng Password: pass*******

Flag: FwordCTF{xxx_xxx_xxx}

Hẹn gặp lại các bạn kỳ sau!!!