stephen@ubuntu:~/hooker$ git https://github.com/CreditTone/hooker.git
stephen@ubuntu:~/hooker$ cd hooker
stephen@ubuntu:~/hooker$ ls
colorful.py com.mokee.aegis mobile-deploy.tar
com.alibaba.wireless com.sankuai.meituan org.mokee.lawnchair
com.changba com.sdiread.kt.ktandroid org.mokee.weatherservice
com.google.android.youtube com.smile.gifmaker __pycache__
com.jifen.qukan com.ss.android.article.news radar.dex
com.jzg.jzgoto.phone com.ss.android.ugc.aweme README.md
com.koudai.weidian.buyer com.tencent.karaoke run_env.py
com.kugou.shiqutouch com.tencent.mm sogou.mobile.explorer
com.lululemon.shop hooker spider.py
com.meicai.mall hooker.py traceJNI
com.meitu.meipaimv js xapk
com.miui.screenrecorder mobile-deploy.sh xinitdeploy.py
stephen@ubuntu:~/hooker$ adb devices
List of devices attached
FA77C0301476 device
#以piexl2为例
stephen@ubuntu:~/hooker$ adb push mobile-deploy.sh /sdcard/
stephen@ubuntu:~/hooker$ adb push mobile-deploy.tar /sdcard/
stephen@ubuntu:~/hooker$ adb shell #进入手机命令行界面
sailfish:/ $ su #进入root权限命令行模式
sailfish:/ $ sh /sdcard/mobile-deploy.sh
disable android firewall.
mobile-deploy/
mobile-deploy/frida-server-14.1.3-android-arm
mobile-deploy/frida-server-14.1.3-android-x86
mobile-deploy/frpc_arm
mobile-deploy/tcpforward_linux_arm64
mobile-deploy/busybox-armv7m
mobile-deploy/tcpforward_linux_arm
mobile-deploy/frpc_arm64
mobile-deploy/frida-server-14.1.3-android-arm64
mobile-deploy/tcpforward_linux_x86
mobile-deploy/busybox-i686
mobile-deploy/frpc_x86
start frida-server
start network adb.
deploy successfull.
stephen@ubuntu:~/hooker$ #如果你看到你的adb命令被弹出来了,表示已经正常部署。
1.关闭iptables防火墙,解决部分手机默认防火墙开启的问题
2.启动frida-server,如果你的手机是arm64他将优先启动arm64位的frida-server
3.在/data/mobile-deploy目录生成tools_env.rc 当你有内网穿透和网络服务转发、编辑文件、检测网络方面的需求时可以执行source /data/mobile-deploy/tools_env.rc,它将临时生成vi、telnet、frpc、tcpforward、ll命令以便你进行更便捷的开发,如图
stephen@ubuntu:~/hooker$ ./hooker
PID Name Identifier
----- ----------------------------- -------------------------------------------------------------
2857 Android Auto com.google.android.projection.gearhead
1779 Android Services Library com.google.android.ext.services
929 Android 系统 android
5073 Carrier Services com.google.android.ims
11051 Device Health Services com.google.android.apps.turbo
2913 Device Personalization S… com.google.android.as
2522 Google com.google.android.googlequicksearchbox
15189 Google Play 商店 com.android.vending
2101 Google Play 服务 com.google.android.gms
2833 Google VR 服务 com.google.vr.vrcore
7710 Google 服务框架 com.google.android.gsf
2546 NFC服务 com.android.nfc
929 NetworkStack com.android.networkstack.inprocess
929 一体化位置信息 com.android.location.fused
14468 云端硬盘 com.google.android.apps.docs
14403 信息 com.google.android.apps.messaging
12073 存储已屏蔽的号码 com.android.providers.blockednumber
1574 实时数据壁纸 com.ustwo.lwp
15637 抖音 com.ss.android.ugc.aweme
2480 搜狗输入法 com.sohu.inputmethod.sogou
12073 用户字典 com.android.providers.userdictionary
13362 电话 com.google.android.dialer
1704 电话和短信存储 com.android.providers.telephony
1704 电话服务 com.android.phone
11818 知乎 com.zhihu.android
1451 系统界面 com.android.systemui
12424 紧急警报 com.android.cellbroadcastreceiver
12073 联系人存储 com.android.providers.contacts
1431 蓝牙 com.android.bluetooth
929 设置存储 com.android.providers.settings
10149 运营商设置 com.google.android.wfcactivation
14376 通讯录 com.google.android.contacts
929 通话管理 com.android.server.telecom
14807 阿里巴巴 com.alibaba.wireless
Enter the need to attach package.
:
stephen@ubuntu:~/hooker$ ./hooker
PID Name Identifier
----- ----------------------------- -------------------------------------------------------------
15637 抖音 com.ss.android.ugc.aweme
2480 搜狗输入法 com.sohu.inputmethod.sogou
12073 用户字典 com.android.providers.userdictionary
13362 电话 com.google.android.dialer
1704 电话和短信存储 com.android.providers.telephony
1704 电话服务 com.android.phone
11818 知乎 com.zhihu.android
1451 系统界面 com.android.systemui
12424 紧急警报 com.android.cellbroadcastreceiver
12073 联系人存储 com.android.providers.contacts
1431 蓝牙 com.android.bluetooth
929 设置存储 com.android.providers.settings
10149 运营商设置 com.google.android.wfcactivation
14376 通讯录 com.google.android.contacts
929 通话管理 com.android.server.telecom
14807 阿里巴巴 com.alibaba.wireless
Enter the need to attach package.
: com.ss.android.ugc.aweme #在此处输入进程的Identifier即可调试应用
It's com.ss.android.ugc.aweme that you have attached app.
--------------------------------------------------
Please enter e, s, j, c or ex command.
a: Discovering activities.
b: Discovering services.
c: Discovering object. eg:'c {
objectId}'
d: Object2Explain. eg:'d {
objectId}'
v: Discovering view. eg:'v {
viewId}'
e: Determines whether a class exists. eg:'e android.app.Application'
s: Discovering classes by a class'regex. eg:'s com.tencent.mm.Message.*'
t: Discovering offspring classes by a class'name. eg:'t com.tencent.mm.BasicActivity'
j: Generating hooked js. eg:'j okhttp3.Request$Builder:build'
k: Generating hooked the string generation js with a keyword. eg:'k {
YourKeyword}'
l: Generating hooked the param generation js with a param keyword. eg:'l {
YourKeyword}'
m: Discovering so module.
ex: Exit to the upper layer. eg:'ex'
:
stephen@ubuntu:~/hooker/com.ss.android.ugc.aweme$ ls
activity_events.js attach click.js hooking kill objection spider.py url.js web_view.js
android_ui.js cipher.js edit_text.js ipc.js log object_store.js text_view.js view_pager.js xinitdeploy
a : 打印Activity栈的所有实例,当前界面排最前面。你可以立刻获取当前手机界面的Activity实现类、继承关系、实现接口、Activity中的所有属性值和方法声明。配合jadx动静分析效果最佳,分析Activity对象的内部情况将极快的提供逆向的线索。图片太大无法上传,演示动画自己打开看:https://www.chuantu.xyz/t6/741/1616134297x2073530471.gif
b : 打印Service栈的所有实例。和a命令一样,获取当前手机界面的Service实现类、继承关系、实现接口、Service中的所有属性值和方法声明。配合jadx动静分析效果最佳,分析Service对象的内部情况将极快的提供逆向的线索。
e : 检测一个类在内存中是否存在。大部分情况下静态分析的类在内存中会存在,但是有时app会做热更新可能会出现类被替换的情况。作为一个严谨的逆向工程师在对类进行操作之前检测类是否存在内存中是个好习惯。如:e com.bytedance.frameworks.encryptor.EncryptorUtil 输出:True表示存在 False表示不存在
Please enter e, s, h or ex command.
e: Determines whether a class exists. eg:'e android.app.Application'
s: Discovering classes in the specified path. eg1:'s com.example.myapplication' In regex eg2:'s com.example.net.*'
j: Generating hooked js. eg1:'j okhttp3.Request:build' To specific Multiple methods eg2:'j okhttp3.Request:url,method,build'
ex: Exit to the upper layer. eg:'ex'
:s com.example.myapplication
python hooker.py -p com.example.myapplication -s com.example.myapplication
androidVersion:7.1.2
Discovering:com.example.myapplication
class com.example.myapplication.MainActivity extends androidx.appcompat.app.AppCompatActivity
class com.example.myapplication.MainActivity$1 implements android.view.View$OnClickListener
class com.example.myapplication.MainActivity$2 implements android.view.View$OnClickListener
Discovering done
#由此我们知道com.example.myapplication这个包下有一个类com.example.myapplication.MainActivity,并且在com.example.myapplication.MainActivity中有两个内部类com.example.myapplication.MainActivity$1和com.example.myapplication.MainActivity$2
Please enter e, s, h or ex command.
e: Determines whether a class exists. eg:'e android.app.Application'
s: Discovering classes in the specified path. eg1:'s com.example.myapplication' In regex eg2:'s com.example.net.*'
j: Generating hooked js. eg1:'j okhttp3.Request:build' To specific Multiple methods eg2:'j okhttp3.Request:url,method,build'
ex: Exit to the upper layer. eg:'ex'
:j com.example.myapplication.MainActivity:stringFromJNI,stringFromJNI2
python hooker.py -p com.example.myapplication -j com.example.myapplication.MainActivity:stringFromJNI,stringFromJNI2
Hooking js code have generated. Path is ef555384-772a-11ea-bfdd-086d41d57a6a.js.
#生成的js文件是当前目录的ef555384-772a-11ea-bfdd-086d41d57a6a.js
#建议使用https://tool.oschina.net/codeformat/js/做格式化处理
Java.perform(function() {
var com_example_myapplication_MainActivity_clz = Java.use('com.example.myapplication.MainActivity');
com_example_myapplication_MainActivity_clz.stringFromJNI2.overload().implementation = function() {
printStacks('public static native java.lang.String com.example.myapplication.MainActivity.stringFromJNI2()');
return com_example_myapplication_MainActivity_clz.stringFromJNI2();
};
com_example_myapplication_MainActivity_clz.stringFromJNI.overload().implementation = function() {
printStacks('public native java.lang.String com.example.myapplication.MainActivity.stringFromJNI()');
return this.stringFromJNI();
};
});
#根据自身需求做修改
androidVersion:7.1.2
inject dex of radar.
injected.
Discovering:com.example.myapplication
class com.example.myapplication.MainActivity extends androidx.appcompat.app.AppCompatActivity
hasLocalNativeMethod:true
fields:131
constructors:1
methods:445
class com.example.myapplication.MainActivity$1 extends java.lang.Object
hasLocalNativeMethod:false
fields:2
constructors:1
methods:10
class com.example.myapplication.MainActivity$2 extends java.lang.Object
hasLocalNativeMethod:false
fields:2
constructors:1
methods:10
Discovering done
执行:Java.perform(function() {
var com_example_myapplication_MainActivity_clz = Java.use('com.example.myapplication.MainActivity');com_example_myapplication_MainActivity_clz.stringFromJNI2.overload().implementation = function() {
printStacks('public static native java.lang.String com.example.myapplication.MainActivity.stringFromJNI2()');return com_example_myapplication_MainActivity_clz.stringFromJNI2();};com_example_myapplication_MainActivity_clz.stringFromJNI.overload().implementation = function() {
printStacks('public native java.lang.String com.example.myapplication.MainActivity.stringFromJNI()');return this.stringFromJNI();};com_example_myapplication_MainActivity_clz.stringFromJNI3.overload('java.lang.String','java.lang.String').implementation = function(v0,v1) {
printStacks('private static native java.lang.String com.example.myapplication.MainActivity.stringFromJNI3(java.lang.String,java.lang.String)');return com_example_myapplication_MainActivity_clz.stringFromJNI3(v0,v1);};});
sys.stdin.read()
public native java.lang.String com.example.myapplication.MainActivity.stringFromJNI()
at com.example.myapplication.MainActivity.stringFromJNI(Native Method)
at com.example.myapplication.MainActivity$1.onClick(MainActivity.java:35)
at android.view.View.performClick(View.java:5637)
at android.view.View$PerformClick.run(View.java:22433)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6236)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)
public static native java.lang.String com.example.myapplication.MainActivity.stringFromJNI2()
at com.example.myapplication.MainActivity.stringFromJNI2(Native Method)
at com.example.myapplication.MainActivity$2.onClick(MainActivity.java:44)
at android.view.View.performClick(View.java:5637)
at android.view.View$PerformClick.run(View.java:22433)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6236)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)
##关于作者
var author = {
name : "guozhong",
bilibili : "https://space.bilibili.com/105035514",
email : "[email protected]",
experience : ["Android应用开发", "网络爬虫", "Android逆向", "JAVA/Go后台开发", "中间件开发"]
}