Example #1
0
 def sort_key(self):
     """ How to sort the credential dump."""
     return self.service + self.port.zfill(5) + canonicalise_ip(self.ip)
def html_print(scan_time,
               scan_id,
               invalid_host_count,
               vulnerable_hosts=[],
               vulnerabilities=[],
               credentials=[]):
    TEMPLATE_DIR = os.path.abspath(os.path.dirname(__file__))
    TEMPLATE_DIR = os.path.join(TEMPLATE_DIR, 'templates')
    templateLoader = FileSystemLoader(searchpath=TEMPLATE_DIR)
    env = Environment(loader=templateLoader)
    env.filters['print_it'] = print_it
    report = env.get_template('html.tmpl')
    return report.render(title=CONF.email.report_subject,
                         scan_time=scan_time,
                         scan_id=scan_id,
                         vulnerablehosts=sorted([h for h in vulnerable_hosts if h.printable_host()], key=lambda host: canonicalise_ip(host.ip)),
                         dump=CONF.dump,
                         vulnerabilities=sorted(vulnerabilities,
                                                key=methodcaller('sort_key')),
                         credentials=sorted(credentials,
                                            key=methodcaller('sort_key')),
                         total=len(vulnerable_hosts),
                         list_boring=CONF.list_boring,
                         white_listed=len([h for h in vulnerable_hosts if h.whitelisted()]),
                         invalid_hosts=CONF.disable_host_validation,
                         invalid_host_count=invalid_host_count)
Example #3
0
 def sort_key(self):
     """ How to sort the vulnerability dump."""
     return self.name + self.port.zfill(5) + \
         self.service + canonicalise_ip(self.ip)