-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathcodetamper.py
77 lines (65 loc) · 2.2 KB
/
codetamper.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
import sys, getopt, inspect, os, subprocess, re
def ifTestOnlyAPK(file):
val = True;
f=open(file, "r")
if f.mode != 'r':
print 'Something went wrong'
sys.exit(2)
contents = f.read()
if "android:testOnly" not in contents:
val = False;
f.close()
return val
def mainfestdebuggable():
print 'I: Setting android:debuggable flag to true'
f=open("base/AndroidManifest.xml", "r")
if f.mode != 'r':
print 'Something went wrong'
sys.exit(2)
contents = f.read()
if "android:debuggable" not in contents:
contents = contents.replace("<application", "<application android:debuggable=\"true\"")
elif "android:debuggable=\"false\"" in contents:
contents = contents.replace("android:debuggable=\"false\"", "android:debuggable=\"true\"")
f.close()
f=open("base/AndroidManifest.xml", "w+")
f.write(contents)
f.close()
print ' complete'
print '------------------------------'
def usercertificate():
print 'I: Applying SSL bypass'
f=open("base/AndroidManifest.xml", "r")
if f.mode != 'r':
print 'Something went wrong'
sys.exit(2)
contents = f.read()
if "android:networkSecurityConfig" not in contents:
contents = contents.replace("<application", "<application android:networkSecurityConfig=\"@xml/networkSecurityConfig\"")
else:
result = re.sub('android:networkSecurityConfig="(.*?)"', 'android:networkSecurityConfig="@xml/networkSecurityConfig"', contents)
contents = result
#print(result)
f.close()
f=open("base/AndroidManifest.xml", "w+")
f.write(contents)
f.close()
createConfigFile()
print ' complete'
print '------------------------------'
def createConfigFile():
dirName = "base/res/xml"
if not os.path.exists("base/res/xml"):
os.mkdir(dirName)
print("I: Directory '"+dirName+"' Created")
f=open("dependency/networkSecurityConfig.xml", "r")
contents = f.read()
f.close()
f=open("base/res/xml/networkSecurityConfig.xml", "w+")
f.write(contents)
f.close()
def main(argv):
mainfestdebuggable()
usercertificate()
if __name__ == "__main__":
main(sys.argv[1:])