-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-burpsuite-ca.py
110 lines (72 loc) · 2.72 KB
/
install-burpsuite-ca.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import subprocess
__author__ = "h4pp1n3ss"
__date__ = "18062021"
__version__ = "0.1"
__description__ = '''\
Install burpsuite certificate on Android Emulator
Tested on: Android Emulator (AVD)
command: emulator @Pixel_2_XL_API_26 -writable-system -selinux disabled -no-audio -no-boot-anim
'''
import os
import time
import sys
if not sys.version.startswith('3'):
print("[!] Error: This script only work with Python3\n")
exit(1)
def is_device_up():
output = subprocess.getoutput("adb devices")
if "emulator" in output:
return True
else:
return False
def get_root():
messages = ['restarting adbd as root', 'adbd is already running as root']
output = subprocess.getoutput("adb root")
for n in messages:
if n in output:
print("[+] Info: Already root")
n = 0
while True:
print("[!] Info: Retry {}".format(n))
output = subprocess.getoutput("adb remount")
if "remount succeeded" in output:
print("[+] Info: remount succeded")
break
else:
print("[-] Error: remount failed, check command manually")
n += 1
def download_burp_certificate():
output = subprocess.getoutput("curl --proxy http://127.0.0.1:8080 -o cacert.der http://burp/cert")
try:
os.path.exists('cacert.der')
subprocess.getoutput("openssl x509 -inform DER -in cacert.der -out cacert.pem")
subprocess.getoutput("cp cacert.der $(openssl x509 -inform PEM -subject_hash_old -in cacert.pem |head -1).0")
except Exception as e:
print(e)
print("[+] Info: Certificate ready to install")
def install_burp_certificate():
# Check if the certificate exists
ca = subprocess.getoutput("ls $(openssl x509 -inform PEM -subject_hash_old -in cacert.pem |head -1).0")
output = subprocess.getoutput("adb shell \"ls /system/etc/security/cacerts\"")
if ca in output:
print("[+] Info: Certificate {} already installed".format(ca))
else:
subprocess.getoutput("adb push {} /sdcard/".format(ca))
time.sleep(2)
subprocess.getoutput("adb shell \"mv /sdcard/{} /system/etc/security/cacerts/\"".format(ca))
subprocess.getoutput("adb shell \"chmod 644 /system/etc/security/cacerts/{}\"".format(ca))
print("[+] Info: Certificate {} installed sucessfully".format(ca))
def main():
if is_device_up():
print("[*] Info: Device attached")
else:
print("[-] Error: Device not attached")
exit(-1)
time.sleep(2)
get_root()
time.sleep(2)
download_burp_certificate()
time.sleep(2)
install_burp_certificate()
if __name__ == "__main__":
main()