Values marked M were measured on a physical device: Xiaomi M2101K6P, Android 11 / API 30,
arm64-v8a, kernel 4.14.180, from adb shell as uid 2000, no root. Everything else is from AOSP or
kernel source.
# adb shell
ls-lZ/dev/binder/dev/hwbinder/dev/vndbinder# M: all three are symlinks into binderfs
ps-A-oPID,USER,LABEL,NAME|grepservicemanager# M: pids 606/607/608, three domains
ls/dev/binderfs/binder_logs/# root only
service list
service check SERVICE
service call SERVICE CODE [i32 N | i64 N | f N | d N | s16 STR | null
| fd FILE | nfd N | afd FILE] ...
Arg
Writes
i32 N
32-bit int
i64 N
64-bit int
f N
float
d N
double
s16 STR
UTF-16 string
null
a null binder
fd FILE
a descriptor for FILE
nfd N
descriptor number N
afd FILE
an ashmem descriptor holding FILE's contents
service call writes the interface token for you, obtained by sending '_NTF' first.
It cannot write booleans (use i32 1), arrays, Parcelables, Bundles or Lists.
# adb shell — the standard opening moves
servicelist|wc-l# M: 217
servicechecknotification
servicecallnotification1598968902# '_NTF' -> "android.app.INotificationManager"
servicecallnotification1599098439# '_PNG'
servicecallnotification2# M: SecurityException "Disallowed call for uid 2000"
servicecallpackage1s16com.android.settings
# host — enumerate: name -> interface -> owner -> SELinux type
python3-Bscripts/binder-service-map.py
python3-Bscripts/binder-service-map.py--no-interface# no token check
python3-Bscripts/binder-service-map.py--unlabelled# default SELinux type
python3-Bscripts/binder-service-map.py--explainnotification
python3-Bscripts/binder-service-map.py--capture./snap
python3-Bscripts/binder-service-map.py--fixtureexamples/fixture-device-snapshot
python3-Bscripts/binder-service-map.py--json>snap.json
# host — decode a parcel dump from `service call` or from the C probe
python3-Bscripts/parcel-decode.py--paste# then paste and Ctrl-D
python3-Bscripts/parcel-decode.pydump.txt--astoken
adbshellservicecallactivity1598968902|python3-Bscripts/parcel-decode.py-
# host — build and run the raw client$NDK/aarch64-linux-android21-clang-Wall-Wextra-O2examples/binder-probe.c-obinder-probe
adbpushbinder-probe/data/local/tmp/&&adbshellchmod755/data/local/tmp/binder-probe
adbshell/data/local/tmp/binder-probe
adbshell/data/local/tmp/binder-probe--getserviceactivity
adbshell/data/local/tmp/binder-probe--callnotification2
adbshell/data/local/tmp/binder-probe--callnotification2--forge-uid0
adbshell/data/local/tmp/binder-probe--callnotification2--tokenandroid.os.IServiceManager
# host — trace transactions live
frida-U-fcom.example.target-lscripts/trace-binder-transactions.js
frida-U-nsystem_server-lscripts/trace-binder-transactions.js
# services this app publishes
grep-rn"extends .*\.Stub\b"out/sources/
grep-rn"protected boolean onTransact"out/sources/
# THE headline query: onTransact with no interface token check
grep-rln"onTransact"out/sources/|xargsgrep-L"enforceInterface"# onTransact with no caller check at all
grep-rln"onTransact"out/sources/|xargsgrep-L"getCallingUid\|checkCalling\|enforceCalling"# descriptors -- these survive R8 and are often the original class names
grep-rhn'DESCRIPTOR = "'out/sources/|sed's/.*= //'|tr-d'";'|sort-u
# transaction codes
grep-rn"FIRST_CALL_TRANSACTION"out/sources/
# identity misuse
grep-rn-B5-A20"clearCallingIdentity"out/sources/
grep-rn"checkCallingOrSelfPermission"out/sources/
grep-rn"getCallingWorkSourceUid"out/sources/
# smali
grep-rn"enforceInterface"out_apktool/smali*/
grep-rn-A30"sparse-switch"out_apktool/smali*/|grep"0x5f4e5446"# native$NDK/llvm-nm-DClibx.so|grep-iE"onTransact|BnInterface|BpInterface|getCallingUid"$NDK/llvm-stringslibx.so|grep-E"^[a-z][a-z0-9_]*(\.[A-Za-z0-9_]+){2,}$"|sort-u