Esempio n. 1
0
    def __perform_havoc(self, payload_array, metadata, use_splicing):
        perf = metadata["performance"]
        havoc_amount = havoc.havoc_range(self.HAVOC_MULTIPLIER / perf)

        if use_splicing:
            self.stage_update_label("afl_splice")
            havoc.mutate_seq_splice_array(payload_array, self.execute,
                                          havoc_amount)
        else:
            self.stage_update_label("afl_havoc")
            havoc.mutate_seq_havoc_array(payload_array, self.execute,
                                         havoc_amount)
Esempio n. 2
0
    def __perform_havoc(self, payload_array, metadata, use_splicing):
        # log_master("Havoc...")
        default_info = {"method": "havoc", "parent": metadata["id"]}
        perf = 1 / metadata["info"]["performance"]
        if metadata and len(metadata["fav_bits"]) > 0:
            havoc_amount = havoc.havoc_range(perf * self.HAVOC_MULTIPLIER *
                                             2.0)
            # radamsa_amount = havoc.havoc_range(
            #     perf * self.HAVOC_MULTIPLIER * 2.0) / self.RADAMSA_DIV
        else:
            havoc_amount = havoc.havoc_range(perf * self.HAVOC_MULTIPLIER)
            # radamsa_amount = havoc.havoc_range(perf * self.HAVOC_MULTIPLIER) / self.RADAMSA_DIV

        if not use_splicing:
            havoc.mutate_seq_havoc_array(payload_array, self.execute,
                                         default_info, havoc_amount)
        else:
            havoc.mutate_seq_splice_array(payload_array, self.execute,
                                          default_info, havoc_amount)
Esempio n. 3
0
    def __perform_havoc(self, payload_array, payload, use_splicing):
        log_master("Havoc...")
        self.kafl_state["progress_bitflip"] = self.kafl_state[
            "progress_bitflip_amount"]
        self.kafl_state["progress_arithmetic"] = self.kafl_state[
            "progress_arithmetic_amount"]
        self.kafl_state["progress_interesting"] = self.kafl_state[
            "progress_interesting_amount"]
        self.kafl_state["progress_redqueen"] = self.kafl_state[
            "progress_requeen_amount"]

        if payload and payload.node_type == KaflNodeType.favorite:
            self.kafl_state["progress_havoc_amount"] = havoc.havoc_range(
                self.kafl_state.get_performance() * self.HAVOC_MULTIPLIER *
                2.0)
            self.kafl_state["progress_specific_amount"] = havoc.havoc_range(
                self.kafl_state.get_performance() * self.HAVOC_MULTIPLIER *
                2.0) / self.RADAMSA_DIV
        else:
            self.kafl_state["progress_havoc_amount"] = havoc.havoc_range(
                self.kafl_state.get_performance() * self.HAVOC_MULTIPLIER)
            self.kafl_state["progress_specific_amount"] = havoc.havoc_range(
                self.kafl_state.get_performance() *
                self.HAVOC_MULTIPLIER) / self.RADAMSA_DIV

        if not use_splicing:
            self.kafl_state["technique"] = "HAVOC"
            havoc.mutate_seq_havoc_array(
                payload_array, self.__havoc_handler,
                self.kafl_state["progress_havoc_amount"])
        else:
            self.kafl_state["technique"] = "SPLICING"
            havoc.mutate_seq_splice_array(
                payload_array, self.__splicing_handler,
                self.kafl_state["progress_havoc_amount"], self.kafl_state)
        self.__buffered_handler(None, last_payload=True)

        mutate_seq_radamsa_array(payload_array,
                                 self.__radamsa_handler,
                                 self.kafl_state["progress_specific_amount"],
                                 kafl_state=self.kafl_state)
        self.__buffered_handler(None, last_payload=True)
Esempio n. 4
0
    def handle_initial(self, payload, metadata):
        time_initial_start = time.time()

        if self.config.argument_values["trace"]:
            self.stage_update_label("trace")
            self.slave.trace_payload(payload, metadata)

        self.stage_update_label("calibrate")
        # Update input performance using multiple randomized executions
        # Scheduler will de-prioritize execution of very slow nodes..
        num_execs = 10
        timer_start = time.time()
        havoc.mutate_seq_havoc_array(payload, self.execute, num_execs)
        timer_end = time.time()
        self.performance = (timer_end - timer_start) / num_execs

        # Trimming only for stable + non-crashing inputs
        if metadata["info"][
                "exit_reason"] != "regular":  #  or metadata["info"]["stable"]:
            log_slave("Validate: Skip trimming..", self.slave.slave_id)
            return None

        center_trim = False

        new_payload = perform_trim(payload, metadata, self.execute)

        if center_trim:
            new_payload = perform_center_trim(new_payload,
                                              metadata,
                                              self.execute,
                                              trimming_bytes=2)
        self.initial_time += time.time() - time_initial_start
        if new_payload == payload:
            return None
        #log_slave("before trim:\t\t{}".format(repr(payload)), self.slave.slave_id)
        #log_slave("after trim:\t\t{}".format(repr(new_payload)), self.slave.slave_id)
        return new_payload