예제 #1
0
파일: dump.py 프로젝트: huyphan/mitmproxy
    def _process_flow(self, f):
        self.state.delete_flow(f)
        if self.filt and not f.match(self.filt):
            return

        if f.response:
            if self.o.flow_detail > 0:
                if f.response.content == http.CONTENT_MISSING:
                    sz = "(content missing)"
                else:
                    sz = utils.pretty_size(len(f.response.content))
                result = " << %s %s"%(str_response(f.response), sz)
            if self.o.flow_detail > 1:
                result = result + "\n\n" + self.indent(4, f.response.headers)
            if self.o.flow_detail > 2:
                if f.response.content == http.CONTENT_MISSING:
                    cont = self.indent(4, "(content missing)")
                elif utils.isBin(f.response.content):
                    d = netlib.utils.hexdump(f.response.content)
                    d = "\n".join("%s\t%s %s"%i for i in d)
                    cont = self.indent(4, d)
                elif f.response.content:
                    cont = self.indent(4, f.response.content)
                else:
                    cont = ""
                result = result + "\n\n" + cont
        elif f.error:
            result = " << %s"%f.error.msg

        if self.o.generated_replay_script:
            self.add_replay_code(f, result)

        if self.o.flow_detail == 1:
            print >> self.outfile, str_request(f, self.showhost)
            print >> self.outfile, result

        elif self.o.flow_detail == 2:
            print >> self.outfile, str_request(f, self.showhost)
            print >> self.outfile, self.indent(4, f.request.headers)
            print >> self.outfile
            print >> self.outfile, result
            print >> self.outfile, "\n"
        elif self.o.flow_detail >= 3:
            print >> self.outfile, str_request(f, self.showhost)
            print >> self.outfile, self.indent(4, f.request.headers)
            if f.request.content != http.CONTENT_MISSING and utils.isBin(f.request.content):
                d = netlib.utils.hexdump(f.request.content)
                d = "\n".join("%s\t%s %s"%i for i in d)
                print >> self.outfile, self.indent(4, d)
            elif f.request.content:
                print >> self.outfile, self.indent(4, f.request.content)
            print >> self.outfile
            print >> self.outfile, result
            print >> self.outfile, "\n"
        if self.o.flow_detail:
            self.outfile.flush()
예제 #2
0
파일: dump.py 프로젝트: rains31/mitmproxy
    def _process_flow(self, f):
        self.state.delete_flow(f)
        if self.filt and not f.match(self.filt):
            return

        if f.response:
            if self.o.flow_detail > 0:
                if f.response.content == http.CONTENT_MISSING:
                    sz = "(content missing)"
                else:
                    sz = utils.pretty_size(len(f.response.content))
                result = " << %s %s" % (str_response(f.response), sz)
            if self.o.flow_detail > 1:
                result = result + "\n\n" + self.indent(4, f.response.headers)
            if self.o.flow_detail > 2:
                if f.response.content == http.CONTENT_MISSING:
                    cont = self.indent(4, "(content missing)")
                elif utils.isBin(f.response.content):
                    d = netlib.utils.hexdump(f.response.content)
                    d = "\n".join("%s\t%s %s" % i for i in d)
                    cont = self.indent(4, d)
                elif f.response.content:
                    cont = self.indent(4, f.response.content)
                else:
                    cont = ""
                result = result + "\n\n" + cont
        elif f.error:
            result = " << %s" % f.error.msg

        if self.o.flow_detail == 1:
            print >> self.outfile, str_request(f, self.showhost)
            print >> self.outfile, result
        elif self.o.flow_detail == 2:
            print >> self.outfile, str_request(f, self.showhost)
            print >> self.outfile, self.indent(4, f.request.headers)
            print >> self.outfile
            print >> self.outfile, result
            print >> self.outfile, "\n"
        elif self.o.flow_detail >= 3:
            print >> self.outfile, str_request(f, self.showhost)
            print >> self.outfile, self.indent(4, f.request.headers)
            if f.request.content != http.CONTENT_MISSING and utils.isBin(
                    f.request.content):
                d = netlib.utils.hexdump(f.request.content)
                d = "\n".join("%s\t%s %s" % i for i in d)
                print >> self.outfile, self.indent(4, d)
            elif f.request.content:
                print >> self.outfile, self.indent(4, f.request.content)
            print >> self.outfile
            print >> self.outfile, result
            print >> self.outfile, "\n"
        if self.o.flow_detail:
            self.outfile.flush()
예제 #3
0
파일: dump.py 프로젝트: nlitsme/mitmproxy
    def _process_flow(self, f):
        self.state.delete_flow(f)
        if self.filt and not f.match(self.filt):
            return

        if f.response:
            sz = utils.pretty_size(len(f.response.content))
            if self.o.verbosity > 0:
                result = " << %s %s"%(str_response(f.response), sz)
            if self.o.verbosity > 1:
                result = result + "\n\n" + self.indent(4, f.response.headers)
            if self.o.verbosity > 2:
                if utils.isBin(f.response.content):
                    d = netlib.utils.hexdump(f.response.content)
                    d = "\n".join("%s\t%s %s"%i for i in d)
                    cont = self.indent(4, d)
                elif f.response.content:
                    cont = self.indent(4, f.response.content)
                else:
                    cont = ""
                result = result + "\n\n" + cont
        elif f.error:
            result = " << %s"%f.error.msg

        if self.o.verbosity == 1:
            print >> self.outfile, str_request(f.request, self.showhost)
            print >> self.outfile, result
        elif self.o.verbosity == 2:
            print >> self.outfile, str_request(f.request, self.showhost)
            print >> self.outfile, self.indent(4, f.request.headers)
            print >> self.outfile
            print >> self.outfile, result
            print >> self.outfile, "\n"
        elif self.o.verbosity >= 3:
            print >> self.outfile, str_request(f.request, self.showhost)
            print >> self.outfile, self.indent(4, f.request.headers)
            if utils.isBin(f.request.content):
                d = netlib.utils.hexdump(f.request.content)
                d = "\n".join("%s\t%s %s"%i for i in d)
                cont = self.indent(4, d)

                print >> self.outfile, cont
            elif f.request.content:
                print >> self.outfile, self.indent(4, f.request.content)
            print >> self.outfile
            print >> self.outfile, result
            print >> self.outfile, "\n"
        if self.o.verbosity:
            self.outfile.flush()
예제 #4
0
파일: dump.py 프로젝트: nask0/mitmproxy
 def _print_message(self, message):
     if self.o.flow_detail >= 2:
         print(self.indent(4, message.headers.format()), file=self.outfile)
     if self.o.flow_detail >= 3:
         if message.content == CONTENT_MISSING:
             print(self.indent(4, "(content missing)"), file=self.outfile)
         elif message.content:
             print("", file=self.outfile)
             content = message.get_decoded_content()
             if not utils.isBin(content):
                 try:
                     jsn = json.loads(content)
                     print(
                         self.indent(
                             4,
                             json.dumps(
                                 jsn,
                                 indent=2)),
                         file=self.outfile)
                 except ValueError:
                     print(self.indent(4, content), file=self.outfile)
             else:
                 d = netlib.utils.hexdump(content)
                 d = "\n".join("%s\t%s %s" % i for i in d)
                 print(self.indent(4, d), file=self.outfile)
     if self.o.flow_detail >= 2:
         print("", file=self.outfile)
예제 #5
0
    def _process_flow(self, f):
        self.state.delete_flow(f)
        if self.filt and not f.match(self.filt):
            return

        if f.response:
            sz = utils.pretty_size(len(f.response.content))
            if self.o.verbosity > 0:
                result = " << %s %s" % (str_response(f.response), sz)
            if self.o.verbosity > 1:
                result = result + "\n\n" + self.indent(4, f.response.headers)
            if self.o.verbosity > 2:
                if utils.isBin(f.response.content):
                    d = netlib.utils.hexdump(f.response.content)
                    d = "\n".join("%s\t%s %s" % i for i in d)
                    cont = self.indent(4, d)
                elif f.response.content:
                    cont = self.indent(4, f.response.content)
                else:
                    cont = ""
                result = result + "\n\n" + cont
        elif f.error:
            result = " << %s" % f.error.msg

        if self.o.verbosity == 1:
            print >> self.outfile, str_request(f.request, self.showhost)
            print >> self.outfile, result
        elif self.o.verbosity == 2:
            print >> self.outfile, str_request(f.request, self.showhost)
            print >> self.outfile, self.indent(4, f.request.headers)
            print >> self.outfile
            print >> self.outfile, result
            print >> self.outfile, "\n"
        elif self.o.verbosity >= 3:
            print >> self.outfile, str_request(f.request, self.showhost)
            print >> self.outfile, self.indent(4, f.request.headers)
            if utils.isBin(f.request.content):
                print >> self.outfile, self.indent(
                    4, netlib.utils.hexdump(f.request.content))
            elif f.request.content:
                print >> self.outfile, self.indent(4, f.request.content)
            print >> self.outfile
            print >> self.outfile, result
            print >> self.outfile, "\n"
        if self.o.verbosity:
            self.outfile.flush()
예제 #6
0
파일: dump.py 프로젝트: winfinit/mitmproxy
 def _print_message(self, message):
     if self.o.flow_detail >= 2:
         print(self.indent(4, message.headers), file=self.outfile)
     if self.o.flow_detail >= 3:
         if message.content == http.CONTENT_MISSING:
             print(self.indent(4, "(content missing)"), file=self.outfile)
         elif message.content:
             print("", file=self.outfile)
             content = message.get_decoded_content()
             if not utils.isBin(content):
                 try:
                     jsn = json.loads(content)
                     print(self.indent(4, json.dumps(jsn, indent=2)), file=self.outfile)
                 except ValueError:
                     print(self.indent(4, content), file=self.outfile)
             else:
                 d = netlib.utils.hexdump(content)
                 d = "\n".join("%s\t%s %s"%i for i in d)
                 print(self.indent(4, d), file=self.outfile)
     if self.o.flow_detail >= 2:
         print("", file=self.outfile)