예제 #1
0
 def req_header(self, flow: flow.Flow) -> None:
     mixto_entry_id = self.get_entry_id()
     self.mitm_method = flow.request.method
     self.mitm_host = flow.request.host
     self.mixto.AddCommit(
         data=self._get_data(
             assemble.assemble_request_head(flow.request).decode(
                 "utf-8", errors="backslashreplace"),
             flow,
         ),
         entry_id=mixto_entry_id,
         title=self._get_title("request.header"),
     )
     print("Sent!")
예제 #2
0
파일: httpdump.py 프로젝트: jwilk/mbank-cli
def response(flow, logindex=[0]):
    try:
        logindex[0] += 1
        path = 'log.{index:06}.{method}.{host}.{path}'.format(
            index=logindex[0],
            method=flow.request.method,
            host=flow.request.host,
            path=re.sub(r'[^\w.]', '_', flow.request.path),
        )
        fd = os.open(path, os.O_TRUNC | os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
        with os.fdopen(fd, 'wb') as log:
            log.write(assemble_request_head(flow.request))
            log.write(flow.request.content)
            log.write(b'\n\n')
            log.write(assemble_response_head(flow.response))
            log.write(flow.response.content)
    except Exception:
        traceback.print_exc(file=sys.stderr)
예제 #3
0
def response(flow, logindex=[0]):
    try:
        logindex[0] += 1
        path = 'log.{index:06}.{method}.{host}.{path}'.format(
            index=logindex[0],
            method=flow.request.method,
            host=flow.request.host,
            path=re.sub(r'[^\w.]', '_', flow.request.path),
        )
        fd = os.open(path, os.O_TRUNC | os.O_WRONLY | os.O_CREAT | os.O_EXCL,
                     0o600)
        with os.fdopen(fd, 'wb') as log:
            log.write(assemble_request_head(flow.request))
            log.write(flow.request.content)
            log.write(b'\n\n')
            log.write(assemble_response_head(flow.response))
            log.write(flow.response.content)
    except Exception:
        traceback.print_exc(file=sys.stderr)
예제 #4
0
    def response(self, flow: http.HTTPFlow):
        if flow.request.text != "" and not is_json(flow.request.text):
            ctx.log.info("request not json")
            return

        if flow.response.text != "" and not is_json(flow.response.text):
            ctx.log.info("response not json")
            return

        with closing(self.conn.cursor()) as cur:
            # TODO :Check option that is not http1 only
            cur.execute("INSERT INTO RawConversations (url, method, reqheaders, req, resheaders, res) VALUES (?, ?, ?, ?, ?, ?)", 
                        (
                            flow.request.url.split("?")[0],
                            flow.request.method,
                            assemble_request_head(flow.request).decode('utf-8'),
                            flow.request.text,
                            assemble_response_head(flow.response).decode('utf-8'),
                            flow.response.text
                        )
            )
예제 #5
0
    def veiw_flow(self, selection):
        flow = self.history[self.history_list.curselection()[0]]
        self.request_veiwer.config(state=tk.NORMAL)
        self.request_veiwer.delete('1.0', tk.END)

        self.response_veiwer.config(state=tk.NORMAL)
        self.response_veiwer.delete('1.0', tk.END)

        if flow.request is not None:
            request = self.byte_to_string(assemble_request_head(flow.request))
            request += flow.request.text
            self.request_veiwer.insert(tk.END, request)
        else:
            self.request_veiwer.insert(tk.END, 'NO REQUEST')

        if flow.response is not None:
            response = self.byte_to_string(assemble_response_head(flow.response))
            response += flow.response.text
            self.response_veiwer.insert(tk.END, response)
        else:
            self.response_veiwer.insert(tk.END, 'NO RESPONSE')

        self.request_veiwer.config(state=tk.DISABLED)
        self.response_veiwer.config(state=tk.DISABLED)
예제 #6
0
def test_assemble_request_head():
    c = assemble_request_head(treq(content=b"foo"))
    assert b"GET" in c
    assert b"qvalue" in c
    assert b"content-length" in c
    assert b"foo" not in c
예제 #7
0
def test_assemble_request_head():
    c = assemble_request_head(treq(content=b"foo"))
    assert b"GET" in c
    assert b"qvalue" in c
    assert b"content-length" in c
    assert b"foo" not in c