From 960f2e8bf0432ade836f73864e4ed33295194420 Mon Sep 17 00:00:00 2001 From: chhsiao90 Date: Wed, 26 Oct 2016 11:32:42 +0800 Subject: Resolved #582: display ClientConnection select cipher of TLS --- mitmproxy/connections.py | 7 ++++++- mitmproxy/io_compat.py | 1 + mitmproxy/tools/console/flowdetailview.py | 2 ++ test/mitmproxy/tutils.py | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mitmproxy/connections.py b/mitmproxy/connections.py index 1c35ec7f..89c6b501 100644 --- a/mitmproxy/connections.py +++ b/mitmproxy/connections.py @@ -21,6 +21,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject): timestamp_ssl_setup: TLS established timestamp timestamp_end: Connection end timestamp sni: Server Name Indication sent by client during the TLS handshake + cipher_name: The current used cipher """ def __init__(self, client_connection, address, server): @@ -42,6 +43,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject): self.timestamp_ssl_setup = None self.protocol = None self.sni = None + self.cipher_name = None def __bool__(self): return bool(self.connection) and not self.finished @@ -64,6 +66,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject): timestamp_ssl_setup=float, timestamp_end=float, sni=str, + cipher_name=str, ) def copy(self): @@ -90,13 +93,15 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject): timestamp_start=None, timestamp_end=None, timestamp_ssl_setup=None, - sni=None + sni=None, + cipher_name=None, )) def convert_to_ssl(self, *args, **kwargs): super().convert_to_ssl(*args, **kwargs) self.timestamp_ssl_setup = time.time() self.sni = self.connection.get_servername() + self.cipher_name = self.connection.get_cipher_name() def finish(self): super().finish() diff --git a/mitmproxy/io_compat.py b/mitmproxy/io_compat.py index ea0e2dee..d8ef75e1 100644 --- a/mitmproxy/io_compat.py +++ b/mitmproxy/io_compat.py @@ -67,6 +67,7 @@ def convert_017_018(data): def convert_018_019(data): data["version"] = (0, 19) data["client_conn"]["sni"] = None + data["client_conn"]["cipher_name"] = None return data diff --git a/mitmproxy/tools/console/flowdetailview.py b/mitmproxy/tools/console/flowdetailview.py index a3f07cd5..d0aad11e 100644 --- a/mitmproxy/tools/console/flowdetailview.py +++ b/mitmproxy/tools/console/flowdetailview.py @@ -84,6 +84,8 @@ def flowdetails(state, flow): ] if cc.sni: parts.append(["Server Name Indication", cc.sni]) + if cc.cipher_name: + parts.append(["Cipher Name", cc.cipher_name]) text.extend( common.format_keyvals(parts, key="key", val="text", indent=4) diff --git a/test/mitmproxy/tutils.py b/test/mitmproxy/tutils.py index 9db65e00..525a0698 100644 --- a/test/mitmproxy/tutils.py +++ b/test/mitmproxy/tutils.py @@ -133,6 +133,7 @@ def tclient_conn(): timestamp_ssl_setup=2, timestamp_end=3, sni="address", + cipher_name="cipher", )) c.reply = controller.DummyReply() return c -- cgit v1.2.3