-
Notifications
You must be signed in to change notification settings - Fork 4
/
tracer.py
50 lines (34 loc) · 1.54 KB
/
tracer.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
# coding:utf-8
from frida_tools import tracer
import json
import requests
BURP_HOST = 'localhost'
BURP_PORT = 26080
def frida_process_message(self, message, data, ui):
handled = False
if message['type'] == 'input':
handled = True
elif message['type'] == 'send':
stanza = message['payload']
if stanza['from'] == '/request':
req_data = stanza['payload'].encode('utf-8')
orig_json_data = json.loads(req_data)
orig_request_url = orig_json_data.pop(u'orig_request_url')
req = requests.request('REQUEST', 'http://%s:%d/' % (BURP_HOST, BURP_PORT),
headers={'content-type':'text/plain', 'ORIG_REQUEST_URI': orig_request_url},
data=json.dumps(orig_json_data))
self._script.post({'type':'input', 'payload': req.content})
handled = True
elif stanza['from'] == '/response':
req_data = stanza['payload'].encode('utf-8')
req = requests.request('RESPONSE', 'http://%s:%d/' % (BURP_HOST, BURP_PORT),
headers={'content-type': 'text/plain'},
data=json.dumps(req_data))
self._script.post({'type': 'output', 'payload': req.content})
handled = True
if not handled:
self.__process_message(message, data, ui)
tracer.Tracer.__process_message = tracer.Tracer._process_message
tracer.Tracer._process_message = frida_process_message
if __name__ == '__main__':
tracer.main()