Metasploit

Standard API Methods Reference

The API methods below are available across all editions of the Metasploit product. All API functions use the naming convention <group>.<method>. All product editions share the basic API groups defined in the Metasploit Framework. Metasploit Pro provides a number of additional APIs for accessing the Pro features. For more information on the Pro APIs, see the Pro API Methods Reference.

For more insight on the standard APIs, check out the online developer documentation.

Authentication

The authentication API provides methods for logging in and managing authentication tokens. The only API that can be accessed without a valid authentication token is auth.login, which in turn returns a token.

All API users are treated as administrative users and can trivially gain access to the underlying operating system. For this reason, you should always protect API keys as if they granted root access to the system on which Metasploit is running.

auth.login

The auth.login method allows a username and password to be supplied which in turn grants the caller with a temporary authentication token. This authentication token expires five minutes after the last request made with it.

Syntax

auth.login(String: Username, String: Password)

Successful Request Example

Client:

[ "auth.login", "MyUserName", "MyPassword"]

Server:

{ "result" => "success", "token" => "a1a1a1a1a1a…" }

Unsuccessful Request Example

Client:

[ "auth.login", "MyUserName", "BadPassword"]

Server:

{
"error" => true,
"error_class" => "Msf::RPC::Exception",
"error_message" => "Invalid User ID or Password"
}

auth.logout

The auth.logout method will remove the specified token from the authentication token list. Note that this method can be used to disable any temporary token, not just the one used by the current user. This method will still return "success" when a permanent token is specified, but the permanent token will not be removed.

Successful Request

Client:

[ "auth.logout", "<token>", "<LogoutToken>"]

Server:

{ "result" => "success" }

Unsuccessful Request

Client:

[ "auth.logout", "<token>", "BadToken"]

Server:

{
"error" => true,
"error_class" => "Msf::RPC::Exception",
"error_message" => "Invalid Authentication Token"
}

auth.token_add

The auth.token_add will add an arbitrary string as a valid permanent authentication token. This token can be used for all future authentication purposes. This method will never return an error, as collisions with an existing token of the same name will be ignored.

Client:

[ "auth.token_add", "<token>", "<NewToken>"]

Server:

{ "result" => "success" }

auth.token_generate

The auth.token_generate method will create a random 32-byte authentication token, add this token to the authenticated list, and return this token to the caller. This method should never return an error if called with a valid authentication token.

Client:

[ "auth.token_generate", "<token>"]

Server:

{ "result" => "success", "token" => "a1a1a1a1a1a…" }

auth.token_list

The auth.token_list method will return an array of all tokens, including both temporary tokens stored in memory and permanent tokens, stored either in memory or in the backend database. This method should never return an error if called with a valid authentication token.

Client:

[ "auth.token_list", "<token>"]

Server:

{ "tokens" => [ "token1", "token2", "token3" ] }

auth.token_remove

The auth.token_remove method will delete a specified token. This will work for both temporary and permanent tokens, including those stored in the database backend. This method should never return an error if called with a valid authentication token.

Client:

[ "auth.token_remove", "<token>", "<TokenToBeRemoved>"]

Server:

{ "result" => "success" }

Core

The core API provides methods for managing global variables in the framework object, saving the current configuration to disk, manipulating the module load paths, reloading all modules, managing background threads, and retrieving the server version.

core.add_module_path

This method provides a way to add a new local file system directory (local to the server) as a module path. This can be used to dynamically load a separate module tree through the API. The path must be accessible to the user ID running the Metasploit service and contain a top-level directory for each module type (exploits, nop, encoder, payloads, auxiliary, post). Module paths will be immediately scanned for new modules and modules that loaded successfully will be immediately available. Note that this will not unload modules that were deleted from the file system since previously loaded (to remove all deleted modules, the core.reload_modules method should be used instead). This module may raise an error response if the specified path does not exist.

Client:

[ "core.add_module_path", "<token>", "<Path>"]

Server:

{
'exploits' => 800,
'auxiliary' => 300,
'post' => 200,
'encoders' => 30,
'nops' => 25,
'payloads' => 250
}

core.module_stats

This method returns the number of modules loaded, broken down by type.

Client:

[ "core.module_stats", "<token>"]

Server:

{
'exploits' => 800,
'auxiliary' => 300,
'post' => 200,
'encoders' => 30,
'nops' => 25,
'payloads' => 250
}

core.reload_modules

This method provides a way to dump and reload all modules from all configured module paths. This is the only way to purge a previously loaded module that the caller would like to remove. This method can take a long time to return, up to a minute on slow servers.

