mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Get the the original header in requestheaders instead of request
This commit is contained in:
parent
0022c810e5
commit
a55eba3b37
@ -27,23 +27,32 @@ import re
|
|||||||
# https://bugzilla.mozilla.org/show_bug.cgi?id=45891
|
# https://bugzilla.mozilla.org/show_bug.cgi?id=45891
|
||||||
parse_host_header = re.compile(r"^(?P<host>[^:]+|\[.+\])(?::(?P<port>\d+))?$")
|
parse_host_header = re.compile(r"^(?P<host>[^:]+|\[.+\])(?::(?P<port>\d+))?$")
|
||||||
|
|
||||||
|
class DnsSpoofing:
|
||||||
|
def __init__(self):
|
||||||
|
self.hostHeader = None
|
||||||
|
|
||||||
def request(flow):
|
def requestheaders(self, flow):
|
||||||
if flow.client_conn.ssl_established:
|
self.hostHeader = flow.request.headers.get('host')
|
||||||
flow.request.scheme = "https"
|
|
||||||
sni = flow.client_conn.connection.get_servername()
|
|
||||||
port = 443
|
|
||||||
else:
|
|
||||||
flow.request.scheme = "http"
|
|
||||||
sni = None
|
|
||||||
port = 80
|
|
||||||
|
|
||||||
host_header = flow.request.pretty_host
|
def request(self, flow):
|
||||||
m = parse_host_header.match(host_header)
|
if flow.client_conn.ssl_established:
|
||||||
if m:
|
flow.request.scheme = "https"
|
||||||
host_header = m.group("host").strip("[]")
|
sni = flow.client_conn.connection.get_servername()
|
||||||
if m.group("port"):
|
port = 443
|
||||||
port = int(m.group("port"))
|
else:
|
||||||
|
flow.request.scheme = "http"
|
||||||
|
sni = None
|
||||||
|
port = 80
|
||||||
|
|
||||||
flow.request.host = sni or host_header
|
host_header = self.hostHeader
|
||||||
flow.request.port = port
|
m = parse_host_header.match(host_header)
|
||||||
|
if m:
|
||||||
|
host_header = m.group("host").strip("[]")
|
||||||
|
if m.group("port"):
|
||||||
|
port = int(m.group("port"))
|
||||||
|
|
||||||
|
flow.request.host = sni or host_header
|
||||||
|
flow.request.port = port
|
||||||
|
|
||||||
|
def start():
|
||||||
|
return DnsSpoofing()
|
||||||
|
Loading…
Reference in New Issue
Block a user