remote-api
remote-api
Release 4.8
This document describes transport, protocol, and individual methods available via the
Metasploit Remote API. This API can be used to programmatically drive the Metasploit
Framework and Metasploit Pro products.
Transport
The Metasploit API is accessed using the HTTP protocol over SSL. In a typical Metasploit Pro
installation, this uses TCP port 3790, however the user can change this as needed. The SSL
certificate is typically self-signed, however the user can exchange this for a root-signed
certificate as necessary. Metasploit Framework users can elect to use SSL or plain HTTP and the
port can be user specified as well. Callers of this API should allow these various transport-level
options to be configured by the user.
Requests
Client requests are encapsulated in a standard HTTP POST to a specific URI, typically "/api" or
"/api/1.0". This POST request must have the Content-Type header specified as
"binary/message-pack", with the body of the request containing actual RPC message.
Responses
403 The authentication credentials supplied were not granted access to the resource
In all circumstances except for a 404 result, the detailed response will be included in the
message body.
The response content-type will always be "binary/message-pack" with the exception of the 404
response format, in which case the body may contain a HTML document.
HTTP/1.1 200 OK
Content-Length: 1024
Content-Type: binary/message-pack
Encoding
All requests and responses use the MessagePack encoding (http://www.msgpack.org/). This encoding
provides an efficient, binary-safe way to transfer nested data types. MessagePack provides
implementations for many different languages, all under the Apache open source license.
["ABC", 1, 2, 3].to_msgpack()
"\x94\xA3\x41\x42\x43\x01\x02\x03"
Requests
With the exception of the authentication API, all methods expect an authentication token as the second
element of the request array, with the rest of the parameters defined by the specific method. Although
most methods use strings and integers for parameters, nested arrays and hashes may be supplied as
well. Methods that accept a list of items as input typically expect these as a single parameter consisting
of an array of elements and not a separate parameter for each element. Some methods may accept a
parameter consisting of a hash that contains specific options.
["core.version", "<token>"]
["modules.search", "<token>", {
"include" => ["exploits", "payloads"],
"keywords" => ["windows"],
"maximum" => 200
} ]
Responses use the same MessagePack encoding as requests and are always returned in the form of a
hash, also known as a dictionary. If this hash contains an "error" element with the value of true,
additional information about the error will be present in the hash fields, otherwise, the hash will contain
the results of the API call.
{
"version" => "4.0.0-release",
"ruby" => "1.9.1 x86_64-linux 2010-01-10"
}
{
"error" => true,
"error_class" => "ArgumentError",
"error_message" => "Unknown API Call"
}
{
"name" => "Microsoft Server Service Stack Corruption",
"description" => "This module exploits a parsing flaw…",
"license" => "Metasploit Framework License (BSD)",
"filepath" => "/modules/exploits/windows/smb/ms08_067_netapi.rb",
"version" => "12540",
"rank" => 500,
"references" =>
[
["CVE", "2008-4250"],
["OSVDB", "49243"],
["MSB", "MS08-067"]
],
"authors" =>
[
"hdm <[email protected]>",
"Brett Moore <[email protected]>",
],
"targets" =>
{
0 => "Automatic Targeting",
1 => "Windows 2000 Universal",
2 => "Windows XP SP0/SP1 Universal",
Versioning
The last parameter in the API URL is the requested version number. To prepare your code for future
versions it is recommended that you append "/1.0" or whatever version of this API you have tested
against. A request for the bare API URL without a version number will result in the latest version of the
API being used to handle the request. For example, the request below will request that version 1.1 of
the API should be used.
The Metasploit products are primarily written in the Ruby programming language; Ruby is by
far the easiest way to use the remote API. In addition to Ruby, any language with support for
MessagePack (Java, Python, C, etc) and HTTPS communication can take advantage of the
remote API.
Ruby
To get started with the Ruby API, install the msfrpc-client GEM (www.rubygems.org). This GEM depends
on librex, another GEM pulled from the Metasploit Framework source code, and MessagePack. Due to
the size of the librex documentation, it is suggested that you install it first separately, without the builtin
documentation, using the following commands:
After the GEM has been installed, the msfrpc-client library becomes available, and two example files are
installed along with the GEM. The following command can be used view the examples:
The msfrpc_irb.rb script is a good starting point for using the API. This script, along with the
msfrpc_pro_report.rb example, both use a standard option parsing mechanism exposed by the Ruby
GEM. This allows for the RPC destination to be configured in three different ways.
The first way is through standard command-line arguments, running msfrpc_irb.rb with the --rpc-help
option will display these.
# ./msfrpc_irb.rb --rpc-help
Usage: ./msfrpc_irb.rb [options]
RPC Options:
--rpc-host HOST
--rpc-port PORT
--rpc-ssl <true|false>
--rpc-uri URI
--rpc-user USERNAME
--rpc-pass PASSWORD
--rpc-token TOKEN
In order to connect to a remote instance of Metasploit, we need to supply the host and port. SSL is
assumed to be on by default, but may be disabled through the relevant option above. The username and
password options can either correspond to a manually configured set of the credentials in the
Metasploit Framework or a Metasploit Pro user account. As an alternative to the username and
password, an authentication token (Metasploit Pro API Key) may be used to authentication instead.
If you wish to store these parameters in a configuration file instead of the command-line, the --rpc-
config option can point to a YAML file with contents matching the syntax below:
options:
host: server
port: 3790
user: username
pass: password
token: token
ssl: true
uri: /api/1.0
Finally, the process environment can be used to set these options. The environment is only considered if
the command-line options are not specified. The corresponding environment variable names for the
options above are:
MSFRPC_HOST
MSFRPC_PORT
MSFRPC_USER
MSFRPC_PASS
MSFRPC_TOKEN
MSFRPC_SSL
MSFRPC_URI
MSFRPC_CONFIG
For a typical Metasploit Pro installation, the only options we need to specify are the host and either a
username and password, or an authentication token. The example below authenticates to the local
Metasploit Pro instance using an existing user account:
An important consideration with the msfrpc-client library is that the authentication token is
automatically passed into each method call for you, so when calling a function such as "core.version",
Copyright © 2011 Rapid7 LLC | Programming 11
you do not need to specify the token as the first parameter. For example, the following code works as
you would expect:
>> rpc.call("core.version")
=> {"version"=>"4.0.0-release", "ruby"=>"1.9.2 x86_64-linux 2010-04-
28", "api"=>"1.0"}
For a slightly more complex example, the msfrpc_pro_report.rb script is a good reference. This script will
generate and download an arbitrary report type from an arbitrary project, through the RPC protocol.
The usage is slightly more complicated, as this script registers its own command-line options while still
supporting the standard set.
RPC Options:
--rpc-host HOST
--rpc-port PORT
--rpc-ssl <true|false>
--rpc-uri URI
--rpc-user USERNAME
--rpc-pass PASSWORD
--rpc-token TOKEN
--rpc-config CONFIG-FILE
--rpc-help
Report Options:
--format FORMAT
--project PROJECT
--output OUTFILE
--help
Active Projects:
default
These two examples provide a base of functionality that be used to implement any form of wrapper or
automation script you can think of. The msfrpc_irb.rb example is a great way to learn the calling syntax
and behavior of the API, while the msfrpc_pro_report.rb example demonstrates the process of
launching a new task and waiting for it to complete.
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.
Authentication
Access to the Metasploit API is controlled through authentication tokens. An authentication is typically a
randomly generated 32-byte string, but may be created ad-hoc as well. These tokens come in two forms;
temporary and permanent.
A temporary token is returned by the API call auth.login, which consults an internal list of valid
usernames and passwords. If a correct username and password is supplied, a token is returned that is
valid for 5 minutes. This token is automatically extended every time it is used to access an API method. If
the token is not used for 5 minutes, another call to auth.login must be made to obtain a new token.
A permanent token acts as an API key that does not expire. Permanent tokens are stored in the
database backend (api_keys table) when a database is available and in memory otherwise. There are
two ways to create a new permanent token through the API. The first method is to authenticate using a
valid login, then using the temporary token to call the auth.token_generate method. This will create a
permanent token either in the database backend or in-memory, depending on the whether a database
is present.
The Metasploit Framework RPC server requires a username and password to be specified. This
username and password combination can be used with the auth.login API to obtain a temporary token
that will grant access to the rest of the API.
Metasploit Pro, by contrast, generates a permanent authentication token on startup and store this
token in a file named <install>/apps/pro/engine/tmp/service.key. The Metasploit Pro interface provides
the ability to manage permanent authentication tokens through the web interface.
The sequence below demonstrates the use of the auth.login API to obtain a token and the subsequent
use of this token to call the core.version API.
The API methods below are available across all editions of the Metasploit product. Keep in mind that the
behavior of the Metasploit Framework can change depending on whether a database backend has been
configured (it is by default, however).
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, always protect API Keys as if they granted root access to the system
on which Metasploit is running.
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 5 minutes after the last
request made with it.
Successful request:
Unsuccessful request:
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:
Unsuccessful request:
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.
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.
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.
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.
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.
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.
core.module_stats
This method returns the number of modules loaded, broken down by type.
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.
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.
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
This method is the counterpart to core.setg in that it provides a way to unset (delete) a previously
configured global option.
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.
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.
core.version
This method returns basic version information about the running framework instance, the Ruby
interpreter, and the RPC protocol version being used.
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.
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.
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".
console.list
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.
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.
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.
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.
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".
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
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.
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.
The job.stop method will terminate the job specified by the Job ID.
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.
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.
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.
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.
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.
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.
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.
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.
The module.compatible_payloads method returns a list of payloads that are compatible with the exploit
module name specified.
The module.compatible_sessions method returns a list of payloads that are compatible with the post
module name specified.
- format – This option can be used to specify an output format, such as "exe" or "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
- 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
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:
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 indiciating 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 Plugin API provides the ability to load, unload, and list loaded plugins.
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".
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".
plugin.loaded
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.
The session.stop method will terminate the session specified in the SessionID parameter.
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.
The shell.write method provides the ability to write data into an active shell session. Note that most
sessions require a terminating newline before they will process a command.
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
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.
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.
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.
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.
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".
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.
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.
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.
The session.ring_last method will return the last issued ReadPointer (sequence number) for the
specified Shell session.
The session.ring_put method is identical to session.shell_write, please see that entry for more
information.
The session.ring_read method is identical to session.shell_read, please see that entry for more
information.
In addition to the Standard API, Metasploit Pro provides access to the extensive commercial feature set.
The API methods below can be used to manage a remote Metasploit Pro instance and include
everything from product activation to automated mass exploitation and reporting. Note that while the
Pro API includes a number of high-level APIs, the Standard API methods are still the best way to manage
low-level primitives, such as Sessions. In some cases, there is overlap between what a Pro API method
provides and what can be found in the Standard API and the comments listed for the Pro API will make it
clear which use case a specific method is designed to solve.
The Pro General API methods provide access to product version information, active projects, and
configured user accounts.
pro.about
The pro.about method returns a hash containing basic information about the running Metasploit Pro
instance.
pro.workspaces
The pro.workspaces method returns a list of all active Metasploit Pro projects. Although these are called
products in the user interface, the underlying object is referred to as a Workspace, and the terms
workspace and project are used interchangeably throughout this guide.
pro.projects
The pro.projects method is an alias for the pro.workspaces method listed above
pro.workspace_add( Hash:WorkspaceOptions )
The pro.workspace_add method adds a new workspace with the specified settings and returns a hash of
that contains information on the newly created workspace.
The pro.project_add method is an alias for the pro.workspace_add method listed above
pro.workspace_del( String:WorkspaceName )
pro.project_del( String:WorkspaceName )
The pro.project_del method is an alias for the pro.workspace_del method listed above
pro.users
The pro.users method returns a list of all configured user accounts in the Metasploit Pro instance.
The Pro License API provides methods for registering and activating the Metasploit Pro product.
The pro.register method accepts a product key as the only parameter, validates that the product key
matches the correct format, and saves the product key internally. The pro.activate method must be
used to fully activate the product. This method returns a hash indicating the result of the register call
and the current state of the product.
The pro.activate method causes the Metasploit Pro installation to attempt an online activation with the
previously registered product key and the specified ActivationOptions. If a 'product_key' element is
provided in the ActivationOptions hash, this key will be registered prior to the activation process. In
most cases, an empty hash can be specified in place of the ActivationOptions. If the Metasploit Pro
instance does not have direct access to the internet, the ActivationOptions can be used to specify an
Copyright © 2011 Rapid7 LLC | API Reference 44
internal HTTP proxy server. Proxy options can be specified in the 'proxy_host', 'proxy_port', 'proxy_user',
and 'proxy_pass' elements of the ActivationOptions hash. Only standard HTTP proxies are supported.
The response to the activate call will either contain a hash of license information, as the pro.register
method does, or a hash containing a 'result' element with the value set to 'failure', and a second
element, 'reason' indicating the reason for this failure. Note that every product key can only be
activated a limited number of times, with the count determined by the license type. In the event that
activation limit has been reached, Rapid7 Support must be contacted to reset the activation count.
The pro.activate_offline method causes the Metasploit Pro installation to load a pre-generated offline
activation file from the specified local filesystem path. Offline activation files are reserved for customers
with network isolation requirements and are available through Rapid7 Support.
pro.license
The pro.license method will return a hash indicating the current Metasploit Pro license.
pro.revert_license
The pro.revert_license method attempts to switch to the last successfully activated product license
before the current one. Only one backup license copy is kept and this method does nothing if there is no
backup license available when it is called. The return value is identical to the pro.license call in that it
provides the newly chosen license information as a hash. This method is used to temporarily use a
license that may provide more users or other capabilities and then fallback to the original license when
that temporary license expires.
The Pro Updates API provides the ability to check for, download, and apply the latest Metasploit Pro
updates. This API also includes a method for restarting the Metasploit Pro services.
The pro.update_available method provides the ability to check for available updates to the Metasploit
Pro instance. The UpdateCheckOptions hash can either be empty or include the 'proxy_host',
'proxy_port', 'proxy_user', and 'proxy_pass' elements to use a HTTP proxy for the check. The return
value includes a hash that indicates whether an update is available, what the version number of this
update is, and a description of what the update contains. Note that the description may contain HTML
formatting.
The pro.update_install method provides the ability to install an update package by name, specified
through the 'version' element of the InstallOptions hash. The 'proxy_host', 'proxy_port', 'proxy_user',
and 'proxy_pass' elements can be supplied in this hash to indicate that a HTTP proxy should be used.
This method returns a hash indicating whether the update was started successfully and what the current
status of the installation is. The download and installation process is completed as a single step as the
progress can be tracked through calls to the pro.update_status method. Note that the
pro.restart_service method must be called to finalize the update.
The pro.update_install_offline method provides the ability install an update package from a local
filesystem. Customers that require offline updates should contact Rapid7 Support to be notified of the
download location of each update package. The status of the offline package installation can be
monitored by calling the pro.update_status method. Note that the pro.restart_service method must be
called to finalize the update.
pro.update_status
The pro.update_status method returns a hash indicating the current status of the update installation
process. If the update is still being retrieved from the server, the current progress of the download will
be returned in the 'download_total', 'download_done', and 'download_pcnt' elements.
The pro.update_stop method forcibly stops any existing update process, whether it is downloading the
update package or installing the contents.
pro.restart_service
The pro.restart_service method causes the Metasploit Pro RPC Service (prosvc) and the Metasploit Pro
Web Service to restart. This is necessary to complete the installation of an update package.
Metasploit Pro uses Tasks to manage background jobs initiated by the user through the web interface.
Scanning, exploiting, bruteforcing, importing, and reporting are all handled through Tasks. The Pro Task
API provides methods for enumerating active tasks, stopping tasks, and retrieving the raw log file for a
given task.
pro.task_list
The pro.task_stop method terminates the task specified in the TaskID parameter.
The pro.task_log method returns the status and log data for the task specified in the TaskID parameter.
The pro.task_delete_log method deletes the associated log file for a specific task.
The Pro Feature API includes methods that provide access to many of the top-level features in the
Metasploit Pro user interface. These methods include launching discovery scans, importing data from
other tools, launching automated exploits, running brute force attacks, and generating reports. Since
these methods are designed to expose all of the functionality available through the user interface, they
take a large number of parameters.
pro.start_discover( Hash:Config )
The pro.start_discover method is the backend method that drives the Scan action within the Metasploit
Pro user interface. This action launches a discovery scan against a range of IP addresses, identifying
active hosts, open services, and extracting information from the discovered services. The resulting data
is stored in the backend database. The pro.start_discover method takes a large number of options in the
form of a single Hash parameter and returns a Task ID that can be monitored using the Pro Task API.
The individual options within the Config hash are defined in the table below.
If we change the same request to scan all 65535 TCP ports, it would look like:
In any case the reply from a successful request would look like:
The pro.start_import method is what drives the Import action within the Metasploit Pro user interface.
This method assumes that a file is already on the local disk (relative to the Metasploit Pro system) or
that a NeXpose Console has been configured with one or more active sites. To import arbitrary data
without having to upload the file to the server first, please see the pro.import_data method instead. The
pro.start_import method takes a large number of options in the form of a single Hash parameter and
returns a Task ID that can be monitored using the Pro Task API.
The individual options within the Config hash are defined in the table below.
The reply from a successful request contains the Task ID, as shown below:
The pro.start_import_creds method is used to import credentials (users, passwords, hashes, and keys).
This method assumes that a file is already on the local disk (relative to the Metasploit Pro system. The
pro.start_import_creds method takes a large number of options in the form of a single Hash parameter
and returns a Task ID that can be monitored using the Pro Task API.
The individual options within the Config hash are defined in the table below.
The reply from a successful request contains the Task ID, as shown below:
The pro.start_nexpose method is used to launch NeXpose scans directly through the Metasploit Pro
service. The pro.start_nexpose method takes a large number of options in the form of a single Hash
parameter and returns a Task ID that can be monitored using the Pro Task API.
The individual options within the Config hash are defined in the table below.
The reply from a successful request contains the Task ID, as shown below:
The pro.start_bruteforce method is used to launch a new Bruteforce task. The pro.start_bruteforce
method takes a large number of options in the form of a single Hash parameter and returns a Task ID
that can be monitored using the Pro Task API. Keep in mind that the Bruteforce task requires hosts and
services to be present first (via Scan, Import, or NeXpose data sources).
The individual options within the Config hash are defined in the table below.
The reply from a successful request contains the Task ID, as shown below:
The pro.start_exploit method is what drives the Exploit action within the Metasploit Pro user interface.
The pro.start_exploit method takes a large number of options in the form of a single Hash parameter
and returns a Task ID that can be monitored using the Pro Task API. Keep in mind that the Exploit action
requires hosts, services, and optionally vulnerabilities to be present before it can be used. This can be
accomplished using the Scan, Import, and NeXpose actions first.
The individual options within the Config hash are defined in the table below.
The reply from a successful request contains the Task ID, as shown below:
The pro.start_webscan method is what drives the WebScan action within the Metasploit Pro user
interface. The pro.start_webscan method takes a large number of options in the form of a single Hash
parameter and returns a Task ID that can be monitored using the Pro Task API. The individual options
within the Config hash are defined in the table below.
The reply from a successful request contains the Task ID, as shown below:
The pro.start_webaudit method is what drives the WebAudit action within the Metasploit Pro user
interface. The pro.start_webaudit method takes a large number of options in the form of a single Hash
parameter and returns a Task ID that can be monitored using the Pro Task API. Keep in mind that the
WebAudit action requires one or more existing forms to have been identified by the WebScan action or
an import from another data source.
The individual options within the Config hash are defined in the table below.
The reply from a successful request contains the Task ID, as shown below:
The pro.start_websploit method is what drives the WebSploitt action within the Metasploit Pro user
interface. The pro.start_websploit method takes a large number of options in the form of a single Hash
parameter and returns a Task ID that can be monitored using the Pro Task API. Keep in mind that the
WebSploit action requires one or more existing vulnerabilities to have been identified by WebAudit or
imported from another data source.
The individual options within the Config hash are defined in the table below.
The pro.start_cleanup method is what drives the Cleanup action within the Metasploit Pro user
interface. The pro.start_cleanup method takes a number of options in the form of a single Hash
parameter and returns a Task ID that can be monitored using the Pro Task API.
The individual options within the Config hash are defined in the table below.
The reply from a successful request contains the Task ID, as shown below:
The pro.start_collect method is what drives the Collect action within the Metasploit Pro user interface.
The pro.start_collect method takes a number of options in the form of a single Hash parameter and
returns a Task ID that can be monitored using the Pro Task API.
The individual options within the Config hash are defined in the table below.
The reply from a successful request contains the Task ID, as shown below:
The pro.start_report method is what drives the Report and Export actions within the Metasploit Pro
user interface. The pro.start_report method takes a number of options in the form of a single Hash
parameter and returns a Task ID that can be monitored using the Pro Task API.
The individual options within the Config hash are defined in the table below.
The reply from a successful request contains the Task ID, as shown below:
Copyright © 2011 Rapid7 LLC | API Reference 87
Server: { "task_id" => "109" }
The pro.import_data method starts a new import task with the supplied data.
The pro.import_file method starts a new import task with the supplied server-local path.
pro.validate_import_file( String:Path )
The pro.validate_import_file method validates a file on disk to verify that it is a support data format.
This method is non-standard in that it only returns a true or false value.
pro.loot_download( Integer:LootID )
The pro.loot_download method downloads the file associated with loot record, by unique ID
pro.loot_list( String:WorkspaceName )
pro.module_search( String:SearchQuery )
The pro.module_search method scans the module database and returns any entries matching the
specified search query.
The pro.module_validate method is used to determine whether a set of options satisfies the
requirements of a given module.
Server: {
"result" => "failure",
"error" => "The following options failed to validate: RHOST."
}
pro.modules( String:ModuleType )
The pro.modules method returns the full set of modules for a given type
pro.report_download(report_id)
pro.report_download_by_task(task_id)
pro.report_list( String:WorkspaceName )
pro.meterpreter_chdir(sid, path)
pro.meterpreter_getcwd(sid)
pro.meterpreter_list(sid, path)
pro.meterpreter_rm(sid, path)
pro.meterpreter_root_paths(sid)
pro.meterpreter_search(sid, query)
pro.meterpreter_tunnel_interfaces(sid)