From 11a7d56584d5f879c81105ce2204e31438fc9150 Mon Sep 17 00:00:00 2001 From: Brendan Coles Date: Mon, 14 Dec 2015 16:19:40 +0000 Subject: [PATCH] Exit cleanly on console history log mkdir failure --- beef | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/beef b/beef index 9a0a1dbeb..961cf8b74 100755 --- a/beef +++ b/beef @@ -138,7 +138,13 @@ if config.get("beef.extension.console.shell.enable") == true require 'extensions/console/shell' puts "" begin - FileUtils.mkdir_p(File.expand_path(config.get("beef.extension.console.shell.historyfolder"))) + log_dir = File.expand_path(config.get("beef.extension.console.shell.historyfolder")) + FileUtils.mkdir_p(log_dir) unless File.directory?(log_dir) + rescue => e + print_error "Could not create log directory for shell history '#{log_dir}': #{e.message}" + exit 1 + end + begin BeEF::Extension::Console::Shell.new(BeEF::Extension::Console::Shell::DefaultPrompt, BeEF::Extension::Console::Shell::DefaultPromptChar, {'config' => config, 'http_hook_server' => http_hook_server}).run rescue Interrupt