Nguyễn Quang Bá
    • 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 No publishing access yet

      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.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      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
    • Make a copy
    • 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 Make a copy 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 No publishing access yet

    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.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Phân tích mã độc android ## Thông tin cơ bản MD5: `ec054b7025b9c35692d42163d1e0bd9f` App name: `DỊCH VỤ CÔNG` Package name: `com.phommvb.dotihanj` Arch: `arm64-v8a, armeabi-v7a` Target SDK: `32: Android 12.0L` Permission: ``` android.permission.CAMERA android.permission.BIND_ACCESSIBILITY_SERVICE android.permission.REQUEST_DELETE_PACKAGES android.permission.QUERY_ALL_PACKAGES android.permission.GET_INSTALLED_APPS android.permission.VIBRATE android.permission.WRITE_EXTERNAL_STORAGE android.permission.READ_EXTERNAL_STORAGE android.permission.GRANT_RUNTIME_PERMISSIONS android.permission.READ_SYNC_STATS android.permission.READ_SYNC_SETTINGS android.permission.DISABLE_KEYGUARD android.permission.WAKE_LOCK android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS android.permission.RECEIVE_BOOT_COMPLETED android.permission.SYSTEM_ALERT_WINDOW android.permission.WRITE_SETTINGS android.permission.FOREGROUND_SERVICE android.permission.READ_SMS android.permission.SEND_SMS android.permission.ACCESS_NETWORK_STATE android.permission.ACCESS_WIFI_STATE android.permission.USE_FULL_SCREEN_INTENT android.permission.SET_WALLPAPER android.permission.CALL_PHONE android.permission.INTERNET android.permission.BATTERY_STATS ``` ApkID: ![image](https://hackmd.io/_uploads/BkGJMx2uC.png) Qua các thông tin trên, ta thấy được mã độc yêu cầu cấp nhiều quyền nhạy cảm. Đồng thời, sử dụng trình protector `Virbox` đối với các lib `l4ccd64a6_***.so`. ## Phân tích chi tiết AndroidManifest.xml: ```xml ................. <application android:theme="@style/md2" android:label="@string/ehv" android:icon="@mipmap/b1w" android:name="v4ccd64a6.l4ccd64a6" android:screenOrientation="portrait" android:allowBackup="true" android:hardwareAccelerated="true" android:supportsRtl="true" android:usesCleartextTraffic="true" android:networkSecurityConfig="@xml/ebz" android:appComponentFactory="androidx.core.app.CoreComponentFactory" android:requestLegacyExternalStorage="true"> <meta-data android:name="SAPP_NAME" android:value="com.yiwuzhibo.BaseApplication"/> <activity android:name="com.yiwuzhibo.activity.NNNNNNNAAAAActivity" android:screenOrientation="portrait"/> <activity android:label="@string/xao" android:icon="@mipmap/b1w" android:name="com.yiwuzhibo.activity.SplashActivity" android:exported="true" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> ....... ``` Theo file AndroidManifest.xml, `v4ccd64a6.l4ccd64a6` sẽ là entrypoint được chạy khi người dùng nhấn vào icon để mở ứng dụng. ![image](https://hackmd.io/_uploads/HJ4X5l3d0.png) Chúng ta thấy có string "virbox", trình protector được sử dụng cho các lib trong asset. Rename lại class,method để thuận tiện hơn. Drop file lib `.so` và load: ![image](https://hackmd.io/_uploads/S1_EFHpdA.png) Overload `onCreate`: ![image](https://hackmd.io/_uploads/H1-4qBadC.png) Tất cả mã nguồn tại entrypoint của chương trình tại đây:[source](https://gist.github.com/h1bAna/d13786debda788a5a4c61c719bfcad12) Tổng quát lại, tại entrypoint của chương trình, mã nguồn thực hiện các hành vi sau: + drop file lib và load + Khởi tạo môi trường phù hợp để phục vụ cho việc dynamic loading. Mình đọc qua 3 hàm `swapApplicationReferences`, `updateAssetManager`,`reinstallContentProviders` thì thấy có chút liên quan đến bài [này](https://mp.weixin.qq.com/s/Uwr6Rimc7Gpnq4wMFZSAag?utm_source=androidweekly&utm_medium=website) File `index.html, kqkticwjgzy.dat` cũng đã được encrypt: ![image](https://hackmd.io/_uploads/rJYx7b2uC.png) ![image](https://hackmd.io/_uploads/Sk7QQbh_R.png) Khi thử phân tích tĩnh file thư viện trong `asset`, ta cũng không thu được gì. Do file đã được bảo vệ bằng `virbox`, rất có thể thư viện đã bị obfuscate. Rất nhiều đoạn tại phân vùng `.text` công cụ không nhận diện được, các hàm thì rất khó đọc và phân tích code. ![image](https://hackmd.io/_uploads/ByUMz7huR.png) Tiến hành cái ứng dụng lên môi trường test, ứng dụng có sử dụng các cơ chế detect root, detect developer mode, detect unlock bootloader,.... để phát hiện môi trường test. Có thể bypass bằng các cài thêm các module ẩn root, ẩn developer mode,.... Giao diện ứng dụng khi truy cập: ![image](https://hackmd.io/_uploads/ryipzm2_R.png) Sử dụng frida để dump các class trong quá trình runtime: [script](https://github.com/apkunpacker/DexDumper/tree/main) ![image](https://hackmd.io/_uploads/S19F7Q2dR.png) ![image](https://hackmd.io/_uploads/ryqvV73dA.png) Các string từ các class được dump từ dex ra đã bị mã hóa, được giải mã trong lúc runtime bằng method `m4ccd64a6.F4ccd64a6_11()`. Tuy nhiên, hàm này là hàm native code, load từ thư viện. Điều này khiến việc decrypt string khó khăn hơn. Vì chưa tìm được cách reverse được method này nên mình dùng hook để bắt input và output. Recover lại được kha khá string. ![image](https://hackmd.io/_uploads/ryLUZ3RuR.png) ```javascript= Java.perform(function() { console.log("[*] Starting script"); Java.enumerateLoadedClasses({ onMatch: function(className) { if (className.includes("m4ccd64a6")) { console.log(`[*] Potential target class found: ${className}`); hookTargetClass(className); } }, onComplete: function() { console.log("[*] Finished enumerating loaded classes"); } }); function hookTargetClass(targetClassName) { Java.perform(function() { try { var targetClass = Java.use(targetClassName); var targetMethod = targetClass.F4ccd64a6_11.overload('java.lang.String'); targetMethod.implementation = function(arg0) { console.log(`[*] Hooked ${targetClassName}.F4ccd64a6_11`); console.log(`[*] Input: ${arg0}`); var result = this.F4ccd64a6_11(arg0); console.log(`[*] Output: ${result}`); return result; }; console.log(`[*] Hooking successful for ${targetClassName}.F4ccd64a6_11`); } catch (e) { console.log(`[*] Error: ${e}`); } }); } }); ``` Sau khi đã có thể hook được thành công, mình nghĩ liệu mình có thể tự gọi hàm bằng frida? Và câu trả lời là có. Đây là ví dụ: ```javascript= Java.perform(function() { console.log("[*] Starting script"); // Liệt kê tất cả các class đã được load Java.enumerateLoadedClasses({ onMatch: function(className) { if (className.includes("m4ccd64a6")) { console.log(`[*] Potential target class found: ${className}`); callTargetMethod(className); } }, onComplete: function() { console.log("[*] Finished enumerating loaded classes"); } }); function callTargetMethod(targetClassName) { Java.perform(function() { try { // Sử dụng class được load động var targetClass = Java.use(targetClassName); // Gọi hàm F4ccd64a6_11 với tham số truyền vào var inputArg = "^L23230F323C2A402C403E2638454C37377C3B35518042454F3D533F5351938A"; var result = targetClass.F4ccd64a6_11(inputArg); console.log(`[*] Called ${targetClassName}.F4ccd64a6_11`); console.log(`[*] Input: ${inputArg}`); console.log(`[*] Output: ${result}`); } catch (e) { console.log(`[*] Error: ${e}`); } }); } }); ``` ![image](https://hackmd.io/_uploads/Bk_NLnAdA.png) Lúc này, nếu muốn decrypt hết tất cả các strings ta có 2 cách. + bung file dex thành smali code, tìm tất các cả string cần decrypt. Chạy frida script để decrypt tất cả đống này, thường là các const-string. Ví dụ như: ![image](https://hackmd.io/_uploads/BysP1T0dA.png) cách này khá hiệu quả và dễ thực hiện + Viết jeb script, cách này khó hơn nhưng đổi lại đọc source dễ hơn. https://blog.viettelcybersecurity.com/mot-vai-phuong-phap-deobfuscate-trong-qua-trinh-phan-tich-ma-doc-android/ Sau khi dịch ngược mã nguồn, có thể thấy ứng dụng này là một banking trojan. Ứng dụng yêu cầu cấp quyền để đăng ký Accessiblity Service. Tính năng này cho phép ứng dụng quay lại màn hình, keylogger,.... Nhằm đánh cắp các thông tin liên quan đến các ứng dụng ngân hàng. Chi tiết hơn: trong libstrategy.so của ứng dụng có các string liên quan đến phone brand, các ứng dụng ngân hàng: ![image](https://hackmd.io/_uploads/rJ6lRtzF0.png) ![image](https://hackmd.io/_uploads/ryA9KdGY0.png) ![image](https://hackmd.io/_uploads/BJuM9uft0.png) Ứng dụng có thể tự thao tác chạm với màn hình, không cần người dùng chạm vào màn hình điểu khiển. ![image](https://hackmd.io/_uploads/r1dbsKfKA.png) ![image](https://hackmd.io/_uploads/BkNpjFGt0.png) ![image](https://hackmd.io/_uploads/rJdk2FfFC.png) ghi lại quá trình authen của user, sau đó có thể tự click lại giống vậy. ![image](https://hackmd.io/_uploads/Sky3RKMFC.png) TouchAccessibilityService ![image](https://hackmd.io/_uploads/rk6ikqzFA.png) LockManager$swipeUp$1 Tự động swipeup, mở khóa màn hình. ![image](https://hackmd.io/_uploads/H18xeqMtR.png) PasswordCapture2 capture mật khẩu ![image](https://hackmd.io/_uploads/SkdMeqzYR.png) RemoteCommandClient tạo connect đến C2 ![image](https://hackmd.io/_uploads/Byjne9Mt0.png) 1 số endpoint của c2, tuy nhiên máy chủ đã không thể connect đến. Kết luận lại: Ứng dụng là trojan banking, khi người dùng cài đặt có nguy cơ bị mã độc ghi lại các thao tác đăng nhập, đánh cắp mật khẩu. Kết hợp với các quyền được cấp khác như đọc sms, ứng dụng có thể tự mở khóa màn hình, mở ứng dụng banking, đăng nhập, tạo giao dịch chuyển tiền, đọc otp từ sms.

    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
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    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