Exemplo n.º 1
0
def main(workspace='', args=None, parser=None):
    parser.add_argument('protocol', help="Desired protocol", default="")
    parser.add_argument('--path', help="Saves the Image in a given path", default=".")
    parsed_args = parser.parse_args(args)

    protocols = parsed_args.protocol.split(",")
    path = parsed_args.path

    for protocol in protocols:

        if not os.path.exists(path):
            print("Invalid Path")
            exit()

        try:
            services = models.get_services(workspace)
        except ResourceDoesNotExist:
            print("Invalid workspace name: ", workspace)
            return 1, None

        for service in services:
            service_protocol = service.protocol.lower()

            if service_protocol == protocol:
                port = str(service.ports[0])

                interface_id = ".".join(service.id.split(".")[:2])
                interface = models.get_interface(workspace, interface_id)
                ip = interface.ipv4["address"]

                print(protocol + "://" + ip + ":" + port)
                screenshot(path, protocol, ip, port)
    return 0, None
Exemplo n.º 2
0
def main(workspace='', args=None, parser=None):

    parser.add_argument('-v',
                        '--verbose',
                        action='store_true',
                        help='Verbose output from the pcapfile library.')
    parser.add_argument('pcap', help='Path to the PCAP file'),

    parsed_args = parser.parse_args(args)

    try:
        from scapy.all import PcapReader
    except ImportError:
        print 'capfile not found, please install it to use this plugin.' \
              ' You can do install it by executing pip2 install scapy in a shell.'
        return 1, None

    if not os.path.isfile(parsed_args.pcap):
        print "pcap file not found: " % parsed_args.pcap
        return 2, None

    pcap = PcapReader(parsed_args.pcap)
    for (domain, ip) in get_domain_resolutions(pcap):
        obj = factory.createModelObject(models.Host.class_signature,
                                        ip,
                                        workspace,
                                        parent_id=None)

        old = models.get_host(workspace, obj.getID())
        if old is None:
            models.create_host(workspace, obj)

        interface = factory.createModelObject(
            models.Interface.class_signature,
            '',
            workspace,
            # mac=bssid,
            ipv4_address=ip,
            ipv4_gateway='',
            ipv4_mask='',
            ipv4_dns='',
            ipv6_address='',
            ipv6_gateway='',
            ipv6_prefix='',
            ipv6_dns='',
            network_segment='',
            hostnames=[domain],
            parent_id=obj.getID())
        old = models.get_interface(workspace, obj.getID())
        if old is None:
            try:
                models.create_interface(workspace, interface)
            except:
                pass

    return 0, None
Exemplo n.º 3
0
def main(workspace="", args=None, parser=None):

    WORKSPACE = workspace

    parser.add_argument("--csv", help="Csv file to import")
    parsed_args = parser.parse_args(args)

    if not parsed_args.csv:
        print "Error: Give a CSV file to import with --csv"
        return 2, None

    try:
        file_csv = open(parsed_args.csv, "r")
    except:
        print "Error: Unreadeable CSV file, check the path"
        raise

    counter = 0
    csv_reader = csv.DictReader(file_csv, delimiter=",", quotechar='"')
    for register in csv_reader:

        host, interface, service, vulnerability, vulnerability_web = parse_register(register)

        # Set all IDs and create objects
        if host is not None:

            host.setID(None)
            if not models.get_host(WORKSPACE, host.getID()):

                counter += 1
                print "New host: " + host.getName()
                models.create_host(WORKSPACE, host)

        if interface is not None:

            interface.setID(host.getID())
            if not models.get_interface(WORKSPACE, interface.getID()):

                counter += 1
                print "New interface: " + interface.getName()
                models.create_interface(WORKSPACE, interface)

        if service is not None:

            service.setID(interface.getID())
            if not models.get_service(WORKSPACE, service.getID()):

                counter += 1
                print "New service: " + service.getName()
                models.create_service(WORKSPACE, service)

        # Check if Service exist, then create the vuln with parent Service.
        # If not exist the Service, create the vuln with parent Host.
        if vulnerability is not None:

            if service is None:
                vulnerability.setID(host.getID())
            else:
                vulnerability.setID(service.getID())
            if not models.get_vuln(WORKSPACE, vulnerability.getID()):

                counter += 1
                print "New vulnerability: " + vulnerability.getName()
                models.create_vuln(WORKSPACE, vulnerability)

        elif vulnerability_web is not None:

            vulnerability_web.setID(service.getID())
            if not models.get_web_vuln(WORKSPACE, vulnerability_web.getID()):

                counter += 1
                print "New web vulnerability: " + vulnerability_web.getName()
                models.create_vuln_web(WORKSPACE, vulnerability_web)

    print "[*]", counter, "new Faraday objects created."
    file_csv.close()
    return 0, None
Exemplo n.º 4
0
def main(workspace='', args=None, parser=None):
    parser.add_argument('host_id', help='Host ID')
    parser.add_argument('name', help='Interface Name')
    parser.add_argument('mac', help='Interface MAC Address')

    parser.add_argument('--ipv4address',
                        help='IPV4 Address',
                        default='0.0.0.0')
    parser.add_argument('--ipv4gateway',
                        help='IPV4 Gateway',
                        default='0.0.0.0')
    parser.add_argument('--ipv4mask', help='IPV4 Mask', default='0.0.0.0')
    parser.add_argument('--ipv4dns',
                        help='IPV4 DNS, as a comma separated list',
                        default='')

    parser.add_argument('--ipv6address',
                        help='IPV6 Address',
                        default='0000:0000:0000:0000:0000:0000:0000:0000')
    parser.add_argument('--ipv6prefix', help='IPV6 Prefix', default='00')
    parser.add_argument('--ipv6gateway',
                        help='IPV4 Gateway',
                        default='0000:0000:0000:0000:0000:0000:0000:0000')
    parser.add_argument('--ipv6dns',
                        help='IPV6 DNS, as a comma separated list',
                        default='')

    parser.add_argument('--netsegment', help='Network Segment', default='')
    parser.add_argument('--hostres', help='Hostname Resolution', default='')

    parser.add_argument(
        '--dry-run',
        action='store_true',
        help='Do not touch the database. Only print the object ID')

    parsed_args = parser.parse_args(args)

    ipv4_dns = filter(None, parsed_args.ipv4dns.split(','))
    ipv6_dns = filter(None, parsed_args.ipv6dns.split(','))

    obj = factory.createModelObject(models.Interface.class_signature,
                                    parsed_args.name,
                                    workspace,
                                    mac=parsed_args.mac,
                                    ipv4_address=parsed_args.ipv4address,
                                    ipv4_mask=parsed_args.ipv4mask,
                                    ipv4_gateway=parsed_args.ipv4gateway,
                                    ipv4_dns=ipv4_dns,
                                    ipv6_address=parsed_args.ipv6address,
                                    ipv6_prefix=parsed_args.ipv6prefix,
                                    ipv6_gateway=parsed_args.ipv6gateway,
                                    ipv6_dns=ipv6_dns,
                                    network_segment=parsed_args.netsegment,
                                    hostname_resolution=parsed_args.hostres,
                                    parent_id=parsed_args.host_id)

    old = models.get_interface(workspace, obj.getID())

    if old is None:
        if not parsed_args.dry_run:
            models.create_interface(workspace, obj)
    else:
        print "An interface with ID %s already exists!" % obj.getID()
        return 2, None

    return 0, obj.getID()
