From 59ec291b6cff1dfa83b316401418b6308df93aac Mon Sep 17 00:00:00 2001 From: iroiro123 Date: Thu, 18 Jun 2015 23:53:27 +0900 Subject: HTTP Transparent Proxy --- libmproxy/protocol/http.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'libmproxy/protocol/http.py') diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index 9c143386..c7479b76 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -1328,7 +1328,20 @@ class HTTPHandler(ProtocolHandler): # value at flow.server_conn self.c.set_server_address((request.host, request.port)) flow.server_conn = self.c.server_conn - + + elif request.form_in == "relative": + if self.c.config.mode == "httptransparent": + h = request.headers.get_first("host") + if h is None: + raise http.HttpError( + 400, + "Invalid request: No Host header" + ) + p = http.parse_url("http://" + h) + request.host, request.port = p[1], p[2] + self.c.set_server_address((request.host, request.port)) + flow.server_conn = self.c.server_conn + return None raise http.HttpError( 400, "Invalid HTTP request form (expected: %s, got: %s)" % ( -- cgit v1.2.3 From 378aa783243cf23d84a39d02dde5420beadc188b Mon Sep 17 00:00:00 2001 From: iroiro123 Date: Sat, 20 Jun 2015 21:43:50 +0900 Subject: Spoof mode --- libmproxy/protocol/http.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'libmproxy/protocol/http.py') diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index c7479b76..61782698 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -1330,19 +1330,22 @@ class HTTPHandler(ProtocolHandler): flow.server_conn = self.c.server_conn elif request.form_in == "relative": - if self.c.config.mode == "httptransparent": - h = request.headers.get_first("host") + if self.c.config.mode == "spoof": + # Host header + h = request.pretty_host(hostheader=True) if h is None: raise http.HttpError( 400, "Invalid request: No Host header" ) p = http.parse_url("http://" + h) - request.host, request.port = p[1], p[2] + request.host = p[1] + request.port = p[2] self.c.set_server_address((request.host, request.port)) flow.server_conn = self.c.server_conn return None + raise http.HttpError( 400, "Invalid HTTP request form (expected: %s, got: %s)" % ( self.expected_form_in, request.form_in -- cgit v1.2.3 From fd903673299c050b7b4137aabf6b9265df3d6233 Mon Sep 17 00:00:00 2001 From: iroiro123 Date: Sun, 21 Jun 2015 00:51:56 +0900 Subject: SSL Spoof mode --- libmproxy/protocol/http.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'libmproxy/protocol/http.py') diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index 61782698..11436b30 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -1336,13 +1336,18 @@ class HTTPHandler(ProtocolHandler): if h is None: raise http.HttpError( 400, - "Invalid request: No Host header" + "Invalid request: No host information" ) p = http.parse_url("http://" + h) - request.host = p[1] - request.port = p[2] + request.scheme = p[0] + request.host = p[1] + request.port = p[2] self.c.set_server_address((request.host, request.port)) flow.server_conn = self.c.server_conn + + if self.c.config.mode == "sslspoof": + # SNI is processed in server.py + return None return None -- cgit v1.2.3 From fbb23b5c9fae6e402d84ddae3c3b8c218def366c Mon Sep 17 00:00:00 2001 From: iroiro123 Date: Tue, 23 Jun 2015 01:49:22 +0900 Subject: changed error handling (ssl spoof mode) --- libmproxy/protocol/http.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'libmproxy/protocol/http.py') diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index 11436b30..9bce7206 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -1347,7 +1347,12 @@ class HTTPHandler(ProtocolHandler): if self.c.config.mode == "sslspoof": # SNI is processed in server.py - return None + if not (flow.server_conn and flow.server_conn.ssl_established): + print ":::::::::::::::" + raise http.HttpError( + 400, + "Invalid request: No host information" + ) return None -- cgit v1.2.3