Client:

[ "core.reload_modules", "<token>"]

Server:

{
'exploits' => 800,
'auxiliary' => 300,
'post' => 200,
'encoders' => 30,
'nops' => 25,
'payloads' => 250
}

core.save

This method causes the current global datastore of the framework instance to be stored to the server's disk, typically in ~/.msf3/config. This configuration will be loaded by default the next time Metasploit is started by that user on that server.

Client:

[ "core.save", "<token>" ]

Server:

{ "result" => "success" }

core.setg

This method provides a way to set a global datastore value in the framework instance of the server. Examples of things that can be set include normal globals like LogLevel, but also the fallback for any modules launched from this point on. For example, the Proxies global option can be set, which would indicate that all modules launched from that point on should go through a specific chain of proxies, unless the Proxies option is specifically overridden for that module.

Client:

[ "core.setg", "<token>", "<OptionName>", "<OptionValue>"]

Server:

{ "result" => "success" }

core.unsetg

This method is the counterpart to core.setg in that it provides a way to unset (delete) a previously configured global option.

Client:

[ "core.unsetg", "<token>", "<OptionName>" ]

Server:

{ "result" => "success" }

core.thread_list

This method will return a list the status of all background threads along with an ID number that can be used to shut down the thread.

Client:

[ "core.thread_list", "<token>"]

Server:

{
0 =>
{
  "status" => "sleep",
  "critical" => true,
  "name" => "SessionScheduler-1",
  "started" => "2011-05-29 15:36:03 -0500"
  },
  1 =>
  {
  "status" => "sleep",
  "critical" => true,
  "name" => "SessionScheduler-2",
  "started" => "2011-05-29 15:36:03 -0500"
}
}

core.thread_kill

This method can be used to kill an errant background thread. The ThreadID should match what was returned by the core.thread_list method. This method will still return success even if the specified thread does not exist.

Client:

[ "core.thread_kill", "<token>", "<ThreadID>"]

Server:

{ "result" => "success" }

core.version

This method returns basic version information about the running framework instance, the Ruby interpreter, and the RPC protocol version being used.

Client:

[ "core.version", "<token>"]

Server:

{
"version" => "4.0.0-release",
"ruby" => "1.9.1 x86_64-linux 2010-01-10",
"api" => "1.0"
}

core.stop

This method will result in the immediate shutdown of the Metasploit server. This should only be used in extreme cases where a better control mechanism is unavailable. Note that the caller may not even receive a response, depending on how fast the server is killed.

Client:

[ "core.stop", "<token>"]

Server:

{ "result" => "success" }

Console

The Console API provides the ability to allocate and work with the Metasploit Framework Console. In addition to being able to send commands and read output, these methods expose the tab completion backend as well being able to detach from and kill interactive sessions. Note that consoles provide the ability to do anything a local Metasploit Framework Console user may do, including running system commands.

console.create

The console.create method is used to allocate a new console instance. The server will return a Console ID ("id") that is required to read, write, and otherwise interact with the new console. The "prompt" element in the return value indicates the current prompt for the console, which may include terminal sequences. Finally, the "busy" element of the return value determines whether the console is still processing the last command (in this case, it always be false). Note that while Console IDs are currently integers stored as strings, these may change to become alphanumeric strings in the future. Callers should treat Console IDs as unique strings, not integers, wherever possible.

Client:

[ "console.create", "<token>"]

Server:

{
"id" => "0",
"prompt" => "msf > ",
"busy" => false
}

console.destroy

The console.destroy method deletes a running console instance by Console ID. Consoles should always be destroyed after the caller is finished to prevent resource leaks on the server side. If an invalid Console ID is specified, the "result" element will be set to the string "failure" as opposed to "success".

Client:

[ "console.destroy", "<token>", "ConsoleID"]

Server:

{ "result" => "success" }

console.list

The console.list method will return a hash of all existing Console IDs, their status, and their prompts.

Client:

[ "console.list", "<token>"]

Server:

{
"0" => {
  "id" => "0",
  "prompt" => "msf exploit(\x01\x02\x01\x02handler\x01\x02) > ",
  "busy" => false
  },
"1" => {
  "id" => "1",
  "prompt" => "msf > ",
  "busy" => true
  }
}

console.write

The console.write method will send data to a specific console, just as if it had been typed by a normal user. This means that most commands will need a newline included at the end for the console to process them properly.

Client:

[ "console.write", "<token>", "0", "version\n"]

Server:

{ "wrote" => 8 }

console.read

The console.read method will return any output currently buffered by the console that has not already been read. The data is returned in the raw form printed by the actual console. Note that a newly allocated console will have the initial banner available to read.

Client:

[ "console.read", "<token>", "0"]

Server:

{
"data" => "Framework: 4.0.0-release.14644[..]\n",
"prompt" => "msf > ",
"busy" => false
}

console.session_detach

The console.session_detach method simulates the user using the Control+Z shortcut to background an interactive session in the Metasploit Framework Console. This method can be used to return to the main Metasploit prompt after entering an interactive session through a sessions –i console command or through an exploit.

Client:

[ "console.session_detach", "<token>", "ConsoleID"]

Server:

{ "result" => "success" }

console.session_kill

The console.session_kill method simulates the user using the Control+C shortcut to abort an interactive session in the Metasploit Framework Console. This method should only be used after a sessions –i command has been written or an exploit was called through the Console API. In most cases, the session API methods are a better way to session termination, while the console.session_detach method is a better way to drop back to the main Metasploit console.

Client:

[ "console.session_kill", "<token>", "ConsoleID"]

Server:

{ "result" => "success" }

console.tabs

The console.tabs command simulates the user hitting the tab key within the Metasploit Framework Console. This method will take a current line of input and return the tab completion options that would be available within the interactive console. This allows an API caller to emulate tab completion through this interface. For example, setting the InputLine to "hel" for a newly allocated console returns a single element array with the option help.

Client:

[ "console.tabs", "<token>", "ConsoleID", "InputLine"]

Server:

{ "tabs" => [ "option1", "option2", "option3" }

Jobs

The Jobs API provides methods for listing jobs, obtaining more information about a specific job, and killing specific jobs. These methods equate the jobs command in the Metasploit Framework Console. Jobs are typically used to manage background modules.

job.list

The job.list method will return a hash, keyed by Job ID, of every active job. The Job ID is required to terminate or obtain more information about a specific job.

Client:

[ "job.list", "<token>"]

Server:

{ "0" => "Exploit: windows/browser/ms03_020_ie_objecttype" }

job.info

The job.info method will return additional data about a specific job. This includes the start time and complete datastore of the module associated with the job.

Client:

[ "job.info", "<token>", "JobID"]

Server:

{
"jid" => 0,
"name" => "Exploit: windows/browser/ms03_020_ie_objecttype",
"start_time" => 1306708444,
"uripath" => "/aHdzfE1i3v",
"datastore" => {
  "EnableContextEncoding" => false,
  "DisablePayloadHandler" => false,
  "SSL" => false,
  "SSLVersion" => "SSL3",
  "SRVHOST" => "0.0.0.0",
  "SRVPORT" => "8080",
  "PAYLOAD" => "windows/meterpreter/reverse_tcp",
  "LHOST" => "192.168.35.149",
  "LPORT"=>"4444"
  }
}

job.stop

The job.stop method will terminate the job specified by the Job ID.

Client:

[ "job.stop", "<token>", "JobID"]

Server:

{ "result" => "success" }

Modules

The Modules API provides the ability to list modules, enumerate their options, identify compatible payloads, and actually run them. All module types share the same API group and the module type is passed in as a parameter when the request would be ambiguous otherwise.

module.exploits

The module.exploits method returns a list of all loaded exploit modules in the framework instance. Note that the exploit/ prefix is not included in the path name of the return module.

Client:

[ "module.exploits", "<token>" ]

Server:

{ "modules" => [
  "linux/pop3/cyrus_pop3d_popsubfolders",
  "linux/ids/snortbopre",
  []
  ]
}

module.auxiliary

The module.auxiliary method returns a list of all loaded auxiliary modules in the framework instance. Note that the auxiliary/ prefix is not included in the path name of the return module.

Client:

[ "module.auxiliary", "<token>" ]

Server:

{ "modules" => [
  "pdf/foxit/authbypass",
  "admin/motorola/wr850g_cred",
  "admin/oracle/post_exploitation/win32exec"
  []
  ]
}

module.post

The module.post method returns a list of all loaded post modules in the framework instance. Note that the post/ prefix is not included in the path name of the return module.

Client:

[ "module.post", "<token>" ]

Server:

{ "modules" => [
  "multi/gather/env",
  "windows/escalate/bypassuac",
  []
  ]
}

module.payloads

The module.payloads method returns a list of all loaded payload modules in the framework instance. Note that the payload/ prefix is not included in the path name of the return module.

Client:

[ "module.payloads", "<token>" ]

Server:

{ "modules" => [
  "linux/armle/exec",
  "linux/armle/shell_reverse_tcp",
  []
  ]
}

module.encoders

The module.encoders method returns a list of all loaded encoder modules in the framework instance. Note that the encoder/ prefix is not included in the path name of the return module.

Client:

[ "module.encoders", "<token>" ]

Server:

{ "modules" => [
  "mipsbe/longxor",
  "sparc/longxor_tag",
  []
  ]
}

module.nops

The module.nops method returns a list of all loaded nop modules in the framework instance. Note that the nop/ prefix is not included in the path name of the return module.

Client:

[ "module.nops", "<token>" ]

Server:

{ "modules" => [
  "armle/simple",
  "sparc/random",
  []
  ]
}

module.info

The module.info method returns a hash of detailed information about the specified module. The ModuleType should be one "exploit", "auxiliary", "post", "payload", "encoder", and "nop". The ModuleName can either include module type prefix (exploit/) or not.

Client:

[ "module.info", "<token>", "ModuleType", "ModuleName" ]

Server:

{
"name" => "SPARC NOP generator",
"description" => "SPARC NOP generator",
"license" => "Metasploit Framework License (BSD)",
"filepath" => "<msf>/modules/nops/sparc/random.rb",
"version" => "10394",
"rank" => 300,
"references" => [],
"authors" => [ "vlad902 <vlad902@gmail.com>" ]
}

module.options

The module.options method returns a hash of datastore options for the specified module. The ModuleType should be one "exploit", "auxiliary", "post", "payload", "encoder", and "nop". The ModuleName can either include module type prefix (exploit/) or not.

Client:

[ "module.options", "<token>", "ModuleType", "ModuleName" ]

Server:

{
"SSL"=> {
  "type" => "bool",
  "required" => false,
  "advanced" => true,
  "evasion" => false,
  "desc" => "Negotiate SSL for outgoing connections",
  "default" => false
  },
"SSLVersion" => {
  "type" => "enum",
  "required" => false,
  "advanced" => true,
  "evasion" => false,
  "desc" => "Specify the version…",
  "default" => "SSL3",
  "enums" => [ "SSL2", "SSL3", "TLS1" ]
  }
}

module.compatible_payloads

The module.compatible_payloads method returns a list of payloads that are compatible with the exploit module name specified.

Client:

[ "module.compatible_payloads", "<token>", "ModuleName" ]

Server:

{
"payloads" => [
  "generic/debug_trap",
  "generic/shell_bind_tcp",
  "generic/shell_reverse_tcp"
  ]
}

module.target_compatible_payloads

The module.target_compatible_payloads method is similar to the module.compatible_payloads method in that it returns a list of matching payloads, however, it restricts those payloads to those that will work for a specific exploit target. For exploit modules that can attack multiple platforms and operating systems, this is the method used to obtain a list of available payloads after a target has been chosen.

Client:

[ "module.target_compatible_payloads", "<token>", "ModuleName", 1 ]

Server:

{
"payloads" => [
  "generic/debug_trap",
  "generic/shell_bind_tcp",
  "generic/shell_reverse_tcp"
  ]
}

module.compatible_sessions

The module.compatible_sessions method returns a list of payloads that are compatible with the post module name specified.

Client:

[ "module.compatible_sessions", "<token>", "ModuleName" ]

Server:

{ "sessions" => [
  "1",
  "2"
  ]
}

module.encode( String: Data, String: EncoderModule, Hash: Options )

The module.encode method provides a way to encode an arbitrary payload (specified as Data) with a specific encoder and set of options. The available options include:

  • format – This option can be used to specify an output format, such as "exe", "vbs", or "raw".
  • badchars – This option can be used to specify a list of raw bytes to avoid in the encoding.
  • platform – This option can be used to set the operating system platform of the encoder.
  • arch – This option can be used to set the architecture of the encoder.
  • ecount – This option specifies the number of encoding passes to be done.

For "exe" format, the following additional options are available:

  • altexe – The name of a specific executable template file to use for the output file.
  • exedir – The name of an alternate directory of templates to consult for the output file.
  • inject – A boolean indicating whether to inject the payload as new thread.

Client:

[ "module.encode", "<token>", "Data", "EncoderModule", {
  "Option1" => "Value1",
  "Option2" => "Value2"
  }
]

Server:

{ "encoded" => "<raw output data>" }

module.execute

The module.execute method provides a way to launch an exploit, run an auxiliary module, trigger a post module on a session, or generate a payload. The ModuleType should be one "exploit", "auxiliary", "post", and "payload". The ModuleName can either include module type prefix (exploit/) or not. The Datastore is the full set of datastore options that should be applied to the module before executing it.

In the case of exploits, auxiliary, or post modules, the server response will return the Job ID of the running module:

Client:

[ "module.execute", "<token>", "ModuleType", "ModuleName", {
  "RHOST" => "1.2.3.4",
  "RPORT" => "80"
  }
]

Server:

{ "job_id" => 1 }

In the case of payload modules, a number of additional options are parsed, including the datastore for the payload itself. These options are:

  • BadChars – The raw list of bytes that needed to be encoded out of the payload
  • Format – The output format that the payload should be converted to ("exe", "ruby", "c")
  • ForceEncoding – A boolean indicating whether encoding should be done even if bytes are OK
  • Template – The path to a template file for EXE output
  • Platform – The operating system platform for the encoder
  • KeepTemplateWorking – A boolean indicating whether to inject a new thread or not
  • NopSledSize – The size of the prefixed mandatory nop sled (default is 0)
  • Iterations – The number of encoding rounds to go through

The response consists of the raw payload data:

Client:

[ "module.execute", "<token>", "ModuleType", "ModuleName", {
  "LHOST" => "4.3.2.1",
  "LPORT" => "4444"
  }
]

Server:

{ "payload" => "<raw payload data>" }

Plugins

The Plugin API provides the ability to load, unload, and list loaded plugins.

plugin.load

The plugin.load method will load the specified plugin in the framework instance. The Options parameter can be used to specify initialization options to the plugin. The individual options are different for each plugin. A failed load will cause this method to return a "result" value of "failure".

Client:

[ "plugin.load", "<token>", "PluginName", {
  "Option1" => "Value1",
  "Option2" => "Value2"
  }
]

Server:

{ "result" => "success" }

plugin.unload

The plugin.unload method will unload a previously loaded plugin by name. The name is not always identical to the string used to load the plugin in the first place, so callers should check the output of plugin.loaded when there is any confusion. A failed load will cause this method to return a "result" value of "failure".

Client:

[ "plugin.unload", "<token>", "PluginName" ]

Server:

{ "result" => "success" }

plugin.loaded

The plugin.loaded method will enumerate all currently loaded plugins.

Client:

[ "plugin.loaded", "<token>" ]

Server:

{ "plugins" => [ "plugin1", "plugin2", "plugin3" ] }

Sessions

The Sessions API is used to list, interact with, and terminate open sessions to compromised systems. The Session ID returned by session.list is used to unique identify a given session. Note that the database IDs used to identify sessions in the Metasploit Pro user interface are translated to a framework instance-local Session ID for use by this API.

session.list

This method will list all active sessions in the framework instance.

Client:

[ "session.list", "<token>" ]

Server:

{
"1" => {
  'type' => "shell",
  "tunnel_local" => "192.168.35.149:44444",
  "tunnel_peer" => "192.168.35.149:43886",
  "via_exploit" => "exploit/multi/handler",
  "via_payload" => "payload/windows/shell_reverse_tcp",
  "desc" => "Command shell",
  "info" => "",
  "workspace" => "Project1",
  "target_host" => "",
  "username" => "root",
  "uuid" => "hjahs9kw",
  "exploit_uuid" => "gcprpj2a",
  "routes" => [ ]
  }
}

session.stop

The session.stop method will terminate the session specified in the SessionID parameter.

Client:

[ "session.stop", "<token>", "SessionID" ]

Server:

{ "result" => "success" }

session.shell_read

The shell.read method provides the ability to read output from a shell session. As of version 3.7.0, shell sessions also ring buffer their output, allowing multiple callers to read from one session without losing data. This is implemented through the optional ReadPointer parameter. If this parameter is not given (or set to 0), the server will reply with all buffered data and a new ReadPointer (as the "seq" element of the reply). If the caller passes this ReadPointer into subsequent calls to shell.read, only data since the previous read will be returned. By continuing to track the ReadPointer returned by the last call and pass it into the next call, multiple readers can all follow the output from a single session without conflict.

Client:

[ "session.shell_read", "<token>", "SessionID", "ReadPointer ]

Server:

{
"seq" => "32",
"data" => "uid=0(root) gid=0(root)…"
}

session.shell_write

The shell.write method provides the ability to write data into an active shell session.

Most sessions require a terminating newline before they will process a command.

Client:

[ "session.shell_write", "<token>", "SessionID", "id\n" ]

Server:

{ "write_count" => "3" }

session.meterpreter_write

The session.meterpeter_write method provides the ability write commands into the Meterpreter Console. This emulates how a user would interact with a Meterpreter session from the Metasploit Framework Console. Note that multiple concurrent callers writing and reading to the same Meterpreter session through this method can lead to a conflict, where one caller gets the others output and vice versa. Concurrent access to a Meterpreter session is best handled by running Post modules or Scripts. A newline does not need to be specified unless the console is currently tied to an interactive channel, such as a sub-shell.

Client:

[ "session.meterpreter_write", "<token>", "SessionID", "ps" ]

Server:

{ "result" => "success" }

session.meterpreter_read

The session.meterpreter_read method provides the ability to read pending output from a Meterpreter session console. As noted in the session.meterpreter_write documentation, this method is problematic when it comes to concurrent access by multiple callers and Post modules or Scripts should be used instead.

Client:

[ "session.meterpreter_read", "<token>", "SessionID"]

Server:

{ "data" => "<raw console output>" }

session.meterpreter_run_single

The session.meterpreter_run_single method provides the ability to run a single Meterpreter console command. This method does not need be terminated by a newline. The advantage to session.meterpreter_run_single over session.meterpreter_write is that this method will always run the Meterpreter command, even if the console tied to this sessions is interacting with a channel.

Client:

[ "session.meterpreter_run_single", "<token>", "SessionID", "ps" ]

Server:

{ "result" => "success" }

session.meterpreter_script

The session.meterpreter_script method provides the ability to run a Meterpreter script on the specified session. This method does not provide a way to specify arguments for a script, but the session.metepreter_run_single method can handle this case.

Client:

["session.meterpreter_script","<token>","SessionID","scriptname"]

Server:

{"result"=>"success"}Server: { "result" => "success" }

session.meterpreter_session_detach

The session.meterpreter_session_detach method stops any current channel or sub-shell interaction taking place by the console associated with the specified Meterpreter session. This simulates the console user pressing the Control+Z hotkey.

Client:

[ "session.meterpreter_session_detach", "<token>", "SessionID" ]

Server:

{ "result" => "success" }

session.meterpreter_session_kill

The session.meterpreter_session_kill method terminates the current channel or sub-shell that the console associated with the specified Meterpreter session is interacting with. This simulates the console user pressing the Control+C hotkey.

Client:

[ "session.meterpreter_session_detach", "<token>", "SessionID" ]

Server:

{ "result" => "success" }

session.meterpreter_tabs

The session.meterpreter_tabs command simulates the user hitting the tab key within the Meterpreter Console. This method will take a current line of input and return the tab completion options that would be available within the interactive console. This allows an API caller to emulate tab completion through this interface. For example, setting the InputLine to "hel" for a newly allocated console returns a single element array with the option help.

Client:

[ "session.meterpreter_tabs", "<token>", "SessionID", "InputLine"]

Server:

{ "tabs" => [ "option1", "option2", "option3" }

session.compatible_modules

The session.compatible_modules method returns a list of Post modules that are compatible with the specified session. This includes matching Meterpreter Post modules to Meterpreter sessions and enforcing platform and architecture restrictions.

Client:

[ "session.compatible_modules", "<token>", "SessionID" ]

Server:

{ "modules" => [ "multi/gather/env" ] }

session.shell_upgrade

The session.shell_upgrade method will attempt to spawn a new Meterpreter session through an existing Shell session. This requires that a multi/handler be running (windows/meterpreter/reverse_tcp) and that the host and port of this handler is provided to this method.

Client:

[ "session.shell_upgrade", "<token>", "SessionID", "1.2.3.4", 4444 ]

Server:

{ "result" => "success" }

session.ring_clear

The session.ring_clear method will wipe out the ring buffer associated with a specific shell session. This may be useful to reclaim memory for idle background sessions.

Client:

[ "session.ring_clear", "<token>", "SessionID" ]

Server:

{ "result" => "success" }

session.ring_last

The session.ring_last method will return the last issued ReadPointer (sequence number) for the specified Shell session.

Client:

[ "session.ring_last", "<token>", "SessionID" ]

Server:

{ "seq" => 112 }

session.ring_put

The session.ring_put method provides the ability to write data into an active shell session.

Most sessions require a terminating newline before they will process a command.

Client:

[ "session.ring_put", "<token>", "SessionID", "id\n" ]

Server:

{ "write_count" => "3" }

Standard API Methods Reference


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.