示例#1
0
def parse_ness_host_vulns(workbook, scanner, scans, config_file=None):
    table_data = []
    table_headers = [{
        "header": "Scan"
    }, {
        "header": "Host IP"
    }, {
        "header": "Port"
    }, {
        "header": "Vulnerability"
    }, {
        "header": "Severity Rating"
    }]

    for scan in scans:
        host_vulns = nessus.get_host_vulns(scanner, scan)

        if config_file:
            host_vulns = nessus.post_process_vulns(config_file,
                                                   host_vulns,
                                                   type=0)

        for host_id, plugin_id in host_vulns.items():
            for plugin_id, values in plugin_id.items():
                for value in values:
                    table_data.append([
                        value["scan"], value["host_ip"],
                        ";".join(value["plugin_output"]["ports"]),
                        value["plugin_name"], value["severity"]
                    ])

    write_worksheet(workbook, "Hosts vs Vulnerabilties", 2, table_headers,
                    table_data)
示例#2
0
def parse_vulns(workbook, scanner, scans, config_file=None):
    table_data = []
    table_headers = [{
        "header": "Scan"
    }, {
        "header": "Vulnerability"
    }, {
        "header": "IP Count"
    }, {
        "header": "Host IP"
    }, {
        "header": "Port Count"
    }, {
        "header": "Port"
    }, {
        "header": "Severity Rating"
    }]

    for scan in scans:
        vuln_hosts = nessus.get_vuln_hosts(scanner, scan)

        if config_file:
            vuln_hosts = nessus.post_process_vulns(config_file,
                                                   vuln_hosts,
                                                   type=1)

        for value in vuln_hosts.values():
            # unify, sort and stringify
            table_data.append([
                ";".join(sorted(set(value["scan"]))), value["plugin_name"],
                len(value["host_ip"]), ";".join(
                    sorted(set(value["host_ip"]),
                           key=lambda x: tuple(map(int, x.split('.'))))),
                len(set(value["plugin_output"]["ports"])), ";".join(
                    sorted(set(value["plugin_output"]["ports"]),
                           key=lambda x: int(x.split("/")[0]))),
                value["severity"]
            ])

    write_worksheet(workbook, "Vulnerability vs Hosts", 2, table_headers,
                    table_data)