janlele91
    • 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 New
    • 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 Note Insights Versions and GitHub Sync 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
    1
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Malware Analysis Revision 🤬 <style>body {text-align: justify}</style> ``` - Phân tích tĩnh, động, kết hợp -> Định nghĩa, công cụ, ... - Mã assembly -> Chương trình có chức năng gì - Đồ án bất kì + Federated Learning + Phân tích mã độc bằng ảnh + Anti VM ... - Câu hỏi mở về an toàn thông tin (không cần code) - 5 câu ``` ## 1. Lí thuyết: ### 1.1 The goals of malware analysis - Xác định chính xác những gì xảy ra với hệ thống bị nhiễm độc, xâm nhập: file, các máy tính, ... - Thiết lập các rule, các signature để phát hiện các loại malware đó - **Host-based signature**: detect malicious code on victim computers (files, registry, ...) - **Network-based signature**: detect malicious code by monitoring network traffic ### 1.2 Malware ### 1.3 Types of Analysis #### 1.3.1 Static Analysis - **Định nghĩa**: Là kĩ thuật phân tích mã độc bằng cách thực hiện dịch ngược lại mã độc mà không thực thi nó. - **Tools**: VirusTotal, strings, a disassembler like IDA Pro, x64dbg, OllyDbg, Radare2 ![](https://i.imgur.com/Zj3R8ri.png) - Bất lợi khi mã độc bị: - Làm rối (Obfuscation) - Mã hóa (Encryption) - Nén (Packing) - Các bước thực hiện: 1. Thiết lập môi trường phân tích an toàn 2. Phân tích ban đầu: Upload to Virustotal 3. Phân tích bằng công cụ: - **PEiD**: Kiểm tra tình trạng ban đầu của file (có bị mã hóa, rối mã hay packed hay không) - **PEView**: Xem thông tin biên dịch của file dưới dạng các header - **Dependency Walker**: Danh sách lib và func được sử dụng - **Strings**: Tìm kiếm các chuỗi (3 ksi tự trở lên) xuất hiện trong file thực thi - **UPX**: dùng để unpack file trong trường hợp file bị packed 4. Sử dụng công cụ dịch ngược như IDA Pro, OllyDBG để phân tích luồng hoạt động. 5. Báo cáo. #### 1.3.2 Dynamic Analysis - **Định nghĩa**: Thực thi mã độc trong một môi trường tách biệt và phân tích dựa trên các hành vi của nó. - **Điều kiện**: - Sử dụng 1 môi trường an toàn tách biệt với máy thật - Đảm bảo không lan truyền mã độc đến các máy khác. - Có thể tắt mạng của máy thật - **Tools**: RegShot, Process Monitor, Process Hacker, CaptureBAT ![](https://i.imgur.com/Ij2VR7X.png) - **RAM Analysis**: MandantRedline and Volatility - **Virtual Machine**: Máy ảo thông thường được dùng. Tuy nhiên, mã độc ngày càng phức tạp khi nó có thể anti máy ảo và thực thi hành vi khác với hành vi ban đầu. - Registry check - File check - MAC check - **Sandbox** - All-in-one software for basic dynamic analysis - Virtualized environment that simulates network services - Các bước thực hiện: 1. Thiết lập môi trường phân tích an toàn. 2. Phân tích trạng thái ban đầu của file để phát hiện mã hoá, nén, obfuscated,... Các hàm import, strings,... 3. Chạy file và phân tích mã độc với các công cụ phân tích động nhằm tìm ra hành vi của mã độc. - **IDA**: Debug - **Process monitor**: Theo dõi tiến trình và các tiến trình con (nếu có). - **Wireshark**: Theo dõi hành vi mạng của mã độc, - **Regshot**: Xem sự thay đổi registry - **Process Explorer**: Theo dõi các trạng thái các tiến trình trong hệ thống 4. Báo cáo. #### 1.3.3 Hybrid Static/ Dynamic - Most Analysis is a mixture: You find something in the disassembly then you confirm/investigate while the malware is executing. - Memory Forensics. Can be very useful, but is not the end-all-be-all ## 2. Đồ án ### 2.1 Phân tích mã độc bằng ảnh ![](https://i.imgur.com/85pEXxV.png) `APK/EXE malware` - Preprocessing: Chuyển đổi 1 file thực thi malware dưới dạng raw byte thành 1 hình ảnh (gray-scale/RGB). - Sắp xếp raw byte của 1 file thành 1 chuỗi 1D - Mỗi byte có giá trị nằm trong khoảng từ 0-255 nên chúng ta có thể biểu diễn nó thành 1 pixel hoàn chỉnh của 1 ảnh gray-scale. Trong trường hợp muốn chuyển đổi thành 1 ảnh RGB, ta chỉ cần gom nhóm 3 bytes thành 1 pixel. - Sau khi gom nhóm thành 1 chuỗi liên tiếp các pixel, thực hiện tạo thành ảnh bằng cách giữ cố định width (chiều rộng) của ảnh, ví dụ như 1920 pixels, rồi sắp xếp lần lượt theo chiều cao (height) cho đến khi hết chuỗi. Trong trường hợp vẫn còn thiếu pixel để hoàn chỉnh ảnh thì thêm các pixel 0 (màu đen) vào cho đủ. - Classifier: - Huấn luyện các mô hình phân loại ảnh tốt như CNN để phát hiện malware dạng ảnh. - Evaluation: - Đánh giá hiệu năng của mô hình. ### 2.2 Anti-VM technique malware #### 2.2.1 Computer malware Phát hiện xem malware có đang được thực thi trong môi trường VM hay không, khi đó chúng sẽ hoạt động khác đi hoặc đơn giản là không hoạt động, gây khó khăn cho việc phân tích Một số “dấu vết đặc trưng” giúp nhận dạng VM như: các file đặc trưng, tiến trình, registry key, services, network adapter,... - CPUID (phổ biến nhất): input là `eax=0x1`, giá trị trả về ở ecx, nếu bit thứ 31 bằng 0 là máy thật, bằng 1 là máy ảo - MMX: một bộ lệnh của Intel dùng cho máy thật. Thông thường nếu bị thiếu bộ MMX này thì khả năng đây là VM - `“VMWare Magic Number”` - Kiểm tra địa chỉ MAC, Adapter name - Kiểm tra Registry key: VMWare Tools - Một số process ví dụ như: vmtoolsd.exe, vmwaretray.exe, vmwareuser.exe, vboxservice.exe, vboxtray.exe. - Một số file : - `(C:\windows\System32\Drivers\) vmmouse.sys, vm3dgl.dll, vmdum.dll,...` - `C:\Program Files\VMware\VMware Tools` - Một số service: `VMTools, Vmmouse, Vmrawdsk, Vmscsi,...` #### 2.2.2 Android malware (Detect emulators) - Kiểm tra các thuộc tính của qemu - Kiểm tra sự tồn tại của qemu pipes: `/dev/socket/qemud` ,`/dev/qemu_pipe` - Kiểm tra qemu files: `/system/lib/libc_malloc_debug_qemu.so`, `/sys/qemu_trace`, `/system/bin/qemu-props` - Kiểm tra qemu driver: There is goldfish under `/proc/tty/drivers` and `/proc/cpuinfo`. - Device id: một số emulator có device id mặc định như `000000000000000`, `012345678912345` - Kiểm tra genymotion files: `/dev/socket/genyd`, `/dev/socket/baseband_genyd` - Detect taintdroid - Operators: Some emulators have "android" as operators - default number - IMSI number ## 2.3 Anti disassembly ### 2.3.1 Khái niệm - là một kỹ thuật mà ở đó các đoạn mã nguồn và dữ liệu trong chương trình được thiết kết sao cho các công cụ phân tích mã hợp ngữ tạo ra các kết quả không chính xác. ### 2.3.2 Khái niệm disassembler - **Linear disassembly**: Phân tách từng lệnh tại một thời điểm dựa theo opcode. Sau đó, sử dụng kích thước của lệnh vừa phân tách để xách định byte cần phân tách tiếp theo. Linear disassembly không phân biệt code và dữ liệu. - **Flow-oriented disassembly**: Không lặp lại mù quán như **linear disassembly**, kiểm tra mỗi lệnh và dựng lên một danh sách các vị trí cần phân tách. Tuy nhiên ở một số trường hợp, thứ tự phân tách có thể dẫn đến đoạn các đoạn mã hợp ngữ khác nhau: - Ở các điều kiện rẽ nhánh: disassembler sẽ lựa chọn một trong 2 vị trí để phân tách (nhánh **đúng** hoặc nhánh **sai**). Hầu hết disassembler thường lựa chọn nhánh **sai** để phân tách. - Ở lệnh **call**: Lưu địa chỉ được gọi đến vào danh sách phân tách trong tương lai. Đối với các byte sau lệnh call, hầu hết disassembler sẽ chọn phân tách tiếp. ### 2.3.3 Các kỹ thuật anti disasssembly - **Linear disassembly**: chèn các byte dữ liệu trùng với opcode của các lệnh. - **Flow-oriented disassembly**: - Chèn các lệnh nhảy đến cùng một đích ![](https://i.imgur.com/bkEfQ3q.png) ![](https://i.imgur.com/mHYwslL.png) - Chèn các lệnh nhảy với điều kiện hằng số ![](https://i.imgur.com/wrxDY7w.png) ###### tags: `malware`, `final`

    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