逆向之路月一

1. 第一个APP

未解决问题

  • Genymotion arm 手机中未安装成功

1.1 安装虚拟机

  • windows 安装 Vmware workstation pro

  • mac 安装 Vmware fusion

1.2 安装kali

  • 打开虚拟机,编辑虚拟机

    • 硬件 -> 更改内存

    • 硬件 -> 显示器不选择加速3D图形

    • 选项 -> 虚拟机名称,自己改个名字

1.3 修改配置kali虚拟机

  • 更改时区

    • dpkg-reconfigure tzdata 选择Asia -> shanghai
  • 更新系统源

    • apt update
  • 安装中文字体 -> 非系统中文

    • apt install xfonts-intl-chinese

    • apt install ttf-wqy-microhei

  • 更改系统字体大小

    • file -> preferences -> Appearance -> Font -> Change -> Size
  • 更改名字 -> hostname

    • nano /etc/hostname -> 修改里面的名字内容
  • 重启

    • 右上角 -> Restart

1.4 安装 Android Studio

  • 切换到桌面

    • cd Desktop/
  • 安装Android Studio

    • wget Android Studio linux 下载地址
  • 解压安装

    • tar -zxvf android-studio-ide-............-linux.tar.gz

    • cd android-studo/bin/

    • ./studio.sh

    • 选择 Do not import settings

    • 选择 Dont send

    • 不要选择代理 选择candel

    • next -> next -> next -> finsh

    • start a new Android Studio project

    • Empty Activity

      • 修改 Name

      • 修改 Language

      • finsh

  • android adb

    • cd Android -> cd Sdk/ -> cd platform-tools/

    • ./adb --help

    • adb connect ip:port

    • adb shell

  • 将adb命令加入到路径中

    • nano ~/.bashrc

    • PATH=$PATH:命令路径

  • 安装软件3款

    • apt install tmux jnettop

    • apt install htop

1.5 安装QtScrcpy(最好用windows、mac,不在linux中使用)

  • 每次投屏前刷新设备列表

  • 可以使用usb线连接,也可以使用wifiadb无线连接

1.6 安装wifidb

1.7 模拟器->Genymotion

  • 选择手机型号

  • Notework mode --> Bridge

    • 桥接真正的网卡

    • 报错修改 Processor(s)、Memory size

  • uname -a

    • 查看设备信息-架构
  • Genymotion arm 桥

    • Genymotion-ARM-Translation_for_8.0.zip

2. linux命令

2.1 kali科学配置

  • nano /etc/proxychains.conf -->配置

    • socket5(协议) 192.127.1.0(地址) 1080(端口)
  • 注释 proxy_dns

2.2 linux 命令

  • curl ip.sb >查看ip地址

  • proxychains curl ip.sb >查看代理ip

  • telnet ip port >ping 地址

  • neofetch > 查看android系统配置的工具

  • cat

  • file * > 查看文件格式

  • echo touch

    • />/>
  • adb shell dumpsys activity top

  • grep 过滤

    • i 忽略大小写
  • ps 查看进程信息

  • tree -NCfhl | grep ***

    • 搜索
  • ln -s 命令路径 /usr/bin

    • 添加软连接到usr/bin 里面

3. 运行环境手机刷机指南

3.1 安卓手机刷机方法论

  • google 搜索 lineageos

  • 点击 DOWNLOAD

  • google 官方镜像

    • google factory image google factory image

      • 8.1.0 (OPM1.171019.011, Dec 2017) Nexus 5x
  • 解压

    • 7z x file.zip

3.2 线刷谷歌官方系统

