Exemplo n.º 1
0
    def valid(self, path):
        if not path:
            return False

        if path.status in self.exclude_status_codes:
            return False

        if self.include_status_codes and path.status not in self.include_status_codes:
            return False

        if self.blacklists.get(path.status) and path.path in self.blacklists.get(path.status):
            return False

        if self.exclude_sizes and human_size(path.length).strip() in self.exclude_sizes:
            return False

        if self.minimum_response_size and self.minimum_response_size > path.length:
            return False

        if self.maximum_response_size and self.maximum_response_size < path.length:
            return False

        for exclude_text in self.exclude_texts:
            if exclude_text in path.body:
                return False

        for exclude_regexp in self.exclude_regexps:
            if (
                re.search(exclude_regexp, path.body)
                is not None
            ):
                return False

        for exclude_redirect in self.exclude_redirects:
            if path.redirect and (
                (
                    re.match(exclude_redirect, path.redirect) is not None
                ) or (
                    exclude_redirect in path.redirect
                )
            ):
                return False

        return True
Exemplo n.º 2
0
    def status_report(self, path, response, full_url, added_to_queue):
        status = response.status
        content_length = human_size(response.length)

        show_path = "/" + self.base_path + path

        if full_url:
            parsed = urlparse(self.target)
            show_path = "{0}://{1}{2}".format(parsed.scheme, parsed.netloc,
                                              show_path)

        message = "[{0}] {1} - {2} - {3}".format(
            time.strftime("%H:%M:%S"),
            status,
            content_length.rjust(6, " "),
            show_path,
        )

        if status in [200, 201, 204]:
            message = self.colorizer.color(message, fore="green")

        elif status == 401:
            message = self.colorizer.color(message, fore="yellow")

        elif status == 403:
            message = self.colorizer.color(message, fore="blue")

        elif status in range(500, 600):
            message = self.colorizer.color(message, fore="red")

        elif status in range(300, 400):
            message = self.colorizer.color(message, fore="cyan")

        else:
            message = self.colorizer.color(message, fore="magenta")

        if response.redirect:
            message += "  ->  {0}".format(response.redirect)
        if added_to_queue:
            message += "     (Added to queue)"

        with self.mutex:
            self.new_line(message)
Exemplo n.º 3
0
    def generate(self):
        file_loader = FileSystemLoader(
            os.path.dirname(os.path.realpath(__file__)) + '/templates/')
        env = Environment(loader=file_loader)

        template = env.get_template('html_report_template.html')

        metadata = {"command": " ".join(sys.argv), "date": time.ctime()}
        results = []
        for entry in self.entries:
            for e in entry.results:
                header_name = "{0}://{1}:{2}/{3}".format(
                    entry.protocol, entry.host, entry.port, entry.base_path)

                status_color_class = ''
                if e.status >= 200 and e.status <= 299:
                    status_color_class = 'text-success'
                elif e.status >= 300 and e.status <= 399:
                    status_color_class = 'text-warning'
                elif e.status >= 400 and e.status <= 599:
                    status_color_class = 'text-danger'

                results.append({
                    "url":
                    header_name + e.path,
                    "path":
                    e.path,
                    "status":
                    e.status,
                    "statusColorClass":
                    status_color_class,
                    "contentLength":
                    human_size(e.get_content_length()),
                    "contentType":
                    e.get_content_type(),
                    "redirect":
                    e.response.redirect
                })

        return template.render(metadata=metadata, results=results)
Exemplo n.º 4
0
    def generate(self):
        result = self.generate_header()

        for entry in self.entries:
            for e in entry.results:
                if (entry.protocol, entry.host, entry.port, entry.base_path,
                        e.path) not in self.written_entries:
                    result += "{0}  ".format(e.status)
                    result += "{0}  ".format(
                        human_size(e.get_content_length()).rjust(6, " "))
                    result += "{0}://{1}:{2}/".format(entry.protocol,
                                                      entry.host, entry.port)
                    result += ("{0}".format(e.path) if entry.base_path == ""
                               else "{0}/{1}".format(entry.base_path, e.path))
                    location = e.response.redirect
                    if location:
                        result += "    -> REDIRECTS TO: {0}".format(location)

                    result += "\n"
                    self.written_entries.append(
                        (entry.protocol, entry.host, entry.port,
                         entry.base_path, e.path))

        return result