Пример #1
0
def main(workspace='', args=None, parser=None):
    parser.add_argument('-q',
                        '--unique',
                        help='Group OSs and print the total amount of hosts.',
                        action='store_true')

    parsed_args = parser.parse_args(args)

    host_count = {}

    for host in models.get_hosts(workspace):

        if parsed_args.unique:
            if host.os in host_count:
                host_count[host.os] += 1
            else:
                host_count[host.os] = 1

        else:
            print(host.os)

    if parsed_args.unique:
        for host, count in host_count.items():
            print('%s\t(%d)' % (host, count))

    return 0, None
Пример #2
0
def main(workspace='', args=None, parser=None):
    parser.add_argument('severity',
                        nargs='?',
                        help='Filter by Severity (<=)',
                        default="info",
                        choices=SEVERITY_OPTIONS)
    parser.add_argument('--couchdb',
                        nargs='?',
                        help='CouchDB URL',
                        default="http://*****:*****@localhost:5984")

    parsed_args = parser.parse_args(args)

    cwe = getCweData(parsed_args.couchdb)

    if cwe is None:
        print('CWE DB not downloaded....EXIT')
        return 2, None

    for host in models.get_hosts(workspace):
        for v in host.getVulns():
            checkSeverity(v, cwe, parsed_args.severity, workspace,
                          parsed_args.couchdb)

        for i in host.getAllInterfaces():
            for s in i.getAllServices():
                for v in s.getVulns():
                    checkSeverity(v, cwe, parsed_args.severity, workspace,
                                  parsed_args.couchdb)

    return 0, None
Пример #3
0
def search_hosts_by_service(workspace, b_service):
    output = ""
    all_hosts = list(models.get_hosts(workspace))
    all_services = list(models.get_services(workspace))
    for host in all_hosts:
        for service in all_services:
            id_service_host = service.parent_id
            if host.id == id_service_host and service.name == b_service:
                output += host.name + "\n"
                break
    return output
Пример #4
0
def main(workspace='', args=None, parser=None):
    ip_regex = re.compile("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")
    not_matching_count = 0
    for host in models.get_hosts(workspace):
        if re.match(ip_regex, host.ip):
            print(host.ip)
        else:
            not_matching_count += 1
    if not_matching_count:
        print('Hosts that has invalid ip addresses {0}'.format(
            not_matching_count))

    return 0, None
Пример #5
0
def main(workspace='', args=None, parser=None):
    parser.add_argument('-y', '--yes', action="store_true")
    parsed_args = parser.parse_args(args)
    if not parsed_args.yes:
        msg = ("Are you sure you want to delete all hosts in the "
               "workspace {}? This action can't be undone [y/n] ".format(
                   workspace))
        if raw_input(msg) not in ('y', 'yes'):
            return 1, None
    for host in models.get_hosts(workspace):
        print('Delete Host:' + host.name)
        models.delete_host(workspace, host.id)
    return 0, None
Пример #6
0
def main(workspace='', args=None, parser=None):
    parser.add_argument('os_filter',
                        nargs='*',
                        help='List of OSs to filter for',
                        default=[])

    parsed_args = parser.parse_args(args)

    for host in models.get_hosts(workspace):

        if not parsed_args.os_filter or (parsed_args.os_filter
                                         and host.os in parsed_args.os_filter):
            print('%s\t%s' % (host.name, host.os))

    return 0, None
Пример #7
0
def main(workspace='', args=None, parser=None):
    parser.add_argument('-s', '--sorted', help='Print a sorted list of IPs.', action='store_true')

    parsed_args = parser.parse_args(args)

    ips = []

    for host in models.get_hosts(workspace):

        if parsed_args.sorted:
            ips += [host.name]
        else:
            print(host.name)

    if parsed_args.sorted:
        print '\n'.join(sorted(ips))

    return 0, None
Пример #8
0
 def get_hosts(self, **params):
     return models.get_hosts(self.active_workspace, **params)