From f28e0d9d939450c440ad27fb8293862a6d03c285 Mon Sep 17 00:00:00 2001 From: elliot <116954050+e-lliot@users.noreply.github.com> Date: Thu, 21 Sep 2023 00:10:07 +1000 Subject: [PATCH] Update fs.rb Added lmkdir command to create new directory on local machine --- .../ui/console/command_dispatcher/stdapi/fs.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb b/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb index ae5ec1be67bf..1a31f12a9f7b 100644 --- a/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb +++ b/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb @@ -90,6 +90,7 @@ def commands 'getwd' => 'Print working directory', 'lcat' => 'Read the contents of a local file to the screen', 'lcd' => 'Change local working directory', + 'lmkdir' => 'Create new directory on local machine', 'lpwd' => 'Print local working directory', 'ls' => 'List files', 'lls' => 'List local files', @@ -117,6 +118,7 @@ def commands 'getwd' => [COMMAND_ID_STDAPI_FS_GETWD], 'lcat' => [], 'lcd' => [], + 'lmkdir' => [], 'lpwd' => [], 'ls' => [COMMAND_ID_STDAPI_FS_STAT, COMMAND_ID_STDAPI_FS_LS], 'lls' => [], @@ -383,6 +385,22 @@ def cmd_lcd(*args) return true end + def cmd_lmkdir(*args) + if (args.length == 0) + print_line("Usage: lmkdir directory") + return true + end + + begin + ::Dir.mkdir(args[0]) + print_line("Directory '#{args[0]}' created successfully.") + rescue => e + print_error("Error creating directory: #{e}") + end + + return true + end + # # Tab completion for the lcd command #