Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@controller.handler
def tcp_open(self, flow):
# TODO: This would break mitmproxy currently.
# self.state.add_flow(flow)
self.active_flows.add(flow)
self.run_script_hook("tcp_open", flow)
@controller.handler
def response(self, f):
print("response", f)
@controller.handler
def requestheaders(self, flow):
for p in self.plugins:
try:
p.requestheaders(flow)
except Exception:
pass
@controller.handler
def serverconnect(self, server_conn):
self.run_script_hook("serverconnect", server_conn)
@controller.handler
def clientconnect(self, root_layer):
self.run_script_hook("clientconnect", root_layer)
@handler
def log(self, l):
pass
@controller.handler
def request(self, flow):
'''
print "-- request --"
print flow.__dict__
print flow.request.__dict__
print flow.request.headers.__dict__
print "--------------"
print
'''
try:
for p in self.plugins:
p.request(flow)
except Exception:
pass
@handler
def tcp_start(self, flow):
pass
@controller.handler
def tcp_message(self, flow):
self.run_script_hook("tcp_message", flow)
message = flow.messages[-1]
direction = "->" if message.from_client else "<-"
self.add_event("{client} {direction} tcp {direction} {server}".format(
client=repr(flow.client_conn.address),
server=repr(flow.server_conn.address),
direction=direction,
), "info")
self.add_event(clean_bin(message.content), "debug")
@controller.handler
def clientdisconnect(self, root_layer):
self.run_script_hook("clientdisconnect", root_layer)