-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathmitm-show-header.py
33 lines (23 loc) · 961 Bytes
/
mitm-show-header.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
from mitmproxy import http
from mitmutils import utils
import re
import logging
CONFIG_FILE = './show-header.yaml'
def searchHeaders(flow, config, state):
config = utils.readFile(config)
url = flow.request.url
if config is not None:
for patternURL, headers in config.items():
if re.match(patternURL, url) is not None:
if state == 'request':
items = flow.request.headers.items()
else:
items = flow.response.headers.items()
logging.warn('>> FOUND ' + state + ' header in: ' + url)
for k, v in items:
if k.lower() in [x.lower() for x in headers]:
logging.warn('-> ' + str(k) + ': ' + str(v))
def request(flow: http.HTTPFlow) -> None:
searchHeaders(flow, CONFIG_FILE, 'request')
def response(flow: http.HTTPFlow) -> None:
searchHeaders(flow, CONFIG_FILE, 'response')