• 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

  • 相关阅读:
    shuffle过程分析
    自定义分组
    自定义排序及Hadoop序列化
    MapReduce常见算法
    Partitioner
    Combiner
    自定义Counter使用
    WordCount_命令行运行时指定参数
    老的API实现WordCount
    Hadoop自定义类型处理手机上网日志
  • 原文地址:https://www.cnblogs.com/tjp40922/p/15171898.html
Copyright © 2020-2023  润新知