aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/protocol
diff options
context:
space:
mode:
authorMichael J. Bazzinotti <mbazzinotti@gmail.com>2016-01-02 10:00:27 -0500
committerMichael J. Bazzinotti <mbazzinotti@gmail.com>2016-01-10 13:05:01 -0500
commite766838a1a6bbb0b2290a3986ba8ae71c736f6f6 (patch)
tree0042fb0d9f5531f57186285faa13e9ea2600bc23 /libmproxy/protocol
parentf8d8a80bd07fe1e40577a2090ba47e3cc5abd3d3 (diff)
downloadmitmproxy-e766838a1a6bbb0b2290a3986ba8ae71c736f6f6.tar.gz
mitmproxy-e766838a1a6bbb0b2290a3986ba8ae71c736f6f6.tar.bz2
mitmproxy-e766838a1a6bbb0b2290a3986ba8ae71c736f6f6.zip
Add Inline Script Hooks to TCP mode
Diffstat (limited to 'libmproxy/protocol')
-rw-r--r--libmproxy/protocol/rawtcp.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/libmproxy/protocol/rawtcp.py b/libmproxy/protocol/rawtcp.py
index 5f08fd17..ccd3c7ec 100644
--- a/libmproxy/protocol/rawtcp.py
+++ b/libmproxy/protocol/rawtcp.py
@@ -13,6 +13,15 @@ from ..exceptions import ProtocolException
from .base import Layer
+class TcpMessage(object):
+ def __init__(self, client_conn, server_conn, sender, receiver, message):
+ self.client_conn = client_conn
+ self.server_conn = server_conn
+ self.sender = sender
+ self.receiver = receiver
+ self.message = message
+
+
class RawTCPLayer(Layer):
chunk_size = 4096
@@ -50,7 +59,13 @@ class RawTCPLayer(Layer):
return
continue
- dst.sendall(buf[:size])
+ tcp_message = TcpMessage(
+ self.client_conn, self.server_conn,
+ self.client_conn if dst == server else self.server_conn,
+ self.server_conn if dst == server else self.client_conn,
+ buf[:size].tobytes())
+ self.channel.ask("tcp_message", tcp_message)
+ dst.sendall(tcp_message.message)
if self.logging:
# log messages are prepended with the client address,
@@ -59,7 +74,7 @@ class RawTCPLayer(Layer):
direction = "-> tcp -> {}".format(repr(self.server_conn.address))
else:
direction = "<- tcp <- {}".format(repr(self.server_conn.address))
- data = clean_bin(buf[:size].tobytes())
+ data = clean_bin(tcp_message.message)
self.log(
"{}\r\n{}".format(direction, data),
"info"