| name | androidstudio-app-pentest-environment |
| description | Android Studio mobile application penetration testing environment setup with Magisk root, Frida, and SSL bypass capabilities |
| triggers | ["set up android pentest environment","configure android studio for app security testing","install magisk on android emulator","root android emulator for pentesting","bypass ssl pinning on android","setup frida for android app testing","create rooted android virtual device","configure android app security toolkit"] |
Android Studio App Pentest Environment Setup
Skill by ara.so — Security Skills collection.
Complete penetration testing environment for Android applications using Android Studio emulators with Magisk root, Frida instrumentation, SSL/TLS bypass, and security testing tools.
What This Project Provides
A comprehensive guide and toolchain for setting up a mobile application security testing environment including:
- Rooted Android Emulator: Using Magisk (面具) for root access
- Frida Framework: Dynamic instrumentation for runtime analysis
- SSL/TLS Bypass: Certificate pinning bypass modules
- Traffic Interception: Proxy configuration for HTTPS inspection
- Anti-Detection: Modules to hide root, Magisk, and emulator detection
Prerequisites
- Android Studio: Latest version from developer.android.com
- SDK Platform-Tools: ADB and fastboot (installed with Android Studio)
- Proxy Tool: Burp Suite, Charles, or mitmproxy
- Git: For cloning tooling repositories
Environment Setup
1. Install Android Studio and SDK
ls ~/Library/Android/sdk
echo 'export ANDROID_HOME=~/Library/Android/sdk' >> ~/.bash_profile
echo 'export PATH=$PATH:$ANDROID_HOME/platform-tools' >> ~/.bash_profile
echo 'export PATH=$PATH:$ANDROID_HOME/tools' >> ~/.bash_profile
echo 'export PATH=$PATH:$ANDROID_HOME/tools/bin' >> ~/.bash_profile
echo 'export PATH=$PATH:$ANDROID_HOME/emulator' >> ~/.bash_profile
source ~/.bash_profile
echo 'export ANDROID_HOME=~/Library/Android/sdk' >> ~/.zshrc
echo 'export PATH=$PATH:$ANDROID_HOME/platform-tools' >> ~/.zshrc
source ~/.zshrc
adb version
2. Create Android Virtual Device (AVD)
emulator -list-avds
emulator -avd Pixel_9_Pro_API_36 -writable-system
3. Root with Magisk (Method A: rootAVD - Recommended)
git clone https://gitlab.com/newbit/rootAVD.git
cd rootAVD
./rootAVD.sh ListAllAVDs
./rootAVD.sh system-images/android-36.1/google_apis/arm64-v8a/ramdisk.img
4. Root with Magisk (Method B: Manual Patch)
emulator -avd Pixel_9_Pro_API_36 -writable-system
adb root
adb remount
adb install Magisk-v28.1.apk
adb push $ANDROID_HOME/system-images/android-36.1/google_apis/arm64-v8a/ramdisk.img /sdcard/Download/
adb pull /sdcard/Download/magisk_patched_xxxxx.img
cp magisk_patched_xxxxx.img $ANDROID_HOME/system-images/android-36.1/google_apis/arm64-v8a/ramdisk.img
Magisk Configuration
Install ZygiskNext (Improved Zygisk)
Install Shamiko (Hide Magisk from Detection)
adb shell su -c 'touch /data/adb/shamiko/whitelist'
adb shell su -c 'ls -la /data/adb/shamiko/'
Install LSPosed Framework
Install Frida
xz -d frida-server-*-android-arm64.xz
adb push frida-server-*-android-arm64 /data/local/tmp/frida-server
adb shell "chmod 755 /data/local/tmp/frida-server"
adb shell "su -c /data/local/tmp/frida-server &"
pip install frida-tools
frida-ps -U
SSL/TLS Certificate Pinning Bypass
Method 1: HTTP Toolkit Module
Method 2: Frida Script (Universal SSL Pinning Bypass)
Java.perform(function() {
console.log("[*] Universal SSL Pinning Bypass loaded");
try {
var CertificatePinner = Java.use('okhttp3.CertificatePinner');
CertificatePinner.check.overload('java.lang.String', 'java.util.List').implementation = function() {
console.log('[+] OkHttp3 Certificate Pinner bypassed');
return;
};
} catch(err) {
console.log('[-] OkHttp3 not found');
}
try {
var X509TrustManager = Java.use('javax.net.ssl.X509TrustManager');
var SSLContext = Java.use('javax.net.ssl.SSLContext');
var TrustManager = Java.registerClass({
name: 'com.sensepost.test.TrustManager',
implements: [X509TrustManager],
methods: {
checkClientTrusted: function(chain, authType) {},
checkServerTrusted: function(chain, authType) {},
getAcceptedIssuers: function() { return []; }
}
});
var TrustManagers = [TrustManager.$new()];
var SSLContext_init = SSLContext.init.overload('[Ljavax.net.ssl.KeyManager;', '[Ljavax.net.ssl.TrustManager;', 'java.security.SecureRandom');
SSLContext_init.implementation = function(keyManager, trustManager, secureRandom) {
console.log('[+] SSLContext TrustManager bypassed');
SSLContext_init.call(this, keyManager, TrustManagers, secureRandom);
};
} catch(err) {
console.log('[-] TrustManager bypass failed: ' + err);
}
try {
var ConscryptFileDescriptorSocket = Java.use('com.android.org.conscrypt.ConscryptFileDescriptorSocket');
ConscryptFileDescriptorSocket.verifyCertificateChain.implementation = function() {
console.log('[+] Conscrypt certificate verification bypassed');
};
} catch(err) {
console.log('[-] Conscrypt not found');
}
});
frida -U -f com.example.app -l ssl-bypass.js --no-pause
Method 3: JustTrustMe (LSPosed Module)
adb install JustTrustMe.apk
Install System CA Certificate
openssl x509 -inform DER -in burp-cert.der -out burp-cert.pem
CERT_HASH=$(openssl x509 -inform PEM -subject_hash_old -in burp-cert.pem | head -1)
cp burp-cert.pem ${CERT_HASH}.0
adb root
adb remount
adb push ${CERT_HASH}.0 /system/etc/security/cacerts/
adb shell "chmod 644 /system/etc/security/cacerts/${CERT_HASH}.0"
adb reboot
Common Frida Scripts
List Installed Packages
frida-ps -Uai
Hook Method to Bypass Root Detection
Java.perform(function() {
var RootDetection = Java.use('com.example.app.RootDetection');
RootDetection.isRooted.implementation = function() {
console.log('[+] Root check bypassed');
return false;
};
});
frida -U -f com.example.app -l root-bypass.js --no-pause
Dump App Memory
Java.perform(function() {
var ActivityThread = Java.use('android.app.ActivityThread');
var app = ActivityThread.currentApplication();
var context = app.getApplicationContext();
console.log('[*] Package Name: ' + context.getPackageName());
console.log('[*] Files Dir: ' + context.getFilesDir().getAbsolutePath());
});
Intercept Crypto Operations
Java.perform(function() {
var Cipher = Java.use('javax.crypto.Cipher');
Cipher.doFinal.overload('[B').implementation = function(input) {
console.log('[*] Cipher.doFinal called');
console.log('[*] Input: ' + Java.use('java.util.Arrays').toString(input));
var result = this.doFinal(input);
console.log('[*] Output: ' + Java.use('java.util.Arrays').toString(result));
return result;
};
});
ADB Commands Reference
adb devices
adb connect <ip>:5555
adb root
adb shell
adb install app.apk
adb install -r app.apk
adb uninstall com.example.app
adb shell pm list packages
adb shell pm path com.example.app
adb push local/file /sdcard/
adb pull /sdcard/file local/
adb logcat
adb logcat | grep -i "keyword"
adb logcat -c
adb shell screencap /sdcard/screen.png
adb pull /sdcard/screen.png
adb shell am start -n com.example.app/.MainActivity
adb shell am force-stop com.example.app
adb shell settings put global http_proxy <ip>:8080
adb shell settings delete global http_proxy
adb shell settings delete global https_proxy
Troubleshooting
Emulator Won't Start
sdkmanager --list | grep system-images
emulator -avd <name> -no-snapshot-load
emulator -avd <name> -wipe-data
ADB Not Detecting Device
adb kill-server
adb start-server
adb connect localhost:5554
Magisk Not Working After Reboot
cd rootAVD
./rootAVD.sh system-images/android-36.1/google_apis/arm64-v8a/ramdisk.img
ls -lh $ANDROID_HOME/system-images/android-36.1/google_apis/arm64-v8a/ramdisk.img
Frida Server Connection Failed
adb shell "su -c killall frida-server"
adb shell "su -c '/data/local/tmp/frida-server -l 0.0.0.0:27042' &"
adb forward tcp:27042 tcp:27042
frida-ps -H localhost:27042
SSL Pinning Still Active
adb shell "ls /system/etc/security/cacerts/ | grep -i <hash>"
App Crashes on Launch
adb shell "su -c rm /data/adb/shamiko/whitelist"
adb reboot
adb logcat | grep -i "fatal\|exception"
Best Practices
- Always create snapshots before making major changes to AVD
- Use Cold Boot for Magisk to load properly
- Keep Magisk and modules updated for latest bypass techniques
- Test bypasses incrementally - enable one at a time
- Use ZygiskNext + Shamiko for better detection evasion
- Avoid Google Play system images - use Google APIs instead
- Clear app data after installing bypass modules
- Monitor logcat during testing to identify security checks
References