Exemple #1
0
    def _print_body(self, body, compress, mime, charset):
        try:
            if compress == Compress.GZIP:
                body = utils.ungzip(body)
            elif compress == Compress.DEFLATE:
                body = utils.decode_deflate(body)

            content = utils.decode_body(body, charset)
            if content:
                if not mime:
                    # guess mime...
                    if content.startswith('{') and content.endswith('}') or content.startswith('[') \
                            and content.endswith(']'):
                        mime = b'application/json'
                if mime is None:
                    mime = ''
                if self.parse_config.pretty:
                    if b'json' in mime:
                        utils.try_print_json(content, self.buf)
                    elif b'www-form-urlencoded' in mime:
                        utils.try_decoded_print(content, self.buf)
                    else:
                        self.buf.write(content)
                else:
                    self.buf.write(content)
                self.buf.write('\n')
        except Exception, e:
            content = utils.decode_body(body, charset)
            self.buf.write(content)
            self.buf.write('\n')
            print(CTCore.colors.RED + "[-] Error parsing body of uri: " +
                  self.uri + " : " + str(e) + CTCore.colors.END)
Exemple #2
0
    def _print_body(self, body, compress, mime, charset):
        if compress == Compress.GZIP:
            body = utils.ungzip(body)
        elif compress == Compress.DEFLATE:
            body = utils.decode_deflate(body)

        content = utils.decode_body(body, charset)
        if content:
            if not mime:
                # guess mime...
                if content.startswith('{') and content.endswith('}') or content.startswith('[') \
                        and content.endswith(']'):
                    mime = b'application/json'
            if mime is None:
                mime = ''
            if self.parse_config.pretty:
                if b'json' in mime:
                    utils.try_print_json(content, self.buf)
                elif b'www-form-urlencoded' in mime:
                    utils.try_decoded_print(content, self.buf)
                else:
                    self.buf.write(content)
            else:
                self.buf.write(content)
            self.buf.write('\n')
Exemple #3
0
    def _print_body(self, body, compress, mime, charset):
        try:
            if compress == Compress.GZIP:
                body = utils.ungzip(body)
            elif compress == Compress.DEFLATE:
                body = utils.decode_deflate(body)

            self.res_body = ""
            if CTCore.b_auto_ungzip:
                self.res_body = body

            content = utils.decode_body(body, charset)
            if content:
                if not mime:
                    # guess mime...
                    if content.startswith('{') and content.endswith('}') or content.startswith('[') \
                            and content.endswith(']'):
                        mime = b'application/json'
                if mime is None:
                    mime = ''
                if self.parse_config.pretty:
                    if b'json' in mime:
                        utils.try_print_json(content, self.buf)
                    elif b'www-form-urlencoded' in mime:
                        utils.try_decoded_print(content, self.buf)
                    else:
                        self.buf.write(content)
                else:
                    self.buf.write(content)
                self.buf.write('\n')
        except Exception,e:
            content = utils.decode_body(body, charset)
            self.buf.write(content)
            self.buf.write('\n')
            print(CTCore.colors.RED +  "[-] Error parsing body of uri: " + self.uri + " : " + str(e) + CTCore.colors.END)
Exemple #4
0
    def _print_body(self, body, compress, mime, charset):
        if compress == Compress.GZIP:
            body = utils.ungzip(body)
        elif compress == Compress.DEFLATE:
            body = utils.decode_deflate(body)

        content = utils.decode_body(body, charset)
        if content:
            if not mime:
                # guess mime...
                if content.startswith('{') and content.endswith('}') or content.startswith('[') \
                        and content.endswith(']'):
                    mime = b'application/json'
            if mime is None:
                mime = ''
            if self.parse_config.pretty:
                if b'json' in mime:
                    utils.try_print_json(content, self.buf)
                elif b'www-form-urlencoded' in mime:
                    utils.try_decoded_print(content, self.buf)
                else:
                    self.buf.write(content)
            else:
                self.buf.write(content)
            self.buf.write('\n')