3.3 Twrp/Magisk/FridaServer

  • 刷机流程

    • kali虚拟机 解压 bullhead-opml.171019.011-factory-3be6fdlc.zip

    • 手机关机(电脑/虚拟机不需要连接手机)

    • 重启,按住音量键↓+开关键;

    • 进入bootloader, DEVICE STATE - unlocked这里必须是解锁的

    • 通过手机线连接到虚拟机

    • 进入 bullhead-opml.171019.011目录

    • 执行命令 ./flash-all.sh, 等待命令执行结果完毕,手机会有连接断开的声音

    • 这一步可能会失败(版本问题)

      • 替换fastboot.zip

      • 星球下载fastboot.zip

      • 解压fastboot.zip 为 ELF 64-bit的文件

      • 对这个fastboot 改名为 fastboot810rl

      • 查看使用的fastboot路径 which fastboot

      • 将改名后的fastboot 复制到 真正执行的fastboot cp fastboot810rl 路径

      • 进入到fastboot 路劲中 将现在使用的fastboot改名备份(注意权限问题 chmod 777 fastboot810rl) 将fastboot810frl 改名为fastboot

    • 刷机完毕后手机会自动重启(看到命令执行完后显示 finished rebooting)

    • 选择中文, 跳过一直到 更多-同意 进入系统

    • 系统将显示休眠时间调长, 打开不锁定屏幕, 打开开发者模式打开 USB调试

    • 接下来root, 使用工具 twrp-3.3.1-0-bullhead.img

      • google 搜索 twrp->选择版本twrp-3.3.1.0->devces page->LG Nexus 5x->Europe->选择3.3.1.0这个版本
    • adb reboot bootloader

    • fastboot flash recovery twrp-3.3.1.0-bullhead.img

    • 选择手机进入recovery mode

    • 向右滑动

    • 将setting中的息屏关掉

    • Magisk-v20.4.zip

      • github Magisk-> releases -> 下载zip包
    • adb push Magisk-V20.4.zip /sdcard/

    • Frida server 下载

      • github Frida -> releases Frida 12.11.7 -> frida-server-12.11.7-android-arm64.xz

      • 7z -x frida-server-12.11.7-android-arm64.xz

    • adb push frida-server-12.11.7-android-arm64 /data/local/tmp/

    • 拔掉手机连接线

    • 点击手机页面install-> 下拉-> Magisk-V20.4.zip-> 右拉-> reboot system -> do not install

    • 连接手机, 装wifiadb, 连接wifi

    • 进入手机系统

    • cd /data/local/tmp/

    • /frida-server-12.11.7-android-arm64

    • frida-server 已经启动了

3.4 Twrp/SuperSU/KaliNethunter

  • 刷机流程

    • 下载kali NetHunter

      • google: kali nethunter

      • downloader

      • Nexus 5x Oreo 下载种子

    • adb reboot bootloader

    • 通过手机线连接到虚拟机

    • 进入 bullhead-opml.171019.011目录

    • 执行命令 ./flash-all.sh, 等待命令执行结果完毕,手机会有连接断开的声音

    • 这一步可能会失败(版本问题)

      • 替换fastboot.zip

      • 星球下载fastboot.zip

      • 解压fastboot.zip 为 ELF 64-bit的文件

      • 对这个fastboot 改名为 fastboot810rl

      • 查看使用的fastboot路径 which fastboot

      • 将改名后的fastboot 复制到 真正执行的fastboot cp fastboot810rl 路径

      • 进入到fastboot 路劲中 将现在使用的fastboot改名备份(注意权限问题 chmod 777 fastboot810rl) 将fastboot810frl 改名为fastboot

    • 刷机完毕后手机会自动重启(看到命令执行完后显示 finished rebooting)

    • 选择中文, 跳过一直到 更多-同意 进入系统

    • 系统将显示休眠时间调长, 打开不锁定屏幕, 打开开发者模式打开 USB调试

    • 接下来root, 使用工具 twrp-3.3.1-0-bullhead.img

      • google 搜索 twrp->选择版本twrp-3.3.1.0->devces page->LG Nexus 5x->Europe->选择3.3.1.0这个版本
    • adb reboot bootloader

    • fastboot flash recovery twrp-3.3.1.0-bullhead.img

    • 选择手机进入recovery mode

    • 向右滑动

    • 将setting中的息屏关掉

    • adb push SR5-SuperSU-V2.82-SR5-20171001224502.zip /sdcard/

    • adb push nethunter-bullhead-oreo-kalifs-full-2020.1.zip /sdcard/

    • 拔掉手机连接线

    • 点击手机页面install-> 下拉-> SuperSU-> 右拉-> reboot system -> do not install

    • 进入adb reboot bootloader

    • recovery mode

    • 下拉 -> nethunter -> 右拉

