forked from shivang1989/andromeda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hook.py
54 lines (40 loc) · 1.93 KB
/
hook.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
import re
def add_hook(ui):
try:
ui.tabWiget.setCurrentIndex(1)
selected_method = str(ui.listWidget_methods.currentItem().text())
print(selected_method)
for i in selected_method.split(" "):
if "(" in i:
activity_without_params = i[:i.index("(")]
# fetching only methodName from full method string
tmp_str = activity_without_params.split(".")
methodName = tmp_str[-1]
# fetching classname where method is located
lastindex_dot = activity_without_params.rindex(".")
required_class_name = activity_without_params[:lastindex_dot]
# fetching parameter count
m = re.search('\((.*)\)', i)
if m:
found = m.group(1)
print("parameters---> ", found)
param_cnt = 0
for item in found.split(","):
if item:
param_cnt = param_cnt + 1
print("parameter count ==> ", param_cnt)
hook_jscode = """setTimeout(function(){
Java.perform(function(){
var MainActivity = Java.use('""" + str(required_class_name) + """');
// Number of params in this method = """ + str(param_cnt) + """
MainActivity.""" + str(methodName) + """.implementation = function(b){
// Your Logic Goes Here.
console.log("Done");
}
});
}, 0);
"""
ui.textEdit_javascript.setText(hook_jscode)
return hook_jscode
except Exception as e:
print("Exception at add_hook: ", e)