- ADB Server Basics
- Copy files to/from a device
- Changing MAC Address (Root Needed)
- Android package manager (pm)
- Activate USB Tethering
- Change Screen Density
- VPN over tethering
- Research
adb devices // To confirm device is connected
adb kill-server // To reset ADB host
adb connect <device local ip> // To connect via wifi
To copy from
a device:
adb
pull
<device>
<computer>
To copy to
a device:
adb
push
<computer>
<device>
Example:
adb push foo.txt /sdcard/foo.txt
adb pull /sdcard/bar.txt C:\
Example:
adb install "C:\com.google.android.youtube.apk"
adb shell
su
ifconfig wlan0 hw ether <XX:XX:XX:XX:XX:XX>
adb shell
su
ifconfig wlan0
Where HWaddr is your MAC Address. Example:
HWaddr 51:04:b6:07:42:73
Get list of system apps
on the device:
adb shell "echo 'apps:' && pm list packages -f | grep /system/app/ | sed 's/.*=/ - /'"
Directories: System apps / pre-installed-bloatware-apps are stored in /system/app
with privileged apps in /system/priv-app
Formatting Regex: s/.*=/ - /
adb
install
path_to_apk
pm uninstall --user 0 app
Option/switches:
-k: To keep the data and cache directories around after package removal.
Example:
pm uninstall -k --user 0 com.facebook.system
pm uninstall -k --user 0 com.facebook.services
pm uninstall -k --user 0 com.facebook.katana
pm uninstall -k --user 0 com.facebook.appmanager
This depends on the Android version:
service call connectivity 32 i32 1 on Ice Cream Sandwich (4.0)
service call connectivity 33 i32 1 on Jelly Bean (4.1 to 4.3)
service call connectivity 34 i32 1 on KitKat (4.4)
service call connectivity 30 i32 1 on Lollipop (5.0)
service call connectivity 31 i32 1 on Lollipop (5.1)
service call connectivity 30 i32 1 on Marshmallow (6.0)
service call connectivity 41 i32 1 on Samsung Marshmallow (6.0)
service call connectivity 33 i32 1 on Nougat (7.0)
service call connectivity 39 i32 1 on Samsung Nougat (7.0)
For Android 8 & above:
service call connectivity 34 i32 1 s16 text (8.0/8.1)
service call connectivity 33 i32 1 s16 text (9.0)
Example (Android 8.1):
adb shell "su -c 'service call connectivity 34 i32 1 s16 text'"
adb
shell
wm
density
<value>
Example:
adb shell wm density 480
adb shell wm density reset // set to default density
A dirty way to forward VPN over any tethered connection on a Android device:
#!/system/bin/sh
# Turn on tethering, then enable VPN, then run this script.
# Grant root access
su
# Setup iptables before forwarding VPN
iptables -t filter -F FORWARD
iptables -t nat -F POSTROUTING
iptables -t filter -I FORWARD -j ACCEPT
iptables -t nat -I POSTROUTING -j MASQUERADE
# forward VPN to wlan0 (change to rndis0 for usb tethering)
ip rule add from 192.168.43.0/24 lookup 61
ip route add default dev tun0 scope link table 61
ip route add 192.168.43.0/24 dev <interface> scope link table 61
ip route add broadcast 255.255.255.255 dev wlan0 scope link table 61
echo "Set up VPN on Wifi hotspot sucessfully"