3.5 开机后wifi有感叹号, 时间无法同步解决办法

在手机的shell里以root用户执行:

  • settings put global captive_portal_http_url https://www.google.cn/generate_204

  • settings put global captive_portal_https_url https://www.google.cn/generate_204

  • settings put global ntp_server 1.hk.pool.ntp.org

  • reboot

4. 四大组件

4.1 app下载网址:apkmirror

4.2 android项目目录结构

Android studio 项目建立完成后会有一个Android视图和Project视图

  • .gradle - Android Studio自动生成的文件

  • .idea - Android Studio自动生成的文件

  • app - 项目中代码、资源等内容放置在这个目录下

    • build - 编译生成的文件

    • libs - 第三方用到的jar包

    • src

      • androidTest - 用来编写Android Test的测试用例的

        • java

          • com.example.demo10
      • main

        • java - 放置java代码的地方

          • com.example.demo10
        • res - 放置资源文件,图片、布局、字符串的资源信息

          • drawable

          • drawable-24

          • layout - 项目的布局

          • mipmap-anydpi-v26

          • mipmap-hdpi

          • mipmap-mdpi

          • mipmap-xhdip

          • mipmap-xxhdpi

          • mipmap-xxhdpi

          • values

        • AndroidManifest.xml

      • test

        • java
    • .gitgnore

    • build.gradle

    • proguard-rules.pro

  • gradle - 包含了gradle wrapper的配置文件,是一个android进行打包的文件

  • .gitignore

  • build.gradle

  • gradle.properties

  • gradlew

  • gradlew.bat

  • local.properties

  • settings.gradle

6. 自动化动态分析和快速定位

  • objection(免)root动态调试apk

  • objection内存漫游和组件控制

  • objection类和方法动态trace

  • objection+DEXDump内存暴力脱壳机

  • objection RPC可以直接curl 的 RPC

6.1 操作步骤

  • 命令行确认安装objection objection version

    • objection: 1.9.5
  • 切换到Desktop创建文件夹 20200815

  • 通过adb命令安装测试fulao2.apk

  • 通过objection直接连接免root设备

    • https://github.com/sensepost/objection/wiki/Patching-Android-Applications

    • Patching: 依赖关系

      • aapt

      • aapt2

      • adb

      • jarsigner

      • apktool

    • 添加软连接到/usr/bin

      • ln -s /root/Desktop/android-studio/jre/bin/jarsigner /usr/bin

      • ln -s /root/Android/Sdk/build-tools/30.0.1/aapt /usr/bin

      • ln -s /root/Android/Sdk/build-tools/30.0.1/aapt2 /usr/bin

      • ln -s /root/Android/Sdk/platform-tools/adb /usr/bin

    • 解压apk看下它里面的lib是哪个架构,按架构来运行:

      • objection patchapk --architecture armeabi-v7a --use-aapt2 --source yourAPK.apk

    • app启动后用objection/frida直接连上即可

    • https://github.com/sensepost/objection/wiki/Using-objection

    • https://github.com/sensepost/objection/wiki/Patching-Android-Applications

  • 安装apktool apktool.jar

    • mv apktool /usr/local/bin/

    • mv apktool.jar /usr/local/bin/

    • chomd 777 apktook*

  • 切换到Desktoop/20200815

  • objection patchapk --source fulao2.apk

  • 生成objection.apk

  • 安装objection生成的apk

6.2 第二个APP

  • 下载DEXDump

7. APP实操去广告去升级重打包

使用objection

  • android hooking list activities

  • android heap search instances android.app.AlertDialog

    • Class instance enumeration complete for android.app.AlertDialog Hashcode Class toString()


      8564083 android.app.AlertDialog android.app.AlertDialog@82ad73

  • plugin load /root/.objection/plugins/Wallbreaker

    • Loaded plugin: wallbreaker
  • plugin wallbreaker objectionsearch android.app.AlertDialog

    • [0x2556] android.app.AlertDialog@82ad73
  • plugin wallbreaker objectdump 0x2556

    package android.app

    class AlertDialog {

    /* static fields /
    static int SHOW; => 69
    static int DISMISS; => 67
    static int CANCEL; => 68
    static String DIALOG_HIERARCHY_TAG; => android:dialogHierarchy
    static String TAG; => Dialog
    static String DIALOG_SHOWING_TAG; => android:dialogShowing
    static int THEME_DEVICE_DEFAULT_LIGHT; => 5
    static int THEME_DEVICE_DEFAULT_DARK; => 4
    static int THEME_HOLO_DARK; => 2
    static int LAYOUT_HINT_NONE; => 0
    static int THEME_HOLO_LIGHT; => 3
    static int LAYOUT_HINT_SIDE; => 1
    static int THEME_TRADITIONAL; => 1

    /
    instance fields /
    int shadowklass; => [0x2582]: class android.app.AlertDialog
    DialogInterfaceOnKeyListener mOnKeyListener; => null boolean mShowing; => true SearchEvent mSearchEvent; => null ActionMode mActionMode; => null boolean mCanceled; => false Handler mHandler; => [0x25aa]: Handler (android.os.Handler) {3e9435c} WindowManager mWindowManager; => [0x25ca]: android.view.WindowManagerImpl@1ffe665 String mCancelAndDismissTaken; => null Message mCancelMessage; => null View mDecor; => [0x25ea]: DecorView@9460f3a[] ActionBar mActionBar; => null Message mDismissMessage; => null Message mShowMessage; => null boolean mCancelable; => true Runnable mDismissAction; => [0x260a]: android.app.-LambdaListenersHandler) {80d83e1}
    Activity mOwnerActivity; => null
    Window mWindow; => [0x265a]: com.android.internal.policy.PhoneWindow@cf5e506
    int mActionModeTypeStarting; => 0
    boolean mCreated; => true
    AlertController mAlert; => [0x267a]: com.android.internal.app.AlertController@91e87c7

    /
    constructor methods */
    void AlertDialog(Context);
    void AlertDialog(Context, int);
    void AlertDialog(Context, int, boolean);
    void AlertDialog(Context, boolean, DialogInterfaceOnCancelListener); ​ /* static methods */ static int identityHashCodeNative(Object); static int identityHashCode(Object); static int resolveDialogTheme(Context, int); static AlertController -get0(AlertDialog); ​ /* instance methods */ int hashCode(); void wait(); void wait(long); void wait(long, int); void notify(); void notifyAll(); boolean equals(Object); Object clone(); void finalize(); Object internalClone(); String toString(); Class getClass(); void openContextMenu(View); void onPanelClosed(int, Menu); boolean onPreparePanel(int, View, Menu); void create(); void onBackPressed(); boolean dispatchTouchEvent(MotionEvent); void hide(); void setFeatureDrawableResource(int, int); boolean onTouchEvent(MotionEvent); View onCreatePanelView(int); ActionMode onWindowStartingActionMode(ActionModeCallback);
    ActionMode onWindowStartingActionMode(ActionModeCallback, int); void updateWindowForCancelable(); boolean onKeyShortcut(int, KeyEvent); boolean onSearchRequested(); boolean onSearchRequested(SearchEvent); void onCreate(Bundle); void onStop(); void setCancelMessage(Message); void setDismissMessage(Message); boolean dispatchKeyEvent(KeyEvent); void onWindowFocusChanged(boolean); void dispatchOnCreate(Bundle); void dismiss(); Object findViewById(int); boolean dispatchGenericMotionEvent(MotionEvent); void takeKeyEvents(boolean); void invalidateOptionsMenu(); boolean onMenuOpened(int, Menu); boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent); ComponentName getAssociatedActivity(); void openOptionsMenu(); void onAttachedToWindow(); boolean onKeyLongPress(int, KeyEvent); boolean dispatchTrackballEvent(MotionEvent); void -android_app_Dialog-mthref-0(); void onActionModeStarted(ActionMode); Activity getOwnerActivity(); void setFeatureDrawable(int, Drawable); void sendShowMessage(); ActionBar getActionBar(); boolean requestWindowFeature(int); void onStart(); void onCreateContextMenu(ContextMenu, View, ContextMenuContextMenuInfo);
    void onActionModeFinished(ActionMode);
    boolean onTrackballEvent(MotionEvent);
    void setFeatureDrawableUri(int, Uri);
    void unregisterForContextMenu(View);
    void setOnDismissListener(DialogInterfaceOnShowListener);
    boolean onContextItemSelected(MenuItem);
    void setTitle(CharSequence);
    void onWindowDismissed(boolean, boolean);
    void setOwnerActivity(Activity);
    void show();
    void registerForContextMenu(View);
    boolean onGenericMotionEvent(MotionEvent);
    boolean takeCancelAndDismissListeners(String, DialogInterfaceOnDismissListener);
    boolean onKeyUp(int, KeyEvent);
    void onWindowAttributesChanged(WindowManagerLayoutParams); Bundle onSaveInstanceState(); SearchEvent getSearchEvent(); void cancel(); View getCurrentFocus(); boolean isShowing(); void onOptionsMenuClosed(Menu); void dismissDialog(); boolean onOptionsItemSelected(MenuItem); boolean onMenuItemSelected(int, MenuItem); Window getWindow(); Context getContext(); boolean onPrepareOptionsMenu(Menu); void closeOptionsMenu(); int getVolumeControlStream(); void setCanceledOnTouchOutside(boolean); void sendDismissMessage(); void onRestoreInstanceState(Bundle); boolean onCreateOptionsMenu(Menu); void setOnKeyListener(DialogInterfaceOnKeyListener);
    void lambdaLayoutParams);
    void setContentView(int);
    void setContentView(View);
    void setContentView(View, ViewGroupOnCancelListener);
    LayoutInflater getLayoutInflater();
    void onContextMenuClosed(Menu);
    void setCustomTitle(View);
    void setButtonPanelLayoutHint(int);
    void setIcon(int);
    void setIcon(Drawable);
    ListView getListView();
    void setIconAttribute(int);
    void setButton2(CharSequence, DialogInterfaceOnClickListener);
    void setButton(int, CharSequence, Message);
    void setButton(CharSequence, DialogInterfaceOnClickListener);
    void setButton3(CharSequence, Message);
    void setMessage(CharSequence);
    void setInverseBackgroundForced(boolean);

    }

  • plugin wallbreaker objectdump 0x267a

    package com.android.internal.app

    class AlertController {

    /* static fields /
    static int MICRO; => 1

    /
    instance fields /
    int shadowklass; => [0x25d2]: class com.android.internal.app.AlertController
    int mViewSpacingLeft; => 0
    Message mButtonNegativeMessage; => null
    boolean mShowTitle; => true
    Message mButtonPositiveMessage; => [0x268a]: { when=-1d5h2m57s195ms what=-1 obj=com.zhibo.media.o@a48a1f4 target=com.android.internal.app.AlertControllerButtonHandler } int mAlertDialogLayout; => 17367080 int mSingleChoiceItemLayout; => 17367058 int mListLayout; => 17367259 CharSequence mButtonNegativeText; => null int mIconId; => 0 int mButtonPanelLayoutHint; => 0 Handler mHandler; => [0x2696]: Handler (com.android.internal.app.AlertControllerButtonHandler) {8fd7d1d}
    TextView mMessageView; => [0x26ba]: android.widget.TextView{17b4b92 V.ED..... ........ 37,5-1213,314 #102000b android:id/message}
    int mViewSpacingRight; => 0
    Message mButtonNeutralMessage; => null
    View mCustomTitleView; => null
    int mViewLayoutResId; => 0
    View mView; => null
    Button mButtonNegative; => [0x26da]: android.widget.Button{771d963 GFED..C.. ......I. 0,0-0,0 #102001a android:id/button2}
    int mViewSpacingBottom; => 0
    \n 3.修复了一个严重BUGm不升级后期将无法进入超级直播!版V1.4.7更新了功能
    boolean mViewSpacingSpecified; => false
    ListAdapter mAdapter; => null
    ScrollView mScrollView; => [0x271a]: android.widget.ScrollView{147e960 V.ED.V... ........ 33,0-1272,346 #10203a7 android:id/scrollView}
    boolean mForceInverseBackground; => false
    CharSequence mButtonPositiveText; => [0x266a]: 立刻升级
    Drawable mIcon; => null
    Window mWindow; => [0x23ca]: com.android.internal.policy.PhoneWindow@cf5e506
    CharSequence mButtonNeutralText; => null
    TextView mTitleView; => [0x2746]: com.android.internal.widget.DialogTitle{4f9ce19 V.ED..... ........ 0,0-1187,79 #1020199 android:id/alertTitle}
    ListView mListView; => null
    Button mButtonPositive; => [0x2756]: android.widget.Button{b7e8ede VFED..C.. ........ 312,11-926,137 #1020019 android:id/button1}
    View1@21ea8bf
    Context mContext; => [0x270a]: android.view.ContextThemeWrapper@d753948
    Button mButtonNeutral; => [0x2796]: android.widget.Button{1323b8c GFED..C.. ......I. 0,0-0,0 #102001b android:id/button3}
    int mMultiChoiceItemLayout; => 17367059
    int mListItemLayout; => 17367057
    DialogInterface mDialogInterface; => [0x27ba]: android.app.AlertDialog@82ad73
    ImageView mIconView; => [0x27da]: android.widget.ImageView{ad032d5 G.ED..... ......I. 0,0-0,0 #1020006 android:id/icon}
    int mButtonPanelSideLayout; => 0
    int mCheckedItem; => -1
    int mViewSpacingTop; => 0
    CharSequence mTitle; => [0x27e6]: 发现新版本 V1.4.7 是否升级

    /
    constructor methods /
    void AlertController(Context, DialogInterface, Window);

    /
    static methods /
    static int identityHashCodeNative(Object);
    static int identityHashCode(Object);
    static AlertController create(Context, DialogInterface, Window);
    static DialogInterface -get6(AlertController);
    static Handler -get7(AlertController);
    static int -get10(AlertController);
    static int -get8(AlertController);
    static int -get11(AlertController);
    static int -get9(AlertController);
    static ListAdapter -set0(AlertController, ListAdapter);
    static int -set1(AlertController, int);
    static boolean canTextInput(View);
    static Button -get0(AlertController);
    static Message -get1(AlertController);
    static Button -get2(AlertController);
    static boolean shouldCenterSingleButton(Context);
    static Message -get3(AlertController);
    static void manageScrollIndicators(View, View, View);
    static Button -get4(AlertController);
    static Message -get5(AlertController);

    /
    instance methods */
    int hashCode();
    void wait();
    void wait(long);
    void wait(long, int);
    void notify();
    void notifyAll();
    boolean equals(Object);
    Object clone();
    void finalize();
    Object internalClone();
    String toString();
    Class getClass();
    void setButtonPanelLayoutHint(int);
    void setIcon(int);
    void setIcon(Drawable);
    void setupButtons(ViewGroup);
    void setCustomTitle(View);
    void setInverseBackgroundForced(boolean);
    Button getButton(int);
    void setupView();
    int getIconAttributeResId(int);
    void setupContent(ViewGroup);
    void centerButton(Button);
    void setBackground(TypedArray, View, View, View, View, boolean, boolean, boolean);
    void setTitle(CharSequence);
    void setupTitle(ViewGroup);
    void installContent();
    void installContent(AlertControllerOnClickListener, Message);
    boolean onKeyDown(int, KeyEvent);
    void setView(int);
    void setView(View);
    void setView(View, int, int, int, int);
    void setMessage(CharSequence);
    ListView getListView();
    void setupCustomContent(ViewGroup);
    ViewGroup resolvePanel(View, View);

    }

  • 从内存中得到了 立刻升级

