Class: Rex::Post::Meterpreter::Ui::Console::CommandDispatcher::Stdapi::Fs
- Inherits:
-
Object
- Object
- Rex::Post::Meterpreter::Ui::Console::CommandDispatcher::Stdapi::Fs
- Includes:
- Msf::Ui::Console::LocalFileSystem, Extensions::Stdapi, Rex::Post::Meterpreter::Ui::Console::CommandDispatcher
- Defined in:
- lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb
Overview
The file system portion of the standard API extension.
Constant Summary collapse
- Klass =
Console::CommandDispatcher::Stdapi::Fs
- @@download_opts =
Options for the download command.
Rex::Parser::Arguments.new( "-h" => [ false, "Help banner" ], "-c" => [ false, "Resume getting a partially-downloaded file" ], "-a" => [ false, "Enable adaptive download buffer size" ], "-b" => [ true, "Set the initial block size for the download" ], "-l" => [ true, "Set the limit of retries (0 unlimits)" ], "-r" => [ false, "Download recursively" ], "-t" => [ false, "Timestamp downloaded files" ])
- @@upload_opts =
Options for the upload command.
Rex::Parser::Arguments.new( "-h" => [ false, "Help banner" ], "-r" => [ false, "Upload recursively" ])
- @@ls_opts =
Options for the ls command
Rex::Parser::Arguments.new( "-h" => [ false, "Help banner" ], "-S" => [ true, "Search string on filename (as regular expression)" ], "-t" => [ false, "Sort by time" ], "-s" => [ false, "Sort by size" ], "-r" => [ false, "Reverse sort order" ], "-x" => [ false, "Show short file names" ], "-l" => [ false, "List in long format (default)" ], "-R" => [ false, "Recursively list subdirectories encountered" ])
Constants included from Extensions::Stdapi
Extensions::Stdapi::COMMAND_ID_STDAPI_AUDIO_MIC_LIST, Extensions::Stdapi::COMMAND_ID_STDAPI_AUDIO_MIC_START, Extensions::Stdapi::COMMAND_ID_STDAPI_AUDIO_MIC_STOP, Extensions::Stdapi::COMMAND_ID_STDAPI_FS_CHDIR, Extensions::Stdapi::COMMAND_ID_STDAPI_FS_CHMOD, Extensions::Stdapi::COMMAND_ID_STDAPI_FS_DELETE_DIR, Extensions::Stdapi::COMMAND_ID_STDAPI_FS_DELETE_FILE, Extensions::Stdapi::COMMAND_ID_STDAPI_FS_FILE_COPY, Extensions::Stdapi::COMMAND_ID_STDAPI_FS_FILE_EXPAND_PATH, Extensions::Stdapi::COMMAND_ID_STDAPI_FS_FILE_MOVE, Extensions::Stdapi::COMMAND_ID_STDAPI_FS_GETWD, Extensions::Stdapi::COMMAND_ID_STDAPI_FS_LS, Extensions::Stdapi::COMMAND_ID_STDAPI_FS_MD5, Extensions::Stdapi::COMMAND_ID_STDAPI_FS_MKDIR, Extensions::Stdapi::COMMAND_ID_STDAPI_FS_MOUNT_SHOW, Extensions::Stdapi::COMMAND_ID_STDAPI_FS_SEARCH, Extensions::Stdapi::COMMAND_ID_STDAPI_FS_SEPARATOR, Extensions::Stdapi::COMMAND_ID_STDAPI_FS_SHA1, Extensions::Stdapi::COMMAND_ID_STDAPI_FS_STAT, Extensions::Stdapi::COMMAND_ID_STDAPI_NET_CONFIG_ADD_ROUTE, Extensions::Stdapi::COMMAND_ID_STDAPI_NET_CONFIG_GET_ARP_TABLE, Extensions::Stdapi::COMMAND_ID_STDAPI_NET_CONFIG_GET_INTERFACES, Extensions::Stdapi::COMMAND_ID_STDAPI_NET_CONFIG_GET_NETSTAT, Extensions::Stdapi::COMMAND_ID_STDAPI_NET_CONFIG_GET_PROXY, Extensions::Stdapi::COMMAND_ID_STDAPI_NET_CONFIG_GET_ROUTES, Extensions::Stdapi::COMMAND_ID_STDAPI_NET_CONFIG_REMOVE_ROUTE, Extensions::Stdapi::COMMAND_ID_STDAPI_NET_RESOLVE_HOST, Extensions::Stdapi::COMMAND_ID_STDAPI_NET_RESOLVE_HOSTS, Extensions::Stdapi::COMMAND_ID_STDAPI_NET_SOCKET_TCP_SHUTDOWN, Extensions::Stdapi::COMMAND_ID_STDAPI_NET_TCP_CHANNEL_OPEN, Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API, Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API_MULTI, Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_MEMREAD, Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_MEMWRITE, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_CHECK_KEY_EXISTS, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_CLOSE_KEY, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_CREATE_KEY, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_DELETE_KEY, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_DELETE_VALUE, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_ENUM_KEY, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_ENUM_KEY_DIRECT, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_ENUM_VALUE, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_ENUM_VALUE_DIRECT, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_LOAD_KEY, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_OPEN_KEY, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_OPEN_REMOTE_KEY, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_QUERY_CLASS, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_QUERY_VALUE, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_QUERY_VALUE_DIRECT, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_SET_VALUE, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_SET_VALUE_DIRECT, Extensions::Stdapi::COMMAND_ID_STDAPI_REGISTRY_UNLOAD_KEY, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_CONFIG_DRIVER_LIST, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_CONFIG_DROP_TOKEN, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_CONFIG_GETENV, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_CONFIG_GETPRIVS, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_CONFIG_GETSID, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_CONFIG_GETUID, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_CONFIG_LOCALTIME, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_CONFIG_REV2SELF, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_CONFIG_STEAL_TOKEN, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_CONFIG_SYSINFO, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_CONFIG_UPDATE_TOKEN, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_EVENTLOG_CLEAR, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_EVENTLOG_CLOSE, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_EVENTLOG_NUMRECORDS, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_EVENTLOG_OLDEST, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_EVENTLOG_OPEN, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_EVENTLOG_READ, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_POWER_EXITWINDOWS, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_ATTACH, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_CLOSE, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_EXECUTE, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_GETPID, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_GET_INFO, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_GET_PROCESSES, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_IMAGE_GET_IMAGES, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_IMAGE_GET_PROC_ADDRESS, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_IMAGE_LOAD, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_IMAGE_UNLOAD, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_KILL, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_MEMORY_ALLOCATE, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_MEMORY_FREE, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_MEMORY_LOCK, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_MEMORY_PROTECT, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_MEMORY_QUERY, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_MEMORY_READ, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_MEMORY_SEARCH, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_MEMORY_UNLOCK, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_MEMORY_WRITE, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_SET_TERM_SIZE, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_THREAD_CLOSE, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_THREAD_CREATE, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_THREAD_GET_THREADS, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_THREAD_OPEN, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_THREAD_QUERY_REGS, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_THREAD_RESUME, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_THREAD_SET_REGS, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_THREAD_SUSPEND, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_THREAD_TERMINATE, Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_WAIT, Extensions::Stdapi::COMMAND_ID_STDAPI_UI_DESKTOP_ENUM, Extensions::Stdapi::COMMAND_ID_STDAPI_UI_DESKTOP_GET, Extensions::Stdapi::COMMAND_ID_STDAPI_UI_DESKTOP_SCREENSHOT, Extensions::Stdapi::COMMAND_ID_STDAPI_UI_DESKTOP_SET, Extensions::Stdapi::COMMAND_ID_STDAPI_UI_ENABLE_KEYBOARD, Extensions::Stdapi::COMMAND_ID_STDAPI_UI_ENABLE_MOUSE, Extensions::Stdapi::COMMAND_ID_STDAPI_UI_GET_IDLE_TIME, Extensions::Stdapi::COMMAND_ID_STDAPI_UI_GET_KEYS_UTF8, Extensions::Stdapi::COMMAND_ID_STDAPI_UI_SEND_KEYEVENT, Extensions::Stdapi::COMMAND_ID_STDAPI_UI_SEND_KEYS, Extensions::Stdapi::COMMAND_ID_STDAPI_UI_SEND_MOUSE, Extensions::Stdapi::COMMAND_ID_STDAPI_UI_START_KEYSCAN, Extensions::Stdapi::COMMAND_ID_STDAPI_UI_STOP_KEYSCAN, Extensions::Stdapi::COMMAND_ID_STDAPI_UI_UNLOCK_DESKTOP, Extensions::Stdapi::COMMAND_ID_STDAPI_WEBCAM_AUDIO_RECORD, Extensions::Stdapi::COMMAND_ID_STDAPI_WEBCAM_GET_FRAME, Extensions::Stdapi::COMMAND_ID_STDAPI_WEBCAM_LIST, Extensions::Stdapi::COMMAND_ID_STDAPI_WEBCAM_START, Extensions::Stdapi::COMMAND_ID_STDAPI_WEBCAM_STOP, Extensions::Stdapi::DELETE_KEY_FLAG_RECURSIVE, Extensions::Stdapi::EXTENSION_ID_STDAPI, Extensions::Stdapi::PROCESS_EXECUTE_FLAG_CHANNELIZED, Extensions::Stdapi::PROCESS_EXECUTE_FLAG_DESKTOP, Extensions::Stdapi::PROCESS_EXECUTE_FLAG_HIDDEN, Extensions::Stdapi::PROCESS_EXECUTE_FLAG_PTY, Extensions::Stdapi::PROCESS_EXECUTE_FLAG_SESSION, Extensions::Stdapi::PROCESS_EXECUTE_FLAG_SUBSHELL, Extensions::Stdapi::PROCESS_EXECUTE_FLAG_SUSPENDED, Extensions::Stdapi::PROCESS_EXECUTE_FLAG_USE_THREAD_TOKEN, Extensions::Stdapi::TLV_TYPE_ADDR_TYPE, Extensions::Stdapi::TLV_TYPE_ALLOCATION_TYPE, Extensions::Stdapi::TLV_TYPE_ALLOC_BASE_ADDRESS, Extensions::Stdapi::TLV_TYPE_ALLOC_PROTECTION, Extensions::Stdapi::TLV_TYPE_ARCHITECTURE, Extensions::Stdapi::TLV_TYPE_ARP_ENTRY, Extensions::Stdapi::TLV_TYPE_AUDIO_DATA, Extensions::Stdapi::TLV_TYPE_AUDIO_DURATION, Extensions::Stdapi::TLV_TYPE_AUDIO_INTERFACE_ID, Extensions::Stdapi::TLV_TYPE_AUDIO_INTERFACE_NAME, Extensions::Stdapi::TLV_TYPE_BASE_ADDRESS, Extensions::Stdapi::TLV_TYPE_BASE_KEY, Extensions::Stdapi::TLV_TYPE_BUILD_TUPLE, Extensions::Stdapi::TLV_TYPE_COMPUTER_NAME, Extensions::Stdapi::TLV_TYPE_CONNECT_RETRIES, Extensions::Stdapi::TLV_TYPE_CREATION_FLAGS, Extensions::Stdapi::TLV_TYPE_DESKTOP, Extensions::Stdapi::TLV_TYPE_DESKTOP_NAME, Extensions::Stdapi::TLV_TYPE_DESKTOP_SCREENSHOT, Extensions::Stdapi::TLV_TYPE_DESKTOP_SCREENSHOT_PE32DLL_BUFFER, Extensions::Stdapi::TLV_TYPE_DESKTOP_SCREENSHOT_PE64DLL_BUFFER, Extensions::Stdapi::TLV_TYPE_DESKTOP_SCREENSHOT_QUALITY, Extensions::Stdapi::TLV_TYPE_DESKTOP_SESSION, Extensions::Stdapi::TLV_TYPE_DESKTOP_STATION, Extensions::Stdapi::TLV_TYPE_DESKTOP_SWITCH, Extensions::Stdapi::TLV_TYPE_DIRECTORY_PATH, Extensions::Stdapi::TLV_TYPE_DOMAIN, Extensions::Stdapi::TLV_TYPE_DRIVER_BASENAME, Extensions::Stdapi::TLV_TYPE_DRIVER_ENTRY, Extensions::Stdapi::TLV_TYPE_DRIVER_FILENAME, Extensions::Stdapi::TLV_TYPE_ENTRY_PARAMETER, Extensions::Stdapi::TLV_TYPE_ENTRY_POINT, Extensions::Stdapi::TLV_TYPE_ENV_GROUP, Extensions::Stdapi::TLV_TYPE_ENV_VALUE, Extensions::Stdapi::TLV_TYPE_ENV_VARIABLE, Extensions::Stdapi::TLV_TYPE_EVENT_CATEGORY, Extensions::Stdapi::TLV_TYPE_EVENT_DATA, Extensions::Stdapi::TLV_TYPE_EVENT_HANDLE, Extensions::Stdapi::TLV_TYPE_EVENT_ID, Extensions::Stdapi::TLV_TYPE_EVENT_NUMRECORDS, Extensions::Stdapi::TLV_TYPE_EVENT_READFLAGS, Extensions::Stdapi::TLV_TYPE_EVENT_RECORDNUMBER, Extensions::Stdapi::TLV_TYPE_EVENT_RECORDOFFSET, Extensions::Stdapi::TLV_TYPE_EVENT_SOURCENAME, Extensions::Stdapi::TLV_TYPE_EVENT_STRING, Extensions::Stdapi::TLV_TYPE_EVENT_TIMEGENERATED, Extensions::Stdapi::TLV_TYPE_EVENT_TIMEWRITTEN, Extensions::Stdapi::TLV_TYPE_EVENT_TYPE, Extensions::Stdapi::TLV_TYPE_EXIT_CODE, Extensions::Stdapi::TLV_TYPE_FILE_HASH, Extensions::Stdapi::TLV_TYPE_FILE_MODE, Extensions::Stdapi::TLV_TYPE_FILE_MODE_T, Extensions::Stdapi::TLV_TYPE_FILE_NAME, Extensions::Stdapi::TLV_TYPE_FILE_PATH, Extensions::Stdapi::TLV_TYPE_FILE_SHORT_NAME, Extensions::Stdapi::TLV_TYPE_FILE_SIZE, Extensions::Stdapi::TLV_TYPE_GATEWAY, Extensions::Stdapi::TLV_TYPE_GATEWAY_STRING, Extensions::Stdapi::TLV_TYPE_HANDLE, Extensions::Stdapi::TLV_TYPE_HKEY, Extensions::Stdapi::TLV_TYPE_HOST_NAME, Extensions::Stdapi::TLV_TYPE_IDLE_TIME, Extensions::Stdapi::TLV_TYPE_IMAGE_BASE, Extensions::Stdapi::TLV_TYPE_IMAGE_FILE, Extensions::Stdapi::TLV_TYPE_IMAGE_FILE_PATH, Extensions::Stdapi::TLV_TYPE_IMAGE_GROUP, Extensions::Stdapi::TLV_TYPE_IMAGE_NAME, Extensions::Stdapi::TLV_TYPE_INHERIT, Extensions::Stdapi::TLV_TYPE_INTERFACE_FLAGS, Extensions::Stdapi::TLV_TYPE_INTERFACE_INDEX, Extensions::Stdapi::TLV_TYPE_INTERFACE_MTU, Extensions::Stdapi::TLV_TYPE_IP, Extensions::Stdapi::TLV_TYPE_IP6_SCOPE, Extensions::Stdapi::TLV_TYPE_IP_PREFIX, Extensions::Stdapi::TLV_TYPE_KEYEVENT_SEND, Extensions::Stdapi::TLV_TYPE_KEYSCAN_TRACK_ACTIVE_WINDOW, Extensions::Stdapi::TLV_TYPE_KEYS_DUMP, Extensions::Stdapi::TLV_TYPE_KEYS_SEND, Extensions::Stdapi::TLV_TYPE_KEY_NAME, Extensions::Stdapi::TLV_TYPE_LANG_SYSTEM, Extensions::Stdapi::TLV_TYPE_LOCAL_DATETIME, Extensions::Stdapi::TLV_TYPE_LOCAL_HOST, Extensions::Stdapi::TLV_TYPE_LOCAL_HOST_RAW, Extensions::Stdapi::TLV_TYPE_LOCAL_PORT, Extensions::Stdapi::TLV_TYPE_LOGGED_ON_USER_COUNT, Extensions::Stdapi::TLV_TYPE_MAC_ADDRESS, Extensions::Stdapi::TLV_TYPE_MAC_NAME, Extensions::Stdapi::TLV_TYPE_MEMORY_SEARCH_MATCH_ADDR, Extensions::Stdapi::TLV_TYPE_MEMORY_SEARCH_MATCH_LEN, Extensions::Stdapi::TLV_TYPE_MEMORY_SEARCH_MATCH_STR, Extensions::Stdapi::TLV_TYPE_MEMORY_SEARCH_NEEDLE, Extensions::Stdapi::TLV_TYPE_MEMORY_SEARCH_RESULTS, Extensions::Stdapi::TLV_TYPE_MEMORY_SEARCH_SECT_LEN, Extensions::Stdapi::TLV_TYPE_MEMORY_SEARCH_START_ADDR, Extensions::Stdapi::TLV_TYPE_MEMORY_STATE, Extensions::Stdapi::TLV_TYPE_MEMORY_TYPE, Extensions::Stdapi::TLV_TYPE_MOUNT, Extensions::Stdapi::TLV_TYPE_MOUNT_NAME, Extensions::Stdapi::TLV_TYPE_MOUNT_SPACE_FREE, Extensions::Stdapi::TLV_TYPE_MOUNT_SPACE_TOTAL, Extensions::Stdapi::TLV_TYPE_MOUNT_SPACE_USER, Extensions::Stdapi::TLV_TYPE_MOUNT_TYPE, Extensions::Stdapi::TLV_TYPE_MOUNT_UNCPATH, Extensions::Stdapi::TLV_TYPE_MOUSE_ACTION, Extensions::Stdapi::TLV_TYPE_MOUSE_X, Extensions::Stdapi::TLV_TYPE_MOUSE_Y, Extensions::Stdapi::TLV_TYPE_NETMASK, Extensions::Stdapi::TLV_TYPE_NETMASK_STRING, Extensions::Stdapi::TLV_TYPE_NETSTAT_ENTRY, Extensions::Stdapi::TLV_TYPE_NETWORK_INTERFACE, Extensions::Stdapi::TLV_TYPE_NETWORK_ROUTE, Extensions::Stdapi::TLV_TYPE_OS_NAME, Extensions::Stdapi::TLV_TYPE_PARENT_PID, Extensions::Stdapi::TLV_TYPE_PEER_HOST, Extensions::Stdapi::TLV_TYPE_PEER_HOST_RAW, Extensions::Stdapi::TLV_TYPE_PEER_PORT, Extensions::Stdapi::TLV_TYPE_PERMISSION, Extensions::Stdapi::TLV_TYPE_PID, Extensions::Stdapi::TLV_TYPE_PORT, Extensions::Stdapi::TLV_TYPE_POWER_FLAGS, Extensions::Stdapi::TLV_TYPE_POWER_REASON, Extensions::Stdapi::TLV_TYPE_PRIVILEGE, Extensions::Stdapi::TLV_TYPE_PROCEDURE_ADDRESS, Extensions::Stdapi::TLV_TYPE_PROCEDURE_NAME, Extensions::Stdapi::TLV_TYPE_PROCESS_ARCH, Extensions::Stdapi::TLV_TYPE_PROCESS_ARCH_NAME, Extensions::Stdapi::TLV_TYPE_PROCESS_ARGUMENTS, Extensions::Stdapi::TLV_TYPE_PROCESS_FLAGS, Extensions::Stdapi::TLV_TYPE_PROCESS_GROUP, Extensions::Stdapi::TLV_TYPE_PROCESS_HANDLE, Extensions::Stdapi::TLV_TYPE_PROCESS_MEMORY, Extensions::Stdapi::TLV_TYPE_PROCESS_NAME, Extensions::Stdapi::TLV_TYPE_PROCESS_PATH, Extensions::Stdapi::TLV_TYPE_PROCESS_PERMS, Extensions::Stdapi::TLV_TYPE_PROCESS_SESSION, Extensions::Stdapi::TLV_TYPE_PROTECTION, Extensions::Stdapi::TLV_TYPE_PROXY_CFG_AUTOCONFIGURL, Extensions::Stdapi::TLV_TYPE_PROXY_CFG_AUTODETECT, Extensions::Stdapi::TLV_TYPE_PROXY_CFG_PROXY, Extensions::Stdapi::TLV_TYPE_PROXY_CFG_PROXYBYPASS, Extensions::Stdapi::TLV_TYPE_REGISTER, Extensions::Stdapi::TLV_TYPE_REGISTER_NAME, Extensions::Stdapi::TLV_TYPE_REGISTER_SIZE, Extensions::Stdapi::TLV_TYPE_REGISTER_VALUE_32, Extensions::Stdapi::TLV_TYPE_ROOT_KEY, Extensions::Stdapi::TLV_TYPE_ROUTE_METRIC, Extensions::Stdapi::TLV_TYPE_SEARCH_GLOB, Extensions::Stdapi::TLV_TYPE_SEARCH_MTIME, Extensions::Stdapi::TLV_TYPE_SEARCH_M_END_DATE, Extensions::Stdapi::TLV_TYPE_SEARCH_M_START_DATE, Extensions::Stdapi::TLV_TYPE_SEARCH_RECURSE, Extensions::Stdapi::TLV_TYPE_SEARCH_RESULTS, Extensions::Stdapi::TLV_TYPE_SEARCH_ROOT, Extensions::Stdapi::TLV_TYPE_SHUTDOWN_HOW, Extensions::Stdapi::TLV_TYPE_SID, Extensions::Stdapi::TLV_TYPE_STAT_BUF, Extensions::Stdapi::TLV_TYPE_STAT_BUF32, Extensions::Stdapi::TLV_TYPE_SUBNET, Extensions::Stdapi::TLV_TYPE_SUBNET_STRING, Extensions::Stdapi::TLV_TYPE_TARGET_HOST, Extensions::Stdapi::TLV_TYPE_TERMINAL_COLUMNS, Extensions::Stdapi::TLV_TYPE_TERMINAL_ROWS, Extensions::Stdapi::TLV_TYPE_THREAD_HANDLE, Extensions::Stdapi::TLV_TYPE_THREAD_ID, Extensions::Stdapi::TLV_TYPE_THREAD_PERMS, Extensions::Stdapi::TLV_TYPE_USER_NAME, Extensions::Stdapi::TLV_TYPE_VALUE_DATA, Extensions::Stdapi::TLV_TYPE_VALUE_NAME, Extensions::Stdapi::TLV_TYPE_VALUE_TYPE, Extensions::Stdapi::TLV_TYPE_WEBCAM_IMAGE, Extensions::Stdapi::TLV_TYPE_WEBCAM_INTERFACE_ID, Extensions::Stdapi::TLV_TYPE_WEBCAM_NAME, Extensions::Stdapi::TLV_TYPE_WEBCAM_QUALITY
Instance Attribute Summary
Attributes included from Ui::Text::DispatcherShell::CommandDispatcher
Instance Method Summary collapse
-
#cmd_cat(*args) ⇒ Object
Reads the contents of a file and prints them to the screen.
-
#cmd_cat_tabs(str, words) ⇒ Object
(also: #cmd_rm_tabs, #cmd_del_tabs, #cmd_mv_tabs, #cmd_move_tabs, #cmd_rename_tabs, #cmd_download_tabs, #cmd_cp_tabs, #cmd_chmod_tabs, #cmd_edit_tabs)
Tab completion for the cat command.
-
#cmd_cd(*args) ⇒ Object
Change the working directory.
-
#cmd_cd_tabs(str, words) ⇒ Object
(also: #cmd_ls_tabs, #cmd_mkdir_tabs, #cmd_rmdir_tabs)
Tab completion for the cd command.
-
#cmd_checksum(*args) ⇒ Object
Retrieve the checksum of a file.
- #cmd_checksum_tabs(str, words) ⇒ Object
-
#cmd_chmod(*args) ⇒ Object
Change the permissions on a remote file.
-
#cmd_cp(*args) ⇒ Object
(also: #cmd_copy)
Move source to destination.
-
#cmd_download(*args) ⇒ Object
Downloads a file or directory from the remote machine to the local machine.
- #cmd_download_help ⇒ Object
-
#cmd_edit(*args) ⇒ Object
Downloads a file to a temporary file, spawns and editor, and then uploads the contents to the remote machine after completion.
- #cmd_edit_help ⇒ Object
-
#cmd_ls(*args) ⇒ Object
(also: #cmd_dir)
Lists files.
- #cmd_ls_help ⇒ Object (also: #cmd_dir_help)
-
#cmd_mkdir(*args) ⇒ Object
Make one or more directory.
-
#cmd_mv(*args) ⇒ Object
(also: #cmd_move, #cmd_rename)
Move source to destination.
-
#cmd_pwd(*args) ⇒ Object
(also: #cmd_getwd)
Display the working directory.
-
#cmd_rm(*args) ⇒ Object
(also: #cmd_del)
Delete the specified file(s).
-
#cmd_rmdir(*args) ⇒ Object
Removes one or more directory if it’s empty.
-
#cmd_search(*args) ⇒ Object
Search for files.
-
#cmd_show_mount(*args) ⇒ Object
Show all the mount points/logical drives (currently geared towards the Windows Meterpreter).
-
#cmd_upload(*args) ⇒ Object
Uploads a file or directory to the remote machine from the local machine.
- #cmd_upload_help ⇒ Object
- #cmd_upload_tabs(str, words) ⇒ Object
-
#commands ⇒ Object
List of supported commands.
- #list_path(path, columns, sort, order, short, recursive = false, depth = 0, search_term = nil) ⇒ Object
-
#name ⇒ Object
Name for this dispatcher.
-
#tab_complete_cdirectory(str, words) ⇒ Object
Provide a generic tab completion for client directory names.
-
#tab_complete_cfilenames(str, words) ⇒ Object
Provide a generic tab completion for client file names.
- #tab_complete_path(str, words, dir_only) ⇒ Object
-
#unexpand_path_for_suggestions(original_path, expanded_path, suggestions) ⇒ Object
After a path expansion followed by a tab completion suggestion set, unexpand the path back so that Readline is happy.
- #vali_date(str) ⇒ Object
Methods included from Msf::Ui::Console::LocalFileSystem
#cmd_lcat, #cmd_lcat_tabs, #cmd_lcd, #cmd_lcd_tabs, #cmd_lls, #cmd_lls_help, #cmd_lmkdir, #cmd_lpwd, #list_local_path, #local_fs_commands, #pretty_perms
Methods included from Rex::Post::Meterpreter::Ui::Console::CommandDispatcher
check_hash, #client, #docs_dir, #filter_commands, #initialize, #log_error, #msf_loaded?, #session, set_hash, #unknown_command
Methods included from Msf::Ui::Console::CommandDispatcher::Session
#cmd_background, #cmd_background_help, #cmd_exit, #cmd_irb, #cmd_irb_help, #cmd_irb_tabs, #cmd_pry, #cmd_pry_help, #cmd_resource, #cmd_resource_help, #cmd_resource_tabs, #cmd_sessions, #cmd_sessions_help
Methods included from Ui::Text::DispatcherShell::CommandDispatcher
#cmd_help, #cmd_help_help, #cmd_help_tabs, #deprecated_cmd, #deprecated_commands, #deprecated_help, #docs_dir, #help_to_s, included, #initialize, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #tab_complete_directory, #tab_complete_filenames, #tab_complete_generic, #tab_complete_source_address, #unknown_command, #update_prompt
Instance Method Details
#cmd_cat(*args) ⇒ Object
Reads the contents of a file and prints them to the screen.
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 260 def cmd_cat(*args) if (args.length == 0) print_line("Usage: cat file") return true end path = args[0] path = client.fs.file.(path) if path =~ if (client.fs.file.stat(path).directory?) print_error("#{path} is a directory") else fd = client.fs.file.new(path, "rb") begin until fd.eof? print(fd.read) end # EOFError is raised if file is empty, do nothing, just catch rescue EOFError end fd.close end true end |
#cmd_cat_tabs(str, words) ⇒ Object Also known as: cmd_rm_tabs, cmd_del_tabs, cmd_mv_tabs, cmd_move_tabs, cmd_rename_tabs, cmd_download_tabs, cmd_cp_tabs, cmd_chmod_tabs, cmd_edit_tabs
Tab completion for the cat command
290 291 292 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 290 def cmd_cat_tabs(str, words) tab_complete_cfilenames(str, words) end |
#cmd_cd(*args) ⇒ Object
Change the working directory.
297 298 299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 297 def cmd_cd(*args) if (args.length == 0) print_line("Usage: cd directory") return true end if args[0] =~ client.fs.dir.chdir(client.fs.file.(args[0])) else client.fs.dir.chdir(args[0]) end return true end |
#cmd_cd_tabs(str, words) ⇒ Object Also known as: cmd_ls_tabs, cmd_mkdir_tabs, cmd_rmdir_tabs
Tab completion for the cd command
314 315 316 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 314 def cmd_cd_tabs(str, words) tab_complete_cdirectory(str, words) end |
#cmd_checksum(*args) ⇒ Object
Retrieve the checksum of a file
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 321 def cmd_checksum(*args) algorithm = args.shift algorithm.downcase! unless algorithm.nil? unless args.length > 0 and CHECKSUM_ALGORITHMS.include?(algorithm) print_line("Usage: checksum [#{ CHECKSUM_ALGORITHMS.join(' / ') }] file1 file2 file3 ...") return true end args.each do |filepath| filepath = client.fs.file.(filepath) if filepath =~ checksum = client.fs.file.send(algorithm, filepath) print_line("#{Rex::Text.to_hex(checksum, '')} #{filepath}") end return true end |
#cmd_checksum_tabs(str, words) ⇒ Object
338 339 340 341 342 343 344 345 346 347 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 338 def cmd_checksum_tabs(str, words) tabs = [] return tabs unless words.length == 1 CHECKSUM_ALGORITHMS.each do |algorithm| tabs << algorithm if algorithm.start_with?(str.downcase) end tabs end |
#cmd_chmod(*args) ⇒ Object
Change the permissions on a remote file
416 417 418 419 420 421 422 423 424 425 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 416 def cmd_chmod(*args) if (args.length != 2) print_line("Usage: chmod permission file") return true end file_path = args[1] file_path = client.fs.file.(file_path) if file_path =~ client.fs.file.chmod(file_path, args[0].to_i(8)) return true end |
#cmd_cp(*args) ⇒ Object Also known as: cmd_copy
Move source to destination
396 397 398 399 400 401 402 403 404 405 406 407 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 396 def cmd_cp(*args) if (args.length < 2) print_line("Usage: cp oldfile newfile") return true end old_path = args[0] old_path = client.fs.file.(old_path) if old_path =~ new_path = args[1] new_path = client.fs.file.(new_path) if new_path =~ client.fs.file.cp(old_path, new_path) return true end |
#cmd_download(*args) ⇒ Object
Downloads a file or directory from the remote machine to the local machine.
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 438 def cmd_download(*args) if (args.empty? or args.include? "-h") cmd_download_help return true end recursive = false src_items = [] last = nil dest = nil tries = false tries_no = 0 opts = {} @@download_opts.parse(args) { |opt, idx, val| case opt when "-a" opts['adaptive'] = true when "-b" opts['block_size'] = val.to_i when "-r" recursive = true opts['recursive'] = true when "-c" opts['continue'] = true when "-l" tries = true tries_no = val.to_i opts['tries'] = true opts['tries_no'] = tries_no when "-t" opts['timestamp'] = '_' + ::Time.now.iso8601 when nil src_items << last if (last) last = val end } # No files given, nothing to do if not last cmd_download_help return true end # Source and destination will be the same if src_items.empty? src_items << last # Use the basename of the remote filename so we don't end up with # a file named c:\\boot.ini in linux dest = ::Rex::Post::Meterpreter::Extensions::Stdapi::Fs::File.basename(last) else dest = last end # Download to a directory, not a pattern if client.fs.file.is_glob?(dest) dest = ::File.dirname(dest) end # Expand the destination file path dest = ::File.(dest) # Go through each source item and download them src_items.each { |src| src = client.fs.file.(src) if src =~ glob = nil if client.fs.file.is_glob?(src) glob = ::File.basename(src) src = ::File.dirname(src) end # Use search if possible for recursive pattern matching. It will work # more intuitively since it will not try to match on intermediate # directories, only file names. if glob && recursive && client.commands.include?(COMMAND_ID_STDAPI_FS_SEARCH) files = client.fs.file.search(src, glob, recursive) if !files.empty? print_line("Downloading #{files.length} file#{files.length > 1 ? 's' : ''}...") files.each do |file| src_separator = client.fs.file.separator src_path = file['path'] + client.fs.file.separator + file['name'] dest_path = ::File.join(dest, ::Rex::FileUtils::clean_path(file['path'].tr(src_separator, ::File::SEPARATOR))) client.fs.file.download(dest_path, src_path, opts) do |step, src, dst| print_status("#{step.ljust(11)}: #{src} -> #{dst}") client.framework.events.on_session_download(client, src, dest) if msf_loaded? end end else print_status("No matching files found for download") end else # Perform direct matching tries_cnt = 0 begin stat = client.fs.file.stat(src) rescue Rex::TimeoutError if (tries && (tries_no == 0 || tries_cnt < tries_no)) tries_cnt += 1 print_error("Error opening: #{src} - retry (#{tries_cnt})") retry else print_error("Error opening: #{src} - giving up") raise end end if (stat.directory?) client.fs.dir.download(dest, src, opts, true, glob) do |step, src, dst| print_status("#{step.ljust(11)}: #{src} -> #{dst}") client.framework.events.on_session_download(client, src, dest) if msf_loaded? end elsif (stat.file?) client.fs.file.download(dest, src, opts) do |step, src, dst| print_status("#{step.ljust(11)}: #{src} -> #{dst}") client.framework.events.on_session_download(client, src, dest) if msf_loaded? end end end } true end |
#cmd_download_help ⇒ Object
427 428 429 430 431 432 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 427 def cmd_download_help print_line("Usage: download [options] src1 src2 src3 ... destination") print_line print_line("Downloads remote files and directories to the local machine.") print_line(@@download_opts.usage) end |
#cmd_edit(*args) ⇒ Object
Downloads a file to a temporary file, spawns and editor, and then uploads the contents to the remote machine after completion.
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 577 def cmd_edit(*args) if args.empty? || args.include?('-h') cmd_edit_help return true end # Get a temporary file path meterp_temp = Tempfile.new('meterp') meterp_temp.binmode temp_path = meterp_temp.path client_path = args[0] client_path = client.fs.file.(client_path) if client_path =~ # Try to download the file, but don't worry if it doesn't exist client.fs.file.download_file(temp_path, client_path) rescue nil # Spawn the editor (default to vi) editor = Rex::Compat.getenv('EDITOR') || 'vi' # If it succeeds, upload it to the remote side. if (system("#{editor} #{temp_path}") == true) client.fs.file.upload_file(client_path, temp_path) end # Get rid of that pesky temporary file ::File.delete(temp_path) rescue nil end |
#cmd_edit_help ⇒ Object
567 568 569 570 571 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 567 def cmd_edit_help print_line('Edit a file on remote machine.') print_line("Usage: edit file") print_line end |
#cmd_ls(*args) ⇒ Object Also known as: cmd_dir
Lists files
678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 678 def cmd_ls(*args) # Set defaults path = client.fs.dir.getwd search_term = nil sort = 'Name' short = nil order = :forward recursive = nil # Parse the args @@ls_opts.parse(args) { |opt, idx, val| case opt # Sort options when '-s' sort = 'Size' when '-t' sort = 'Last modified' # Output options when '-x' short = true when '-l' short = nil when '-r' order = :reverse when '-R' recursive = true # Search when '-S' search_term = val if search_term.nil? print_error("Enter a search term") return true else search_term = /#{search_term}/nmi end # Help and path when "-h" cmd_ls_help return 0 when nil path = val path = client.fs.file.(path) if path =~ end } columns = [ 'Mode', 'Size', 'Type', 'Last modified', 'Name' ] columns.insert(4, 'Short Name') if short stat_path = path # Check session capabilities is_glob = client.fs.file.is_glob?(path) if is_glob if !client.commands.include?(COMMAND_ID_STDAPI_FS_SEARCH) print_line('File globbing not supported with this session') return end stat_path = ::File.dirname(path) end stat = client.fs.file.stat(stat_path) if stat.directory? list_path(path, columns, sort, order, short, recursive, 0, search_term) else print_line("#{stat.prettymode} #{stat.size} #{stat.ftype[0,3]} #{stat.mtime} #{path}") end return true end |
#cmd_ls_help ⇒ Object Also known as: cmd_dir_help
608 609 610 611 612 613 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 608 def cmd_ls_help print_line "Usage: ls [options] [glob/path]" print_line print_line "Lists contents of directory or file info, searchable" print_line @@ls_opts.usage end |
#cmd_mkdir(*args) ⇒ Object
Make one or more directory.
759 760 761 762 763 764 765 766 767 768 769 770 771 772 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 759 def cmd_mkdir(*args) if (args.length == 0) print_line("Usage: mkdir dir1 dir2 dir3 ...") return true end args.each { |dir_path| dir_path = client.fs.file.(dir_path) if dir_path =~ print_line("Creating directory: #{dir_path}") client.fs.dir.mkdir(dir_path) } return true end |
#cmd_mv(*args) ⇒ Object Also known as: cmd_move, cmd_rename
Move source to destination
373 374 375 376 377 378 379 380 381 382 383 384 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 373 def cmd_mv(*args) if (args.length < 2) print_line("Usage: mv oldfile newfile") return true end old_path = args[0] old_path = client.fs.file.(old_path) if old_path =~ new_path = args[1] new_path = client.fs.file.(new_path) if new_path =~ client.fs.file.mv(old_path, new_path) return true end |
#cmd_pwd(*args) ⇒ Object Also known as: cmd_getwd
Display the working directory.
779 780 781 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 779 def cmd_pwd(*args) print_line(client.fs.dir.getwd) end |
#cmd_rm(*args) ⇒ Object Also known as: cmd_del
Delete the specified file(s).
352 353 354 355 356 357 358 359 360 361 362 363 364 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 352 def cmd_rm(*args) if (args.length == 0) print_line("Usage: rm file1 [file2...]") return true end args.each do |file_path| file_path = client.fs.file.(file_path) if file_path =~ client.fs.file.rm(file_path) end return true end |
#cmd_rmdir(*args) ⇒ Object
Removes one or more directory if it’s empty.
788 789 790 791 792 793 794 795 796 797 798 799 800 801 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 788 def cmd_rmdir(*args) if (args.length == 0 or args.include?("-h")) print_line("Usage: rmdir dir1 dir2 dir3 ...") return true end args.each { |dir_path| dir_path = client.fs.file.(dir_path) if dir_path =~ print_line("Removing directory: #{dir_path}") client.fs.dir.rmdir(dir_path) } return true end |
#cmd_search(*args) ⇒ Object
Search for files.
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 139 def cmd_search(*args) root = nil recurse = true globs = [] files = [] modified_start_date = nil modified_end_date = nil opts = Rex::Parser::Arguments.new( "-h" => [ false, "Help Banner" ], "-d" => [ true, "The directory/drive to begin searching from. Leave empty to search all drives. (Default: #{root})" ], "-f" => [ true, "A file pattern glob to search for. (e.g. *secret*.doc?)" ], "-r" => [ true, "Recursively search sub directories. (Default: #{recurse})" ], "-a" => [ true, "Find files modified after timestamp (UTC). Format: YYYY-mm-dd or YYYY-mm-ddTHH:MM:SS"], "-b" => [ true, "Find files modified before timestamp (UTC). Format: YYYY-mm-dd or YYYY-mm-ddTHH:MM:SS"] ) opts.parse(args) { | opt, idx, val | case opt when "-h" print_line("Usage: search [-d dir] [-r recurse] -f pattern [-f pattern]...") print_line("Search for files.") print_line(opts.usage) return when "-d" root = val root = client.fs.file.(root) if root =~ when "-f" globs << val when "-r" recurse = false if val =~ /^(f|n|0)/i when "-a" modified_start_date = vali_date(val) return unless modified_start_date when "-b" modified_end_date = vali_date(val) return unless modified_end_date end } if globs.empty? print_error("You must specify a valid file glob to search for, e.g. >search -f *.doc") return end globs.uniq.each do |glob| files += client.fs.file.search(root, glob, recurse, -1, modified_start_date, modified_end_date) end if files.empty? print_line("No files matching your search were found.") return end header = "Found #{files.length} result#{ files.length > 1 ? 's' : '' }..." results_table = Rex::Text::Table.new( 'WordWrap' => false, 'Width' => 120, 'Header' => header, 'Indent' => 0, 'SortIndex' => 0, 'Columns' => ['Path', 'Size (bytes)', 'Modified (UTC)'], ) files.each do | file | filestr = '' unless file['path'].empty? filestr += "#{file['path']}#{client.fs.file.separator}" end filestr += file['name'] datestr = '' datestr = Time.at(file['mtime']).to_s if file['mtime'] results_table << [filestr, file['size'], datestr] end print_line results_table.to_s end |
#cmd_show_mount(*args) ⇒ Object
Show all the mount points/logical drives (currently geared towards the Windows Meterpreter).
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 221 def cmd_show_mount(*args) if args.include?('-h') print_line('Usage: show_mount') return true end mounts = client.fs.mount.show_mount table = Rex::Text::Table.new( 'Header' => 'Mounts / Drives', 'Indent' => 0, 'SortIndex' => 0, 'Columns' => [ 'Name', 'Type', 'Size (Total)', 'Size (Free)', 'Mapped to' ] ) mounts.each do |d| ts = ::Filesize.from("#{d[:total_space]} B").pretty.split(' ') fs = ::Filesize.from("#{d[:free_space]} B").pretty.split(' ') table << [ d[:name], d[:type], "#{ts[0].rjust(6)} #{ts[1].ljust(3)}", "#{fs[0].rjust(6)} #{fs[1].ljust(3)}", d[:unc] ] end print_line print_line(table.to_s) print_line print_line("Total mounts/drives: #{mounts.length}") print_line end |
#cmd_upload(*args) ⇒ Object
Uploads a file or directory to the remote machine from the local machine.
816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 816 def cmd_upload(*args) if (args.empty? or args.include?("-h")) cmd_upload_help return true end recursive = false src_items = [] last = nil dest = nil @@upload_opts.parse(args) { |opt, idx, val| case opt when "-r" recursive = true when nil if (last) src_items << last end last = val end } return true if not last # Source and destination will be the same src_items << last if src_items.empty? if args.size == 1 dest = client.fs.file.basename(last) else dest = last end dest = client.fs.file.(dest) if dest =~ # Go through each source item and upload them src_items.each { |src| src = ::File.(src) stat = ::File.stat(src) if (stat.directory?) client.fs.dir.upload(dest, src, recursive) { |step, src, dst| print_status("#{step.ljust(11)}: #{src} -> #{dst}") client.framework.events.on_session_upload(client, src, dest) if msf_loaded? } elsif (stat.file?) if client.fs.file.exist?(dest) && client.fs.file.stat(dest).directory? client.fs.file.upload(dest, src) { |step, src, dst| print_status("#{step.ljust(11)}: #{src} -> #{dst}") client.framework.events.on_session_upload(client, src, dest) if msf_loaded? } else client.fs.file.upload_file(dest, src) { |step, src, dst| print_status("#{step.ljust(11)}: #{src} -> #{dst}") client.framework.events.on_session_upload(client, src, dest) if msf_loaded? } end end } return true end |
#cmd_upload_help ⇒ Object
805 806 807 808 809 810 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 805 def cmd_upload_help print_line("Usage: upload [options] src1 src2 src3 ... destination") print_line print_line("Uploads local files and directories to the remote machine.") print_line(@@upload_opts.usage) end |
#cmd_upload_tabs(str, words) ⇒ Object
881 882 883 884 885 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 881 def cmd_upload_tabs(str, words) return [] if words.length > 1 tab_complete_filenames(str, words) end |
#commands ⇒ Object
List of supported commands.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 72 def commands all = { 'cat' => 'Read the contents of a file to the screen', 'cd' => 'Change directory', 'checksum' => 'Retrieve the checksum of a file', 'del' => 'Delete the specified file', 'dir' => 'List files (alias for ls)', 'download' => 'Download a file or directory', 'edit' => 'Edit a file', 'getwd' => 'Print working directory', 'ls' => 'List files', 'mkdir' => 'Make directory', 'pwd' => 'Print working directory', 'rm' => 'Delete the specified file', 'mv' => 'Move source to destination', 'cp' => 'Copy source to destination', 'chmod' => 'Change the permissions of a file', 'rmdir' => 'Remove directory', 'search' => 'Search for files', 'upload' => 'Upload a file or directory', 'show_mount' => 'List all mount points/logical drives', } reqs = { 'cat' => [], 'cd' => [COMMAND_ID_STDAPI_FS_CHDIR], 'checksum' => [COMMAND_ID_STDAPI_FS_MD5, COMMAND_ID_STDAPI_FS_SHA1], 'del' => [COMMAND_ID_STDAPI_FS_DELETE_FILE], 'dir' => [COMMAND_ID_STDAPI_FS_STAT, COMMAND_ID_STDAPI_FS_LS], 'download' => [], 'edit' => [], 'getwd' => [COMMAND_ID_STDAPI_FS_GETWD], 'ls' => [COMMAND_ID_STDAPI_FS_STAT, COMMAND_ID_STDAPI_FS_LS], 'mkdir' => [COMMAND_ID_STDAPI_FS_MKDIR], 'pwd' => [COMMAND_ID_STDAPI_FS_GETWD], 'rmdir' => [COMMAND_ID_STDAPI_FS_DELETE_DIR], 'rm' => [COMMAND_ID_STDAPI_FS_DELETE_FILE], 'mv' => [COMMAND_ID_STDAPI_FS_FILE_MOVE], 'cp' => [COMMAND_ID_STDAPI_FS_FILE_COPY], 'chmod' => [COMMAND_ID_STDAPI_FS_CHMOD], 'search' => [COMMAND_ID_STDAPI_FS_SEARCH], 'upload' => [], 'show_mount' => [COMMAND_ID_STDAPI_FS_MOUNT_SHOW], } # Merge the local file system commands into the filtered commands hash filter_commands(all.merge(local_fs_commands), reqs) end |
#list_path(path, columns, sort, order, short, recursive = false, depth = 0, search_term = nil) ⇒ Object
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 615 def list_path(path, columns, sort, order, short, recursive = false, depth = 0, search_term = nil) # avoid infinite recursion if depth > 100 return end tbl = Rex::Text::Table.new( 'Header' => "Listing: #{path}".force_encoding('UTF-8'), 'SortIndex' => columns.index(sort), 'SortOrder' => order, 'Columns' => columns, 'SearchTerm' => search_term) items = 0 # Enumerate each item... # No need to sort as Table will do it for us client.fs.dir.entries_with_info(path).each do |p| ffstat = p['StatBuf'] fname = p['FileName'] || 'unknown' row = [ ffstat ? ffstat.prettymode : '', ffstat ? ffstat.size : '', ffstat ? ffstat.ftype[0,3] : '', ffstat ? ffstat.mtime : '', fname.force_encoding('UTF-8') ] row.insert(4, p['FileShortName'] || '') if short if fname != '.' && fname != '..' if row.join(' ') =~ /#{search_term}/ tbl << row items += 1 end if recursive && ffstat && ffstat.directory? if client.fs.file.is_glob?(path) child_path = ::File.dirname(path) + ::File::SEPARATOR + fname child_path += ::File::SEPARATOR + ::File.basename(path) else child_path = path + ::File::SEPARATOR + fname end begin list_path(child_path, columns, sort, order, short, recursive, depth + 1, search_term) rescue RequestError end end end end if items > 0 print_line(tbl.to_s) else print_line("No entries exist in #{path}") end end |
#name ⇒ Object
Name for this dispatcher.
124 125 126 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 124 def name "Stdapi: File system" end |
#tab_complete_cdirectory(str, words) ⇒ Object
Provide a generic tab completion for client directory names.
899 900 901 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 899 def tab_complete_cdirectory(str, words) tab_complete_path(str, words, true) end |
#tab_complete_cfilenames(str, words) ⇒ Object
Provide a generic tab completion for client file names. This tab complete method would create request to the client, so sometimes it wouldn’t execute successfully especially on bad network.
892 893 894 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 892 def tab_complete_cfilenames(str, words) tab_complete_path(str, words, false) end |
#tab_complete_path(str, words, dir_only) ⇒ Object
903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 903 def tab_complete_path(str, words, dir_only) if client.platform == 'windows' ::Readline.completion_case_fold = true end if client.commands.include?(COMMAND_ID_STDAPI_FS_LS) = str = client.fs.file.() if =~ results = client.fs.dir.match(, dir_only) rescue [] results = (str, , results) if results.length == 1 && results[0] != str && results[0].end_with?(client.fs.file.separator) # If Readline receives a single value from this function, it will assume we're done with the tab # completing, and add an extra space at the end. # This is annoying if we're recursively tab-traversing our way through subdirectories - # we may want to continue traversing, but MSF will add a space, requiring us to back up to continue # tab-completing our way through successive subdirectories. ::Readline.completion_append_character = nil end results else [] end end |
#unexpand_path_for_suggestions(original_path, expanded_path, suggestions) ⇒ Object
After a path expansion followed by a tab completion suggestion set, unexpand the path back so that Readline is happy
930 931 932 933 934 935 936 937 938 939 940 941 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 930 def (original_path, , suggestions) if original_path == suggestions else result = [] suggestions.each do |suggestion| addition = suggestion[.length..-1] result.append("#{original_path}#{addition}") end result end end |
#vali_date(str) ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb', line 128 def vali_date(str) result = DateTime.parse(str) return result.to_time.to_i rescue print_error("Bad date/time specification (#{str}). Use this format: \"YYYY-mm-dd\" or \"YYYY-mm-ddTHH:MM:SS\", e.g \"1970-01-01\"") nil end |