Example #1
0
    def matchCallback(self, path):
        self.index += 1

        if path.status:

            if path.status not in self.excludeStatusCodes and (
                    not self.includeStatusCodes
                    or path.status in self.includeStatusCodes
            ) and (not self.blacklists.get(path.status)
                   or path.path not in self.blacklists.get(path.status)) and (
                       not self.excludeSizes or FileUtils.size_human(
                           len(path.response.body)).strip()
                       not in self.excludeSizes
                   ) and (not self.minimumResponseSize
                          or self.minimumResponseSize < len(path.response.body)
                          ) and (not self.maximumResponseSize
                                 or self.maximumResponseSize > len(
                                     path.response.body)):

                for excludeText in self.excludeTexts:
                    if excludeText in path.response.body.decode('iso8859-1'):
                        del path
                        return

                for excludeRegexp in self.excludeRegexps:
                    if (re.search(excludeRegexp,
                                  path.response.body.decode('iso8859-1'))
                            is not None):
                        del path
                        return

                pathIsInScanSubdirs = False
                addedToQueue = False

                if self.scanSubdirs:
                    for subdir in self.scanSubdirs:
                        if subdir == path.path + "/":
                            pathIsInScanSubdirs = True

                if not self.recursive and not pathIsInScanSubdirs and "?" not in path.path:
                    if path.response.redirect:
                        addedToQueue = self.addRedirectDirectory(path)

                    else:
                        addedToQueue = self.addDirectory(path.path)

                self.output.statusReport(path.path, path.response,
                                         self.arguments.full_url, addedToQueue)

                if self.arguments.matches_proxy:
                    self.requester.request(path.path,
                                           proxy=self.arguments.matches_proxy)

                newPath = "{}{}".format(self.currentDirectory, path.path)

                self.reportManager.addPath(newPath, path.status, path.response)

                self.reportManager.save()

                del path
Example #2
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 FileUtils.size_human(len(path.response.body)).strip() in self.exclude_sizes:
            return False

        if self.minimum_response_size and self.minimum_response_size > len(path.response.body):
            return False

        if self.maximum_response_size and self.maximum_response_size < len(path.response.body):
            return False

        for exclude_text in self.exclude_texts:
            if exclude_text in path.response.body.decode('iso8859-1'):
                return False

        for exclude_regexp in self.exclude_regexps:
            if (
                re.search(exclude_regexp, path.response.body.decode('iso8859-1'))
                is not None
            ):
                return False

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

        return True
Example #3
0
    def generate(self):
        template_file = os.path.dirname(os.path.realpath(
            __file__)) + '/templates/html_report_template.html'
        mytemplate = Template(filename=template_file)

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

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

                results.append({
                    "url":
                    headerName + e.path,
                    "path":
                    e.path,
                    "status":
                    e.status,
                    "statusColorClass":
                    statusColorClass,
                    "contentLength":
                    FileUtils.size_human(e.getContentLength()),
                    "contentType":
                    e.response.headers.get("content-type"),
                    "redirect":
                    e.response.redirect
                })

        return mytemplate.render(metadata=metadata,
                                 results=json.dumps(results))
Example #4
0
    def matchCallback(self, path):
        self.index += 1

        if self.arguments.skip_on_429 and path.status == 429:
            self.skip429 = True
            return

        if (path.status and path.status not in self.excludeStatusCodes) and (
                not self.includeStatusCodes
                or path.status in self.includeStatusCodes
        ) and (not self.blacklists.get(path.status)
               or path.path not in self.blacklists.get(path.status)) and (
                   not self.excludeSizes
                   or FileUtils.size_human(len(path.response.body)).strip()
                   not in self.excludeSizes) and (
                       not self.minimumResponseSize
                       or self.minimumResponseSize < len(path.response.body)
                   ) and (not self.maximumResponseSize or
                          self.maximumResponseSize > len(path.response.body)):

            for excludeText in self.excludeTexts:
                if excludeText in path.response.body.decode('iso8859-1'):
                    del path
                    return

            for excludeRegexp in self.excludeRegexps:
                if (re.search(excludeRegexp,
                              path.response.body.decode('iso8859-1'))
                        is not None):
                    del path
                    return

            for excludeRedirect in self.excludeRedirects:
                if path.response.redirect and (
                    (re.match(excludeRedirect,
                              path.response.redirect.decode('iso8859-1'))
                     is not None) or
                    (excludeRedirect in path.response.redirect)):
                    del path
                    return

            addedToQueue = False

            if self.recursive and "?" not in path.path and "#" not in path.path:
                if path.response.redirect:
                    addedToQueue = self.addRedirectDirectory(path)
                else:
                    addedToQueue = self.addDirectory(path.path)

            self.output.statusReport(path.path, path.response,
                                     self.arguments.full_url, addedToQueue)

            if self.arguments.replay_proxy:
                self.requester.request(path.path,
                                       proxy=self.arguments.replay_proxy)

            newPath = self.currentDirectory + path.path

            self.reportManager.addPath(newPath, path.status, path.response)

            self.reportManager.save()

            del path