mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-02-01 15:55:28 +00:00
Merge pull request #3989 from nikitastupin/master
Add minimal TCP interception and modification!
This commit is contained in:
commit
e39b52b159
@ -49,3 +49,7 @@ class Intercept:
|
||||
|
||||
def response(self, f):
|
||||
self.process_flow(f)
|
||||
|
||||
def tcp_message(self, f):
|
||||
if self.filt and ctx.options.intercept_active:
|
||||
f.intercept()
|
||||
|
@ -385,7 +385,13 @@ class ConsoleAddon:
|
||||
"""
|
||||
Possible components for console.edit.focus.
|
||||
"""
|
||||
return [
|
||||
flow = self.master.view.focus.flow
|
||||
focus_options = []
|
||||
|
||||
if type(flow) == tcp.TCPFlow:
|
||||
focus_options = ["tcp-message"]
|
||||
elif type(flow) == http.HTTPFlow:
|
||||
focus_options = [
|
||||
"cookies",
|
||||
"urlencoded form",
|
||||
"multipart form",
|
||||
@ -402,6 +408,8 @@ class ConsoleAddon:
|
||||
"url",
|
||||
]
|
||||
|
||||
return focus_options
|
||||
|
||||
@command.command("console.edit.focus")
|
||||
@command.argument("flow_part", type=mitmproxy.types.Choice("console.edit.focus.options"))
|
||||
def edit_focus(self, flow_part: str) -> None:
|
||||
@ -460,6 +468,10 @@ class ConsoleAddon:
|
||||
"console.command",
|
||||
["flow.set", "@focus", flow_part]
|
||||
)
|
||||
elif flow_part == "tcp-message":
|
||||
message = flow.messages[-1]
|
||||
c = self.master.spawn_editor(message.content or b"")
|
||||
message.content = c.rstrip(b"\n")
|
||||
|
||||
def _grideditor(self):
|
||||
gewidget = self.master.window.current("grideditor")
|
||||
|
@ -164,6 +164,10 @@ class FlowDetails(tabs.Tabs):
|
||||
|
||||
from_client = not from_client
|
||||
|
||||
if flow.intercepted:
|
||||
markup = widget_lines[-1].get_text()[0]
|
||||
widget_lines[-1].set_text(("intercept", markup))
|
||||
|
||||
widget_lines.insert(0, self._contentview_status_bar(viewmode.capitalize(), viewmode))
|
||||
|
||||
return searchable.Searchable(widget_lines)
|
||||
|
@ -42,3 +42,13 @@ def test_simple():
|
||||
f = tflow.tflow(resp=True)
|
||||
tctx.cycle(r, f)
|
||||
assert f.intercepted
|
||||
|
||||
tctx.configure(r, intercept_active=False)
|
||||
f = tflow.ttcpflow()
|
||||
tctx.cycle(r, f)
|
||||
assert not f.intercepted
|
||||
|
||||
tctx.configure(r, intercept_active=True)
|
||||
f = tflow.ttcpflow()
|
||||
tctx.cycle(r, f)
|
||||
assert f.intercepted
|
||||
|
Loading…
Reference in New Issue
Block a user