使用hook方法

使用hook方法首先杀掉app进程,重新启动。

- adb shell 进入手机shell

  • su 进入超级用户
  • ps -e | grep zhibo 查看进程
  • kill pid 杀掉进程

使用objection hook会出现来不及的情况,需要启动app立马执行命令,抢速度

  • 打开app

  • objection -g com.hd.zhibo.explore

  • android hooking watch class android.app.AlertDialog

    (agent) Hooking android.app.AlertDialog.-get0(android.app.AlertDialog)
    (agent) Hooking android.app.AlertDialog.resolveDialogTheme(android.content.Context, int)
    (agent) Hooking android.app.AlertDialog.getButton(int)
    (agent) Hooking android.app.AlertDialog.getListView()
    (agent) Hooking android.app.AlertDialog.onCreate(android.os.Bundle)
    (agent) Hooking android.app.AlertDialog.onKeyDown(int, android.view.KeyEvent)
    (agent) Hooking android.app.AlertDialog.onKeyUp(int, android.view.KeyEvent)
    (agent) Hooking android.app.AlertDialog.setButton(int, java.lang.CharSequence, android.content.DialogInterfaceOnClickListener)
    (agent) Hooking android.app.AlertDialog.setButton(java.lang.CharSequence, android.os.Message)
    (agent) Hooking android.app.AlertDialog.setButton2(java.lang.CharSequence, android.content.DialogInterfaceOnClickListener)
    (agent) Hooking android.app.AlertDialog.setButton3(java.lang.CharSequence, android.os.Message)
    (agent) Hooking android.app.AlertDialog.setButtonPanelLayoutHint(int)
    (agent) Hooking android.app.AlertDialog.setCustomTitle(android.view.View)
    (agent) Hooking android.app.AlertDialog.setIcon(int)
    (agent) Hooking android.app.AlertDialog.setIcon(android.graphics.drawable.Drawable)
    (agent) Hooking android.app.AlertDialog.setIconAttribute(int)
    (agent) Hooking android.app.AlertDialog.setInverseBackgroundForced(boolean)
    (agent) Hooking android.app.AlertDialog.setMessage(java.lang.CharSequence)
    (agent) Hooking android.app.AlertDialog.setTitle(java.lang.CharSequence)
    (agent) Hooking android.app.AlertDialog.setView(android.view.View)
    (agent) Hooking android.app.AlertDialog.setView(android.view.View, int, int, int, int)
    (agent) Registering job 6esx9gc8sfj. Type: watch-class for: android.app.AlertDialog
    com.hd.zhibo on (google: 8.1.0) [usb] # (agent) [6esx9gc8sfj] Called android.app.AlertDialog.resolveDialogTheme(android.content.Context, int)
    (agent) [6esx9gc8sfj] Called android.app.AlertDialog.resolveDialogTheme(android.content.Context, int)
    (agent) [6esx9gc8sfj] Called android.app.AlertDialog.onCreate(android.os.Bundle)

  • android hooking watch class_method android.app.AlertDialog.onCreate --dump-args --dump-backtrace --dump-return

    • 查看从哪里到的 android.app.AlertDialog.onCreate
  • objection如何处理开始时hook的问题

    • objection -g com.hd.zhibo explore --startup-command "android hooking watch class_method android.app.AlertDialog.onCreate --dump-args --dump-backtrace --dump-return"
  • if-eqz vA, :cond_** 如果vA等于0则跳转到:cond__**

  • if-nez vA, :cond_** 不等于

  • apktool d zhibo.apk

  • 修改smail问件

  • 打包

    • apktool b zhibo
  • 生成签名 使用keytool

    • keytool -genkey -alias abc.keystore -keyalg RSA -validity 20000 -keystore abc.keystore
  • 使用jarsigner 来签名

    • jarsigner -verbose -keystore abc.keystore -signedjar testx.apk zhibo.apk abc.keystore

