zhangguanzhang's Blog

[持续更新] - 安卓折腾笔记

字数统计: 1.1k阅读时长: 4 min
2024/07/21

长期记录和更新关于安卓和 Linux 的一些折腾笔记

由来

长期记录和更新关于安卓和 Linux 的一些折腾笔记,没有 Linux 和刷机基础的不要看了。

adb

下载

platform-tools

知识点

adb-pic

小米系列手机开 adb 需要登录账号和插入 sim 卡,然后 Linux 和软路由上也可以安装 adb(打通网络后可以做很多事情),不要局限在看到的物体思维上。开了 usb adb 后插入电脑上:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 查看设备
adb devices

# 让设备 adb server 以 5555 方式运行,而非使用 usb
adb tcpip 5555

# tcp 连接
adb connect <ip>:5555

# 不带设备名就是关闭所有连接
adb disconnect [xxx]

# adb 执行任何命令的时候,如果 server 服务没有启动就会启动
# 此命令是杀掉 server 进程,Linux 和 win 都有 server 服务
# daemon 是运行在手机上的,server 管理 client 和 daemon 之间的通信
adb kill-server

# 访问本机 8888 端口转发到设备的 8080 端口
adb forward tcp:8888 tcp:8080

更多见文档 tools/adb

adb shell

一些 adb shell 命令:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ adb shell dumpsys battery
Current Battery Service state:
AC powered: true <-- 接入充电器
USB powered: false
Wireless powered: false
Max charging current: 0
Max charging voltage: 0
Charge counter: 2946000
status: 5
health: 2
present: true
level: 100 <--- 当前电量百分比
scale: 100
voltage: 4262 <-- 电压
temperature: 426 <-- 温度 42.6 ℃
technology: Li-poly
# 开启屏幕分析指针
adb shell settings put system pointer_location 1
# 坐标是坐上0,0 左到右是 X 上到下是 Y,下面是横屏点屏幕上一个按钮的坐标
adb shell input tap 1580 930
# 获取事件,sendevent 模拟比较麻烦
adb shell getevent -l

https://adbinstaller.com/commands

一些问题

打算把 adb 启动在 Linux 上,发现它 daemon 监听端口不是 bind 0.0.0.0:

1
2
3
4
$ ss -nlpt | grep adb
LISTEN 0 4 127.0.0.1:5037 0.0.0.0:* users:(("adb",pid=25471,fd=6))
# https://stackoverflow.com/questions/56130335/adb-port-forwarding-to-listen-on-all-interfaces
$ adb -a nodaemon server start

然后搜了下没有好的解决办法,有人去 hack 源码的,上面这个命令是大佬发的,只能前台运行,可以配合 screen 或者 systemd 啥的常驻。

安卓虚拟化

x86_64 机器上折腾的一些安卓虚拟化笔记,如果要在 x86_64 的安卓和安卓虚拟机或者容器内安装运行 arm64 的 apk ,需要带有 Native Bridge

Bliss OS

一个 x86_64 安卓系统,相对于 android-x86 似乎更新频繁,可以 pve 之类虚拟化导入安装,但是有些版本没带还是把 Native Bridge 删了。

Waydroid

anbox 后继 Waydroid 还没试过,是容器起的模拟器。

budtmo/docker-android

https://github.com/budtmo/docker-android 感觉太重了,而且没 arm64 架构镜像。

remote-android/redroid-doc

https://github.com/remote-android/redroid-doc 尝试运行 arm64 的 apk 成功了,chrome 的浏览器不行,需要有些依赖才可以运行,uc 浏览器也不行,最后用的 arm64 firefox 浏览器。另外发现有些 apk 安装后打开黑屏,最后从 proxmox 虚拟机切到宿主机上 docker 起才解决,也看到有人 arm64 M1 mac 上起安卓容器。

一些软件

scrcpy

https://github.com/Genymobile/scrcpy 牛逼的项目,不用多说,配合 adb 使用:

1
2
3
scrcpy
-S, --turn-screen-off # 远程时候,关闭设备的屏幕
# --max-size 1024 --video-bit-rate=2M --max-fps=15 低画质

关闭屏幕这个,lcd 的触发后,如果关闭 scrcpy 后面屏幕还会亮,而 oled 的则不会,单独想 adb 实现它的关闭屏幕显示而不休眠,可以参考

还有其他很多 scrcpy 项目,以及可以很多编程语言有 scrcpy 的库,可以做到写代码控制手机和上面的应用。

adb 协议

golang

逆向

教程

常见逆向

  • frida objection

unit 游戏逆向

libs/{libil2cpp,libmain,libunity,libxlua}.so

CATALOG
  1. 1. 由来
  2. 2. adb
    1. 2.1. 下载
    2. 2.2. 知识点
    3. 2.3. adb shell
    4. 2.4. 一些问题
  3. 3. 安卓虚拟化
    1. 3.1. Bliss OS
    2. 3.2. Waydroid
    3. 3.3. budtmo/docker-android
    4. 3.4. remote-android/redroid-doc
  4. 4. 一些软件
    1. 4.1. scrcpy
  5. 5. adb 协议
    1. 5.1. golang
  6. 6. 逆向
    1. 6.1. 教程
    2. 6.2. 常见逆向
    3. 6.3. unit 游戏逆向