Since Android 7, apps ignore user provided certificates, unless they are configured to use them.As most applications do not explicitly opt in to use user certificates, we need to place our mitmproxy CA certificate in the system certificate store,in order to avoid having to patch each application, which we want to monitor.
- Get the fastest and smoothest gaming performance with BlueStacks - the world’s most popular, safest and FREE Android emulator for Windows and Mac. Trusted by over 500M gamers.
- The Android Emulator can be run in a variety of configurations to simulate different devices. Each configuration is called a virtual device. When you deploy and test your app on the emulator, you select a pre-configured or custom virtual device that simulates a physical Android device such as a Nexus or Pixel phone.
Please note, that apps can decide to ignore the system certificate store and maintain their own CA certificates. In this case you have to patch the application.
# 1. Prerequisites
Android emulator, android for pc, Andy, Android Apps for PC, Android Games for PC. Play all your favorite android games. Directly from your PC or MAC Just launch andy from your desktop Run all your communication apps. From your desktop. (snapchat, Viber, whatsapp etc) Use your phone as a remote control. When playing games. Here we bring a list of the best Android Emulators for Linux desktops that you can use to run any android application freely. Android emulator is a software application that wholly acts as a real.
Android Studio/Android Sdk is installed (tested with Version 4.1.3 for Linux 64-bit)
An Android Virtual Device (AVD) was created. Setup documentation available here
- The AVD must not run a production build (these will prevent you from using
adb root
) - The proxy settings of the AVD are configured to use mitmproxy. Documentation here
- The AVD must not run a production build (these will prevent you from using
Emulator and adb executables from Android Sdk have been added to $PATH variable
- emulator usually located at
/home/<your_user_name>/Android/Sdk/emulator/emulator
on Linux systems - adb usually located at
/home/<your_user_name>/Android/Sdk/platform-tools/adb
on Linux systems - I added these lines to my
.bashrc
- emulator usually located at
Mitmproxy CA certificate has been created
- Usually located in
~/.mitmproxy/mitmproxy-ca-cert.cer
on Linux systems - If the folder is empty or does not exist, run
mitmproxy
in order to generate the certificates
- Usually located in
# 2. Rename certificate
CA Certificates in Android are stored by the name of their hash, with a ‘0’ as extension (Example: c8450d0d.0
). It is necessary to figure out the hash of your CA certificate and copy it to a file with this hash as filename. Otherwise Android will ignore the certificate.By default, the mitmproxy CA certificate is located in this file: ~/.mitmproxy/mitmproxy-ca-cert.cer
# Instructions
- Enter your certificate folder:
cd ~/.mitmproxy/
- Generate hash and copy certificate :
hashed_name=`openssl x509 -inform PEM -subject_hash_old -in mitmproxy-ca-cert.cer | head -1` && cp mitmproxy-ca-cert.cer $hashed_name.0
# 3. Insert certificate into system certificate store
Now we have to place our CA certificate inside the system certificate store located at /system/etc/security/cacerts/
in the Android filesystem. By default, the /system
partition is mounted as read-only. The following steps describe how to gain write permissions on the /system
partition and how to copy the certificate created in the previous step.
# Instructions for API LEVEL > 28
Starting from API LEVEL 29 (Android 10), it seems to be impossible to mount the “/” partition as read-write. Google provided a workaround for this issue using OverlayFS. Unfortunately, at the time of writing this (11. April 2021), the instructions in this workaround will result in your emulator getting stuck in a boot loop. Some smart guy on Stackoverflow found a way to get the /system
directory writable anyway.
Keep in mind: You always have to start the emulator using the -writable-system
option if you want to use your certificate. Otherwise Android will load a “clean” system image.
Tested on emulators running API LEVEL 29 and 30
# Instructions
- List your AVDs:
emulator -list-avds
(If this yields an empty list, create a new AVD in the Android Studio AVD Manager) - Start the desired AVD:
emulator -avd <avd_name_here> -writable-system
(add-show-kernel
flag for kernel logs) - restart adb as root:
adb root
- disable secure boot verification:
adb shell avbctl disable-verification
- reboot device:
adb reboot
- restart adb as root:
adb root
- perform remount of partitions as read-write:
adb remount
. (If adb tells you that you need to reboot, reboot againadb reboot
and runadb remount
again.) - push your renamed certificate from step 2:
adb push <path_to_certificate> /system/etc/security/cacerts
- set certificate permissions:
adb shell chmod 664 /system/etc/security/cacerts/<name_of_pushed_certificate>
- reboot device:
adb reboot
# Instructions for API LEVEL <= 28
Tested on emulators running API LEVEL 26, 27 and 28
Keep in mind: You always have to start the emulator using the -writable-system
option if you want to use your certificate. Otherwise Android will load a “clean” system image.
- List your AVDs:
emulator -list-avds
(If this yields an empty list, create a new AVD in the Android Studio AVD Manager) - Start the desired AVD:
emulator -avd <avd_name_here> -writable-system
(add-show-kernel
flag for kernel logs) - restart adb as root:
adb root
- perform remount of partitions as read-write:
adb remount
. (If adb tells you that you need to reboot, reboot againadb reboot
and runadb remount
again.) - push your renamed certificate from step 2:
adb push <path_to_certificate> /system/etc/security/cacerts
- set certificate permissions:
adb shell chmod 664 /system/etc/security/cacerts/<name_of_pushed_certificate>
- reboot device:
adb reboot
Since Android 7, apps ignore user provided certificates, unless they are configured to use them.As most applications do not explicitly opt in to use user certificates, we need to place our mitmproxy CA certificate in the system certificate store,in order to avoid having to patch each application, which we want to monitor.
Please note, that apps can decide to ignore the system certificate store and maintain their own CA certificates. In this case you have to patch the application.
# 1. Prerequisites
Android Studio/Android Sdk is installed (tested with Version 4.1.3 for Linux 64-bit)
An Android Virtual Device (AVD) was created. Setup documentation available here
- The AVD must not run a production build (these will prevent you from using
adb root
) - The proxy settings of the AVD are configured to use mitmproxy. Documentation here
- The AVD must not run a production build (these will prevent you from using
Emulator and adb executables from Android Sdk have been added to $PATH variable
- emulator usually located at
/home/<your_user_name>/Android/Sdk/emulator/emulator
on Linux systems - adb usually located at
/home/<your_user_name>/Android/Sdk/platform-tools/adb
on Linux systems - I added these lines to my
.bashrc
- emulator usually located at
Mitmproxy CA certificate has been created
- Usually located in
~/.mitmproxy/mitmproxy-ca-cert.cer
on Linux systems - If the folder is empty or does not exist, run
mitmproxy
in order to generate the certificates
- Usually located in
# 2. Rename certificate
CA Certificates in Android are stored by the name of their hash, with a ‘0’ as extension (Example: c8450d0d.0
). It is necessary to figure out the hash of your CA certificate and copy it to a file with this hash as filename. Otherwise Android will ignore the certificate.By default, the mitmproxy CA certificate is located in this file: ~/.mitmproxy/mitmproxy-ca-cert.cer
# Instructions
- Enter your certificate folder:
cd ~/.mitmproxy/
- Generate hash and copy certificate :
hashed_name=`openssl x509 -inform PEM -subject_hash_old -in mitmproxy-ca-cert.cer | head -1` && cp mitmproxy-ca-cert.cer $hashed_name.0
# 3. Insert certificate into system certificate store
Now we have to place our CA certificate inside the system certificate store located at /system/etc/security/cacerts/
in the Android filesystem. By default, the /system
partition is mounted as read-only. The following steps describe how to gain write permissions on the /system
partition and how to copy the certificate created in the previous step.
# Instructions for API LEVEL > 28
Starting from API LEVEL 29 (Android 10), it seems to be impossible to mount the “/” partition as read-write. Google provided a workaround for this issue using OverlayFS. Unfortunately, at the time of writing this (11. April 2021), the instructions in this workaround will result in your emulator getting stuck in a boot loop. Some smart guy on Stackoverflow found a way to get the /system
directory writable anyway.
Keep in mind: You always have to start the emulator using the -writable-system
option if you want to use your certificate. Otherwise Android will load a “clean” system image.
Android Emulator With Root
Tested on emulators running API LEVEL 29 and 30
# Instructions
- List your AVDs:
emulator -list-avds
(If this yields an empty list, create a new AVD in the Android Studio AVD Manager) - Start the desired AVD:
emulator -avd <avd_name_here> -writable-system
(add-show-kernel
flag for kernel logs) - restart adb as root:
adb root
- disable secure boot verification:
adb shell avbctl disable-verification
- reboot device:
adb reboot
- restart adb as root:
adb root
- perform remount of partitions as read-write:
adb remount
. (If adb tells you that you need to reboot, reboot againadb reboot
and runadb remount
again.) - push your renamed certificate from step 2:
adb push <path_to_certificate> /system/etc/security/cacerts
- set certificate permissions:
adb shell chmod 664 /system/etc/security/cacerts/<name_of_pushed_certificate>
- reboot device:
adb reboot
# Instructions for API LEVEL <= 28
Tested on emulators running API LEVEL 26, 27 and 28
Android Emulator Roms
Keep in mind: You always have to start the emulator using the -writable-system
option if you want to use your certificate. Otherwise Android will load a “clean” system image.
Android Emulator Rotate
- List your AVDs:
emulator -list-avds
(If this yields an empty list, create a new AVD in the Android Studio AVD Manager) - Start the desired AVD:
emulator -avd <avd_name_here> -writable-system
(add-show-kernel
flag for kernel logs) - restart adb as root:
adb root
- perform remount of partitions as read-write:
adb remount
. (If adb tells you that you need to reboot, reboot againadb reboot
and runadb remount
again.) - push your renamed certificate from step 2:
adb push <path_to_certificate> /system/etc/security/cacerts
- set certificate permissions:
adb shell chmod 664 /system/etc/security/cacerts/<name_of_pushed_certificate>
- reboot device:
adb reboot