def res_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_response_head(flow.response).decode( "utf-8", errors="backslashreplace"), flow, ), entry_id=mixto_entry_id, title=self._get_title("response.header"), ) print("Sent!")
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)
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)
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 ) )
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)
def test_assemble_response_head(): c = assemble_response_head(tresp()) assert b"200" in c assert b"svalue" in c assert b"message" not in c
def test_assemble_response_head(): c = assemble_response_head(tresp()) assert b"200" in c assert b"svalue" in c assert b"message" not in c