TwentySeV
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Hunting Thực hiện rà soát ở 3 vị trí - Note ở đây - Note ở [Windows](https://hackmd.io/@TwentySeV/S1zevplE1g) - Note ở [Tools_SOC](https://hackmd.io/@TwentySeV/rJ7vsjxS1e) - Checklist cty ở [repo](https://github.com/vanniichan/BlueTeam_Note/tree/main/Hunting_Checklists) # PII File - **Personally Identifiable Information (PII)** là file chứa thông tin của một người hoặc nhiều người một cách cụ thể, chẳng hạn như địa chỉ, tên tuổi, vị trí, ... File này thường hay bị sờ đến. - Một số định dạng file như `.json`, `.csv`, `.db`... - **Nó chỉ là định nghĩa chung, không phải tên file** # Anti-Forensic Techniques - Các dịch vụ ẩn danh có xu hướng sử dụng các cổng cụ thể (ví dụ: TOR thường sử dụng các cổng `9001` và `9050`). # Lệnh cơ bản trong DFIR ## Đối với Linux > Tất cả các lệnh này đều không mặc định ở 2 thư mục `/tmp` or `/var/tmp` ### Tìm kiếm các tệp dựa trên lần sửa đổi hoặc thời gian truy cập cuối cùng của chúng ``` find /tmp -mtime -2 # Files modified in the last 2 days ``` ### Tìm các tệp lớn chiếm dung lượng đĩa ``` find /tmp -size +10M # Find files larger than 10MB ``` ### Tìm các tệp có quyền không chính xác (ví dụ: có thể ghi toàn cục) ``` find /tmp -type f -perm -o=w ``` ### grep Khi dùng grep để tìm file chú ý dùng grep là `\.php` chứ không phải là `*.php` bởi vì `*.php` chỉ tìm ở thư mục hiện tại. Nó không tìm trong toàn bộ đường dẫn Biểu thức |Công dụng |Ví dụ khớp| Ví dụ không khớp --|--|--|-- `\.php` |Regex (tìm .php trong chuỗi) |`index.php`, `/path/to/file.php`| `filephp`, `abc_php` `*.php` |Wildcard (tìm file có đuôi .php) |`index.php`, `test123.php` |`file.php.bak`, `filephp` ### strings Trường hợp file bị ẩn, không đọc được bằng `cat` ![image](https://hackmd.io/_uploads/Hk-CgtTHgg.png) ``` strings [tên_file] ``` ### hexdump Trường hợp file bị ẩn, không đọc được bằng `cat` ![image](https://hackmd.io/_uploads/Hk-CgtTHgg.png) ``` hexdump -C [tên_file] ``` ### od Trường hợp file bị ẩn, không đọc được bằng `cat` ![image](https://hackmd.io/_uploads/Hk-CgtTHgg.png) ``` od -c /etc/ld.so.preload ``` # Hex signature Dấu hiệu để tìm trong các file dump để tìm giá trị hex cần tìm (ví dụ như `powershell.dmp`) ## RSA private key ("RSA2") ``` RSA2 ... 52 53 41 32 ``` ![image](https://hackmd.io/_uploads/HJzRkBdAJe.png) >Bonus: Đối với loại RSA này có thể tìm giá trị `n` và `p` với `n` 256 byte đầu ở ảnh trên bắt đầu từ ` C2 14 C8` 128 byte sau là `p` từ đó tính được private key # Encrypt/Decrypt ## Decrypt RSA - Để lấy giá trị `p`, `q`, `N`, `e`, and `d` ``` openssl rsa -in private-key.pem -text -noout ``` - Có private key thì gen public key ``` openssl rsa -in private-key.pem -pubout -out public-key.pem ``` - Decrypt RSA ``` openssl pkeyutl -decrypt -in ciphertext -inkey private-key.pem -out decrypted.txt ``` ## Get HMAC 256 ``` openssl dgst -sha256 -hmac "mysecretkey" message.txt ``` # shellcode ## Signature Phần đầu `\xfc\x48...` là dấu hiệu cho thấy đây là **shellcode x64** ```shell unsigned char shellcode[] = "\xfc\x48\x81\xe4\xf0\xff\xff\xff\xe8\xd0\x00\x00\x00\x41" "\x51\x41\x50\x52\x51\x56\x48\x31\xd2\x65\x48\x8b\x52\x60" ... ``` # Command ## grep and perl (-P) Cho regex sau ``` \S+.*POST\s\/mgmt\/tm\/util\/bash\b.* ``` Khi sử dụng `grep` mặc định không hỗ trợ các ký tự thoát như `\S` (ký tự không phải khoảng trắng) – nó không phải cú pháp POSIX BRE/ERE. Do đó ta sẽ dùng `perl` ``` cat access.log | perl -ne 'print if /\S+.*POST\s\/mgmt\/tm\/util\/bash\b/' ``` Hoặc sử dụng option `-P` của `grep` ``` cat access.log | grep -P "\S+.*POST\s\/mgmt\/tm\/util\/bash\b.*" ``` # Threat Hunting in SIEM, EDR, XDR, ... ## Query ### `process.command_line` và `powershell.file.script_block_text` Trong query của các con SIEM thường có 2 trường (ví dụ bên dưới là của ELK), đây là 2 trường cần chú ý Thuộc tính| process.command_line| powershell.file.script_block_text --|--|-- Nguồn log| Sự kiện Process Creation (Sysmon ID 1, Windows 4688…) |PowerShell Script Block Logging (Windows Event ID 4104) |Ghi lại |Chuỗi tham số được truyền cho tiến trình khi khởi chạy (powershell.exe -…) |Nội dung mã PowerShell sau khi PowerShell biên dịch khối script (đầy đủ lệnh thực thi, kể cả phần tải xuống/giải mã) # Xác định thời gian chính xác Để có được thời gian file được mở/tải (ở mức filesystem) ta cần ưu tiên thứ tự file sau để xác định chính xác | Ưu tiên | Artifact / Log | Sự kiện/chứng cứ chính | Ý nghĩa thời gian | Lý do chọn / Lưu ý UTC | | ------: | ----------------------------------------------------------------------------------------- | --------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- | | 1 | **Sysmon** – `Microsoft-Windows-Sysmon/Operational.evtx`, **Event ID 1 (Process Create)** | Process **được khởi tạo** | Thời điểm **bắt đầu chạy** tiến trình | Mốc chính xác nhất để trả lời “activated”. Event time chuẩn; xuất/parse rồi **chuẩn hoá về UTC** (viewer có thể hiển thị theo local). | | 2 | **Security.evtx**, **Event ID 4688 (Process Creation)** | Process **được tạo** | Thời điểm **bắt đầu chạy** tiến trình | Dùng khi không có Sysmon. Cũng cần chuẩn hoá về **UTC** khi báo cáo. | | 3 | **Task Scheduler logs** (`Microsoft-Windows-TaskScheduler/Operational`) | Lệnh chạy qua tác vụ | Thời điểm tác vụ **được trigger** | Hữu ích nếu malware chạy qua Scheduled Task; vẫn xác nhận bằng (1)/(2) nếu có. | | 4 | **Prefetch** `*.pf` | **Run count** + **(Last/Previous Run Times)** | Thời điểm **chạy (gần)**, có thể là mốc cập nhật | FILETIME → UTC. Rất tốt để **củng cố**, nhưng có thể lệch vài giây so với event create. | | 5 | **BAM/DAM** (Registry) | Lần chạy gần nhất của EXE | “Last execution time” | Dùng để tham chiếu/đối chiếu; chuyển FILETIME → UTC. | | 6 | **AmCache.hve** | Dấu vết chương trình đã từng được chạy/cài | Thường là **first seen / last modified** | Bổ sung bối cảnh; không luôn là *moment of activation*. | | 7 | **SRUM** (System Resource Usage Monitor) | Hoạt động app/network theo khoảng | Mốc theo **cửa sổ thời gian (coarse)** | Tốt để khung thời gian; không chính xác đến giây. | | 8 | **ActivitiesCache.db** (Windows Timeline) | Hoạt động người dùng/app | Thời điểm **activity** (không phải kernel open) | Dùng cho ngữ cảnh; không dùng làm mốc chính xác “activated”. | | 9 | **MFT / LNK / RecentDocs** | Tồn tại/được mở bởi shell | Timestamps file/system | Chứng minh file xuất hiện/mở, **không** khẳng định đã thực thi. Dùng để hỗ trợ. | # Sửa lỗi vol chưa nhận được symbols ``` ┌──(kali㉿kali)-[~/Desktop/volatility3-2.26.0] └─$ mkdir /volatility3/symbols/linux/ ┌──(kali㉿kali)-[~/Desktop/volatility3-2.26.0] └─$ wget https://raw.githubusercontent.com/Abyss-W4tcher/volatility3-symbols/master/banners/banners_plain.json ┌──(kali㉿kali)-[~/Desktop/volatility3-2.26.0] └─$ grep -A 2 'dùng lệnh banner để lấy thông tin' banners_plain.json # Gỉa sử trả về "Linux version 3.2.0-4-amd64 (debian-kernel@lists.debian.org) (gcc version 4.6.3 (Debian 4.6.3-14) ) #1 SMP Debian 3.2.57-3+deb7u2": [ "Debian/amd64/3.2.0/4/Debian_3.2.0-4-amd64_3.2.57-3+deb7u2_amd64.json.xz" ], ┌──(kali㉿kali)-[~/Desktop/volatility3-2.26.0] └─$ wget https://github.com/Abyss-W4tcher/volatility3-symbols/raw/master/Debian/amd64/3.2.0/4/Debian_3.2.0-4-amd64_3.2.57-3+deb7u2_amd64.json.xz -P <volatility3_installation>/volatility3/symbols/linux/ ``` # Cơ chế đọc Registry trong các tool Một số công cụ sẽ hiển thị `ControlSet00x` rõ ràng; `regedit` khi đang xem hệ thống đang chạy thì thường ánh xạ và hiển thị `CurrentControlSet`. Trong báo cáo kỹ thuật người ta thường dùng `HKLM\SYSTEM\CurrentControlSet\…` để chỉ rõ ta đang nói về control set đang hoạt động, tránh ghi nhầm vào một ControlSet cụ thể. Ví dụ đáp án là `HKLM\SYSTEM\CurrentControlSet\Services\PortProxy\v4tov4\tcp` còn ở tool sẽ xuất hiện như ảnh ![image](https://hackmd.io/_uploads/rJzbNBBneg.png) # TeamView - Là RRM tool - Vị trí ở: `C:\Program Files\TeamViewer\TeamViewerXX_Logfile.log` hoặc ở `C:\Users\<TênUser>\AppData\Roaming\TeamViewer\TeamViewerXX_Logfile.log` ## Log Để tìm hành vi download các file độc ta sẽ tìm bằng các string: - `download` - `write file` ![image](https://hackmd.io/_uploads/r1hV3awnel.png) Để tìm hành vi gửi file đi ta tìm bằng các string: - `send file` ![image](https://hackmd.io/_uploads/S1A5ryOhee.png) # Filter event Một số trick filter để giảm event thừa ## Filter các file độc Ta filter những mục có `Last Run` có giá trị, nhưng các mục `Previous Run` thì trống để tìm chương trình vừa được chạy lần đầu tiên trên hệ thống -> Mục tiêu là để: - Có thể đó là mã độc mới được cài đặt và khởi chạy - Giúp xác định thời điểm xâm nhập ban đầu hoặc bước leo thang quyền Tham khảo [WriteUp](https://hackmd.io/@TwentySeV/Hyvbx4BAxe) ## Filter trên Prefetch Một trường hợp để hiểu: > Một số công cụ có thể dùng để thực hiện Kerberoasting đó là impacket, Rubeus, PowerSploit (Invoke-Kerberoast), nhưng khi được cung cấp prefetch thì nghĩa là 90% là Rubeus vì impacket được viết bằng python và PowerSploit là script PowerShell # Note 1. Truy tìm thiết bị thuộc về loại gì thông qua địa chỉ MAC tại [link này](https://mac.lc/) Chúng ta có thể thấy rằng giá trị tiền tố địa chỉ MAC của thiết bị Apple là "98:CA:33". ![image](https://hackmd.io/_uploads/BkQw1D0tJl.png) 2. WAF (Web Application Firewall) hoạt động ở trước web server. Nó chặn các request xấu (như SQLi, XSS, RFI...) **trước khi chúng kịp đi tới web server. Vì vậy, web server logs (như access.log hoặc error.log) sẽ không ghi nhận những request đó.** 3. **Body SHA-256** thường xuất hiện trong bối cảnh email, cybersecurity, hoặc thẩm định nội dung, và nó có một số tác dụng chính tùy vào ngữ cảnh cụ thể: - Là hash SHA-256 được tính từ phần thân (body) của một email hoặc một request, file, v.v - Các hệ thống chống spam/malware dùng SHA-256 của body để: + So sánh với hash trong blacklist/whitelist. + Phân loại nội dung giống nhau dù tiêu đề khác nhau.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully