How to use the boofuzz.exception.BoofuzzError function in boofuzz

To help you get started, we’ve selected a few boofuzz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jtpereyda / boofuzz / boofuzz / sessions.py View on Github external
Args:
            target (Target): Target to open.
        """
        if not self._reuse_target_connection:
            out_of_available_sockets_count = 0
            while True:
                try:
                    target.open()
                    break  # break if no exception
                except exception.BoofuzzTargetConnectionFailedError:
                    self._fuzz_data_logger.log_info(constants.WARN_CONN_FAILED_TERMINAL)
                    self._restart_target(target)
                except exception.BoofuzzOutOfAvailableSockets:
                    out_of_available_sockets_count += 1
                    if out_of_available_sockets_count == 50:
                        raise exception.BoofuzzError("There are no available sockets. Ending fuzzing.")
                    self._fuzz_data_logger.log_info("There are no available sockets. Waiting for another 5 seconds.")
                    time.sleep(5)
github jtpereyda / boofuzz / boofuzz / sessions.py View on Github external
super(Session, self).__init__()

        self.session_filename = session_filename
        self._index_start = max(index_start, 1)
        self._index_end = index_end
        self.sleep_time = sleep_time
        self.restart_interval = restart_interval
        self.web_port = web_port
        self._keep_web_open = keep_web_open
        self.console_gui = console_gui
        self._crash_threshold_node = crash_threshold_request
        self._crash_threshold_element = crash_threshold_element
        self.restart_sleep_time = restart_sleep_time
        if fuzz_data_logger is not None:
            raise exception.BoofuzzError("Session fuzz_data_logger is deprecated. Use fuzz_loggers instead!")
        if fuzz_loggers is None:
            fuzz_loggers = []
        if self.console_gui and os.name != "nt":
            fuzz_loggers.append(fuzz_logger_curses.FuzzLoggerCurses(web_port=self.web_port))
            self._keep_web_open = False
        if len(fuzz_loggers) == 0:
            fuzz_loggers = [fuzz_logger_text.FuzzLoggerText()]

        helpers.mkdir_safe(os.path.join(constants.RESULTS_DIR))
        self._run_id = datetime.datetime.utcnow().replace(microsecond=0).isoformat().replace(":", "-")
        self._db_filename = os.path.join(constants.RESULTS_DIR, "run-{0}.db".format(self._run_id))
        self._db_logger = fuzz_logger_db.FuzzLoggerDb(
            db_filename=self._db_filename, num_log_cases=fuzz_db_keep_only_n_pass_cases
        )

        self._crash_filename = "boofuzz-crash-bin-{0}".format(self._run_id)
github jtpereyda / boofuzz / boofuzz / exception.py View on Github external
import attr


class BoofuzzError(Exception):
    pass


class BoofuzzRestartFailedError(BoofuzzError):
    pass


class BoofuzzCallbackError(BoofuzzError):
    pass


class BoofuzzTargetConnectionFailedError(BoofuzzError):
    pass


class BoofuzzTargetConnectionReset(BoofuzzError):
    pass


@attr.s
class BoofuzzTargetConnectionAborted(BoofuzzError):
    """
    Raised on `errno.ECONNABORTED`.
    """
github jtpereyda / boofuzz / boofuzz / sessions.py View on Github external
Args:
            target (Target): Target to open.
        """
        if not self._reuse_target_connection:
            out_of_available_sockets_count = 0
            while True:
                try:
                    target.open()
                    break  # break if no exception
                except exception.BoofuzzTargetConnectionFailedError:
                    self._fuzz_data_logger.log_info(constants.WARN_CONN_FAILED_TERMINAL)
                    self._restart_target(target)
                except exception.BoofuzzOutOfAvailableSockets:
                    out_of_available_sockets_count += 1
                    if out_of_available_sockets_count == 50:
                        raise exception.BoofuzzError("There are no available sockets. Ending fuzzing.")
                    self._fuzz_data_logger.log_info("There are no available sockets. Waiting for another 5 seconds.")
                    time.sleep(5)
github jtpereyda / boofuzz / boofuzz / socket_connection.py View on Github external
data = data[:self.MAX_PAYLOADS[self.proto]]
        except KeyError:
            pass  # data = data

        try:
            if self.proto == "tcp":
                num_sent = self._sock.send(data)
            elif self.proto == "ssl":
                if len(data) > 0:
                    num_sent = self._sock.send(data)
                else:
                    num_sent = 0
            elif self.proto == "udp":
                if self.server:
                    if self._udp_client_port is None:
                        raise exception.BoofuzzError("recv must be called before send with udp fuzzing servers.")
                    num_sent = self._sock.sendto(data, self._udp_client_port)
                else:
                    num_sent = self._sock.sendto(data, (self.host, self.port))
            elif self.proto == "raw-l2":
                num_sent = self._sock.sendto(data, (self.host, 0))
            elif self.proto == "raw-l3":
                # Address tuple: (interface string,
                #                 Ethernet protocol number,
                #                 packet type (recv only),
                #                 hatype (recv only),
                #                 Ethernet address)
                # See man 7 packet for more details.
                num_sent = self._sock.sendto(data, (self.host, self.ethernet_proto, 0, 0, self.l2_dst))
            else:
                raise exception.SullyRuntimeError("INVALID PROTOCOL SPECIFIED: %s" % self.proto)
        except socket.error as e:
github jtpereyda / boofuzz / boofuzz / exception.py View on Github external
class BoofuzzTargetConnectionReset(BoofuzzError):
    pass


@attr.s
class BoofuzzTargetConnectionAborted(BoofuzzError):
    """
    Raised on `errno.ECONNABORTED`.
    """

    socket_errno = attr.ib()
    socket_errmsg = attr.ib()


class BoofuzzNoSuchTestCase(BoofuzzError):
    pass


class BoofuzzRpcError(BoofuzzError):
    pass


class SullyRuntimeError(Exception):
    pass


class SizerNotUtilizedError(Exception):
    pass


class MustImplementException(Exception):
github jtpereyda / boofuzz / boofuzz / exception.py View on Github external
class BoofuzzTargetConnectionFailedError(BoofuzzError):
    pass


class BoofuzzOutOfAvailableSockets(BoofuzzError):
    pass


class BoofuzzTargetConnectionReset(BoofuzzError):
    pass


@attr.s
class BoofuzzTargetConnectionAborted(BoofuzzError):
    """
    Raised on `errno.ECONNABORTED`.
    """

    socket_errno = attr.ib()
    socket_errmsg = attr.ib()


class BoofuzzNoSuchTestCase(BoofuzzError):
    pass


class BoofuzzRpcError(BoofuzzError):
    pass
github jtpereyda / boofuzz / boofuzz / exception.py View on Github external
import attr


class BoofuzzError(Exception):
    pass


class BoofuzzRestartFailedError(BoofuzzError):
    pass


class BoofuzzTargetConnectionFailedError(BoofuzzError):
    pass


class BoofuzzOutOfAvailableSockets(BoofuzzError):
    pass


class BoofuzzTargetConnectionReset(BoofuzzError):
    pass


@attr.s
class BoofuzzTargetConnectionAborted(BoofuzzError):
    """
    Raised on `errno.ECONNABORTED`.
    """