-
-
Save mhils/3a1ebb56479fc7c660942c57cb37312d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import typing | |
from mitmproxy.ctx import options | |
from mitmproxy.proxy import config, RootContext, protocol | |
force_tcp = config.HostMatcher() | |
def load(l): | |
l.add_option( | |
"force_tcp", typing.Sequence[str], [], | |
"Force plain (non-TLS) TCP with server-side greetings", | |
) | |
# Monkeypatch RootContext.next_layer | |
RootContext.actual_next_layer = RootContext.next_layer | |
def next_layer(self, top_layer): | |
if force_tcp(top_layer.server_conn.address): | |
return protocol.RawTCPLayer(top_layer) | |
return RootContext.actual_next_layer(self, top_layer) | |
RootContext.next_layer = next_layer | |
def configure(updated): | |
if "force_tcp" in updated: | |
global force_tcp | |
force_tcp = config.HostMatcher(options.force_tcp) | |
def done(): | |
RootContext.next_layer = RootContext.actual_next_layer | |
del RootContext.actual_next_layer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment