APP杀手-frida

APP克星系列

安卓平台

安卓「服务端-手机」frida使用环境配置(一)

简单的hook实践

下载

1
2
# 选择合适的版本下载
https://github.com/frida/frida/releases

如何知道合适的版本

1
2
# 查看安卓机芯片架构
adb shell getprop ro.product.cpu.abi

安装:

1
2
# 把frida-server 放到 安卓的/data/local/tmp/目录
adb push frida-server /data/local/tmp/

安卓端启动frida服务

1
2
3
4
5
6
# 进入超级权限
su
# 给予可执行权限
chmod +x /data/local/tmp/frida-server
# 启动frida服务端
/data/local/tmp/frida-server

实验demo

1
2
3
4
5
6
7
8
9
# hello-frida.js

setTimeout(
function(){
Java.perform(function(){
console.log("hello frida!")
})
}
)

测试demo,使用命令执行进行hook操作

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
➜  z frida -U -l hello-frida.js 师傅端
____
/ _ | Frida 15.1.28 - A world-class dynamic instrumentation toolkit
| (_| |
> _ | Commands:
/_/ |_| help -> Displays the help system
. . . . object? -> Display information about 'object'
. . . . exit/quit -> Exit
. . . .
. . . . More info at https://frida.re/docs/home/
. . . .
. . . . Connected to Android Emulator 5554 (id=emulator-5554)
Attaching...
hello frida!
[Android Emulator 5554::师傅端 ]->

IOS平台

工具拓展

Frida下载地址:https://github.com/frida/frida/releases

frida-ios-dump:https://github.com/AloneMonkey/frida-ios-dump

adb常用命令拓展

* 查看设备

1
adb devices

ps这个命令是查看当前连接的设备, 连接到计算机的android设备或者模拟器将会列出显示

若有多台安卓设备,可以通过在adb后面加上 -s <设备id> 对指定设备进行装包、卸载等操作

*启动adb

1
adb start-server

*关闭adb

1
adb kill-server

* 安装软件

1
adb install <apk文件路径>

* 卸载软件

1
adb uninstall <应用进程名>

*卸载app但保留数据和缓存文件

1
adb uninstall -k<package>

*重新启动设别

1
adb reboot

*重启到bootloader,即刷机模式

1
adb reboot bootloader

*重启到recovery,即恢复模式

1
adb reboot recovery

*从电脑上发送文件到设备

1
2
adb push <本地路径> <远程路径>
ps:push命令可以把本机电脑上的文件或者文件夹复制到设备(手机)

*从设备上下载文件到电脑

1
2
adb pull <远程路径> <本地路径>
ps: 用pull命令可以把设备(手机)上的文件或者文件夹复制到本机电脑

*取得设备root权限

1
adb remount

*登录设备shell

1
2
3
adb shell
adb shell <command命令>
ps: adb shell 后面加的是linux系统操作指令,也即直接运行设备命令, 相当于执行远程命令

*使用adb命令对手机进行截屏并拷贝到电脑

1
2
adb shell /system/bin/screencap -p /sdcard/screenshot.png(保存到手机)
adb pull /sdcard/screenshot.png d:/screenshot.png(拷贝到电脑)

*输出当前servers信息

1
adb shell dumpsys 

ps: 输出信息的开始部分就是所有运行的service

-查询到运行的system service后,就可以在dumpsys后面加上service的名字,查看指定的service信息。

1
2
3
4
adb shell dumpsys activity
adb shell dumpsys cpuinfo(CPU)
adb shell dumpsys batterystate(电池)
adb shell dumpsys window(分辨率)

*检测手机运行时间

1
adb shell uptime

*查看logcat日志

1
adb logcat -v time-s tag > xxx.log

ps: 其中-v time使输出的日志带时间信息,-s用于通过tag过滤日志(也可以通过管道grep过滤),> 使保存到本地文件。若直接在终端查看日志,则不加。

1
2
3
4
adb logcat | grep <正则表达式>
ps: grep后为正则表达式
adb logcat | grep <正则表达式> | tee xxx.log
ps:使用 tee可以实现同时在终端输出且保存到文件

*强制杀死进程

1
adb shell amforce-stop <进程名>

*启动指定Activity

1
adb shell am start-n <进程名> /<Acitvity>

*开关wifi

1
2
adb shell svc wifienable #打开wifi
adb shell svc wifidisable #关闭wifi

*查看wifi密码

1
adb shell cat/data/misc/wifi/*.conf

*获取序列号

1
adb get-serialno

*查看设备cpu和内存占用情况

1
adb shell top

*查看占用内存前6的app

1
adb shell top -m 6

*刷新一次内存信息,然后返回

1
adb shell top -n 1

*查询各进程内存使用情况

1
adb shell procrank

*杀死一个进程

1
adb shell kill[pid]

*查看进程列表

1
adb shell ps

*查看指定进程状态

1
adb shell ps -x[PID]

*查看后台services信息

1
adb shell servicelist

*查看当前内存占用

1
adb shell cat/proc/meminfo

*查看IO内存分区

1
adb shell cat/proc/iomem

*重命名文件

1
adb shell rename <原文件名> <修改后文件名>

*删除system/avi.apk

1
adb shell rm/system/avi.apk

*删除文件夹及其下面所有文件

1
adb shell rm -r<文件夹>

*移动文件

1
adb shell mv <原文件路径> <移动后文件路径>

*设置文件权限

1
adb shell chmod 777<文件>

*新建文件夹

1
adb shell mkdirpath/foldelname

*查看文件内容

1
adb shell cat<file>

*清除log缓存

1
adb logcat -c

*查看bug报告

1
adb bugreport 

*获取设备名称

1
adb shell cat/system/build.prop

*查看ADB帮助

1
adb help

*跑monkey

1
adb shell monkey -v-p <进程名> <次数>

*当adb 显示端口被占用,拒绝访问时的处理办法:

1
2
3
4
5
adb nodaemon server//查看哪个端口被占用
netstat -ano |findstr "<端口号>" //提示占用该端口的进程(非0地址)
(下面步骤可省略,可通过任务管理器杀死)
tasklist /fi “PIDeq <进程号>”//通过pid查看所有进程
taskkill /pid <进程号> /f//杀死进程

APP杀手-frida
https://cha111ng1.github.io/2022/04/13/APP杀手-frida/
作者
Cha111Ng1
发布于
2022年4月13日
许可协议