-
Notifications
You must be signed in to change notification settings - Fork 936
/
run_env.py
122 lines (84 loc) · 2.95 KB
/
run_env.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
111
112
113
114
115
116
117
118
119
120
121
'''
Created on 2020年4月20日
@author: stephen
'''
import io
import os
import re
def readJs(filename):
return io.open('./js/' + filename,'r',encoding= 'utf8').read()
def readFile(filename):
return io.open(filename,'r',encoding= 'utf8').read()
base_jscode = readJs("base.js")
loadxinit_dexfile_template_jscode = """
var loadedXRadar = false;
function loadXinitDexfile(dexfile) {
loadDexfile('/data/user/0/{PACKAGENAME}/xinit/'+dexfile);
};
function loadXRadarDexfile() {
loadedXRadar = true;
loadDexfile('/data/user/0/{PACKAGENAME}/radar.dex');
};
function fastTojson(javaObject) {
var JSONClz = Java.use("gz.com.alibaba.fastjson.JSON");
return JSONClz.toJSONString(javaObject);
};
function getPrettyString(javaObject) {
var XPretty = Java.use("gz.util.XPretty");
return XPretty.getPrettyString(javaObject);
};
function xPretty(javaObject) {
var str = getPrettyString(javaObject);
console.log(str);
};
function getField(javaObject, fieldName) {
var X = Java.use("gz.util.X");
return X.getField(javaObject, fieldName);
};
function storeObjectAndLog(javaObject) {
try {
var className = getClassName(javaObject);
var ObjectsStore = Java.use("gz.radar.objects.ObjectsStore");
var objectId = ObjectsStore.storeObject(javaObject);
console.log(className + " ObjectsStoreId: " +objectId);
} catch (error) {
console.error("你传的不是一个有效的java对象!");
}
};
"""
radar_jscode = readJs("radar.js")
jsfmt_jscode = readJs("jsfmt.js")
string_hooker_jscode = readJs("string_hooker.js")
rpc_jscode = base_jscode + radar_jscode + jsfmt_jscode + readJs("rpc.js")
url_jscode = readJs("url.js")
android_ui_jscode = readJs("android_ui.js")
edit_text_jscode = readJs("edit_text.js")
text_view_jscode = readJs("text_view.js")
click_jscode = readJs("click.js")
activity_events_jscode = readJs("activity_events.js")
object_store_jscode = readJs("object_store.js")
keystore_dump_jscode = readJs("keystore_dump.js")
ssl_log_jscode = readJs("ssl_log.js")
just_trust_me_jscode = readJs("just_trust_me.js")
just_trust_me_okhttp_hook_finder_jscode = readJs("just_trust_me_okhttp_hook_finder.js")
hook_RN_jscode = readJs("hook_RN.js")
dump_dex_jscode = readJs("dump_dex.js")
def getPythonLaucher():
pythonLaucher = os.environ.get("__PYVENV_LAUNCHER__")
if not pythonLaucher:
pythonLaucher = os.environ.get("_", "/usr/bin/python3")
return pythonLaucher
xinitPyScript = "#! " + getPythonLaucher() + "\n\n" + readFile("xinitdeploy.py")
disableSslPinningPyScript = "#! " + getPythonLaucher() + "\n\n" + readFile("disable_sslpinning.py")
spiderPyScript = readFile("spider.py")
def getRemoteDriver():
text = readFile(".hooker_driver")
if not text:
return None
searchResult = re.search('\d+\.\d+\.\d+\.\d+:\d+', text)
if searchResult:
return searchResult.group()
return None
def init(packageName):
if packageName == None:
return