2012-02-07 03:39:37 +00:00
|
|
|
import urwid
|
|
|
|
import common
|
2012-03-22 01:57:57 +00:00
|
|
|
from .. import filt, version
|
|
|
|
|
|
|
|
footer = [
|
|
|
|
("heading", 'mitmproxy v%s '%version.VERSION),
|
|
|
|
('heading_key', "q"), ":back ",
|
|
|
|
]
|
2012-02-07 03:39:37 +00:00
|
|
|
|
|
|
|
class HelpView(urwid.ListBox):
|
2012-02-08 08:47:39 +00:00
|
|
|
def __init__(self, master, help_context, state):
|
|
|
|
self.master, self.state = master, state
|
|
|
|
self.help_context = help_context or []
|
2012-02-07 03:39:37 +00:00
|
|
|
urwid.ListBox.__init__(
|
|
|
|
self,
|
|
|
|
self.helptext()
|
|
|
|
)
|
|
|
|
|
|
|
|
def helptext(self):
|
|
|
|
text = []
|
2012-08-31 01:28:04 +00:00
|
|
|
text.append(urwid.Text([("head", "This view:\n")]))
|
2012-02-08 08:47:39 +00:00
|
|
|
text.extend(self.help_context)
|
|
|
|
|
2012-02-11 05:23:07 +00:00
|
|
|
text.append(urwid.Text([("head", "\n\nMovement:\n")]))
|
2012-02-08 09:55:48 +00:00
|
|
|
keys = [
|
|
|
|
("j, k", "up, down"),
|
|
|
|
("h, l", "left, right (in some contexts)"),
|
|
|
|
("space", "page down"),
|
|
|
|
("pg up/down", "page up/down"),
|
|
|
|
("arrows", "up, down, left, right"),
|
|
|
|
]
|
|
|
|
text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
|
|
|
|
|
2012-02-11 05:23:07 +00:00
|
|
|
text.append(urwid.Text([("head", "\n\nGlobal keys:\n")]))
|
2012-02-07 03:39:37 +00:00
|
|
|
keys = [
|
|
|
|
("c", "client replay"),
|
2012-09-01 23:53:00 +00:00
|
|
|
("H", "edit global header set patterns"),
|
2012-02-07 03:39:37 +00:00
|
|
|
("i", "set interception pattern"),
|
2012-04-01 22:49:57 +00:00
|
|
|
("M", "change global default display mode"),
|
|
|
|
(None,
|
|
|
|
common.highlight_key("automatic", "a") +
|
|
|
|
[("text", ": automatic detection")]
|
|
|
|
),
|
|
|
|
(None,
|
2013-04-16 21:54:34 +00:00
|
|
|
common.highlight_key("hex", "e") +
|
2012-04-01 22:49:57 +00:00
|
|
|
[("text", ": Hex")]
|
|
|
|
),
|
2013-04-16 21:54:34 +00:00
|
|
|
(None,
|
|
|
|
common.highlight_key("html", "h") +
|
|
|
|
[("text", ": HTML")]
|
|
|
|
),
|
2012-04-01 22:49:57 +00:00
|
|
|
(None,
|
|
|
|
common.highlight_key("image", "i") +
|
|
|
|
[("text", ": Image")]
|
|
|
|
),
|
|
|
|
(None,
|
|
|
|
common.highlight_key("javascript", "j") +
|
|
|
|
[("text", ": JavaScript")]
|
|
|
|
),
|
|
|
|
(None,
|
|
|
|
common.highlight_key("json", "s") +
|
|
|
|
[("text", ": JSON")]
|
|
|
|
),
|
2014-01-04 16:13:46 +00:00
|
|
|
(None,
|
|
|
|
common.highlight_key("css", "c") +
|
|
|
|
[("text", ": CSS")]
|
|
|
|
),
|
2012-04-01 22:49:57 +00:00
|
|
|
(None,
|
|
|
|
common.highlight_key("urlencoded", "u") +
|
|
|
|
[("text", ": URL-encoded data")]
|
|
|
|
),
|
|
|
|
(None,
|
|
|
|
common.highlight_key("raw", "r") +
|
|
|
|
[("text", ": raw data")]
|
|
|
|
),
|
|
|
|
(None,
|
|
|
|
common.highlight_key("xml", "x") +
|
|
|
|
[("text", ": XML")]
|
|
|
|
),
|
2012-08-17 06:27:47 +00:00
|
|
|
(None,
|
|
|
|
common.highlight_key("amf", "f") +
|
|
|
|
[("text", ": AMF (requires PyAMF)")]
|
|
|
|
),
|
2012-02-07 03:39:37 +00:00
|
|
|
("o", "toggle options:"),
|
2012-04-08 08:16:25 +00:00
|
|
|
(None,
|
|
|
|
common.highlight_key("anticache", "a") +
|
|
|
|
[("text", ": prevent cached responses")]
|
|
|
|
),
|
|
|
|
(None,
|
|
|
|
common.highlight_key("anticomp", "c") +
|
|
|
|
[("text", ": prevent compressed responses")]
|
|
|
|
),
|
2013-03-17 04:31:35 +00:00
|
|
|
(None,
|
|
|
|
common.highlight_key("showhost", "h") +
|
|
|
|
[("text", ": use Host header for URL display")]
|
|
|
|
),
|
2012-04-08 08:16:25 +00:00
|
|
|
(None,
|
|
|
|
common.highlight_key("killextra", "k") +
|
|
|
|
[("text", ": kill requests not part of server replay")]
|
|
|
|
),
|
|
|
|
(None,
|
|
|
|
common.highlight_key("norefresh", "n") +
|
|
|
|
[("text", ": disable server replay response refresh")]
|
|
|
|
),
|
|
|
|
(None,
|
|
|
|
common.highlight_key("upstream certs", "u") +
|
|
|
|
[("text", ": sniff cert info from upstream server")]
|
|
|
|
),
|
2012-02-07 03:39:37 +00:00
|
|
|
|
2012-02-20 23:42:43 +00:00
|
|
|
("q", "quit / return to flow list"),
|
2012-02-07 03:39:37 +00:00
|
|
|
("Q", "quit without confirm prompt"),
|
2012-04-03 23:24:58 +00:00
|
|
|
("R", "edit replacement patterns"),
|
2012-02-07 03:39:37 +00:00
|
|
|
("s", "set/unset script"),
|
|
|
|
("S", "server replay"),
|
|
|
|
("t", "set sticky cookie expression"),
|
|
|
|
("u", "set sticky auth expression"),
|
|
|
|
]
|
|
|
|
text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
|
|
|
|
|
2012-02-11 05:23:07 +00:00
|
|
|
text.append(urwid.Text([("head", "\n\nFilter expressions:\n")]))
|
2012-02-07 03:39:37 +00:00
|
|
|
f = []
|
|
|
|
for i in filt.filt_unary:
|
|
|
|
f.append(
|
|
|
|
("~%s"%i.code, i.help)
|
|
|
|
)
|
|
|
|
for i in filt.filt_rex:
|
|
|
|
f.append(
|
|
|
|
("~%s regex"%i.code, i.help)
|
|
|
|
)
|
|
|
|
for i in filt.filt_int:
|
|
|
|
f.append(
|
|
|
|
("~%s int"%i.code, i.help)
|
|
|
|
)
|
|
|
|
f.sort()
|
|
|
|
f.extend(
|
|
|
|
[
|
|
|
|
("!", "unary not"),
|
|
|
|
("&", "and"),
|
|
|
|
("|", "or"),
|
|
|
|
("(...)", "grouping"),
|
|
|
|
]
|
|
|
|
)
|
|
|
|
text.extend(common.format_keyvals(f, key="key", val="text", indent=4))
|
|
|
|
|
2012-02-11 05:23:07 +00:00
|
|
|
text.append(
|
|
|
|
urwid.Text(
|
|
|
|
[
|
|
|
|
"\n",
|
|
|
|
("text", " Regexes are Python-style.\n"),
|
|
|
|
("text", " Regexes can be specified as quoted strings.\n"),
|
|
|
|
("text", " Header matching (~h, ~hq, ~hs) is against a string of the form \"name: value\".\n"),
|
|
|
|
("text", " Expressions with no operators are regex matches against URL.\n"),
|
|
|
|
("text", " Default binary operator is &.\n"),
|
|
|
|
("head", "\n Examples:\n"),
|
|
|
|
]
|
|
|
|
)
|
2012-02-07 03:39:37 +00:00
|
|
|
)
|
|
|
|
examples = [
|
|
|
|
("google\.com", "Url containing \"google.com"),
|
|
|
|
("~q ~b test", "Requests where body contains \"test\""),
|
|
|
|
("!(~q & ~t \"text/html\")", "Anything but requests with a text/html content type."),
|
|
|
|
]
|
|
|
|
text.extend(common.format_keyvals(examples, key="key", val="text", indent=4))
|
2012-02-11 05:23:07 +00:00
|
|
|
return text
|
2012-02-07 03:39:37 +00:00
|
|
|
|
2012-06-03 08:11:07 +00:00
|
|
|
def keypress(self, size, key):
|
|
|
|
key = common.shortcuts(key)
|
|
|
|
if key == "q":
|
|
|
|
self.master.statusbar = self.state[0]
|
|
|
|
self.master.body = self.state[1]
|
|
|
|
self.master.header = self.state[2]
|
|
|
|
self.master.make_view()
|
|
|
|
return None
|
|
|
|
elif key == "?":
|
|
|
|
key = None
|
|
|
|
return urwid.ListBox.keypress(self, size, key)
|