8. 真实app实操带壳app重打包去强制升级

  • DEXDump三种使用模式脱壳

  • Objection快速自动化定位 基于hook

  • Wallbreaker内存可视化漫游 基于类的instance,类的声明周期

  • 所见即所得的代码定位思路

  • 修改源码重打包去强制升级

  1. top 查看进程信息
  1. frida -ps -U 列出手机上所有的进程信息
  1. grep(global search regular expression(RE) and print out the line) 文本搜索工具
-a 不要忽略二进制数据。
-A<显示列数> 除了显示符合范本样式的那一行之外,并显示该行之后的内容。
-b 在显示符合范本样式的那一行之外,并显示该行之前的内容。
-c 计算符合范本样式的列数。
-C<显示列数>或-<显示列数>  除了显示符合范本样式的那一列之外,并显示该列之前后的内容。
-d<进行动作> 当指定要查找的是目录而非文件时,必须使用这项参数,否则grep命令将回报信息并停止动作。
-e<范本样式> 指定字符串作为查找文件内容的范本样式。
-E 将范本样式为延伸的普通表示法来使用,意味着使用能使用扩展正则表达式。
-f<范本文件> 指定范本文件,其内容有一个或多个范本样式,让grep查找符合范本条件的文件内容,格式为每一列的范本样式。
-F 将范本样式视为固定字符串的列表。
-G 将范本样式视为普通的表示法来使用。
-h 在显示符合范本样式的那一列之前,不标示该列所属的文件名称。
-H 在显示符合范本样式的那一列之前,标示该列的文件名称。
-i 忽略字符大小写的差别。
-l 列出文件内容符合指定的范本样式的文件名称。
-L 列出文件内容不符合指定的范本样式的文件名称。
-n 在显示符合范本样式的那一列之前,标示出该列的编号。
-q 不显示任何信息。
-R/-r 此参数的效果和指定“-d recurse”参数相同。
-s 不显示错误信息。
-v 反转查找。
-w 只显示全字符合的列。
-x 只显示全列符合的列。
-y 此参数效果跟“
-i”相同。
-o 只输出文件中匹配到的部分。
  1. ps -e | grep .....

