Get the the original header in requestheaders instead of request

This commit is contained in:
Ammonite 2017-01-20 23:43:53 +01:00
parent 0022c810e5
commit a55eba3b37

View File

@ -27,8 +27,14 @@ import re
# https://bugzilla.mozilla.org/show_bug.cgi?id=45891
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):
self.hostHeader = flow.request.headers.get('host')
def request(self, flow):
if flow.client_conn.ssl_established:
flow.request.scheme = "https"
sni = flow.client_conn.connection.get_servername()
@ -38,7 +44,7 @@ def request(flow):
sni = None
port = 80
host_header = flow.request.pretty_host
host_header = self.hostHeader
m = parse_host_header.match(host_header)
if m:
host_header = m.group("host").strip("[]")
@ -47,3 +53,6 @@ def request(flow):
flow.request.host = sni or host_header
flow.request.port = port
def start():
return DnsSpoofing()