objection的基礎使用


0x1 介紹&安裝Objection

objection是基於frida的命令行hook工具, 可以讓你不寫代碼, 敲幾句命令就可以對java函數的高顆粒度hook, 還支持RPC調用

目前只支持Java層的hook, 但是objection有提供插件接口, 可以自己寫frida腳本去定義接口

比如葫蘆娃大佬的脫殼插件, 實名推薦: FRIDA-DEXDump

官方倉庫: objection


  • 安裝前置條件
1
2
1. python版本 > 3.4
2. pip版本 > 9.0
  • 安裝命令

pip3 install objection

安裝完成后, 直接輸入objection, 就可以看到食用方法了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Usage: objection [OPTIONS] COMMAND [ARGS]...

_ _ _ _
___| |_|_|___ ___| |_|_|___ ___
| . | . | | -_| _| _| | . | |
|___|___| |___|___|_| |_|___|_|_|
|___|(object)inject(ion)

Runtime Mobile Exploration
by: @leonjza from @sensepost

By default, communications will happen over USB, unless the --network
option is provided.

Options:
-N, --network Connect using a network connection instead of USB.
[default: False]
-h, --host TEXT [default: 127.0.0.1]
-p, --port INTEGER [default: 27042]
-ah, --api-host TEXT [default: 127.0.0.1]
-ap, --api-port INTEGER [default: 8888]
-g, --gadget TEXT Name of the Frida Gadget/Process to connect to.
[default: Gadget]
-S, --serial TEXT A device serial to connect to.
-d, --debug Enable debug mode with verbose output. (Includes
agent source map in stack traces)
--help Show this message and exit.

Commands:
api Start the objection API server in headless...
device_type Get information about an attached device.
explore Start the objection exploration REPL.
patchapk Patch an APK with the frida-gadget.so.
patchipa Patch an IPA with the FridaGadget dylib.
run Run a single objection command.
version Prints the current version and exists.

0x2 簡單使用一下

  • 使用前幾個使用tips
1
2
3
1. 空格鍵: 忘記命令直接輸入空格鍵, 會有提示與補全
2. help: help [command] 會有詳細介紹指定命令的作用與例子
3. jobs: 任務管理系統, 可以方便的查看與刪除任務
  • 啟動Frida-server並轉發端口

  • 附加需要調試的app, 進入交互界面

1
objection -g [packageName] explore
  • 可以使用該env命令枚舉與所討論的應用程序相關的其他有趣目錄: env
1
2
3
4
5
6
7
8
9
10
11
12
13
com.opera.mini.native on (samsung: 6.0.1) [usb] # env


Name Path

---------------------- ------------------------------------------------------------

filesDirectory /data/user/0/com.opera.mini.native/files
cacheDirectory /data/user/0/com.opera.mini.native/cache
externalCacheDirectory /storage/emulated/0/Android/data/com.opera.mini.native/cache
codeCacheDirectory /data/user/0/com.opera.mini.native/code_cache
obbDir /storage/emulated/0/Android/obb/com.opera.mini.native
packageCodePath /data/app/com.opera.mini.native-1/base.apk
  • 我們可以使用以下file download命令從遠程文件系統中下載文件:
    file download [file] [outfile]