8.1 第一种脱壳方法

  • objection -g com.hello.qqc explore

  • frida 查看frida相关信息

  • env 环境?

  • plugin load /root/.objection/plugins/dexdump/frida_dexdump

  • plugin dexdump dump

    • 得到dexdump解析后的dex地址
  • 切换到生成dex文件的目录

  • grep -ril "MainActivity" *

    • 得到搜索结果

8.2 第二种脱壳方法-直接运行main.py

  • 在 frida_dexdump 目录下的 main.py

    • /root/.objection/plugins/dexdump/firda_dexdump
  • python3 main.py

    • 直接运行这个命令会失败,双进程保护

    • 使用frida先占个坑?

    • objection -g com.hello.qqc explore

    • 再执行 python3 main.py

8.3 pip install frida-dexdump

  • pip install frida-dexdump

  • frida-dexdump

9. App加固的种类、甄别和处理方式

9.1 libart.so和dex文件

  • 安卓系统架构

9.2 Android混淆加固发展史

  • 2010-> dex2jar、 apktool android逆向分析工具(没有保护的app)

  • 代码混淆(ProGuard、 DexGuard)

  • 动态加载

  • Native 层加密

    • ollvm
  • 核心数据、功能云端化

9.3 查壳脱壳(工具)的核心原理

  • 一键(Dex保护+资源保护+Native保护) = app加固服务

  • 梆梆安全成立

  • 爱加密

  • 娜迦

  • 360、腾讯、百度、阿里、网易

  • 文件落地加载

  • 不落地加载

  • 抹头

你可能感兴趣的:(逆向之路月一)