From ba144b15bc1a33f71200e54eb4a25894a11d6a53 Mon Sep 17 00:00:00 2001 From: madt1m Date: Fri, 22 Jun 2018 22:43:05 +0200 Subject: [PATCH] Added initial protobuf definitions --- mitmproxy/io/db.py | 0 mitmproxy/io/proto/connection.proto | 38 +++++++++++++++++++++ mitmproxy/io/proto/http.proto | 51 +++++++++++++++++++++++++++++ mitmproxy/io/protobuf.py | 11 +++++++ 4 files changed, 100 insertions(+) create mode 100644 mitmproxy/io/db.py create mode 100644 mitmproxy/io/proto/connection.proto create mode 100644 mitmproxy/io/proto/http.proto create mode 100644 mitmproxy/io/protobuf.py diff --git a/mitmproxy/io/db.py b/mitmproxy/io/db.py new file mode 100644 index 000000000..e69de29bb diff --git a/mitmproxy/io/proto/connection.proto b/mitmproxy/io/proto/connection.proto new file mode 100644 index 000000000..fdcb0d137 --- /dev/null +++ b/mitmproxy/io/proto/connection.proto @@ -0,0 +1,38 @@ +syntax='proto2'; + +message Address { + optional string host = 1; + optional int32 port = 2; +} + +message ClientConnection { + optional string id = 1; + optional Address address = 2; + optional bool tls_established = 3; + optional string clientcert = 4; + optional string mitmcert = 5; + optional float timestamp_start = 6; + optional float timestamp_tls_setup = 7; + optional float timestamp_end = 8; + optional string sni = 9; + optional string cipher_name = 10; + optional bytes alpn_proto_negotiated = 11; + optional string tls_version = 12; +} + +message ServerConnection { + optional string id = 1; + optional Address address = 2; + optional Address ip_address = 3; + optional Address source_address = 4; + optional bool tls_established = 5; + optional string cert = 6; + optional string sni = 7; + optional bytes alpn_proto_negotiated = 8; + optional string tls_version = 9; + optional float timestamp_start = 10; + optional float timestamp_tcp_setup = 11; + optional float timestamp_tls_setup = 12; + optional float timestamp_end = 13; +} + diff --git a/mitmproxy/io/proto/http.proto b/mitmproxy/io/proto/http.proto new file mode 100644 index 000000000..f1b90f78b --- /dev/null +++ b/mitmproxy/io/proto/http.proto @@ -0,0 +1,51 @@ +syntax='proto2'; +import "connection.proto"; + +message HTTPFlow { + optional HTTPRequest request = 1; + optional HTTPResponse response = 2; + optional HTTPError error = 3; + optional ClientConnection client_conn = 4; + optional ServerConnection server_conn = 5; + optional bool intercepted = 6; + optional bool marked = 7; + optional string mode = 8; + optional string id = 9; + optional int32 version = 10; +} + +message HTTPRequest { + optional string first_line_format = 1; + optional bytes method = 2; + optional bytes scheme = 3; + optional bytes host = 4; + optional int32 port = 5; + optional bytes path = 6; + optional bytes http_version = 7; + repeated HTTPHeader headers = 8; + optional bytes content = 9; + optional int64 timestamp_start = 10; + optional int64 timestamp_end = 11; + optional bool is_replay = 12; +} + +message HTTPResponse { + optional bytes http_version = 1; + optional int32 status_code = 2; + optional bytes reason = 3; + repeated HTTPHeader headers = 4; + optional bytes content = 5; + optional int64 timestamp_start = 6; + optional int64 timestamp_end = 7; + optional bool is_replay = 8; +} + +message HTTPError { + optional string msg = 1; + optional int64 timestamp = 2; +} + +message HTTPHeader { + optional bytes name = 1; + optional bytes value = 2; +} \ No newline at end of file diff --git a/mitmproxy/io/protobuf.py b/mitmproxy/io/protobuf.py new file mode 100644 index 000000000..2dd0f1e7d --- /dev/null +++ b/mitmproxy/io/protobuf.py @@ -0,0 +1,11 @@ + + +"Just define dumps and loads. Files will be handled later. Or maybe...do it, and DONT use it." + +import typing + +def dumps(value) -> bytes: + pass + +def dump(value, file_handle: typing.BinaryIO) -> None: + pass