Esempio n. 1
0
    def flowtext(self):
        text = []

        title = urwid.Text("Flow details")
        title = urwid.Padding(title, align="left", width=("relative", 100))
        title = urwid.AttrWrap(title, "heading")
        text.append(title)

        if self.flow.response:
            c = self.flow.response.cert
            if c:
                text.append(urwid.Text([("head", "Server Certificate:")]))
                parts = [
                    ["Type", "%s, %s bits"%c.keyinfo],
                    ["SHA1 digest", c.digest("sha1")],
                    ["Valid to", str(c.notafter)],
                    ["Valid from", str(c.notbefore)],
                    ["Serial", str(c.serial)],
                ]

                parts.append(
                    [
                        "Subject",
                        urwid.BoxAdapter(
                            urwid.ListBox(common.format_keyvals(c.subject, key="highlight", val="text")),
                            len(c.subject)
                        )
                    ]
                )

                parts.append(
                    [
                        "Issuer",
                        urwid.BoxAdapter(
                            urwid.ListBox(common.format_keyvals(c.issuer, key="highlight", val="text")),
                            len(c.issuer)
                        )
                    ]
                )

                if c.altnames:
                    parts.append(
                        [
                            "Alt names",
                            ", ".join(c.altnames)
                        ]
                    )
                text.extend(common.format_keyvals(parts, key="key", val="text", indent=4))

        if self.flow.request.client_conn:
            text.append(urwid.Text([("head", "Client Connection:")]))
            cc = self.flow.request.client_conn
            parts = [
                ["Address", "%s:%s"%tuple(cc.address)],
                ["Requests", "%s"%cc.requestcount],
                ["Closed", "%s"%cc.close],
            ]
            text.extend(common.format_keyvals(parts, key="key", val="text", indent=4))

        return text
    def flowtext(self):
        text = []

        title = urwid.Text("Flow details")
        title = urwid.Padding(title, align="left", width=("relative", 100))
        title = urwid.AttrWrap(title, "heading")
        text.append(title)

        if self.flow.response:
            c = self.flow.response.cert
            if c:
                text.append(urwid.Text([("head", "Server Certificate:")]))
                parts = [
                    ["Type", "%s, %s bits" % c.keyinfo],
                    ["SHA1 digest", c.digest("sha1")],
                    ["Valid to", str(c.notafter)],
                    ["Valid from", str(c.notbefore)],
                    ["Serial", str(c.serial)],
                ]

                parts.append([
                    "Subject",
                    urwid.BoxAdapter(
                        urwid.ListBox(
                            common.format_keyvals(c.subject,
                                                  key="highlight",
                                                  val="text")), len(c.subject))
                ])

                parts.append([
                    "Issuer",
                    urwid.BoxAdapter(
                        urwid.ListBox(
                            common.format_keyvals(c.issuer,
                                                  key="highlight",
                                                  val="text")), len(c.issuer))
                ])

                if c.altnames:
                    parts.append(["Alt names", ", ".join(c.altnames)])
                text.extend(
                    common.format_keyvals(parts,
                                          key="key",
                                          val="text",
                                          indent=4))

        if self.flow.request.client_conn:
            text.append(urwid.Text([("head", "Client Connection:")]))
            cc = self.flow.request.client_conn
            parts = [
                ["Address", "%s:%s" % tuple(cc.address)],
                ["Requests", "%s" % cc.requestcount],
                ["Closed", "%s" % cc.close],
            ]
            text.extend(
                common.format_keyvals(parts, key="key", val="text", indent=4))

        return text
Esempio n. 3
0
 def __call__(self, hdrs, content, limit):
     try:
         img = Image.open(cStringIO.StringIO(content))
     except IOError:
         return None
     parts = [
         ("Format", str(img.format_description)),
         ("Size", "%s x %s px"%img.size),
         ("Mode", str(img.mode)),
     ]
     for i in sorted(img.info.keys()):
         if i != "exif":
             parts.append(
                 (str(i), str(img.info[i]))
             )
     if hasattr(img, "_getexif"):
         ex = img._getexif()
         if ex:
             for i in sorted(ex.keys()):
                 tag = TAGS.get(i, i)
                 parts.append(
                     (str(tag), str(ex[i]))
                 )
     clean = []
     for i in parts:
         clean.append([utils.cleanBin(i[0]), utils.cleanBin(i[1])])
     fmt = common.format_keyvals(
             clean,
             key = "header",
             val = "text"
         )
     return "%s image"%img.format, fmt
Esempio n. 4
0
def _mkhelp():
    text = []
    keys = [
        ("A", "accept all intercepted flows"),
        ("a", "accept this intercepted flow"),
        ("b", "save request/response body"),
        ("d", "delete flow"),
        ("D", "duplicate flow"),
        ("e", "edit request/response"),
        ("f", "load full body data"),
        ("J", "dump this flow to JSON"),
        ("m", "change body display mode for this entity"),
            (None,
                common.highlight_key("automatic", "a") +
                [("text", ": automatic detection")]
            ),
            (None,
                common.highlight_key("hex", "h") +
                [("text", ": Hex")]
            ),
            (None,
                common.highlight_key("image", "i") +
                [("text", ": Image")]
            ),
            (None,
                common.highlight_key("javascript", "j") +
                [("text", ": JavaScript")]
            ),
            (None,
                common.highlight_key("json", "s") +
                [("text", ": JSON")]
            ),
            (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")]
            ),
        ("M", "change default body display mode"),
        ("p", "previous flow"),
        ("r", "replay request"),
        ("V", "revert changes to request"),
        ("v", "view body in external viewer"),
        ("w", "save all flows matching current limit"),
        ("W", "save this flow"),
        ("x", "delete body"),
        ("X", "view flow details"),
        ("z", "encode/decode a request/response"),
        ("tab", "toggle request/response view"),
        ("space", "next flow"),
        ("|", "run script on this flow"),
    ]
    text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
    return text
Esempio n. 5
0
    def conn_text(self, conn):
        txt = common.format_keyvals([(h + ":", v) for (h, v) in conn.headers.lst], key="header", val="text")
        if conn.content is not None:
            override = self.state.get_flow_setting(self.flow, (self.state.view_flow_mode, "prettyview"))
            viewmode = self.state.default_body_view if override is None else override

            if conn.content == flow.CONTENT_MISSING:
                msg, body = "", [urwid.Text([("error", "[content missing]")])]
            else:
                msg, body = self.content_view(viewmode, conn)

            cols = [urwid.Text([("heading", msg)])]
            if override is not None:
                cols.append(
                    urwid.Text(
                        [" ", ("heading", "["), ("heading_key", "m"), ("heading", (":%s]" % viewmode.name))],
                        align="right",
                    )
                )
            title = urwid.AttrWrap(urwid.Columns(cols), "heading")
            txt.append(title)
            txt.extend(body)
        elif conn.content == flow.CONTENT_MISSING:
            pass
        return urwid.ListBox(txt)
Esempio n. 6
0
    def __call__(self, hdrs, content, limit):
        v = hdrs.get_first("content-type")
        if v:
            v = utils.parse_content_type(v)
            if not v:
                return
            boundary = v[2].get("boundary")
            if not boundary:
                return

            rx = re.compile(r'\bname="([^"]+)"')
            keys = []
            vals = []

            for i in content.split("--" + boundary):
                parts = i.splitlines()
                if len(parts) > 1 and parts[0][0:2] != "--":
                    match = rx.search(parts[1])
                    if match:
                        keys.append(match.group(1) + ":")
                        vals.append(utils.cleanBin(
                            "\n".join(parts[3+parts[2:].index(""):])
                        ))
            r = [
                urwid.Text(("highlight", "Form data:\n")),
            ]
            r.extend(common.format_keyvals(
                zip(keys, vals),
                key = "header",
                val = "text"
            ))
            return "Multipart form", r
Esempio n. 7
0
def _mkhelp():
    text = []
    keys = [
        ("A", "accept all intercepted flows"),
        ("a", "accept this intercepted flow"),
        ("b", "save request/response body"),
        ("d", "delete flow"),
        ("D", "duplicate flow"),
        ("e", "edit request/response"),
        ("m", "change body display mode"),
            (None,
                common.highlight_key("raw", "r") +
                [("text", ": raw data")]
            ),
            (None,
                common.highlight_key("pretty", "p") +
                [("text", ": pretty-print XML, HTML and JSON")]
            ),
            (None,
                common.highlight_key("hex", "h") +
                [("text", ": hex dump")]
            ),
        ("p", "previous flow"),
        ("r", "replay request"),
        ("V", "revert changes to request"),
        ("v", "view body in external viewer"),
        ("w", "save all flows matching current limit"),
        ("W", "save this flow"),
        ("z", "encode/decode a request/response"),
        ("tab", "toggle request/response view"),
        ("space", "next flow"),
        ("|", "run script on this flow"),
    ]
    text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
    return text
Esempio n. 8
0
 def make_help(self):
     text = []
     text.append(urwid.Text([("text", "Editor control:\n")]))
     keys = [
         ("A", "insert row before cursor"),
         ("a", "add row after cursor"),
         ("d", "delete row"),
         ("e", "spawn external editor on current field"),
         ("q", "return to flow view"),
         ("r", "read value from file"),
         ("R", "read unescaped value from file"),
         ("esc", "return to flow view/exit field edit mode"),
         ("tab", "next field"),
         ("enter", "edit field"),
     ]
     text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
     text.append(
         urwid.Text(
             [
                 "\n",
                 ("text", "Values are escaped Python-style strings.\n"),
             ]
         )
     )
     return text
Esempio n. 9
0
 def __call__(self, hdrs, content, limit):
     lines = utils.urldecode(content)
     if lines:
         body = common.format_keyvals([(k + ":", v) for (k, v) in lines],
                                      key="header",
                                      val="text")
         return "URLEncoded form", body
Esempio n. 10
0
def _mkhelp():
    text = []
    keys = [
        ("A", "accept all intercepted flows"),
        ("a", "accept this intercepted flow"),
        ("b", "save request/response body"),
        ("d", "delete flow"),
        ("D", "duplicate flow"),
        ("e", "edit request/response"),
        ("m", "change body display mode"),
            (None,
                common.highlight_key("raw", "r") +
                [("text", ": raw data")]
            ),
            (None,
                common.highlight_key("pretty", "p") +
                [("text", ": pretty-print XML, HTML and JSON")]
            ),
            (None,
                common.highlight_key("hex", "h") +
                [("text", ": hex dump")]
            ),
        ("p", "previous flow"),
        ("r", "replay request"),
        ("V", "revert changes to request"),
        ("v", "view body in external viewer"),
        ("w", "save all flows matching current limit"),
        ("W", "save this flow"),
        ("z", "encode/decode a request/response"),
        ("tab", "toggle request/response view"),
        ("space", "next flow"),
        ("|", "run script on this flow"),
    ]
    text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
    return text
Esempio n. 11
0
    def _cached_conn_text(self, e, content, hdrItems, viewmode):
        hdr = []
        hdr.extend(
            common.format_keyvals(
                [(h+":", v) for (h, v) in hdrItems],
                key = "header",
                val = "text"
            )
        )
        hdr.append("\n")

        txt = [urwid.Text(hdr)]
        if content:
            if viewmode == common.VIEW_BODY_HEX:
                txt.extend(self._view_conn_binary(content))
            elif viewmode == common.VIEW_BODY_PRETTY:
                if e:
                    decoded = encoding.decode(e, content)
                    if decoded:
                        content = decoded
                        if e and e != "identity":
                            txt.append(
                                urwid.Text(("highlight", "Decoded %s data:\n"%e))
                            )
                txt.extend(self._find_pretty_view(content, hdrItems))
            else:
                txt.extend(self._view_conn_raw(content))
        return urwid.ListBox(txt)
Esempio n. 12
0
    def conn_text(self, conn):
        txt = common.format_keyvals([(h + ":", v)
                                     for (h, v) in conn.headers.lst],
                                    key="header",
                                    val="text")
        if conn.content is not None:
            override = self.state.get_flow_setting(
                self.flow,
                (self.state.view_flow_mode, "prettyview"),
            )
            viewmode = self.state.default_body_view if override is None else override

            if conn.content == flow.CONTENT_MISSING:
                msg, body = "", [urwid.Text([("error", "[content missing]")])]
            else:
                msg, body = self.content_view(viewmode, conn)

            cols = [urwid.Text([
                ("heading", msg),
            ])]
            if override is not None:
                cols.append(
                    urwid.Text([
                        " ",
                        ('heading', "["),
                        ('heading_key', "m"),
                        ('heading', (":%s]" % viewmode.name)),
                    ],
                               align="right"))
            title = urwid.AttrWrap(urwid.Columns(cols), "heading")
            txt.append(title)
            txt.extend(body)
        elif conn.content == flow.CONTENT_MISSING:
            pass
        return urwid.ListBox(txt)
Esempio n. 13
0
    def __call__(self, hdrs, content, limit):
        v = hdrs.get_first("content-type")
        if v:
            v = utils.parse_content_type(v)
            if not v:
                return
            boundary = v[2].get("boundary")
            if not boundary:
                return

            rx = re.compile(r'\bname="([^"]+)"')
            keys = []
            vals = []

            for i in content.split("--" + boundary):
                parts = i.splitlines()
                if len(parts) > 1 and parts[0][0:2] != "--":
                    match = rx.search(parts[1])
                    if match:
                        keys.append(match.group(1) + ":")
                        vals.append(
                            netlib.utils.cleanBin("\n".join(
                                parts[3 + parts[2:].index(""):])))
            r = [
                urwid.Text(("highlight", "Form data:\n")),
            ]
            r.extend(
                common.format_keyvals(zip(keys, vals),
                                      key="header",
                                      val="text"))
            return "Multipart form", r
Esempio n. 14
0
 def __call__(self, hdrs, content, limit):
     try:
         img = Image.open(cStringIO.StringIO(content))
     except IOError:
         return None
     parts = [
         ("Format", str(img.format_description)),
         ("Size", "%s x %s px" % img.size),
         ("Mode", str(img.mode)),
     ]
     for i in sorted(img.info.keys()):
         if i != "exif":
             parts.append((str(i), str(img.info[i])))
     if hasattr(img, "_getexif"):
         ex = img._getexif()
         if ex:
             for i in sorted(ex.keys()):
                 tag = TAGS.get(i, i)
                 parts.append((str(tag), str(ex[i])))
     clean = []
     for i in parts:
         clean.append(
             [netlib.utils.cleanBin(i[0]),
              netlib.utils.cleanBin(i[1])])
     fmt = common.format_keyvals(clean, key="header", val="text")
     return "%s image" % img.format, fmt
Esempio n. 15
0
 def _cached_conn_text(self, content, hdrItems, viewmode, pretty_type):
     txt = common.format_keyvals(
             [(h+":", v) for (h, v) in hdrItems],
             key = "header",
             val = "text"
         )
     if content:
         msg, body = contentview.get_content_view(viewmode, pretty_type, hdrItems, content)
         title = urwid.AttrWrap(urwid.Columns([
             urwid.Text(
                 [
                     ("heading", msg),
                 ]
             ),
             urwid.Text(
                 [
                     " ",
                     ('heading', "["),
                     ('heading_key', "m"),
                     ('heading', (":%s]"%contentview.CONTENT_VIEWS[self.master.state.view_body_mode])),
                 ],
                 align="right"
             ),
         ]), "heading")
         txt.append(title)
         txt.extend(body)
     return urwid.ListBox(txt)
Esempio n. 16
0
def view_urlencoded(hdrs, content):
    lines = utils.urldecode(content)
    if lines:
        body = common.format_keyvals(
                    [(k+":", v) for (k, v) in lines],
                    key = "header",
                    val = "text"
               )
        return "URLEncoded form", body
Esempio n. 17
0
 def __call__(self, hdrs, content, limit):
     lines = utils.urldecode(content)
     if lines:
         body = common.format_keyvals(
                     [(k+":", v) for (k, v) in lines],
                     key = "header",
                     val = "text"
                )
         return "URLEncoded form", body
Esempio n. 18
0
 def _view_conn_urlencoded(self, lines):
     kv = common.format_keyvals(
             [(k+":", v) for (k, v) in lines],
             key = "header",
             val = "text"
          )
     return [
                 urwid.Text(("highlight", "URLencoded data:\n")),
                 urwid.Text(kv)
             ]
Esempio n. 19
0
 def _view_conn_urlencoded(self, lines):
     return  [
                 urwid.Text(
                     common.format_keyvals(
                             [(k+":", v) for (k, v) in lines],
                             key = "header",
                             val = "text"
                     )
                 )
             ]
Esempio n. 20
0
 def make_help(self):
     h = GridEditor.make_help(self)
     text = []
     text.append(urwid.Text([("text", "Special keys:\n")]))
     keys = [
         ("U", "add User-Agent header"),
     ]
     text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
     text.append(urwid.Text([("text", "\n")]))
     text.extend(h)
     return text
Esempio n. 21
0
 def make_help(self):
     h = GridEditor.make_help(self)
     text = []
     text.append(urwid.Text([("text", "Special keys:\n")]))
     keys = [
         ("U", "add User-Agent header"),
     ]
     text.extend(
         common.format_keyvals(keys, key="key", val="text", indent=4))
     text.append(urwid.Text([("text", "\n")]))
     text.extend(h)
     return text
Esempio n. 22
0
def _mkhelp():
    text = []
    keys = [
        ("A", "insert row before cursor"),
        ("a", "add row after cursor"),
        ("d", "delete row"),
        ("e", "spawn external editor on current field"),
        ("q", "return to flow view"),
        ("esc", "return to flow view/exit field edit mode"),
        ("tab", "next field"),
        ("enter", "edit field"),
    ]
    text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
    return text
Esempio n. 23
0
def _mkhelp():
    text = []
    keys = [
        ("A", "insert row before cursor"),
        ("a", "add row after cursor"),
        ("d", "delete row"),
        ("e", "spawn external editor on current field"),
        ("q", "return to flow view"),
        ("esc", "return to flow view/exit field edit mode"),
        ("tab", "next field"),
        ("enter", "edit field"),
    ]
    text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
    return text
Esempio n. 24
0
    def _view_conn_formdata(self, content, boundary):
        rx = re.compile(r'\bname="([^"]+)"')
        keys = []
        vals = []

        for i in content.split("--" + boundary):
            parts = i.splitlines()
            if len(parts) > 1 and parts[0][0:2] != "--":
                match = rx.search(parts[1])
                if match:
                    keys.append(match.group(1) + ":")
                    vals.append(utils.cleanBin("\n".join(parts[3 + parts[2:].index("") :])))
        r = [urwid.Text(("highlight", "Form data:\n"))]
        r.extend(common.format_keyvals(zip(keys, vals), key="header", val="text"))
        return r
Esempio n. 25
0
 def conn_text_raw(self, conn):
     """
         Based on a request/response, conn, returns the elements for
         display.
     """
     headers = common.format_keyvals([(h + ":", v)
                                      for (h, v) in conn.headers.lst],
                                     key="header",
                                     val="text")
     if conn.content is not None:
         override = self.override_get()
         viewmode = self.viewmode_get(override)
         msg, body = self.cont_view_handle_missing(conn, viewmode)
     elif conn.content == flow.CONTENT_MISSING:
         pass
     return headers, msg, body
Esempio n. 26
0
    def _cached_conn_text(self, e, content, hdrItems, viewmode):
        hdr = []
        hdr.extend(
            common.format_keyvals(
                [(h+":", v) for (h, v) in hdrItems],
                key = "header",
                val = "text"
            )
        )
        txt = [urwid.Text(hdr)]
        if content:
            msg = ""
            if viewmode == common.VIEW_BODY_HEX:
                body = self._view_conn_binary(content)
            elif viewmode == common.VIEW_BODY_PRETTY:
                emsg = ""
                if e:
                    decoded = encoding.decode(e, content)
                    if decoded:
                        content = decoded
                        if e and e != "identity":
                            emsg = "[decoded %s]"%e
                msg, body = self._find_pretty_view(content, hdrItems)
                if emsg:
                    msg = emsg + " " + msg
            else:
                body = self._view_conn_raw(content)

            title = urwid.AttrWrap(urwid.Columns([
                urwid.Text(
                    [
                        ("statusbar", msg),
                    ]
                ),
                urwid.Text(
                    [
                        " ",
                        ('statusbar_text', "["),
                        ('statusbar_key', "m"),
                        ('statusbar_text', (":%s]"%common.BODY_VIEWS[self.master.state.view_body_mode])),
                    ],
                    align="right"
                ),
            ]), "statusbar")
            txt.append(title)
            txt.extend(body)
        return urwid.ListBox(txt)
Esempio n. 27
0
 def conn_text_raw(self, conn):
     """
         Based on a request/response, conn, returns the elements for
         display.
     """
     headers = common.format_keyvals(
             [(h+":", v) for (h, v) in conn.headers.lst],
             key = "header",
             val = "text"
         )
     if conn.content is not None:
         override = self.override_get()
         viewmode = self.viewmode_get(override)
         msg, body = self.cont_view_handle_missing(conn, viewmode)
     elif conn.content == flow.CONTENT_MISSING:
         pass
     return headers, msg, body
Esempio n. 28
0
    def _cached_conn_text(self, e, content, hdrItems, viewmode):
        txt = common.format_keyvals(
                [(h+":", v) for (h, v) in hdrItems],
                key = "header",
                val = "text"
            )
        if content:
            msg = ""
            if viewmode == common.VIEW_BODY_HEX:
                body = self._view_flow_binary(content)
            elif viewmode == common.VIEW_BODY_PRETTY:
                emsg = ""
                if e:
                    decoded = encoding.decode(e, content)
                    if decoded:
                        content = decoded
                        if e and e != "identity":
                            emsg = "[decoded %s]"%e
                msg, body = self._find_pretty_view(content, hdrItems)
                if emsg:
                    msg = emsg + " " + msg
            else:
                body = self._view_flow_raw(content)

            title = urwid.AttrWrap(urwid.Columns([
                urwid.Text(
                    [
                        ("heading", msg),
                    ]
                ),
                urwid.Text(
                    [
                        " ",
                        ('heading', "["),
                        ('heading_key', "m"),
                        ('heading', (":%s]"%common.BODY_VIEWS[self.master.state.view_body_mode])),
                    ],
                    align="right"
                ),
            ]), "heading")
            txt.append(title)
            txt.extend(body)
        return urwid.ListBox(txt)
Esempio n. 29
0
def _mkhelp():
    text = []
    keys = [
        ("A", "accept all intercepted flows"),
        ("a", "accept this intercepted flow"),
        ("b", "save request/response body"),
        ("d", "delete flow"),
        ("D", "duplicate flow"),
        ("e", "edit request/response"),
        ("f", "load full body data"),
        ("m", "change body display mode for this entity"),
        (None, common.highlight_key("automatic", "a") +
         [("text", ": automatic detection")]),
        (None, common.highlight_key("hex", "e") + [("text", ": Hex")]),
        (None, common.highlight_key("html", "h") + [("text", ": HTML")]),
        (None, common.highlight_key("image", "i") + [("text", ": Image")]),
        (None,
         common.highlight_key("javascript", "j") + [("text", ": JavaScript")]),
        (None, common.highlight_key("json", "s") + [("text", ": JSON")]),
        (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")]),
        ("M", "change default body display mode"),
        ("p", "previous flow"),
        ("r", "replay request"),
        ("V", "revert changes to request"),
        ("v", "view body in external viewer"),
        ("w", "save all flows matching current limit"),
        ("W", "save this flow"),
        ("x", "delete body"),
        ("X", "view flow details"),
        ("z", "encode/decode a request/response"),
        ("tab", "toggle request/response view"),
        ("space", "next flow"),
        ("|", "run script on this flow"),
        ("/", "search in response body (case sensitive)"),
        ("n", "repeat previous search"),
    ]
    text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
    return text
Esempio n. 30
0
def _mkhelp():
    text = []
    keys = [
        ("A", "accept all intercepted connections"),
        ("a", "accept this intercepted connection"),
        ("C", "clear connection list or eventlog"),
        ("d", "delete connection from view"),
        ("l", "set limit filter pattern"),
        ("L", "load saved flows"),
        ("r", "replay request"),
        ("R", "revert changes to request"),
        ("v", "toggle eventlog"),
        ("w", "save all flows matching current limit"),
        ("W", "save this flow"),
        ("X", "kill and delete connection, even if it's mid-intercept"),
        ("tab", "tab between eventlog and connection list"),
        ("enter", "view connection"),
        ("|", "run script on this flow"),
    ]
    text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
    return text
Esempio n. 31
0
def _mkhelp():
    text = []
    keys = [
        ("A", "accept all intercepted flows"),
        ("a", "accept this intercepted flow"),
        ("C", "clear flow list or eventlog"),
        ("d", "delete flow"),
        ("D", "duplicate flow"),
        ("e", "toggle eventlog"),
        ("l", "set limit filter pattern"),
        ("L", "load saved flows"),
        ("r", "replay request"),
        ("V", "revert changes to request"),
        ("w", "save flows "),
        ("W", "stream flows to file"),
        ("X", "kill and delete flow, even if it's mid-intercept"),
        ("tab", "tab between eventlog and flow list"),
        ("enter", "view flow"),
        ("|", "run script on this flow"),
    ]
    text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
    return text
Esempio n. 32
0
def _mkhelp():
    text = []
    keys = [
        ("A", "accept all intercepted flows"),
        ("a", "accept this intercepted flows"),
        ("C", "clear flow list or eventlog"),
        ("d", "delete flow"),
        ("D", "duplicate flow"),
        ("e", "toggle eventlog"),
        ("l", "set limit filter pattern"),
        ("L", "load saved flows"),
        ("r", "replay request"),
        ("V", "revert changes to request"),
        ("w", "save all flows matching current limit"),
        ("W", "save this flow"),
        ("X", "kill and delete flow, even if it's mid-intercept"),
        ("tab", "tab between eventlog and flow list"),
        ("enter", "view flow"),
        ("|", "run script on this flow"),
    ]
    text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
    return text
Esempio n. 33
0
    def conn_text(self, conn):
        txt = common.format_keyvals(
                [(h+":", v) for (h, v) in conn.headers.lst],
                key = "header",
                val = "text"
            )
        if conn.content:
            override = self.state.get_flow_setting(
                self.flow,
                (self.state.view_flow_mode, "prettyview"),
            )
            viewmode = self.state.default_body_view if override is None else override

            msg, body = self.content_view(viewmode, conn)

            cols = [
                urwid.Text(
                    [
                        ("heading", msg),
                    ]
                )
            ]
            if override is not None:
                cols.append(
                    urwid.Text(
                        [
                            " ",
                            ('heading', "["),
                            ('heading_key', "m"),
                            ('heading', (":%s]"%contentview.VIEW_NAMES[viewmode])),
                        ],
                        align="right"
                    )
                )
            title = urwid.AttrWrap(urwid.Columns(cols), "heading")
            txt.append(title)
            txt.extend(body)
        return urwid.ListBox(txt)
Esempio n. 34
0
 def make_help(self):
     text = []
     text.append(urwid.Text([("text", "Editor control:\n")]))
     keys = [
         ("A", "insert row before cursor"),
         ("a", "add row after cursor"),
         ("d", "delete row"),
         ("e", "spawn external editor on current field"),
         ("q", "return to flow view"),
         ("r", "read value from file"),
         ("R", "read unescaped value from file"),
         ("esc", "return to flow view/exit field edit mode"),
         ("tab", "next field"),
         ("enter", "edit field"),
     ]
     text.extend(
         common.format_keyvals(keys, key="key", val="text", indent=4))
     text.append(
         urwid.Text([
             "\n",
             ("text", "Values are escaped Python-style strings.\n"),
         ]))
     return text
Esempio n. 35
0
    def _view_flow_formdata(self, content, boundary):
        rx = re.compile(r'\bname="([^"]+)"')
        keys = []
        vals = []

        for i in content.split("--" + boundary):
            parts = i.splitlines()
            if len(parts) > 1 and parts[0][0:2] != "--":
                match = rx.search(parts[1])
                if match:
                    keys.append(match.group(1) + ":")
                    vals.append(utils.cleanBin(
                        "\n".join(parts[3+parts[2:].index(""):])
                    ))
        r = [
            urwid.Text(("highlight", "Form data:\n")),
        ]
        r.extend(common.format_keyvals(
            zip(keys, vals),
            key = "header",
            val = "text"
        ))
        return r
Esempio n. 36
0
 def _view_flow_urlencoded(self, lines):
     return common.format_keyvals(
                 [(k+":", v) for (k, v) in lines],
                 key = "header",
                 val = "text"
            )
Esempio n. 37
0
    def helptext(self):
        text = []
        text.append(urwid.Text([("head", "Keys for this view:\n")]))
        text.extend(self.help_context)

        text.append(urwid.Text([("head", "\n\nMovement:\n")]))
        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))

        text.append(urwid.Text([("head", "\n\nGlobal keys:\n")]))
        keys = [
            ("c", "client replay"),
            ("i", "set interception pattern"),
            ("o", "toggle options:"),
            (None, common.highlight_key("anticache", "a") +
             [("text", ": prevent cached responses")]),
            (None, common.highlight_key("anticomp", "c") +
             [("text", ": prevent compressed responses")]),
            (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")]),
            ("q", "quit / return to flow list"),
            ("Q", "quit without confirm prompt"),
            ("R", "set reverse proxy mode"),
            ("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))

        text.append(urwid.Text([("head", "\n\nFilter expressions:\n")]))
        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))

        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"),
            ]))
        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))
        return text
Esempio n. 38
0
    def helptext(self):
        text = []
        text.append(urwid.Text([("head", "Keys for this view:\n")]))
        text.extend(self.help_context)

        text.append(urwid.Text([("head", "\n\nMovement:\n")]))
        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))

        text.append(urwid.Text([("head", "\n\nGlobal keys:\n")]))
        keys = [
            ("c", "client replay"),
            ("i", "set interception pattern"),

            ("o", "toggle options:"),
            (None,
                common.highlight_key("anticache", "a") +
                [("text", ": prevent cached responses")]
            ),
            (None,
                common.highlight_key("anticomp", "c") +
                [("text", ": prevent compressed responses")]
            ),
            (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")]
            ),

            ("q", "quit / return to flow list"),
            ("Q", "quit without confirm prompt"),
            ("P", "set reverse proxy mode"),
            ("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))

        text.append(urwid.Text([("head", "\n\nFilter expressions:\n")]))
        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))

        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"),
               ]
            )
        )
        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))
        return text
Esempio n. 39
0
    def helptext(self):
        text = []
        text.append(urwid.Text([("head", "This view:\n")]))
        text.extend(self.help_context)

        text.append(urwid.Text([("head", "\n\nMovement:\n")]))
        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))

        text.append(urwid.Text([("head", "\n\nGlobal keys:\n")]))
        keys = [
            ("c", "client replay"),
            ("H", "edit global header set patterns"),
            ("i", "set interception pattern"),
            ("M", "change global default display mode"),
                (None,
                    common.highlight_key("automatic", "a") +
                    [("text", ": automatic detection")]
                ),
                (None,
                    common.highlight_key("hex", "e") +
                    [("text", ": Hex")]
                ),
                (None,
                    common.highlight_key("html", "h") +
                    [("text", ": HTML")]
                ),
                (None,
                    common.highlight_key("image", "i") +
                    [("text", ": Image")]
                ),
                (None,
                    common.highlight_key("javascript", "j") +
                    [("text", ": JavaScript")]
                ),
                (None,
                    common.highlight_key("json", "s") +
                    [("text", ": JSON")]
                ),
                (None,
                    common.highlight_key("css", "c") +
                    [("text", ": CSS")]
                ),
                (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")]
                ),
                (None,
                    common.highlight_key("amf", "f") +
                    [("text", ": AMF (requires PyAMF)")]
                ),
            ("o", "toggle options:"),
                (None,
                    common.highlight_key("anticache", "a") +
                    [("text", ": prevent cached responses")]
                ),
                (None,
                    common.highlight_key("anticomp", "c") +
                    [("text", ": prevent compressed responses")]
                ),
                (None,
                    common.highlight_key("showhost", "h") +
                    [("text", ": use Host header for URL display")]
                ),
                (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")]
                ),

            ("q", "quit / return to flow list"),
            ("Q", "quit without confirm prompt"),
            ("R", "edit replacement patterns"),
            ("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))

        text.append(urwid.Text([("head", "\n\nFilter expressions:\n")]))
        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))

        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"),
               ]
            )
        )
        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))
        return text
Esempio n. 40
0
 def _view_flow_urlencoded(self, lines):
     return common.format_keyvals(
                 [(k+":", v) for (k, v) in lines],
                 key = "header",
                 val = "text"
            )