aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/console
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2012-08-17 19:50:50 -0700
committerAldo Cortesi <aldo@corte.si>2012-08-17 19:50:50 -0700
commit5c80450ce7036c9bb010ec8240493b041de79642 (patch)
treef0d8198a5e1094be6ecf7cefe96aac95b26ea778 /libmproxy/console
parenta66d018363e6d0c597577ed459308d4c80cbc2cc (diff)
parent3189d144a521fcc98695dd079fb3dd4304de2eee (diff)
downloadmitmproxy-5c80450ce7036c9bb010ec8240493b041de79642.tar.gz
mitmproxy-5c80450ce7036c9bb010ec8240493b041de79642.tar.bz2
mitmproxy-5c80450ce7036c9bb010ec8240493b041de79642.zip
Merge pull request #62 from slam/amf
Optional AMF decoding support
Diffstat (limited to 'libmproxy/console')
-rw-r--r--libmproxy/console/contentview.py28
-rw-r--r--libmproxy/console/help.py4
2 files changed, 30 insertions, 2 deletions
diff --git a/libmproxy/console/contentview.py b/libmproxy/console/contentview.py
index 2443c188..4efbb2b1 100644
--- a/libmproxy/console/contentview.py
+++ b/libmproxy/console/contentview.py
@@ -20,6 +20,7 @@ VIEW_RAW = 7
VIEW_HEX = 8
VIEW_HTML = 9
VIEW_OUTLINE = 10
+VIEW_AMF = 11
VIEW_NAMES = {
VIEW_AUTO: "Auto",
@@ -36,7 +37,7 @@ VIEW_NAMES = {
}
-VIEW_PROMPT = (
+VIEW_PROMPT = [
("auto detect", "a"),
("hex", "e"),
("html", "h"),
@@ -48,7 +49,7 @@ VIEW_PROMPT = (
("multipart", "m"),
("urlencoded", "u"),
("xml", "x"),
-)
+]
VIEW_SHORTCUTS = {
"a": VIEW_AUTO,
@@ -285,6 +286,10 @@ def view_image(hdrs, content, limit):
)
return "%s image"%img.format, fmt
+def view_amf(hdrs, content, limit):
+ s = utils.pretty_amf(content)
+ if s:
+ return "AMF", _view_text(s[:limit], len(s), limit)
PRETTY_FUNCTION_MAP = {
VIEW_XML: view_xml,
@@ -344,3 +349,22 @@ def get_content_view(viewmode, hdrItems, content, limit):
else:
msg.append(ret[0])
return " ".join(msg), ret[1]
+
+
+#
+# Enable optional decoding methods at runtime
+#
+
+# AMF decoding requires pyamf
+try:
+ import pyamf
+
+ VIEW_SHORTCUTS["f"] = VIEW_AMF
+ VIEW_PROMPT.append(("amf", "f"))
+ VIEW_NAMES[VIEW_AMF] = "AMF"
+ CONTENT_TYPES_MAP["application/x-amf"] = VIEW_AMF
+ PRETTY_FUNCTION_MAP[VIEW_AMF] = view_amf
+except ImportError:
+ pass
+
+
diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py
index 64428fcc..e278e763 100644
--- a/libmproxy/console/help.py
+++ b/libmproxy/console/help.py
@@ -83,6 +83,10 @@ class HelpView(urwid.ListBox):
common.highlight_key("xml", "x") +
[("text", ": XML")]
),
+ (None,
+ common.highlight_key("amf", "f") +
+ [("text", ": AMF (requires PyAMF)")]
+ ),
("o", "toggle options:"),
(None,
common.highlight_key("anticache", "a") +