Пример #1
0
    def grab_html_title(url):
        try:
            r = requests.get(url, verify=False)
            html = bs4.BeautifulSoup(r.text, 'html.parser')

            return StringUtils.remove_non_printable_chars(
                html.title.text.strip())
        except:
            return ''
Пример #2
0
    def grab_html_title(url):
        """Return HTML title from an URL"""
        try:
            r = requests.get(url, verify=False)
            html = bs4.BeautifulSoup(r.text, 'html.parser')

            # Remove non-ASCII characters and duplicate spaces
            title = StringUtils.remove_non_printable_chars(
                html.title.text.strip())
            title = " ".join(title.split())

            # Shorten if necessary
            title = StringUtils.shorten(title, 250)

            return title
        except:
            return ''
Пример #3
0
    def detect_vulns(self):
        """
        Detect vulnerability from command output
        Important: A command output might contain several vulnerabilities with the 
        same pattern.
        """
        if self.service.name in vulns_match.keys():

            if self.tool_name in vulns_match[self.service.name].keys():
                p = vulns_match[self.service.name][self.tool_name]

                for pattern in p.keys():

                    logger.debug('Search for vulns pattern: {pattern}'.format(
                        pattern=pattern))

                    # Important: Multiple search/match
                    #m = re.search(pattern, self.cmd_output, re.IGNORECASE)
                    try:
                        mall = re.finditer(pattern, self.cmd_output,
                                           re.IGNORECASE | re.MULTILINE)
                    except Exception as e:
                        logger.warning('Error with matchstring [{pattern}], you ' \
                            'should review it. Exception: {exception}'.format(
                                pattern=pattern, exception=e))
                        break

                    # Process each match
                    if mall:
                        for m in mall:
                            name = self.__replace_tokens_from_matchobj(
                                p[pattern], m)
                            if name is None:
                                continue

                            # Add vulnerability to context
                            logger.debug('Vuln pattern matches')
                            self.cu.add_vuln(
                                StringUtils.remove_non_printable_chars(name))