diff options
Diffstat (limited to 'libmproxy')
-rw-r--r-- | libmproxy/console.py | 17 | ||||
-rw-r--r-- | libmproxy/utils.py | 7 |
2 files changed, 22 insertions, 2 deletions
diff --git a/libmproxy/console.py b/libmproxy/console.py index 46aacab6..09149186 100644 --- a/libmproxy/console.py +++ b/libmproxy/console.py @@ -924,6 +924,17 @@ class ConsoleMaster(flow.FlowMaster): break self._trailer(sum(len(i) for i in lines), txt) + def _view_conn_urlencoded(self, lines, txt): + txt.append(urwid.Text(("highlight", "URLencoded data:\n"))) + txt.append( + urwid.Text( + format_keyvals( + [(k+":", v) for (k, v) in lines], + key = "header", + val = "text" + ) + ) + ) def _find_pretty_view(self, content, hdrItems, txt): ctype = None @@ -931,9 +942,13 @@ class ConsoleMaster(flow.FlowMaster): if i[0] == "content-type": ctype = i[1] break + if ctype and "x-www-form-urlencoded" in ctype: + data = utils.urldecode(content) + if data: + return self._view_conn_urlencoded(data, txt) if utils.isXML(content): return self._view_conn_xmlish(content, txt) - if ctype and "application/json" in ctype: + elif ctype and "application/json" in ctype: lines = utils.pretty_json(content) if lines: return self._view_conn_json(lines, txt) diff --git a/libmproxy/utils.py b/libmproxy/utils.py index 38fc6107..04a145d5 100644 --- a/libmproxy/utils.py +++ b/libmproxy/utils.py @@ -12,7 +12,8 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -import re, os, subprocess, datetime, textwrap, errno, sys, time, functools, copy +import re, os, subprocess, datetime, textwrap, errno +import time, functools, copy, cgi import json CERT_SLEEP_TIME = 1 @@ -120,6 +121,10 @@ def pretty_json(s): return json.dumps(p, sort_keys=True, indent=4).split("\n") +def urldecode(s): + return cgi.parse_qsl(s) + + def hexdump(s): """ Returns a set of typles: |