Beispiel #1
0
def main(argv):
    log.logger = log.Logger()
    out = None
    zone = None
    try:
        nsec3_chain = {}
        try:
            opts, args = getopt.gnu_getopt(argv[1:], "z:o:v")
        except getopt.GetoptError, err:
            usage(argv)
        for opt, arg in opts:
            if opt == '-z':
                zone = n3map.name.fqdn_from_text(arg)
            if opt == '-o':
                out = open(arg, "wb")
            if opt == '-v':
                log.logger.loglevel += 1

        if out is None:
            out = sys.stdout

        if len(args) < 1:
            usage(argv)

        records_file = rrfile.open_input_rrfile(args[0])
        salt = None
        iterations = None
        for nsec3 in records_file.nsec3_reader():
            if salt == None or iterations == None:
                salt = nsec3.salt
                iterations = nsec3.iterations
            elif salt != nsec3.salt or iterations != nsec3.iterations:
                raise ZoneChangedError, "zone salt or iterations not unique!"
            nsec3_chain[nsec3.hashed_owner] = nsec3
        records_file.close()
        log.info("read {0:d} records. ready for input!".format(
            len(nsec3_chain)))

        if len(nsec3_chain) == 0:
            return 0
        if sys.stdin.isatty():
            try:
                while True:
                    line = raw_input()
                    lookup_nsec3(nsec3_chain, salt, iterations, zone, line,
                                 out)
            except (EOFError), e:
                pass
Beispiel #2
0
def main(argv):
    log.logger = log.Logger()
    out = None
    zone = None
    try:
        nsec3_chain = {}
        try:
            opts, args = getopt.gnu_getopt(argv[1:], "z:o:v")
        except getopt.GetoptError, err:
            usage(argv)
        for opt, arg in opts:
            if opt == '-z':
                zone = n3map.name.fqdn_from_text(arg)
            if opt == '-o':
                out = open(arg, "wb")
            if opt == '-v':
                log.logger.loglevel += 1

        if out is None:
            out = sys.stdout

        if len(args) < 1:
            usage(argv)

        records_file = rrfile.open_input_rrfile(args[0])
        salt = None
        iterations = None
        for nsec3 in records_file.nsec3_reader():
            if salt == None or iterations == None:
                salt = nsec3.salt
                iterations = nsec3.iterations
            elif salt != nsec3.salt or iterations != nsec3.iterations:
                raise ZoneChangedError, "zone salt or iterations not unique!"
            nsec3_chain[nsec3.hashed_owner] = nsec3;
        records_file.close()
        log.info("read {0:d} records. ready for input!".format(len(nsec3_chain)))

        if len(nsec3_chain) == 0:
            return 0
        if sys.stdin.isatty():
            try:
                while True:
                    line = raw_input()
                    lookup_nsec3(nsec3_chain, salt, iterations, zone, line, out)
            except (EOFError), e:
                pass
Beispiel #3
0
def main(argv):
    log.logger = log.Logger()
    try:
        if len(argv) < 2:
            usage(argv)
        if len(argv) == 3:
            out = open(argv[2], "wb")
        else:
            out = sys.stdout

        records_file = rrfile.open_input_rrfile(argv[1])

        for nsec3 in records_file.nsec3_reader():
            nsec3_hash = util.str_to_hex(nsec3.hashed_owner)
            zone = str(nsec3.zone)
            iterations = "{0:d}".format(nsec3.iterations)
            salt = util.str_to_hex(nsec3.salt)
            out.write("$NSEC3$" + "$".join((iterations, salt,
                nsec3_hash, zone)) + "\n")
    except (IOError, N3MapError), e:
        log.fatal(e)
Beispiel #4
0
def main(argv):
    log.logger = log.Logger()
    try:
        if len(argv) < 2:
            usage(argv)
        if len(argv) == 3:
            out = open(argv[2], "wb")
        else:
            out = sys.stdout

        records_file = rrfile.open_input_rrfile(argv[1])

        for nsec3 in records_file.nsec3_reader():
            nsec3_hash = util.base32_ext_hex_encode(nsec3.hashed_owner).lower()
            zone = str(nsec3.zone)
            zone = re.sub('\.$', '', zone)
            iterations = "{0:d}".format(nsec3.iterations)
            salt = util.str_to_hex(nsec3.salt)
            out.write(":".join((nsec3_hash, "." + zone, salt, iterations)) 
                    + "\n")
    except (IOError, N3MapError), e:
        log.fatal(e)
Beispiel #5
0
def main(argv):
    log.logger = log.Logger()
    try:
        if len(argv) < 2:
            usage(argv)
        if len(argv) == 3:
            out = open(argv[2], "wb")
        else:
            out = sys.stdout

        records_file = rrfile.open_input_rrfile(argv[1])

        for nsec3 in records_file.nsec3_reader():
            nsec3_hash = util.base32_ext_hex_encode(nsec3.hashed_owner).lower()
            zone = str(nsec3.zone)
            zone = re.sub('\.$', '', zone)
            iterations = "{0:d}".format(nsec3.iterations)
            salt = util.str_to_hex(nsec3.salt)
            out.write(":".join((nsec3_hash, "." + zone, salt, iterations)) +
                      "\n")
    except (IOError, N3MapError), e:
        log.fatal(e)
Beispiel #6
0
        if options['zone_type'] == 'nsec3':
            (hash_queues, process_pool) = prehash.create_prehash_pool(
                options['processes'], options['queue_element_size'],
                options['use_openssl'])
            if options['predict']:
                proc,pipe = create_zone_predictor()
                predictor = (proc,pipe)
            else:
                predictor = None


        if options['input'] is not None:
            records_file = None
            try:
                records_file = rrfile.open_input_rrfile(options['input'])
                chain = []
                if options['zone_type'] == 'nsec3':
                    for rr in records_file.nsec3_reader():
                        check_part_of_zone(rr, zone)
                        chain.append(rr)
                    label_counter = records_file.label_counter
                elif options['zone_type'] == 'nsec':
                    for rr in records_file.nsec_reader():
                        check_part_of_zone(rr, zone)
                        chain.append(rr)
            except IOError, e:
                log.fatal("unable to read input file: \n", str(e))
            except FileParseError, e:
                log.fatal("unable to parse input file: \n", str(e))
            finally:
Beispiel #7
0
                zone, qprovider, options['detection_attempts'])

        if options['zone_type'] == 'nsec3':
            (hash_queues, process_pool) = prehash.create_prehash_pool(
                options['processes'], options['queue_element_size'],
                options['use_openssl'])
            if options['predict']:
                proc, pipe = create_zone_predictor()
                predictor = (proc, pipe)
            else:
                predictor = None

        if options['input'] is not None:
            records_file = None
            try:
                records_file = rrfile.open_input_rrfile(options['input'])
                chain = []
                if options['zone_type'] == 'nsec3':
                    for rr in records_file.nsec3_reader():
                        check_part_of_zone(rr, zone)
                        chain.append(rr)
                    label_counter = records_file.label_counter
                elif options['zone_type'] == 'nsec':
                    for rr in records_file.nsec_reader():
                        check_part_of_zone(rr, zone)
                        chain.append(rr)
            except IOError, e:
                log.fatal("unable to read input file: \n", str(e))
            except FileParseError, e:
                log.fatal("unable to parse input file: \n", str(e))
            finally: