Skip to main content

MsfRpcClient

Struct MsfRpcClient 

Source
pub struct MsfRpcClient { /* private fields */ }

Implementations§

Source§

impl MsfRpcClient

Source

pub fn new( host: &str, port: u16, username: &str, password: &str, ssl: bool, ) -> Self

Source

pub fn login(&mut self) -> Result<MSFLoginResult>

Source

pub fn logout(&mut self)

Source

pub fn is_authenticated(&self) -> bool

Source

pub fn get_workspaces(&self) -> Result<MSFWorkspacesResult>

Source

pub fn get_hosts(&self, workspace: Option<&str>) -> Result<MSFHostsResult>

Source

pub fn check_host_exists( &self, address: &str, workspace: Option<&str>, ) -> Result<MSFHostCheckResult>

Source

pub fn rpc_call( &self, method: &str, params: &[MsgValue], timeout_secs: u64, ) -> Result<MsgValue>

Generic authenticated RPC call: [method, token, ...params].

Used by the exploitation layer for module discovery, execution and job monitoring. Returns the raw msgpack response so the caller can map it to strongly typed models.

Source

pub fn module_exists(&self, module_type: &str, name: &str) -> Result<bool>

Verify that a module exists on the connected Metasploit instance. module_type is exploit, auxiliary or post.

Distinguishes three outcomes: the module exists (Ok(true)), it does not exist (Ok(false)), or the lookup itself failed (Err).

Source

pub fn module_info(&self, module_type: &str, name: &str) -> Result<MsgValue>

Fetch full module metadata via module.info.

The RPC module.info handler accepts [ModuleType, ModuleName] on all supported framework releases. A modern server answers with a rich metadata map for known modules and an error map ― classifiable as “module not found” or an RPC failure ― for unknown ones. Only very old frameworks still expect the single full-name signature; when the modern response signals an argument-shape mismatch (rather than a missing module) we fall back to that form once.

Source

pub fn module_options(&self, module_type: &str, name: &str) -> Result<MsgValue>

Fetch the datastore options for a module via module.options. Mirrors the module.info lookup logic (modern form first, legacy single-name fallback reserved for servers that reject the modern one).

Source

pub fn list_modules_for_type(&self, module_type: &str) -> Result<Vec<MSFModule>>

List every module of the given RPC type currently loaded by the instance. Returns full refnames including the type prefix, e.g. auxiliary/scanner/http/robots_txt.

RPC listing methods take no arguments; passing a module name to them is ignored (or rejected by stricter servers) and would never be a valid existence probe.

Source

pub fn list_modules(&self) -> Result<Vec<MSFModule>>

Load the union of all exploit, auxiliary and post modules known to the connected instance. Used by the process pipeline so suggestions are grounded in what the instance can actually run.

Source

pub fn module_execute( &self, module_type: &str, name: &str, options: &BTreeMap<String, String>, payload: Option<&str>, ) -> Result<MsgValue>

Execute a module. Returns a map containing job_id on success or an error payload on failure.

Source

pub fn job_list(&self) -> Result<MsgValue>

List all running jobs. Response map: { "jobs": { "0": {...}, ... } }.

Source

pub fn job_info(&self, job_id: &str) -> Result<MsgValue>

Fetch status of a single job by id.

Source

pub fn job_stop(&self, job_id: &str) -> Result<MsgValue>

Stop a running job by id.

Source

pub fn session_list(&self) -> Result<MsgValue>

List current sessions. Response map: { "sessions": { "1": {...}, ... } }.

Source

pub fn db_loots(&self, workspace: &str) -> Result<MsgValue>

List loot records for a workspace.

Trait Implementations§

Source§

impl Clone for MsfRpcClient

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MsfRpcClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more