Exemplo n.º 5
0
def main(workspace="", args=None, parser=None):

    WORKSPACE = workspace

    parser.add_argument("--csv", help="Csv file to import")
    parsed_args = parser.parse_args(args)

    if not parsed_args.csv:
        print "Error: Give a CSV file to import with --csv"
        return 2, None

    try:
        file_csv = open(parsed_args.csv, "r")
    except:
        print "Error: Unreadeable CSV file, check the path"
        raise

    counter = 0
    csv_reader = csv.DictReader(file_csv, delimiter=",", quotechar='"')
    for register in csv_reader:

        host, interface, service, vulnerability, vulnerability_web = parse_register(
            register)

        # Set all IDs and create objects
        if host is not None:

            host.setID(None)
            if not models.get_host(WORKSPACE, host.getID()):

                counter += 1
                print "New host: " + host.getName()
                models.create_host(WORKSPACE, host)

        if interface is not None:

            interface.setID(host.getID())
            if not models.get_interface(WORKSPACE, interface.getID()):

                counter += 1
                print "New interface: " + interface.getName()
                models.create_interface(WORKSPACE, interface)

        if service is not None:

            service.setID(interface.getID())
            if not models.get_service(WORKSPACE, service.getID()):

                counter += 1
                print "New service: " + service.getName()
                models.create_service(WORKSPACE, service)

        # Check if Service exist, then create the vuln with parent Service.
        # If not exist the Service, create the vuln with parent Host.
        if vulnerability is not None:

            if service is None:
                vulnerability.setID(host.getID())
            else:
                vulnerability.setID(service.getID())
            if not models.get_vuln(WORKSPACE, vulnerability.getID()):

                counter += 1
                print "New vulnerability: " + vulnerability.getName()
                models.create_vuln(WORKSPACE, vulnerability)

        elif vulnerability_web is not None:

            vulnerability_web.setID(service.getID())
            if not models.get_web_vuln(WORKSPACE, vulnerability_web.getID()):

                counter += 1
                print "New web vulnerability: " + vulnerability_web.getName()
                models.create_vuln_web(WORKSPACE, vulnerability_web)

    print "[*]", counter, "new Faraday objects created."
    file_csv.close()
    return 0, None
def main(workspace='', args=None, parser=None):
    parser.add_argument('host_name', help='Host name')
    parser.add_argument('os', help='OS')

    parser.add_argument('interface_name', help='Interface Name')
    parser.add_argument('mac', help='Interface MAC Address')

    parser.add_argument('--ipv4address', help='IPV4 Address', default='0.0.0.0')
    parser.add_argument('--ipv4gateway', help='IPV4 Gateway', default='0.0.0.0')
    parser.add_argument('--ipv4mask', help='IPV4 Mask', default='0.0.0.0')
    parser.add_argument('--ipv4dns', help='IPV4 DNS, as a comma separated list', default='[]')

    parser.add_argument('--ipv6address', help='IPV6 Address', default='0000:0000:0000:0000:0000:0000:0000:0000')
    parser.add_argument('--ipv6prefix', help='IPV6 Prefix', default='00')
    parser.add_argument('--ipv6gateway', help='IPV4 Gateway', default='0000:0000:0000:0000:0000:0000:0000:0000')
    parser.add_argument('--ipv6dns', help='IPV6 DNS, as a comma separated list', default='')

    parser.add_argument('--netsegment', help='Network Segment', default='')
    parser.add_argument('--hostres', help='Hostname Resolution', default='')


    parser.add_argument('--dry-run', action='store_true', help='Do not touch the database. Only print the object ID')

    parsed_args = parser.parse_args(args)

    obj_host = factory.createModelObject(models.Host.class_signature, parsed_args.host_name,
                                    workspace, os=parsed_args.os, parent_id=None)


    old_host = models.get_host(workspace, obj_host.getID())

    if old_host is None:
        if not parsed_args.dry_run:
            models.create_host(workspace, obj_host)
    else:
        print "A host with ID %s already exists!" % obj_host.getID()
        return 2, None



    obj_interface = factory.createModelObject(models.Interface.class_signature, parsed_args.interface_name, workspace,
                                    mac=parsed_args.mac,
                                    ipv4_address=parsed_args.ipv4address,
                                    ipv4_mask=parsed_args.ipv4mask,
                                    ipv4_gateway=parsed_args.ipv4gateway,
                                    ipv4_dns=parsed_args.ipv4dns,
                                    ipv6_address=parsed_args.ipv6address,
                                    ipv6_prefix=parsed_args.ipv6prefix,
                                    ipv6_gateway=parsed_args.ipv6gateway,
                                    ipv6_dns=parsed_args.ipv6dns,
                                    network_segment=parsed_args.netsegment,
                                    hostname_resolution=parsed_args.hostres,
                                    parent_id= obj_host.getID() )

    old_interface = models.get_interface(workspace, obj_interface.getID())

    if old_interface is None:
        if not parsed_args.dry_run:
            models.create_interface(workspace, obj_interface)
    else:
        print "An interface with ID %s already exists!" % obj_interface.getID()
        return 2, None

    return 0, obj_interface.getID()