Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
When fuzzing RPC for example, register this method to establish the RPC bind.
@see: pre_send()
Args:
target (session.target): Target we are sending data to
"""
if len(self._pre_send_methods) > 0:
try:
for f in self._pre_send_methods:
self._fuzz_data_logger.open_test_step('Pre_Send callback: "{0}"'.format(f.__name__))
f(target=target, fuzz_data_logger=self._fuzz_data_logger, session=self, sock=target)
except Exception:
self._fuzz_data_logger.log_error(
constants.ERR_CALLBACK_FUNC.format(func_name="pre_send") + traceback.format_exc()
)
raise exception.BoofuzzRestartFailedError()
self._fuzz_data_logger.log_info("Giving the process 3 seconds to settle in")
time.sleep(3)
# if we have custom restart methods, execute them
elif len(self._restart_methods) > 0:
try:
for f in self._restart_methods:
self._fuzz_data_logger.open_test_step('Target restart callback: "{0}"'.format(f.__name__))
f(target=target, fuzz_data_logger=self._fuzz_data_logger, session=self, sock=target)
except exception.BoofuzzRestartFailedError:
raise
except Exception:
self._fuzz_data_logger.log_error(
constants.ERR_CALLBACK_FUNC.format(func_name="restart_target") + traceback.format_exc()
)
finally:
self._fuzz_data_logger.open_test_step("Cleaning up connections from callbacks")
target.close()
if self._reuse_target_connection:
self._fuzz_data_logger.open_test_step("Reopening target connection")
target.open()
# otherwise all we can do is wait a while for the target to recover on its own.
else:
self._fuzz_data_logger.log_info(
"No reset handler available... sleeping for {} seconds".format(self.restart_sleep_time)
)
time.sleep(self.restart_sleep_time)
# pass specified target parameters to the PED-RPC server to re-establish connections.
raise exception.BoofuzzRestartFailedError()
self._fuzz_data_logger.log_info("Giving the process 3 seconds to settle in")
time.sleep(3)
# if we have custom restart methods, execute them
elif len(self._restart_methods) > 0:
try:
for f in self._restart_methods:
self._fuzz_data_logger.open_test_step('Target restart callback: "{0}"'.format(f.__name__))
f(target=target, fuzz_data_logger=self._fuzz_data_logger, session=self, sock=target)
except exception.BoofuzzRestartFailedError:
raise
except Exception:
self._fuzz_data_logger.log_error(
constants.ERR_CALLBACK_FUNC.format(func_name="restart_target") + traceback.format_exc()
)
finally:
self._fuzz_data_logger.open_test_step("Cleaning up connections from callbacks")
target.close()
if self._reuse_target_connection:
self._fuzz_data_logger.open_test_step("Reopening target connection")
target.open()
# otherwise all we can do is wait a while for the target to recover on its own.
else:
self._fuzz_data_logger.log_info(
"No reset handler available... sleeping for {} seconds".format(self.restart_sleep_time)
)
time.sleep(self.restart_sleep_time)
# pass specified target parameters to the PED-RPC server to re-establish connections.
When fuzzing RPC for example, register this method to establish the RPC bind.
@see: pre_send()
Args:
target (session.target): Target we are sending data to
"""
if len(self._pre_send_methods) > 0:
try:
for f in self._pre_send_methods:
self._fuzz_data_logger.open_test_step('Pre_Send callback: "{0}"'.format(f.__name__))
f(target=target, fuzz_data_logger=self._fuzz_data_logger, session=self, sock=target)
except Exception:
self._fuzz_data_logger.log_error(
constants.ERR_CALLBACK_FUNC.format(func_name="pre_send") + traceback.format_exc()
)