Skip to content

Instantly share code, notes, and snippets.

@patuuh
Created April 4, 2024 07:27
Show Gist options
  • Save patuuh/19a27379244295ce741689ed3820e870 to your computer and use it in GitHub Desktop.
Save patuuh/19a27379244295ce741689ed3820e870 to your computer and use it in GitHub Desktop.
Burp Suite certificate auto-setup to rooted Android device
import os
import sys
import platform
# Runs all necessary commands to setup burp cert
# Windows adb.exe location hardcoded to C:\Android\adb.exe
# If this location is different, change it from the code
#
# 1. Connect rooted Android device to computer with USB
# 2. Run command: 'adb devices' and make sure your device shows up
# 3. Run command: 'python burpcert.py <path to burp cert>' e.g., 'python burpcert.py cacert.der'
# 4. View the output of the commands and make sure the script finished without errors
# 5. Done! Happy hunting
if len(sys.argv) < 2:
print("Give burp cert name as a parameter. i.e \'python burpcert.py cacert.der\'")
exit()
else:
certName=sys.argv[1]
if "Win" in platform.system():
adb = "C:\\Android\\adb.exe"
else:
adb = "adb"
print(f"cmd: {adb} push {certName} /sdcard/")
os.system(f'{adb} push {certName} /sdcard/')
print(f"cmd: {adb} shell \"su -c \'mount -o rw,remount /\'\"")
os.system(f'{adb} shell "su -c \'mount -o rw,remount /\'"')
#{adb} shell "su -c \'cp /sdcard/9a5ba575.0 /sdcard/9a5ba575.0.bak\'"
print(f"cmd: {adb} shell \"su -c \'cp /sdcard/{certName} /sdcard/9a5ba575.0\'\"")
os.system(f'{adb} shell "su -c \'cp /sdcard/{certName} /sdcard/9a5ba575.0\'"')
print(f"cmd: {adb} shell \"su -c \'cp /sdcard/9a5ba575.0 /system/etc/security/cacerts/\'\"")
os.system(f'{adb} shell "su -c \'cp /sdcard/9a5ba575.0 /system/etc/security/cacerts/\'"')
print(f"cmd: {adb} shell \"su -c \'chmod 644 /system/etc/security/cacerts/9a5ba575.0\'\"")
os.system(f'{adb} shell "su -c \'chmod 644 /system/etc/security/cacerts/9a5ba575.0\'"')
print(f"cmd: {adb} shell \"su -c \'chown root:root /system/etc/security/cacerts/9a5ba575.0\'\"")
os.system(f'{adb} shell "su -c \'chown root:root /system/etc/security/cacerts/9a5ba575.0\'"')
print(f"cmd: {adb} shell \"su -c \'mount -o ro,remount /\'\"")
os.system(f'{adb} shell "su -c \'mount -o ro,remount /\'"')
print("Done!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment