-
Notifications
You must be signed in to change notification settings - Fork 32
/
diff-gui.py
160 lines (130 loc) · 4.24 KB
/
diff-gui.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
from flask import *
from jinja2 import Environment
from os import listdir
from os.path import isfile, join,dirname,realpath
import os
import sys
import frida
import requests
import json
import getopt
import socket
import redis
# default variables
port=8000
modulePath=os.path.dirname(os.path.realpath(__file__))+"/modules/"
listenAddress="127.0.0.1"
device = None
red = redis.StrictRedis()
HTML = """{{title}}"""
app = Flask(__name__)
'''
landing page, ask for the remote address of the device, if no remote adresse juste let the input empty
'''
@app.route('/')
def hello_world():
return render_template('intro.html')
'''
show list of running process on the device
'''
@app.route('/packages',methods=['GET'])
def show_packages():
global device
try:
remote = request.args.get('remote')
if device == None:
if len(remote) != 0:
# check remote ip address
try:
socket.inet_aton(remote)
print "adding remote device to device manager : ",remote
device=frida.get_device_manager().add_remote_device(remote)
print "remote device : ", device
except socket.error:
return render_template('intro.html')
else:
device = frida.get_usb_device()
# get list of apps
packages=device.enumerate_processes()
print packages
except frida.ServerNotRunningError :
return render_template('error.html',error="cannot connect to remote :(")
return render_template('packages_list.html',
packages=packages)
def event_stream():
pubsub = red.pubsub()
pubsub.subscribe('diffdroid')
print "JUST SUBSCRIBE TO DIFFDROID"
for message in pubsub.listen():
print "EVENT_STREAM : ",message
yield 'data: %s\n\n' % message['data']
@app.route('/stream')
def stream():
return Response(event_stream(),
mimetype="text/event-stream")
def get_messages_from_js(message,data):
red.publish('diffdroid', message['payload'])
print "JUST_PUBLISHED : ", message['payload']
#sse.publish({"message": json.dumps(message['payload'])}, type='greeting')
#r = requests.post("http://127.0.0.1:8000/ding", data=json.dumps(message['payload']), headers=head)
def start_frida(x,bleeh):
global device
print device
process = device.attach(bleeh)
script = process.create_script(x)
script.on('message',get_messages_from_js)
script.load()
@app.route('/hack')
def hack():
module = request.args.get('module')
txt = open(modulePath+module,'r').read()
return render_template('main.html',
content=txt)
@app.route('/lol',methods=['GET', 'POST'])
def lol():
try:
blah = request.get_json()
bleeh = request.args.get('package_name')
if blah is None:
return "boo"
else:
x = Environment().from_string(HTML).render(title=request.get_json())
start_frida(x,bleeh)
response = jsonify({"message":"ok"})
response.status_code = 200
return response
except Exception as e:
print e.message, e.args
@app.route('/list')
def list():
bleeh = request.args.get('package_name')
filess = [f for f in listdir(modulePath) if isfile(join(modulePath, f))]
return render_template("list.html",
posts=filess,
package_name = bleeh)
@app.route('/update')
def update():
return render_template("update.html")
def main(argv):
global modulePath
global listenAddress
global port
try:
opts, args = getopt.getopt(argv[1:],"hp:a:",["help","port=","address="])
except getopt.GetoptError:
print "Usage:"
print argv[0] + ' -p <port>'
sys.exit(2)
for opt, arg in opts:
print "OPT ",opt
if opt in ('-h',"--help"):
print "Usage:"
print argv[0] + ' -p <port>'
sys.exit()
elif opt in ("-p", "--port"):
port = arg
elif opt in ("-a","--address"):
listenAddress= arg
app.run(host=listenAddress,port=port,threaded=True)
if __name__ == '__main__':
main(sys.argv)