From 46fef357f4ebff4a12d866b70c382bf101adaf65 Mon Sep 17 00:00:00 2001 From: James Lee Date: Tue, 28 Feb 2012 16:31:03 -0700 Subject: [PATCH] Clean up some rdoc comments This adds categories for the various interfaces that meterpreter and shell sessions implement so they are grouped logically in the docs. --- lib/msf/base/sessions/command_shell.rb | 18 ++++++++++ lib/msf/base/sessions/meterpreter.rb | 49 +++++++++++++++----------- 2 files changed, 46 insertions(+), 21 deletions(-) diff --git a/lib/msf/base/sessions/command_shell.rb b/lib/msf/base/sessions/command_shell.rb index 9c8627c2bd..266b37a556 100644 --- a/lib/msf/base/sessions/command_shell.rb +++ b/lib/msf/base/sessions/command_shell.rb @@ -27,6 +27,8 @@ class CommandShell include Msf::Session::Scriptable + ## + # :category: Msf::Session::Scriptable implementors # # Executes the supplied script, must be specified as full path. # @@ -71,6 +73,8 @@ class CommandShell self.class.type end + ## + # :category: Msf::Session::Provider::SingleCommandShell implementors # # The shell will have been initialized by default. # @@ -78,6 +82,8 @@ class CommandShell return true end + ## + # :category: Msf::Session::Provider::SingleCommandShell implementors # # Explicitly run a single command, return the output. # @@ -100,6 +106,8 @@ class CommandShell buff end + ## + # :category: Msf::Session::Provider::SingleCommandShell implementors # # Read from the command shell. # @@ -161,6 +169,8 @@ class CommandShell buff end + ## + # :category: Msf::Session::Provider::SingleCommandShell implementors # # Writes to the command shell. # @@ -177,6 +187,8 @@ class CommandShell end end + ## + # :category: Msf::Session::Provider::SingleCommandShell implementors # # Closes the shell. # @@ -225,6 +237,9 @@ class CommandShell protected + ## + # :category: Msf::Session::Interactive implementors + # # Override the basic session interaction to use shell_read and # shell_write instead of operating on rstream directly. def _interact @@ -236,6 +251,9 @@ protected end end + ## + # :category: Msf::Session::Interactive implementors + # def _interact_stream fds = [rstream.fd, user_input.fd] while self.interacting diff --git a/lib/msf/base/sessions/meterpreter.rb b/lib/msf/base/sessions/meterpreter.rb index c369e31b65..9606423086 100644 --- a/lib/msf/base/sessions/meterpreter.rb +++ b/lib/msf/base/sessions/meterpreter.rb @@ -18,10 +18,10 @@ module Sessions ### class Meterpreter < Rex::Post::Meterpreter::Client + include Msf::Session # # The meterpreter session is interactive # - include Msf::Session include Msf::Session::Interactive include Msf::Session::Comm @@ -81,6 +81,11 @@ class Meterpreter < Rex::Post::Meterpreter::Client self.class.type end + ## + # :category: Msf::Session::Provider::SingleCommandShell implementors + # + # Create a channelized shell process on the target + # def shell_init return true if @shell @@ -91,6 +96,8 @@ class Meterpreter < Rex::Post::Meterpreter::Client end + ## + # :category: Msf::Session::Provider::SingleCommandShell implementors # # Read from the command shell. # @@ -116,6 +123,8 @@ class Meterpreter < Rex::Post::Meterpreter::Client end end + ## + # :category: Msf::Session::Provider::SingleCommandShell implementors # # Write to the command shell. # @@ -133,6 +142,11 @@ class Meterpreter < Rex::Post::Meterpreter::Client len end + ## + # :category: Msf::Session::Provider::SingleCommandShell implementors + # + # Terminate the shell channel + # def shell_close @shell.close @shell = nil @@ -167,11 +181,7 @@ class Meterpreter < Rex::Post::Meterpreter::Client end ## - # - # Msf::Session overrides - # - ## - + # :category: Msf::Session overrides # # Cleans up the meterpreter client session. # @@ -181,6 +191,8 @@ class Meterpreter < Rex::Post::Meterpreter::Client super end + ## + # :category: Msf::Session overrides # # Returns the session description. # @@ -190,11 +202,7 @@ class Meterpreter < Rex::Post::Meterpreter::Client ## - # - # Msf::Session::Scriptable implementors - # - ## - + # :category: Msf::Session::Scriptable implementors # # Runs the meterpreter script in the context of a script container # @@ -205,11 +213,7 @@ class Meterpreter < Rex::Post::Meterpreter::Client ## - # - # Msf::Session::Interactive implementors - # - ## - + # :category: Msf::Session::Interactive implementors # # Initializes the console's I/O handles. # @@ -222,6 +226,8 @@ class Meterpreter < Rex::Post::Meterpreter::Client super end + ## + # :category: Msf::Session::Interactive implementors # # Resets the console's I/O handles. # @@ -249,6 +255,8 @@ class Meterpreter < Rex::Post::Meterpreter::Client console.queue_cmd(cmd) end + ## + # :category: Msf::Session::Interactive implementors # # Explicitly runs a command in the meterpreter console. # @@ -316,6 +324,7 @@ class Meterpreter < Rex::Post::Meterpreter::Client end end rescue ::Interrupt + dlog("Interrupt while loading sysinfo: #{e.class}: #{e}") raise $! rescue ::Exception => e # Log the error but otherwise ignore it so we don't kill the @@ -325,6 +334,8 @@ class Meterpreter < Rex::Post::Meterpreter::Client end end + ## + # :category: Msf::Session::Interactive implementors # # Interacts with the meterpreter client at a user interface level. # @@ -343,11 +354,7 @@ class Meterpreter < Rex::Post::Meterpreter::Client ## - # - # Msf::Session::Comm implementors - # - ## - + # :category: Msf::Session::Comm implementors # # Creates a connection based on the supplied parameters and returns it to # the caller. The connection is created relative to the remote machine on