Skip to content

Instantly share code, notes, and snippets.

@brnoleal
Created June 15, 2023 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brnoleal/6c04a39fa0c94244f60b9ab47fa37f1b to your computer and use it in GitHub Desktop.
Save brnoleal/6c04a39fa0c94244f60b9ab47fa37f1b to your computer and use it in GitHub Desktop.
########### Android Certificate ###########
## Create and send a new root certificate to android
openssl x509 -inform DER -in cacert.der -out cacert.pem
subject_hash_id=$(openssl x509 -inform PEM -subject_hash_old -in cacert.pem | head -1)
cp cacert.pem $subject_hash_id.0
adb root
adb shell "su 0 -c mount -o rw,remount /"
adb push $subject_hash_id.0 /system/etc/security/cacerts
adb shell "su 0 -c chmod 664 /system/etc/security/cacerts/$subject_hash_id.0"
adb reboot
## If you have issue with "adb shell mount" try:
adb push $subject_hash_id.0 /data/local/tmp
adb shell "chmod 664 /data/local/tmp/$subject_hash_id.0"
echo $subject_hash_id.0 # remember this output. e.g.: 9a5ba575.0
adb shell
su
mount -o rw,remount /
mv /data/local/tmp/9a5ba575.0 /system/etc/security/cacerts/9a5ba575.0
chmod 664 /system/etc/security/cacerts/9a5ba575.0
mount -o ro,remount /
adb reboot
########### Configure proxy ###########
## Set values
https://stackoverflow.com/questions/36200703/how-to-configure-a-proxy-exclusion-list-on-android-non-programmatically
adb shell settings put global global_http_proxy_host 127.0.0.1
adb shell settings put global global_http_proxy_port 8080
adb shell settings put global global_http_proxy_exclusion_list "*.googleapis.com,*.google.com,*.gstatic.com"
adb reverse tcp:8080 tcp:8080
## Remove configs
adb shell settings delete global global_http_proxy_host
adb shell settings delete global global_http_proxy_port
adb shell settings delete global global_http_proxy_exclusion_list
adb reverse --remove-all
########### Get device details ###########
## Properties
https://stackoverflow.com/questions/21099301/android-adb-commands-to-get-the-device-properties?rq=1
adb shell settings list global
adb shell getprop ro.build.tags
adb shell getprop ro.product.cpu.abi
adb logcat --pid=$(adb shell pidof -s com.app.name)
adb logcat *:V --pid=$(adb shell pidof -s com.app.name)
adb logcat *:E --pid=$(adb shell pidof -s com.app.name)
## Activities
adb shell dumpsys package com.app.name | grep -i activity
adb shell dumpsys package com.app.name | grep -i activity | grep -i filter | awk -F" " '{print $2}' > activities.txt
adb shell am start -n com.app.name/activity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment