Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions boofuzz/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ def __init__(
restart_callbacks=None,
restart_threshold=None,
restart_timeout=None,
restart_wait=3,
pre_send_callbacks=None,
post_test_case_callbacks=None,
post_start_target_callbacks=None,
Expand Down Expand Up @@ -480,6 +481,7 @@ def __init__(
self.restart_sleep_time = restart_sleep_time
self.restart_threshold = restart_threshold
self.restart_timeout = restart_timeout
self.restart_wait = restart_wait
if fuzz_loggers is None:
fuzz_loggers = []
if self.console_gui and os.name != "nt":
Expand Down Expand Up @@ -1043,8 +1045,8 @@ def _restart_target(self, target):
self._fuzz_data_logger.log_info("Restarting target process using {}".format(monitor.__class__.__name__))
if monitor.restart_target(target=target, fuzz_data_logger=self._fuzz_data_logger, session=self):
# TODO: doesn't this belong in the process monitor?
self._fuzz_data_logger.log_info("Giving the process 3 seconds to settle in")
time.sleep(3)
self._fuzz_data_logger.log_info("Giving the process %d seconds to settle in" % self.restart_wait)
time.sleep(self.restart_wait)
Comment thread
SR4ven marked this conversation as resolved.
Outdated
restarted = True
break

Expand Down
31 changes: 19 additions & 12 deletions boofuzz/utils/debugger_thread_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,23 @@ def run(self):
gone, _ = psutil.wait_procs([self._psutil_proc])
self.exit_status = gone[0].returncode
else:
exit_info = os.waitpid(self.pid, 0)
self.exit_status = exit_info[1] # [0] is the pid
# Waitpid doesn't work well on windows, switching to _process.wait()
self.exit_status = self._process.wait()

default_reason = "Process died for unknown reason"
if self.exit_status is not None:
if os.WCOREDUMP(self.exit_status):
reason = "Segmentation fault"
elif os.WIFSTOPPED(self.exit_status):
reason = "Stopped with signal " + str(os.WTERMSIG(self.exit_status))
elif os.WIFSIGNALED(self.exit_status):
reason = "Terminated with signal " + str(os.WTERMSIG(self.exit_status))
elif os.WIFEXITED(self.exit_status):
reason = "Exit with code - " + str(os.WEXITSTATUS(self.exit_status))
else:
try:
if os.WCOREDUMP(self.exit_status):
reason = "Segmentation fault"
elif os.WIFSTOPPED(self.exit_status):
reason = "Stopped with signal " + str(os.WTERMSIG(self.exit_status))
elif os.WIFSIGNALED(self.exit_status):
reason = "Terminated with signal " + str(os.WTERMSIG(self.exit_status))
elif os.WIFEXITED(self.exit_status):
reason = "Exit with code - " + str(os.WEXITSTATUS(self.exit_status))
else:
reason = default_reason
except AttributeError: # Windows does not support WCOREDUMP
reason = default_reason
else:
reason = default_reason
Expand Down Expand Up @@ -210,7 +213,11 @@ def get_exit_status(self):

def stop_target(self):
try:
os.kill(self.pid, signal.SIGKILL)
try:
os.kill(self.pid, signal.SIGKILL)
except AttributeError:
# Windows does not support signal.SIGKILL
os.system("taskkill /F /PID:%d" % self.pid)
except OSError as e:
print(
'Error while killing process. PID: {0} errno: {1} "{2}"'.format(self.pid, e.errno, os.strerror(e.errno))
Expand Down
17 changes: 5 additions & 12 deletions process_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from boofuzz.utils.process_monitor_pedrpc_server import ProcessMonitorPedrpcServer


def serve_procmon(port, crash_bin, proc_name, ignore_pid, log_level):
def serve_procmon(ip, port, crash_bin, proc_name, ignore_pid, log_level):
with ProcessMonitorPedrpcServer(
host="0.0.0.0",
host=ip,
port=port,
crash_filename=crash_bin,
debugger_class=DebuggerThreadSimple,
Expand All @@ -22,14 +22,6 @@ def serve_procmon(port, crash_bin, proc_name, ignore_pid, log_level):
servlet.serve_forever()


# app.args.add_argument("-c", "--crash_bin", help='filename to serialize crash bin class to',
# default='boofuzz-crash-bin', metavar='FILENAME')
# app.args.add_argument("-i", "--ignore_pid", help='PID to ignore when searching for target process', type=int,
# metavar='PID')
# app.args.add_argument("-l", "--log_level", help='log level: default 1, increase for more verbosity', type=int,
# default=1, metavar='LEVEL')
# app.args.add_argument("-p", "--proc_name", help='process name to search for and attach to', metavar='NAME')
# app.args.add_argument("-P", "--port", help='TCP port to bind this agent to', type=int, default=DEFAULT_PROCMON_PORT)
@click.command()
@click.option(
"--crash-bin",
Expand Down Expand Up @@ -58,8 +50,9 @@ def serve_procmon(port, crash_bin, proc_name, ignore_pid, log_level):
)
@click.option("--proc-name", "--proc_name", "-p", help="process name to search for and attach to", metavar="NAME")
@click.option("--port", "-P", help="TCP port to bind this agent to", type=int, default=DEFAULT_PROCMON_PORT)
def go(crash_bin, ignore_pid, log_level, proc_name, port):
serve_procmon(port=port, crash_bin=crash_bin, proc_name=proc_name, ignore_pid=ignore_pid, log_level=log_level)
@click.option("--ip", "-I", help="IP of the computer", type=str, default="0.0.0.0")
Comment thread
SR4ven marked this conversation as resolved.
Outdated
def go(crash_bin, ignore_pid, log_level, proc_name, port, ip):
serve_procmon(ip, port=port, crash_bin=crash_bin, proc_name=proc_name, ignore_pid=ignore_pid, log_level=log_level)


if __name__ == "__main__":
Expand Down