1
2
com.opera.mini.native on (samsung: 6.0.1) [usb] # file download fhash.dat fhash.dat
Downloading /data/user/0/com.opera.mini.native/cache/fhash.dat to fhash.dat
  • 可以列出app具有的所有avtivity: android hooking list activities

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12

    com.opera.mini.native on (samsung: 6.0.1) [usb] # android hooking list activities
    com.facebook.ads.AudienceNetworkActivity
    com.google.android.gms.ads.AdActivity
    com.google.android.gms.auth.api.signin.internal.SignInHubActivity
    com.google.android.gms.common.api.GoogleApiActivity
    com.opera.android.AssistActivity
    com.opera.android.MiniActivity
    com.opera.android.ads.AdmobIntentInterceptor
    com.opera.mini.android.Browser

    Found 8 classes
  • 啟動指定avtivity: android intent launch_activity [class_activity]

    1
    2
    3

    com.opera.mini.native on (samsung: 6.0.1) [usb] # android intent launch_activity com.facebook.ads.AudienceNetworkActivity
    Launching Activity: com.facebook.ads.AudienceNetworkActivity...
  • RPC 調用命令: curl -s "http://127.0.0.1:8888/rpc/invoke/androidHookingListActivities"

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12

    $ curl -s "http://127.0.0.1:8888/rpc/invoke/androidHookingListActivities"
    ["com.reddit.frontpage.StartActivity","com.reddit.frontpage.IntroductionActivity", ... snip ...]

    - RPC調用執行腳本:`url -X POST -H "Content-Type: text/javascript" http://127.0.0.1:8888/script/runonce -d "@script.js"`

    $ cat script.js
    {
    send(Frida.version);
    }

    [{"payload":"12.8.0","type":"send"}]

RPC WIKI

0x3 API介紹

以下只是寫了一部分指令和功能, 詳細的功能需要合理運用空格help

  • Memory 指令

    1
    2
    3
    4
    memory list modules //枚舉當前進程模塊
    memory list exports [lib_name] //查看指定模塊的導出函數
    memory list exports libart.so --json /root/libart.json //將結果保存到json文件中
    memory search --string --offsets-only //搜索內存
  • android heap

1
2
3
4
5
6
7
8
//堆內存中搜索指定類的實例, 可以獲取該類的實例id
search instances search instances com.xx.xx.class

//直接調用指定實例下的方法
android heap execute [ins_id] [func_name]

//自定義frida腳本, 執行實例的方法
android heap execute [ins_id]
  • root
1
2
3
4
5
//嘗試關閉app的root檢測
android root disable

//嘗試模擬root環境
android root simulate
  • ui

    1
    2
    3
    4
    5
    //截圖
    android ui screenshot [image.png]

    //設置FLAG_SECURE權限
    android ui FLAG_SECURE false
  • 內存漫游

1
2
3
4
5
6
7
8
9
10
11
//列出內存中所有的類
android hooking list classes

//在內存中所有已加載的類中搜索包含特定關鍵詞的類
android hooking search classes [search_name]

//在內存中所有已加載的方法中搜索包含特定關鍵詞的方法
android hooking search methods [search_name]

//直接生成hook代碼
android hooking generate simple [class_name]
  • hook 方式
1
2
3
4
5
6
7
8
9
10
11
12
13
  /*
hook指定方法, 如果有重載會hook所有重載,如果有疑問可以看
--dump-args : 打印參數
--dump-backtrace : 打印調用棧
--dump-return : 打印返回值
*/
android hooking watch class_method com.xxx.xxx.methodName --dump-args --dump-backtrace --dump-return

//hook指定類, 會打印該類下的所以調用
android hooking watch class com.xxx.xxx

//設置返回值(只支持bool類型)
android hooking set return_value com.xxx.xxx.methodName false
  • Spawn方式Hook
1
objection -g packageName explore --startup-command '[obejection_command]'
  • activity和service操作
1
2
3
4
5
6
7
8
9
10
11
//枚舉activity
android hooking list activities

//啟動activity
android intent launch_activity [activity_class]

//枚舉services
android hooking list services

//啟動services
android intent launch_service [services_class]
  • 任務管理器
1
2
3
4
5
//查看任務列表
jobs list

//關閉任務
jobs kill [task_id]
  • 關閉app的ssl校驗

    1
    android sslpinning disable
  • 監控系統剪貼板

1
2
//獲取Android剪貼板服務上的句柄並每5秒輪詢一次用於數據。 如果發現新數據,與之前的調查不同,則該數據將被轉儲到屏幕上。
help android clipboard
  • 執行命令行
1
help android shell_exec [command]

 

轉自:http://strivemario.work/archives/8eec80c3.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM