Esempio n. 1
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", "down, up"),
            ("h, l", "left, right (in some contexts)"),
            ("g, G", "go to beginning, end"),
            ("space", "page down"),
            ("pg up/down", "page up/down"),
            ("ctrl+b/ctrl+f", "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 = [
            ("i", "set interception pattern"),
            ("o", "options"),
            ("q", "quit / return to previous page"),
            ("Q", "quit without confirm prompt"),
            ("R", "replay of requests/responses from file"),
        ]
        text.extend(
            common.format_keyvals(keys, key="key", val="text", indent=4))

        text.append(urwid.Text([("head", "\n\nFilter expressions:\n")]))
        text.extend(
            common.format_keyvals(flowfilter.help,
                                  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. 2
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", "down, up"),
            ("h, l", "left, right (in some contexts)"),
            ("g, G", "go to beginning, end"),
            ("space", "page down"),
            ("pg up/down", "page up/down"),
            ("ctrl+b/ctrl+f", "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 = [
            ("i", "set interception pattern"),
            ("o", "options"),
            ("q", "quit / return to previous page"),
            ("Q", "quit without confirm prompt"),
            ("R", "replay of requests/responses from file"),
        ]
        text.extend(
            common.format_keyvals(keys, key="key", val="text", indent=4)
        )

        text.append(urwid.Text([("head", "\n\nFilter expressions:\n")]))
        text.extend(common.format_keyvals(flowfilter.help, 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. 3
0
def _mkhelp():
    text = []
    keys = [
        ("A", "accept all intercepted flows"),
        ("a", "accept this intercepted flow"),
        ("b", "save request/response body"),
        ("C", "clear flow list or eventlog"),
        ("d", "delete flow"),
        ("D", "duplicate flow"),
        ("E", "export"),
        ("e", "toggle eventlog"),
        ("F", "toggle follow flow list"),
        ("l", "set limit filter pattern"),
        ("L", "load saved flows"),
        ("m", "toggle flow mark"),
        ("n", "create a new request"),
        ("P", "copy flow to clipboard"),
        ("r", "replay request"),
        ("U", "unmark all marked flows"),
        ("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. 4
0
def _mkhelp():
    text = []
    keys = [
        ("A", "accept all intercepted flows"),
        ("a", "accept this intercepted flow"),
        ("b", "save request/response body"),
        ("C", "export flow to clipboard"),
        ("d", "delete flow"),
        ("D", "duplicate flow"),
        ("e", "toggle eventlog"),
        ("E", "export flow to file"),
        ("f", "filter view"),
        ("F", "toggle follow flow list"),
        ("L", "load saved flows"),
        ("m", "toggle flow mark"),
        ("M", "toggle marked flow view"),
        ("n", "create a new request"),
        ("r", "replay request"),
        ("S", "server replay request/s"),
        ("U", "unmark all marked flows"),
        ("V", "revert changes to request"),
        ("w", "save flows "),
        ("W", "stream flows to file"),
        ("X", "kill and delete flow, even if it's mid-intercept"),
        ("z", "clear flow list or eventlog"),
        ("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. 5
0
    def conn_text(self, conn):
        if conn:
            txt = common.format_keyvals([(h + ":", v)
                                         for (h, v) in conn.headers.fields],
                                        key="header",
                                        val="text")
            viewmode = self.viewmode_get()
            msg, body = self.content_view(viewmode, conn)

            cols = [
                urwid.Text([
                    ("heading", msg),
                ]),
                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)
        else:
            txt = [
                urwid.Text(""),
                urwid.Text([
                    ("highlight", "No response. Press "),
                    ("key", "e"),
                    ("highlight", " and edit any aspect to add one."),
                ])
            ]
        return searchable.Searchable(self.state, txt)
Esempio n. 6
0
def _mkhelp():
    text = []
    keys = [
        ("enter/space", "select"),
    ]
    text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
    return text
Esempio n. 7
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", "save changes and exit editor"),
         ("r", "read value from file"),
         ("R", "read unescaped value from file"),
         ("esc", "save changes and exit editor"),
         ("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. 8
0
def _mkhelp():
    text = []
    keys = [
        ("enter/space", "activate option"),
        ("C", "clear all options"),
    ]
    text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
    return text
Esempio n. 9
0
def test_format_keyvals():
    assert common.format_keyvals([
        ("aa", "bb"),
        None,
        ("cc", "dd"),
        (None, "dd"),
        (None, "dd"),
    ])
Esempio n. 10
0
def _mkhelp():
    text = []
    keys = [
        ("enter/space", "activate option"),
        ("C", "clear all options"),
    ]
    text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
    return text
Esempio n. 11
0
def test_format_keyvals():
    assert common.format_keyvals(
        [
            ("aa", "bb"),
            None,
            ("cc", "dd"),
            (None, "dd"),
            (None, "dd"),
        ]
    )
Esempio n. 12
0
 def make_help(self):
     h = super().make_help()
     text = [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. 13
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. 14
0
def _mkhelp():
    text = []
    keys = [
        ("A", "accept all intercepted flows"),
        ("a", "accept this intercepted flow"),
        ("b", "save request/response body"),
        ("D", "duplicate flow"),
        ("d", "delete flow"),
        ("E", "export"),
        ("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"),
        ("P", "copy request/response (content/headers) to clipboard"),
        ("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"),
        ("z", "encode/decode a request/response"),
        ("tab", "next tab"),
        ("h, l", "previous tab, next tab"),
        ("space", "next flow"),
        ("|", "run script on this flow"),
        ("/", "search (case sensitive)"),
        ("n", "repeat search forward"),
        ("N", "repeat search backwards"),
    ]
    text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
    return text
Esempio n. 15
0
    def conn_text(self, conn):
        if conn:
            txt = common.format_keyvals(
                [(h + ":", v) for (h, v) in conn.headers.items(multi=True)],
                key = "header",
                val = "text"
            )
            viewmode = self.viewmode_get()
            msg, body = self.content_view(viewmode, conn)

            cols = [
                urwid.Text(
                    [
                        ("heading", msg),
                    ]
                ),
                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)
        else:
            txt = [
                urwid.Text(""),
                urwid.Text(
                    [
                        ("highlight", "No response. Press "),
                        ("key", "e"),
                        ("highlight", " and edit any aspect to add one."),
                    ]
                )
            ]
        return searchable.Searchable(self.state, txt)
Esempio n. 16
0
 def make_help(self):
     text = [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", "save changes and exit editor"),
         ("r", "read value from file"),
         ("R", "read unescaped value from file"),
         ("esc", "save changes and exit editor"),
         ("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. 17
0
def _mkhelp():
    text = []
    keys = [
        ("A", "accept all intercepted flows"),
        ("a", "accept this intercepted flow"),
        ("b", "save request/response body"),
        ("C", "export flow to clipboard"),
        ("d", "delete flow"),
        ("D", "duplicate flow"),
        ("e", "toggle eventlog"),
        ("E", "export flow to file"),
        ("f", "filter view"),
        ("F", "toggle follow flow list"),
        ("L", "load saved flows"),
        ("m", "toggle flow mark"),
        ("M", "toggle marked flow view"),
        ("n", "create a new request"),
        ("N", "add filter to remove Noise"),
        ("r", "replay request"),
        ("R", "repeat this 64 times with incrementing id"),
        ("S", "server replay request/s"),
        ("u", "toggle listed flows markings"),
        ("U", "unmark all marked flows"),
        ("v", "remove all filters"),
        ("V", "revert changes to request"),
        ("w", "save flows "),
        ("W", "stream flows to file"),
        ("X", "kill and delete flow, even if it's mid-intercept"),
        ("z", "clear flow list or eventlog"),
        ("tab", "tab between eventlog and flow list"),
        ("enter", "view flow"),
        ("|", "run script on this flow"),
        ("f1", "toggle authenticion to fail/pass"),
        ("f2", "toggle authorization to fail/pass"),
        ("f3", "toggle payu salt leak to fail/pass"),
        ("f4", "toggle otp leak to fail/pass")
    ]
    text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
    return text
Esempio n. 18
0
def _mkhelp():
    text = []
    keys = [("enter/space", "select")]
    text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
    return text
Esempio n. 19
0
def flowdetails(state, flow):
    text = []

    cc = flow.client_conn
    sc = flow.server_conn
    req = flow.request
    resp = flow.response

    if sc is not None:
        text.append(urwid.Text([("head", "Server Connection:")]))
        parts = [
            ["Address", repr(sc.address)],
            ["Resolved Address", repr(sc.ip_address)],
        ]

        text.extend(
            common.format_keyvals(parts, key="key", val="text", indent=4)
        )

        c = sc.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)],
                [
                    "Subject",
                    urwid.BoxAdapter(
                        urwid.ListBox(
                            common.format_keyvals(
                                c.subject,
                                key="highlight",
                                val="text"
                            )
                        ),
                        len(c.subject)
                    )
                ],
                [
                    "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 cc is not None:
        text.append(urwid.Text([("head", "Client Connection:")]))

        parts = [
            ["Address", repr(cc.address)],
        ]

        text.extend(
            common.format_keyvals(parts, key="key", val="text", indent=4)
        )

    parts = []

    if cc is not None and cc.timestamp_start:
        parts.append(
            [
                "Client conn. established",
                maybe_timestamp(cc, "timestamp_start")
            ]
        )
        if cc.ssl_established:
            parts.append(
                [
                    "Client conn. TLS handshake",
                    maybe_timestamp(cc, "timestamp_ssl_setup")
                ]
            )
    if sc is not None and sc.timestamp_start:
        parts.append(
            [
                "Server conn. initiated",
                maybe_timestamp(sc, "timestamp_start")
            ]
        )
        parts.append(
            [
                "Server conn. TCP handshake",
                maybe_timestamp(sc, "timestamp_tcp_setup")
            ]
        )
        if sc.ssl_established:
            parts.append(
                [
                    "Server conn. TLS handshake",
                    maybe_timestamp(sc, "timestamp_ssl_setup")
                ]
            )
    if req is not None and req.timestamp_start:
        parts.append(
            [
                "First request byte",
                maybe_timestamp(req, "timestamp_start")
            ]
        )
        parts.append(
            [
                "Request complete",
                maybe_timestamp(req, "timestamp_end")
            ]
        )
    if resp is not None and resp.timestamp_start:
        parts.append(
            [
                "First response byte",
                maybe_timestamp(resp, "timestamp_start")
            ]
        )
        parts.append(
            [
                "Response complete",
                maybe_timestamp(resp, "timestamp_end")
            ]
        )

    if parts:
        # sort operations by timestamp
        parts = sorted(parts, key=lambda p: p[1])

        text.append(urwid.Text([("head", "Timing:")]))
        text.extend(common.format_keyvals(parts, key="key", val="text", indent=4))
    return searchable.Searchable(state, text)
Esempio n. 20
0
def flowdetails(state, flow):
    text = []

    cc = flow.client_conn
    sc = flow.server_conn
    req = flow.request
    resp = flow.response

    if sc is not None:
        text.append(urwid.Text([("head", "Server Connection:")]))
        parts = [
            ["Address", repr(sc.address)],
            ["Resolved Address", repr(sc.ip_address)],
        ]

        text.extend(
            common.format_keyvals(parts, key="key", val="text", indent=4))

        c = sc.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)],
                     [
                         "Subject",
                         urwid.BoxAdapter(
                             urwid.ListBox(
                                 common.format_keyvals(c.subject,
                                                       key="highlight",
                                                       val="text")),
                             len(c.subject))
                     ],
                     [
                         "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 cc is not None:
        text.append(urwid.Text([("head", "Client Connection:")]))

        parts = [
            ["Address", repr(cc.address)],
        ]

        text.extend(
            common.format_keyvals(parts, key="key", val="text", indent=4))

    parts = []

    if cc is not None and cc.timestamp_start:
        parts.append([
            "Client conn. established",
            maybe_timestamp(cc, "timestamp_start")
        ])
        if cc.ssl_established:
            parts.append([
                "Client conn. TLS handshake",
                maybe_timestamp(cc, "timestamp_ssl_setup")
            ])
    if sc is not None and sc.timestamp_start:
        parts.append(
            ["Server conn. initiated",
             maybe_timestamp(sc, "timestamp_start")])
        parts.append([
            "Server conn. TCP handshake",
            maybe_timestamp(sc, "timestamp_tcp_setup")
        ])
        if sc.ssl_established:
            parts.append([
                "Server conn. TLS handshake",
                maybe_timestamp(sc, "timestamp_ssl_setup")
            ])
    if req is not None and req.timestamp_start:
        parts.append(
            ["First request byte",
             maybe_timestamp(req, "timestamp_start")])
        parts.append(
            ["Request complete",
             maybe_timestamp(req, "timestamp_end")])
    if resp is not None and resp.timestamp_start:
        parts.append(
            ["First response byte",
             maybe_timestamp(resp, "timestamp_start")])
        parts.append(
            ["Response complete",
             maybe_timestamp(resp, "timestamp_end")])

    if parts:
        # sort operations by timestamp
        parts = sorted(parts, key=lambda p: p[1])

        text.append(urwid.Text([("head", "Timing:")]))
        text.extend(
            common.format_keyvals(parts, key="key", val="text", indent=4))
    return searchable.Searchable(state, text)
Esempio n. 21
0
def _mkhelp():
    text = []
    keys = [
        ("A", "accept all intercepted flows"),
        ("a", "accept this intercepted flow"),
        ("b", "save request/response body"),
        ("C", "export flow to clipboard"),
        ("D", "duplicate flow"),
        ("d", "delete flow"),
        ("e", "edit request/response"),
        ("f", "load full body data"),
        ("m", "change body display mode for this entity\n(default mode can be changed in the options)"),
        (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")]
         ),
        ("E", "export flow to file"),
        ("r", "replay request"),
        ("V", "revert changes to request"),
        ("v", "view body in external viewer"),
        ("w", "save all flows matching current view filter"),
        ("W", "save this flow"),
        ("x", "delete body"),
        ("z", "encode/decode a request/response"),
        ("tab", "next tab"),
        ("h, l", "previous tab, next tab"),
        ("space", "next flow"),
        ("|", "run script on this flow"),
        ("/", "search (case sensitive)"),
        ("n", "repeat search forward"),
        ("N", "repeat search backwards"),
    ]
    text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
    return text