2023-12-09
How To Fix Opencl Platform Not Found Issue On Android

To run llama.cpp on Oneplus Ace2V, you need an extra step:

1
2
export LD_LIBRARY_PATH=/vendor/lib64:/vendor/lib64/mt6983:/vendor/lib64/egl/mt6983

Read More

2022-12-07
直接调用安卓方法 Frida 直接调用二进制里面的方法

Read More

2022-11-04
Android Packet Capture

disable ssl pinning

use frida scripts specific to applications

justtrustme xposed

sslunpinning xposed

apk-mitm by repacking apk and resigning

capture, packet routing

recommend to use: PCAPdroid-API

PCAPdroid API reference

1
2
adb shell am start -e action start -e pcap_dump_mode udp_exporter -e collector_ip_address 127.0.0.1 -e collector_port 5123 -e app_filter com.tencent.mobileqq -n com.emanuelef.remote_capture.debug/com.emanuelef.remote_capture.activities.CaptureCtrl

setting up http proxy via adb:

1
2
3
# this does not ensure that the target app is captured.
adb shell settings put global http_proxy <address>:<port>

Read More

2022-11-04
Adb Wifi Always On

adb over wifi always on

warning: could be dangerous cause adb remote connections seem without any password. consider protect that with some proxy.

turning on:

1
2
3
4
setprop service.adb.tcp.port 5555
stop adbd
start adbd

turning off:

1
2
3
4
setprop service.adb.tcp.port -1
stop adbd
start adbd

set things under /data/adb/services.d/ and make them executable

1
2
3
mount -o remount,rw /
# then you can modify /sytem/etc/init.d, but not /system/bin cause it is a copy of /data/system/bin. you should create script there.

create this under /system/etc/init.d/

1
2
3
4
5
6
7
service adb_wifi_enable /system/bin/adb_wifi_enable.sh
disabled
oneshot
seclabel u:r:magisk:s0
on property:sys.boot_completed=1
start adb_wifi_enable

Read More

2022-10-15
Android Remote Control, App Automation

to change the resolution of android device run this command:

1
2
3
4
5
# <width>x<height>
adb shell wm size 3000x2000
# reset window size
adb shell wm size reset


launch scrcpy with HID simulation and screen off:

1
2
scrcpy -SK


run android in docker, run adb in docker

device discovery, termux daemon, remote unlock

unlock requires screenshot and input events.

https://technastic.com/unlock-android-phone-pin-pattern-adb/

click ok after input password:

https://stackoverflow.com/questions/29072501/how-to-unlock-android-phone-through-adb

scrcpy client

https://github.com/leng-yue/py-scrcpy-client

https://leng-yue.github.io/py-scrcpy-client/guide.html#bind-events

you want to use android emulator on macos m1?

https://github.com/google/android-emulator-m1-preview/releases/tag/0.3

check android screen lock/unlock state

https://android.stackexchange.com/questions/191086/adb-commands-to-get-screen-state-and-locked-state

Bonjour/Avahi/Zeroconf

logic: if the kill switch is off, when no physical input events happens, or not focused on scrcpy window with keyboard/mouse input events on pc for some time, allow to interact with the phone.

get physical events:

warning: this command could be offline for a short period of time after using the scrcpy. must automatically reconnect if the device is not offline.

1
2
adb -s 192.168.10.3:5555 shell getevent

to get focused window title:

hint: for headless ssh sessions, must set apropriate xorg environment variables, eg: env XAUTHORITY="/run/user/0/gdm/Xauthority" DISPLAY=:1 python3

general method:

1
2
3
import pywinctl
pywinctl.getActiveWindowTitle()

for linux:

1
2
watch -n 2 xdotool getactivewindow getwindowname

for macos: (allow permission first, deprecated since it will not get the window title instead of the program name)

https://alvinalexander.com/mac-os-x/applescript-unix-mac-osx-foreground-application-result/

(where is the window name?)

1
2
sleep 3 && osascript -e 'tell application "System Events"' -e 'set frontApp to name of first application process whose frontmost is true' -e 'end tell'

to get input events on macos:

download keylogger here:

https://hackernoon.com/writing-an-keylogger-for-macos-in-python-24adfa22722

https://github.com/beatsbears/pkl?ref=hackernoon.com

1
2
python pkl_nowriting.py

input events on linux:

1
2
xinput test-xi2 --root

Read More