示例#1
0
    def _walk_zone(self):
        dname = self.start
        covering_nsec = None
        while not self._finished(dname):
            query_dn, recv_nsec = self._retrieve_nsec(dname, covering_nsec)
            if len(recv_nsec) == 0:
                raise NSECWalkError, (
                    'no NSEC RR received\n',
                    "Maybe the zone doesn't support DNSSEC or uses NSEC3 RRs")
            covering_nsec = self._find_covering_rr(recv_nsec, query_dn)
            if covering_nsec is None:
                raise NSECWalkError, (
                    "no covering NSEC RR received for domain name ",
                    str(dname))

            log.debug2('covering NSEC RR found: ', str(covering_nsec))

            self._write_record(covering_nsec)

            if (covering_nsec.owner > covering_nsec.next_owner
                    and covering_nsec.next_owner != self.zone):
                raise NSECWalkError, ('NSEC owner > next_owner, ',
                                      'but next_owner != zone')

            self.nsec_chain.append(covering_nsec)
            log.info('discovered owner: ', str(covering_nsec.owner), "\t",
                     ' '.join(covering_nsec.types))
            log.update()
            dname = covering_nsec.next_owner

        self._write_number_of_records(len(self.nsec_chain))
        return self.nsec_chain
示例#2
0
    def _walk_zone(self):
        dname = self.start
        covering_nsec = None
        while not self._finished(dname):
            query_dn, recv_nsec = self._retrieve_nsec(dname, covering_nsec)
            if len(recv_nsec) == 0:
                raise NSECWalkError, ('no NSEC RR received\n',
                    "Maybe the zone doesn't support DNSSEC or uses NSEC3 RRs")
            covering_nsec = self._find_covering_rr(recv_nsec, query_dn)
            if covering_nsec is None:
                raise NSECWalkError, ("no covering NSEC RR received for domain name ", 
                        str(dname))

            log.debug2('covering NSEC RR found: ', str(covering_nsec))
            
            self._write_record(covering_nsec)
            
            if (covering_nsec.owner > covering_nsec.next_owner and
                    covering_nsec.next_owner != self.zone):
                raise NSECWalkError, ('NSEC owner > next_owner, ', 
                        'but next_owner != zone')

            self.nsec_chain.append(covering_nsec)
            log.info('discovered owner: ', str(covering_nsec.owner),
                    "\t", ' '.join(covering_nsec.types))
            log.update()
            dname = covering_nsec.next_owner

        self._write_number_of_records(len(self.nsec_chain))
        return self.nsec_chain
示例#3
0
    def build_corpus(self):
        log.info("Initializing Corpus...")

        # Resetting Corpus to avoid at restart to have with ASLR more blocks than needed
        self.accumulated_coverage = set()

        corpus = [
            self.project.corpus_dir + "/" + x
            for x in os.listdir(self.project.corpus_dir)
        ]
        corpus.sort()

        for c in self.corpus_blacklist:
            if c in corpus:
                corpus.remove(c)

        if len(corpus) == 0:
            log.warn(
                "Corpus is empty, please add files/directories with 'add'")
            return False

        for infile in corpus:
            fuzz_pkt = open(infile, "rb").read()
            coverage_last = None
            for i in range(5):
                t = time.strftime("%Y-%m-%d %H:%M:%S")
                log.update(t + " [iteration=%d] %s" % (i, infile))

                # send packet to target
                coverage = self.get_coverage_of_payload(
                    fuzz_pkt, infile, corpus)
                if coverage is None or len(coverage) == 0:
                    log.warn(
                        f"No coverage was returned! you might want to delete {infile} from corpus if it happens "
                        f"more often")

                # log.info("Iteration=%d  covlen=%d file=%s" % (i, len(coverage), infile))

                if coverage_last is not None and coverage_last != coverage:
                    log.warn(t +
                             " [iteration=%d] Inconsistent coverage for %s!" %
                             (i, infile))
                    # log.info("diff a-b:" + " ".join([str(x) for x in coverage_last.difference(coverage)]))
                    # log.info("diff b-a:" + " ".join([str(x) for x in coverage.difference(coverage_last)]))

                coverage_last = coverage
                # Accumulate coverage:
                self.accumulated_coverage = self.accumulated_coverage.union(
                    coverage_last)

            write_drcov_file(
                self.modules, coverage_last,
                self.project.coverage_dir + "/" + infile.split("/")[-1])

        log.finish_update(
            "Using %d input files which cover a total of %d basic blocks!" %
            (len(corpus), len(self.accumulated_coverage)))
        self.corpus = corpus
        return True
示例#4
0
    def _find_uncovered_dn(self, generator, break_early=False):
        is_covered = self.nsec3_chain.covers
        while True:
            for ptlabel,dn_hash in self._prehash_iter:
                if not is_covered(dn_hash):
                    dn = name.DomainName(name.Label(ptlabel), *self.zone.labels)
                    owner_b32 = util.base32_ext_hex_encode( dn_hash).lower()
                    hashed_dn = name.DomainName( name.Label(owner_b32), *self.zone.labels)
                    log.debug3('found uncovered dn: ', str(dn), '; hashed: ', str(hashed_dn))
                    return dn,dn_hash

            self.stats['tested_hashes'] += len(self._prehash_list)
            hashes, label_counter_state = self._hash_queues.next().recv()
            if self._label_counter_state < label_counter_state:
                self._label_counter_state = label_counter_state
            self._prehash_list = hashes
            self._prehash_iter = iter(hashes)
            log.update()
            if break_early:
                return None,None
示例#5
0
def mainProcess(str1,str2,order,name_log):
	process_failed=False
	renew_working_dir()
	# --- get the std command.
	std_order=processFuncs.separate_num_and_letter(order)
	command=classCommands.makeCommand(std_order)

	# --- Get the file list:
	flt=getFileList()

	if not command.whether_rename(): # --- this command will not rename the files
		if command.Help.value:
			command.print_help()
	else: # --- this command will rename the files.
		if command.cancel.value:
			if name_log and name_log[0].length>=2:
				for i in range(len(name_log)):
					cur_name=name_log[i].back()
					dot_pos=cur_name.rfind('.')
					suffix=cur_name[dot_pos:] if dot_pos>0 else ''
					tmp_name='Begin_bcigiuipgva3cvGHVGHjsbv__{Num:0>6d}__avhav_End'.format(Num=i)+suffix
					os.rename(cur_name,tmp_name)
				for i in range(len(name_log)):
					pre_name=name_log[i].lists[name_log[i].length-2]
					dot_pos=pre_name.rfind('.')
					suffix=pre_name[dot_pos:] if dot_pos>0 else ''
					cur_name='Begin_bcigiuipgva3cvGHVGHjsbv__{Num:0>6d}__avhav_End'.format(Num=i)+suffix
					os.rename(cur_name,pre_name)
					name_log[i].pop()
			else:
				error.warning(418)
				process_failed=True
		else:
			flt=processFuncs.sort_by_command(flt,command)
			for i in range(len(flt)):
				begins,ends=processFuncs.getBegs_and_ends(flt[i].mainName,str1,command)

				if begins:
					real_str2=processFuncs.real_str2(i+1,str2,command,len(flt))
					new_main_name=processFuncs.replace(flt[i].mainName,real_str2,begins,ends)
					flt[i].rename(new_main_name)
			# --- To Check if there are empty names in new names.
			if validity.have_empty_names_in(flt):
				error.warning(419)
				process_failed=True
				return command.Quit and not command.Help
			# --- To Check if new names are the sames the olds.
			all_same=True
			for f in flt:
				if f.oriFullName!=f.fullName:
					all_same=False
			if all_same:
				error.warning(420)
				process_failed=True
				return command.Quit and not command.Help
			# --- To Check if the new names have conflict with old names during and after the process of raneming
			if not validity.conflict_while_rename(flt):
				for i in range(len(flt)):
					os.rename(flt[i].oriFullName,flt[i].fullName)
				log.update(name_log,flt)
			else:
				error.warning(validity.conflict_while_rename(flt))
				process_failed=True
	if not process_failed:
		error.warning(0)
	return command.Quit and not command.Help
        invalid = False
        user_choice = user.choice()

        if user_choice == 1:  #if user select to borrow
            display.heading("which book are you borrowing?")
            display.matrix(book_list)
            user_select = user.choice()
            updated_data = book.borrow_book(user_select, user_data, book_list)
            user_data = updated_data[0]
            book_list = updated_data[1]
            log_msg = updated_data[2]
            print(log_msg)

            #updating files according to change
            user.update(user_name, user_data)
            log.update(user_name, log_msg)
            book.update(book_list)

        elif user_choice == 2:  #if user select to return
            display.heading("which book are you returning?")
            display.user_data(user_data)
            if len(user_data) != 0:
                user_select = user.choice()
                updated_data = book.return_book(user_select, user_data,
                                                book_list)
                user_data = updated_data[0]
                book_list = updated_data[1]
                log_msg = updated_data[2]
                print(log_msg)

                #updating files according to change
示例#7
0
def sage_prompt():
    log.update()
    return '%s'%_prompt
示例#8
0
def sage_prompt():
    log.update()
    return '%s'%_prompt