aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/console
diff options
context:
space:
mode:
Diffstat (limited to 'libmproxy/console')
-rw-r--r--libmproxy/console/contentview.py39
-rw-r--r--libmproxy/console/flowview.py10
-rw-r--r--libmproxy/console/help.py6
3 files changed, 49 insertions, 6 deletions
diff --git a/libmproxy/console/contentview.py b/libmproxy/console/contentview.py
index 2b46064a..53841c73 100644
--- a/libmproxy/console/contentview.py
+++ b/libmproxy/console/contentview.py
@@ -12,7 +12,7 @@ import netlib.utils
import common
from .. import utils, encoding, flow
from ..contrib import jsbeautifier, html2text
-
+import subprocess
try:
import pyamf
from pyamf import remoting, flex
@@ -137,7 +137,7 @@ class ViewXML:
class ViewJSON:
name = "JSON"
- prompt = ("json", "j")
+ prompt = ("json", "s")
content_types = ["application/json"]
def __call__(self, hdrs, content, limit):
lines = utils.pretty_json(content)
@@ -364,6 +364,38 @@ class ViewImage:
)
return "%s image"%img.format, fmt
+class ViewProtobuf:
+ """Human friendly view of protocol buffers
+ The view uses the protoc compiler to decode the binary
+ """
+
+ name = "Protocol Buffer"
+ prompt = ("protobuf", "p")
+ content_types = ["application/x-protobuf"]
+
+ @staticmethod
+ def is_available():
+ try:
+ p = subprocess.Popen(["protoc", "--version"], stdout=subprocess.PIPE)
+ out, _ = p.communicate()
+ return out.startswith("libprotoc")
+ except:
+ return False
+
+ def decode_protobuf(self, content):
+ # if Popen raises OSError, it will be caught in
+ # get_content_view and fall back to Raw
+ p = subprocess.Popen(['protoc', '--decode_raw'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ out, _ = p.communicate(input=content)
+ return out
+
+ def __call__(self, hdrs, content, limit):
+ decoded = self.decode_protobuf(content)
+ txt = _view_text(decoded[:limit], len(decoded), limit)
+ return "Protobuf", txt
views = [
ViewAuto(),
@@ -381,6 +413,9 @@ views = [
if pyamf:
views.append(ViewAMF())
+if ViewProtobuf.is_available():
+ views.append(ViewProtobuf())
+
content_types_map = {}
for i in views:
for ct in i.content_types:
diff --git a/libmproxy/console/flowview.py b/libmproxy/console/flowview.py
index 9bec7bc6..8932b912 100644
--- a/libmproxy/console/flowview.py
+++ b/libmproxy/console/flowview.py
@@ -34,10 +34,14 @@ def _mkhelp():
[("text", ": automatic detection")]
),
(None,
- common.highlight_key("hex", "h") +
+ common.highlight_key("hex", "e") +
[("text", ": Hex")]
),
(None,
+ common.highlight_key("html", "h") +
+ [("text", ": HTML")]
+ ),
+ (None,
common.highlight_key("image", "i") +
[("text", ": Image")]
),
@@ -201,7 +205,7 @@ class FlowView(common.WWrap):
def wrap_body(self, active, body):
parts = []
- if self.flow.intercepting and not self.flow.request.acked:
+ if self.flow.intercepting and not self.flow.request.reply.acked:
qt = "Request intercepted"
else:
qt = "Request"
@@ -210,7 +214,7 @@ class FlowView(common.WWrap):
else:
parts.append(self._tab(qt, "heading_inactive"))
- if self.flow.intercepting and self.flow.response and not self.flow.response.acked:
+ if self.flow.intercepting and self.flow.response and not self.flow.response.reply.acked:
st = "Response intercepted"
else:
st = "Response"
diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py
index 40f81955..de373083 100644
--- a/libmproxy/console/help.py
+++ b/libmproxy/console/help.py
@@ -57,10 +57,14 @@ class HelpView(urwid.ListBox):
[("text", ": automatic detection")]
),
(None,
- common.highlight_key("hex", "h") +
+ common.highlight_key("hex", "e") +
[("text", ": Hex")]
),
(None,
+ common.highlight_key("html", "h") +
+ [("text", ": HTML")]
+ ),
+ (None,
common.highlight_key("image", "i") +
[("text", ": Image")]
),