gomsf

package module
v2.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 12 Imported by: 0

README

go-msf

Go Reference Go Report Card Version

Production-ready Go client for the Metasploit Framework RPC API. Automate penetration testing, security research, and red team operations with type-safe Go.

go-msf is a modern, idiomatic Go library for interacting with Metasploit's RPC API. Build security automation tools, CI/CD security pipelines, and custom exploit frameworks with clean, type-safe Go code.

Features

  • Complete RPC Coverage — Core, modules, consoles, sessions, jobs, plugins, auth, and database operations
  • Event MonitoringClient.Events polls sessions, jobs and watched output streams and emits state changes on a channel; the foundation for UIs and automation
  • Automatic Re-auth — Clients built with NewClient re-authenticate once and retry when msfrpcd invalidates their token
  • Type-Safe API — Strongly typed requests and responses with validation
  • Context Support — Full context.Context integration for timeouts and cancellation
  • Error Handling — Structured error types for RPC failures, timeouts, and validation errors
  • Concurrent-Safe — Designed for safe use across goroutines
  • Zero Dependencies — Minimal external dependencies (only msgpack for RPC encoding)

Installation

go get github.com/jolovicdev/go-msf/v2

Requires Go 1.26 or later.

Version

v2.0.1 — See releases for changes. Versioning follows Semantic Versioning.

Quick Start

package main

import (
	"context"
	"fmt"
	"log"

	gomsf "github.com/jolovicdev/go-msf/v2"
)

func main() {
	ctx := context.Background()

	client, err := gomsf.NewClient(
		"yourpassword",
		gomsf.WithHost("127.0.0.1"),
		gomsf.WithPort(55553),
		gomsf.WithSSL(false),
	)
	if err != nil {
		log.Fatal(err)
	}
	defer client.Logout(ctx)

	version, err := client.Core().Version(ctx)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("Metasploit v%s connected\n", version.Version)
}

Prerequisites

Starting Metasploit RPC

Using msfrpcd (recommended for production):

msfrpcd -P yourpassword -S -f

With explicit bind options:

msfrpcd -P yourpassword -a 127.0.0.1 -p 55553 -S -f

From msfconsole (for development):

load msgrpc Pass=yourpassword

API Documentation

Client Configuration
// Password authentication
client, err := gomsf.NewClient(password, options...)

// Token authentication (if you already have a token)
client, err := gomsf.NewClientWithToken(token, options...)

Options:

Option Default Description
WithHost(host) 127.0.0.1 RPC server host
WithPort(port) 55553 RPC server port
WithURI(uri) /api/ RPC endpoint path
WithSSL(enabled) true Use HTTPS (disable with false)
WithUsername(username) msf RPC username
WithHTTPClient(client) http.DefaultClient Custom HTTP client
WithConsolePollInterval(d) 500ms Console polling interval
WithSessionPollInterval(d) 1s Session polling interval
Core Operations
version, err := client.Core().Version(ctx)
stats, err := client.Core().ModuleStats(ctx)
threads, err := client.Core().ThreadList(ctx)
err = client.Core().ReloadModules(ctx)
Module Management
// List available modules
exploits, err := client.Modules().Exploits(ctx)
payloads, err := client.Modules().Payloads(ctx)
aux, err := client.Modules().Auxiliary(ctx)

// Use a module
mod, err := client.Modules().Use(ctx, gomsf.ExploitModuleType, "windows/smb/ms08_067_netapi")
if err != nil {
    return err
}

// Set options
if err := mod.SetOption("RHOSTS", "192.168.1.10"); err != nil {
    return err
}

// Execute
result, err := mod.Execute(ctx)
Console Operations
console, err := client.Consoles().Create(ctx)
if err != nil {
    return err
}
defer client.Consoles().Destroy(ctx, console.ID)

con, err := client.Consoles().GetConsole(ctx, console.ID)
if err != nil {
    return err
}

output, err := con.RunCommand(ctx, "show exploits", 10*time.Second)
Session Management
sessions, err := client.Sessions().List(ctx)
session, err := client.Sessions().Get(ctx, "1")
err = client.Sessions().Stop(ctx, "1")

// Meterpreter interaction
meterpreter := gomsf.NewMeterpreterSession(client, "1")
output, err := meterpreter.RunWithOutput(ctx, "getuid", []string{">"}, 30*time.Second)
Jobs
jobs, err := client.Jobs().List(ctx)
info, err := client.Jobs().Info(ctx, "0")
err = client.Jobs().Stop(ctx, "0")
Plugins
plugins, err := client.Plugins().List(ctx)
err = client.Plugins().Load(ctx, "plugin_name")
err = client.Plugins().Unload(ctx, "plugin_name")
Database
status, err := client.DB().Status(ctx)
driver, err := client.DB().Driver(ctx)
workspace, err := client.DB().CurrentWorkspace(ctx)
workspaces, err := client.DB().Workspaces().List(ctx)

Error Handling

The library provides structured error types for reliable error handling:

Error Description
ErrNotAuthenticated Call requires authentication but client has no token
ErrUnexpectedResponse Metasploit returned malformed/unexpected data
ErrCommandTimeout Console or session command timed out
ErrSessionNotFound Session ID does not exist
ErrConsoleNotFound Console ID does not exist
ErrInvalidOption Invalid module option or enum value
ErrJobNotFound Job ID does not exist
ErrRPC Metasploit returned structured RPC error

Handle RPC errors:

var rpcErr *gomsf.RPCError
if errors.Is(err, gomsf.ErrRPC) && errors.As(err, &rpcErr) {
    fmt.Printf("RPC Error: %s - %s\n", rpcErr.Class, rpcErr.Message)
}

Testing

Run unit tests:

go test ./...

Run integration tests (requires running Metasploit RPC):

export RUN_MSF_INTEGRATION=1
export MSF_PASSWORD=testpass123
export MSF_USERNAME=msf
export MSF_HOST=127.0.0.1
export MSF_PORT=55553
export MSF_SSL=false

go test -v ./...

Security Considerations

  • SSL/TLS: The library defaults to SSL enabled. Use WithSSL(false) only in trusted development environments.
  • Self-Signed Certificates: When using self-signed certs, provide a custom *http.Client with appropriate TLS configuration via WithHTTPClient().
  • Credentials: Never hardcode credentials. Use environment variables or secure secret management.

Examples

See the examples directory for complete working examples.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT License — see LICENSE for details.

Copyright (c) 2026 Dušan Jolović


Keywords: metasploit golang, metasploit rpc client, go penetration testing, security automation, red team tools, metasploit api, exploit framework go, security research tools, msfrpcd client, golang offensive security

Documentation

Overview

Package gomsf provides a Go client for Metasploit's RPC API.

The package is organized around a Client plus manager types for each RPC domain, including core operations, modules, consoles, sessions, jobs, plugins, authentication, and database access.

Typical usage starts with NewClient or NewClientWithToken, then accesses managers from the client:

client, err := gomsf.NewClient("password", gomsf.WithSSL(false))
if err != nil {
	return err
}

version, err := client.Core().Version(ctx)
if err != nil {
	return err
}

The package prefers explicit failures over silent coercion. Malformed RPC payloads return ErrUnexpectedResponse. Structured Metasploit RPC failures return *RPCError and match ErrRPC. Command helper methods for consoles and sessions return ErrCommandTimeout. Module option validation errors match ErrInvalidOption.

Clients created with NewClient recover automatically when msfrpcd rejects their token (after a restart or token removal): the call re-authenticates once and retries. Clients created with NewClientWithToken have no stored password and surface the RPC error instead.

Client.Events starts an EventMonitor that polls session.list, job.list and any watched session or console output streams, and emits state changes on a channel. It is the intended foundation for UIs and automation:

monitor := client.Events(ctx)

for event := range monitor.C() {
	switch event.Type {
	case gomsf.EventSessionOpened:
		monitor.WatchSession(event.SessionID)
	case gomsf.EventSessionOutput:
		fmt.Print(event.Data)
	}
}

Note that the monitor consumes output: watching a session or console transfers ownership of its output stream, because the underlying RPC reads drain the server-side buffer.

Live Metasploit integration tests are opt-in through RUN_MSF_INTEGRATION=1.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotAuthenticated   = errors.New("not authenticated")
	ErrInvalidOption      = errors.New("invalid module option")
	ErrSessionNotFound    = errors.New("session not found")
	ErrConsoleNotFound    = errors.New("console not found")
	ErrJobNotFound        = errors.New("job not found")
	ErrUnexpectedResponse = errors.New("unexpected rpc response")
	ErrCommandTimeout     = errors.New("command timeout")
	ErrRPC                = errors.New("rpc error")
)

Functions

This section is empty.

Types

type AuthManager

type AuthManager struct {
	// contains filtered or unexported fields
}

func NewAuthManager

func NewAuthManager(rpc RPCCaller) *AuthManager

func (*AuthManager) TokenAdd

func (m *AuthManager) TokenAdd(ctx context.Context, token string) error

func (*AuthManager) TokenGenerate

func (m *AuthManager) TokenGenerate(ctx context.Context) (string, error)

func (*AuthManager) TokenList

func (m *AuthManager) TokenList(ctx context.Context) ([]string, error)

func (*AuthManager) TokenRemove

func (m *AuthManager) TokenRemove(ctx context.Context, token string) error

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(password string, opts ...ClientOption) (*Client, error)

func NewClientWithToken

func NewClientWithToken(token string, opts ...ClientOption) (*Client, error)

func (*Client) Auth

func (c *Client) Auth() *AuthManager

func (*Client) Call

func (c *Client) Call(ctx context.Context, method MsfRpcMethod, args ...interface{}) (interface{}, error)

Call performs an RPC round trip. If the server rejects the token and the client was constructed with NewClient, it re-authenticates once and retries. Logout is exempt: a rejected token there only ends the local session.

func (*Client) Consoles

func (c *Client) Consoles() *ConsoleManager

func (*Client) Core

func (c *Client) Core() *CoreManager

func (*Client) DB

func (c *Client) DB() *DbManager

func (*Client) Events

func (c *Client) Events(ctx context.Context, opts ...EventOption) *EventMonitor

Events starts an EventMonitor against the connected msfrpcd. Cancel ctx to stop it; the returned channel is closed after the monitor stops.

func (*Client) IsAuthenticated

func (c *Client) IsAuthenticated() bool

func (*Client) Jobs

func (c *Client) Jobs() *JobManager

func (*Client) Logout

func (c *Client) Logout(ctx context.Context) error

func (*Client) Modules

func (c *Client) Modules() *ModuleManager

func (*Client) Plugins

func (c *Client) Plugins() *PluginManager

func (*Client) Sessions

func (c *Client) Sessions() *SessionManager

func (*Client) Token

func (c *Client) Token() string

type ClientOption

type ClientOption func(*Client)

func WithConsolePollInterval

func WithConsolePollInterval(interval time.Duration) ClientOption

func WithHTTPClient

func WithHTTPClient(client *http.Client) ClientOption

func WithHost

func WithHost(host string) ClientOption

func WithPort

func WithPort(port int) ClientOption

func WithSSL

func WithSSL(ssl bool) ClientOption

func WithSessionPollInterval

func WithSessionPollInterval(interval time.Duration) ClientOption

func WithURI

func WithURI(uri string) ClientOption

func WithUsername

func WithUsername(username string) ClientOption

type Console

type Console struct {
	ID     string `msgpack:"id" json:"id"`
	Prompt string `msgpack:"prompt" json:"prompt"`
	Busy   bool   `msgpack:"busy" json:"busy"`
}

type ConsoleManager

type ConsoleManager struct {
	// contains filtered or unexported fields
}

func NewConsoleManager

func NewConsoleManager(rpc RPCCaller) *ConsoleManager

func (*ConsoleManager) Create

func (m *ConsoleManager) Create(ctx context.Context) (*Console, error)

func (*ConsoleManager) Destroy

func (m *ConsoleManager) Destroy(ctx context.Context, cid string) error

func (*ConsoleManager) GetConsole

func (m *ConsoleManager) GetConsole(ctx context.Context, cid string) (*MsfConsole, error)

func (*ConsoleManager) List

func (m *ConsoleManager) List(ctx context.Context) ([]*Console, error)

type ConsoleReadResult

type ConsoleReadResult struct {
	Data   string `msgpack:"data" json:"data"`
	Prompt string `msgpack:"prompt" json:"prompt"`
	Busy   bool   `msgpack:"busy" json:"busy"`
}

type CoreManager

type CoreManager struct {
	// contains filtered or unexported fields
}

func NewCoreManager

func NewCoreManager(rpc RPCCaller) *CoreManager

func (*CoreManager) AddModulePath

func (m *CoreManager) AddModulePath(ctx context.Context, path string) error

func (*CoreManager) KillThread

func (m *CoreManager) KillThread(ctx context.Context, threadID string) error

func (*CoreManager) ModuleStats

func (m *CoreManager) ModuleStats(ctx context.Context) (map[string]interface{}, error)

func (*CoreManager) ReloadModules

func (m *CoreManager) ReloadModules(ctx context.Context) error

func (*CoreManager) Save

func (m *CoreManager) Save(ctx context.Context) error

func (*CoreManager) SetGlobal

func (m *CoreManager) SetGlobal(ctx context.Context, key, value string) error

func (*CoreManager) Stop

func (m *CoreManager) Stop(ctx context.Context) error

func (*CoreManager) ThreadList

func (m *CoreManager) ThreadList(ctx context.Context) (map[string]interface{}, error)

func (*CoreManager) UnsetGlobal

func (m *CoreManager) UnsetGlobal(ctx context.Context, key string) error

func (*CoreManager) Version

func (m *CoreManager) Version(ctx context.Context) (*VersionInfo, error)

type Credential

type Credential struct {
	Host    string `msgpack:"host" json:"host"`
	Port    int    `msgpack:"port" json:"port"`
	Proto   string `msgpack:"proto" json:"proto"`
	Service string `msgpack:"sname" json:"sname"`
	User    string `msgpack:"user" json:"user"`
	Pass    string `msgpack:"pass" json:"pass"`
	Type    string `msgpack:"type" json:"type"`
}

type DbManager

type DbManager struct {
	// contains filtered or unexported fields
}

func NewDbManager

func NewDbManager(rpc RPCCaller) *DbManager

func (*DbManager) Connect

func (m *DbManager) Connect(ctx context.Context, opts map[string]interface{}) error

func (*DbManager) Creds

func (m *DbManager) Creds(ctx context.Context, opts map[string]interface{}) ([]*Credential, error)

func (*DbManager) CurrentWorkspace

func (m *DbManager) CurrentWorkspace(ctx context.Context) (string, error)

func (*DbManager) Disconnect

func (m *DbManager) Disconnect(ctx context.Context) error

func (*DbManager) Driver

func (m *DbManager) Driver(ctx context.Context) (string, error)

func (*DbManager) Hosts

func (m *DbManager) Hosts(ctx context.Context, opts map[string]interface{}) ([]*Host, error)

func (*DbManager) Loots

func (m *DbManager) Loots(ctx context.Context, opts map[string]interface{}) ([]*Loot, error)

func (*DbManager) Services

func (m *DbManager) Services(ctx context.Context, opts map[string]interface{}) ([]*Service, error)

func (*DbManager) SetWorkspace

func (m *DbManager) SetWorkspace(ctx context.Context, name string) error

func (*DbManager) Status

func (m *DbManager) Status(ctx context.Context) (map[string]interface{}, error)

func (*DbManager) Vulns

func (m *DbManager) Vulns(ctx context.Context, opts map[string]interface{}) ([]*Vuln, error)

func (*DbManager) Workspaces

func (m *DbManager) Workspaces() *WorkspaceManager

type Event

type Event struct {
	Type      EventType
	Timestamp time.Time
	Session   *Session
	SessionID string
	ConsoleID string
	Job       *Job
	Data      string
	Err       error
}

Event is one state change observed by an EventMonitor. Which fields are set depends on Type: SessionID and Session for session_opened/session_closed, SessionID and Data for session_output, ConsoleID and Data for console_output, Job for job_started/job_stopped, Err for error.

type EventMonitor

type EventMonitor struct {
	// contains filtered or unexported fields
}

EventMonitor polls session.list, job.list and watched output streams, and emits the resulting state changes on a channel. Sessions already open when the monitor starts are reported as session_opened, so a late-attaching UI receives the full current state.

Event delivery applies backpressure: when the consumer falls behind and the channel is full, polling pauses until the consumer drains it, so events are never dropped but a slow consumer slows the monitor down with it. Size the buffer with WithEventBuffer if consumers may stall.

Watching a session or console transfers ownership of its output to the monitor: session.shell_read / session.meterpreter_read / console.read drain the server-side buffer, so a watched stream must only be read through the monitor's events.

func NewEventMonitor

func NewEventMonitor(ctx context.Context, rpc RPCCaller, opts ...EventOption) *EventMonitor

func (*EventMonitor) C

func (m *EventMonitor) C() <-chan Event

C returns the event channel. It is closed when the monitor stops.

func (*EventMonitor) UnwatchConsole

func (m *EventMonitor) UnwatchConsole(cid string)

UnwatchConsole removes a console from the polled output streams.

func (*EventMonitor) UnwatchSession

func (m *EventMonitor) UnwatchSession(sid string)

UnwatchSession removes a session from the polled output streams.

func (*EventMonitor) WatchConsole

func (m *EventMonitor) WatchConsole(cid string)

WatchConsole adds a console to the polled output streams.

func (*EventMonitor) WatchSession

func (m *EventMonitor) WatchSession(sid string)

WatchSession adds a session to the polled output streams.

type EventOption

type EventOption func(*EventMonitor)

func WithEventBuffer

func WithEventBuffer(size int) EventOption

func WithEventJobInterval

func WithEventJobInterval(interval time.Duration) EventOption

func WithEventOutputInterval

func WithEventOutputInterval(interval time.Duration) EventOption

func WithEventSessionInterval

func WithEventSessionInterval(interval time.Duration) EventOption

type EventType

type EventType string
const (
	EventSessionOpened EventType = "session_opened"
	EventSessionClosed EventType = "session_closed"
	EventSessionOutput EventType = "session_output"
	EventConsoleOutput EventType = "console_output"
	EventJobStarted    EventType = "job_started"
	EventJobStopped    EventType = "job_stopped"
	EventError         EventType = "error"
)

type Host

type Host struct {
	Address     string `msgpack:"address" json:"address"`
	Mac         string `msgpack:"mac" json:"mac"`
	Name        string `msgpack:"name" json:"name"`
	State       string `msgpack:"state" json:"state"`
	OSName      string `msgpack:"os_name" json:"os_name"`
	OSFlavor    string `msgpack:"os_flavor" json:"os_flavor"`
	OSVersion   string `msgpack:"os_version" json:"os_version"`
	OSSP        string `msgpack:"os_sp" json:"os_sp"`
	OSLang      string `msgpack:"os_lang" json:"os_lang"`
	Purpose     string `msgpack:"purpose" json:"purpose"`
	Info        string `msgpack:"info" json:"info"`
	Comments    string `msgpack:"comments" json:"comments"`
	Scope       string `msgpack:"scope" json:"scope"`
	VirtualHost string `msgpack:"virtual_host" json:"virtual_host"`
	Arch        string `msgpack:"arch" json:"arch"`
}

type Job

type Job struct {
	ID          string `msgpack:"id" json:"id"`
	Name        string `msgpack:"name" json:"name"`
	Description string `msgpack:"description" json:"description"`
}

type JobManager

type JobManager struct {
	// contains filtered or unexported fields
}

func NewJobManager

func NewJobManager(rpc RPCCaller) *JobManager

func (*JobManager) Info

func (m *JobManager) Info(ctx context.Context, jobID string) (map[string]interface{}, error)

func (*JobManager) List

func (m *JobManager) List(ctx context.Context) (map[string]string, error)

func (*JobManager) Stop

func (m *JobManager) Stop(ctx context.Context, jobID string) error

type Loot

type Loot struct {
	Host string `msgpack:"host" json:"host"`
	Type string `msgpack:"ltype" json:"ltype"`
	Name string `msgpack:"name" json:"name"`
	Data string `msgpack:"data" json:"data"`
	Info string `msgpack:"info" json:"info"`
}

type MeterpreterSession

type MeterpreterSession struct {
	SID string
	// contains filtered or unexported fields
}

func NewMeterpreterSession

func NewMeterpreterSession(rpc RPCCaller, sid string) *MeterpreterSession

func (*MeterpreterSession) Detach

func (s *MeterpreterSession) Detach(ctx context.Context) error

func (*MeterpreterSession) DirectorySeparator

func (s *MeterpreterSession) DirectorySeparator(ctx context.Context) (string, error)

func (*MeterpreterSession) Kill

func (s *MeterpreterSession) Kill(ctx context.Context) error

func (*MeterpreterSession) Read

func (s *MeterpreterSession) Read(ctx context.Context) (string, error)

func (*MeterpreterSession) RunScript

func (s *MeterpreterSession) RunScript(ctx context.Context, path string) (string, error)

func (*MeterpreterSession) RunSingle

func (s *MeterpreterSession) RunSingle(ctx context.Context, cmd string) (string, error)

func (*MeterpreterSession) RunWithOutput

func (s *MeterpreterSession) RunWithOutput(ctx context.Context, cmd string, endStrings []string, timeout time.Duration) (string, error)

func (*MeterpreterSession) Tabs

func (s *MeterpreterSession) Tabs(ctx context.Context, line string) ([]string, error)

func (*MeterpreterSession) Write

func (s *MeterpreterSession) Write(ctx context.Context, data string) error

type Module

type Module struct {
	ModuleType ModuleType
	Name       string
	Info       *MsfModuleInfo
	// contains filtered or unexported fields
}

func NewModule

func NewModule(rpc RPCCaller, modType ModuleType, name string) (*Module, error)

func NewModuleWithContext

func NewModuleWithContext(ctx context.Context, rpc RPCCaller, modType ModuleType, name string) (*Module, error)

func (*Module) CompatiblePayloads

func (m *Module) CompatiblePayloads(ctx context.Context) ([]string, error)

func (*Module) CompatibleSessions

func (m *Module) CompatibleSessions(ctx context.Context) ([]string, error)

func (*Module) Execute

func (m *Module) Execute(ctx context.Context) (*ModuleExecuteResult, error)

func (*Module) ExecuteWithPayload

func (m *Module) ExecuteWithPayload(ctx context.Context, payload *Module) (*ModuleExecuteResult, error)

func (*Module) GetOption

func (m *Module) GetOption(option string) (interface{}, error)

func (*Module) MissingRequired

func (m *Module) MissingRequired() []string

func (*Module) OptionInfo

func (m *Module) OptionInfo(option string) (*MsfModuleOption, error)

func (*Module) Options

func (m *Module) Options() []string

func (*Module) RequiredOptions

func (m *Module) RequiredOptions() []string

func (*Module) RunOptions

func (m *Module) RunOptions() map[string]interface{}

func (*Module) SetOption

func (m *Module) SetOption(option string, value interface{}) error

func (*Module) Targets

func (m *Module) Targets() []string

Targets returns the exploit's target list, captured when the module was loaded. There is no module.targets RPC; msfrpcd reports targets inside module.info keyed by integer index.

type ModuleExecuteResult

type ModuleExecuteResult struct {
	JobID int    `msgpack:"job_id" json:"job_id"`
	UUID  string `msgpack:"uuid" json:"uuid"`
}

type ModuleManager

type ModuleManager struct {
	// contains filtered or unexported fields
}

func NewModuleManager

func NewModuleManager(rpc RPCCaller) *ModuleManager

func (*ModuleManager) Auxiliary

func (m *ModuleManager) Auxiliary(ctx context.Context) ([]string, error)

func (*ModuleManager) CompatiblePayloads

func (m *ModuleManager) CompatiblePayloads(ctx context.Context, name string) ([]string, error)

CompatiblePayloads returns the payloads compatible with an exploit. The RPC takes the full module name only; the type is implied.

func (*ModuleManager) CompatibleSessions

func (m *ModuleManager) CompatibleSessions(ctx context.Context, name string) ([]string, error)

CompatibleSessions returns the sessions an exploit, auxiliary or post module can run against. The RPC infers the module type from the name prefix, so name must be the full module path.

func (*ModuleManager) Encoders

func (m *ModuleManager) Encoders(ctx context.Context) ([]string, error)

func (*ModuleManager) Evasion

func (m *ModuleManager) Evasion(ctx context.Context) ([]string, error)

func (*ModuleManager) Execute

func (m *ModuleManager) Execute(ctx context.Context, modType ModuleType, name string, options map[string]interface{}) (*ModuleExecuteResult, error)

func (*ModuleManager) Exploits

func (m *ModuleManager) Exploits(ctx context.Context) ([]string, error)

func (*ModuleManager) Info

func (m *ModuleManager) Info(ctx context.Context, modType ModuleType, name string) (*MsfModuleInfo, error)

func (*ModuleManager) Nops

func (m *ModuleManager) Nops(ctx context.Context) ([]string, error)

func (*ModuleManager) Payloads

func (m *ModuleManager) Payloads(ctx context.Context) ([]string, error)

func (*ModuleManager) Post

func (m *ModuleManager) Post(ctx context.Context) ([]string, error)

func (*ModuleManager) Use

func (m *ModuleManager) Use(ctx context.Context, modType ModuleType, name string) (*Module, error)

type ModuleReference

type ModuleReference struct {
	Type  string `msgpack:"type" json:"type"`
	Value string `msgpack:"value" json:"value"`
}

type ModuleType

type ModuleType string
const (
	ExploitModuleType   ModuleType = "exploit"
	PayloadModuleType   ModuleType = "payload"
	AuxiliaryModuleType ModuleType = "auxiliary"
	PostModuleType      ModuleType = "post"
	EncoderModuleType   ModuleType = "encoder"
	NopModuleType       ModuleType = "nop"
	EvasionModuleType   ModuleType = "evasion"
)

type MsfConsole

type MsfConsole struct {
	CID string
	// contains filtered or unexported fields
}

func NewMsfConsole

func NewMsfConsole(rpc RPCCaller, cid string) *MsfConsole

func (*MsfConsole) IsBusy

func (c *MsfConsole) IsBusy(ctx context.Context) (bool, error)

func (*MsfConsole) Read

func (*MsfConsole) RunCommand

func (c *MsfConsole) RunCommand(ctx context.Context, command string, timeout time.Duration) (string, error)

func (*MsfConsole) SessionDetach

func (c *MsfConsole) SessionDetach(ctx context.Context) error

func (*MsfConsole) SessionKill

func (c *MsfConsole) SessionKill(ctx context.Context) error

func (*MsfConsole) Tabs

func (c *MsfConsole) Tabs(ctx context.Context, line string) ([]string, error)

func (*MsfConsole) Write

func (c *MsfConsole) Write(ctx context.Context, command string) error

type MsfModuleInfo

type MsfModuleInfo struct {
	Name        string            `msgpack:"name" json:"name"`
	Description string            `msgpack:"description" json:"description"`
	License     string            `msgpack:"license" json:"license"`
	FilePath    string            `msgpack:"filepath" json:"filepath"`
	Version     string            `msgpack:"version" json:"version"`
	Rank        string            `msgpack:"rank" json:"rank"`
	Targets     []string          `msgpack:"targets" json:"targets"`
	References  []ModuleReference `msgpack:"references" json:"references"`
	Authors     []string          `msgpack:"authors" json:"authors"`
}

type MsfModuleOption

type MsfModuleOption struct {
	Type     string      `msgpack:"type" json:"type"`
	Required bool        `msgpack:"required" json:"required"`
	Advanced bool        `msgpack:"advanced" json:"advanced"`
	Evasion  bool        `msgpack:"evasion" json:"evasion"`
	Desc     string      `msgpack:"desc" json:"desc"`
	Default  interface{} `msgpack:"default,omitempty" json:"default,omitempty"`
	Enums    []string    `msgpack:"enums,omitempty" json:"enums,omitempty"`
}

type MsfRpcMethod

type MsfRpcMethod string
const (
	AuthLogin                            MsfRpcMethod = "auth.login"
	AuthLogout                           MsfRpcMethod = "auth.logout"
	AuthTokenList                        MsfRpcMethod = "auth.token_list"
	AuthTokenAdd                         MsfRpcMethod = "auth.token_add"
	AuthTokenGenerate                    MsfRpcMethod = "auth.token_generate"
	AuthTokenRemove                      MsfRpcMethod = "auth.token_remove"
	ConsoleCreate                        MsfRpcMethod = "console.create"
	ConsoleList                          MsfRpcMethod = "console.list"
	ConsoleDestroy                       MsfRpcMethod = "console.destroy"
	ConsoleRead                          MsfRpcMethod = "console.read"
	ConsoleWrite                         MsfRpcMethod = "console.write"
	ConsoleTabs                          MsfRpcMethod = "console.tabs"
	ConsoleSessionKill                   MsfRpcMethod = "console.session_kill"
	ConsoleSessionDetach                 MsfRpcMethod = "console.session_detach"
	CoreVersion                          MsfRpcMethod = "core.version"
	CoreStop                             MsfRpcMethod = "core.stop"
	CoreSetG                             MsfRpcMethod = "core.setg"
	CoreUnsetG                           MsfRpcMethod = "core.unsetg"
	CoreSave                             MsfRpcMethod = "core.save"
	CoreReloadModules                    MsfRpcMethod = "core.reload_modules"
	CoreModuleStats                      MsfRpcMethod = "core.module_stats"
	CoreAddModulePath                    MsfRpcMethod = "core.add_module_path"
	CoreThreadList                       MsfRpcMethod = "core.thread_list"
	CoreThreadKill                       MsfRpcMethod = "core.thread_kill"
	DbHosts                              MsfRpcMethod = "db.hosts"
	DbServices                           MsfRpcMethod = "db.services"
	DbVulns                              MsfRpcMethod = "db.vulns"
	DbWorkspaces                         MsfRpcMethod = "db.workspaces"
	DbCurrentWorkspace                   MsfRpcMethod = "db.current_workspace"
	DbGetWorkspace                       MsfRpcMethod = "db.get_workspace"
	DbSetWorkspace                       MsfRpcMethod = "db.set_workspace"
	DbDelWorkspace                       MsfRpcMethod = "db.del_workspace"
	DbAddWorkspace                       MsfRpcMethod = "db.add_workspace"
	DbGetHost                            MsfRpcMethod = "db.get_host"
	DbReportHost                         MsfRpcMethod = "db.report_host"
	DbReportService                      MsfRpcMethod = "db.report_service"
	DbGetService                         MsfRpcMethod = "db.get_service"
	DbGetNote                            MsfRpcMethod = "db.get_note"
	DbGetClient                          MsfRpcMethod = "db.get_client"
	DbReportClient                       MsfRpcMethod = "db.report_client"
	DbReportNote                         MsfRpcMethod = "db.report_note"
	DbNotes                              MsfRpcMethod = "db.notes"
	DbGetRef                             MsfRpcMethod = "db.get_ref"
	DbDelVuln                            MsfRpcMethod = "db.del_vuln"
	DbDelNote                            MsfRpcMethod = "db.del_note"
	DbDelService                         MsfRpcMethod = "db.del_service"
	DbDelHost                            MsfRpcMethod = "db.del_host"
	DbReportVuln                         MsfRpcMethod = "db.report_vuln"
	DbEvents                             MsfRpcMethod = "db.events"
	DbReportEvent                        MsfRpcMethod = "db.report_event"
	DbReportLoot                         MsfRpcMethod = "db.report_loot"
	DbLoots                              MsfRpcMethod = "db.loots"
	DbReportCred                         MsfRpcMethod = "db.report_cred"
	DbCreds                              MsfRpcMethod = "db.creds"
	DbImportData                         MsfRpcMethod = "db.import_data"
	DbGetVuln                            MsfRpcMethod = "db.get_vuln"
	DbClients                            MsfRpcMethod = "db.clients"
	DbDelClient                          MsfRpcMethod = "db.del_client"
	DbDriver                             MsfRpcMethod = "db.driver"
	DbConnect                            MsfRpcMethod = "db.connect"
	DbStatus                             MsfRpcMethod = "db.status"
	DbDisconnect                         MsfRpcMethod = "db.disconnect"
	JobList                              MsfRpcMethod = "job.list"
	JobStop                              MsfRpcMethod = "job.stop"
	JobInfo                              MsfRpcMethod = "job.info"
	ModuleExploits                       MsfRpcMethod = "module.exploits"
	ModuleEvasion                        MsfRpcMethod = "module.evasion"
	ModuleAuxiliary                      MsfRpcMethod = "module.auxiliary"
	ModulePayloads                       MsfRpcMethod = "module.payloads"
	ModuleEncoders                       MsfRpcMethod = "module.encoders"
	ModuleNops                           MsfRpcMethod = "module.nops"
	ModulePost                           MsfRpcMethod = "module.post"
	ModuleOptions                        MsfRpcMethod = "module.options"
	ModuleInfo                           MsfRpcMethod = "module.info"
	ModuleCompatiblePayloads             MsfRpcMethod = "module.compatible_payloads"
	ModuleCompatibleSessions             MsfRpcMethod = "module.compatible_sessions"
	ModuleExecute                        MsfRpcMethod = "module.execute"
	ModuleEncodeFormats                  MsfRpcMethod = "module.encode_formats"
	ModuleEncode                         MsfRpcMethod = "module.encode"
	PluginLoad                           MsfRpcMethod = "plugin.load"
	PluginUnload                         MsfRpcMethod = "plugin.unload"
	PluginLoaded                         MsfRpcMethod = "plugin.loaded"
	SessionList                          MsfRpcMethod = "session.list"
	SessionStop                          MsfRpcMethod = "session.stop"
	SessionShellRead                     MsfRpcMethod = "session.shell_read"
	SessionShellWrite                    MsfRpcMethod = "session.shell_write"
	SessionShellUpgrade                  MsfRpcMethod = "session.shell_upgrade"
	SessionMeterpreterRead               MsfRpcMethod = "session.meterpreter_read"
	SessionRingRead                      MsfRpcMethod = "session.ring_read"
	SessionRingPut                       MsfRpcMethod = "session.ring_put"
	SessionRingLast                      MsfRpcMethod = "session.ring_last"
	SessionRingClear                     MsfRpcMethod = "session.ring_clear"
	SessionMeterpreterWrite              MsfRpcMethod = "session.meterpreter_write"
	SessionMeterpreterSessionDetach      MsfRpcMethod = "session.meterpreter_session_detach"
	SessionMeterpreterSessionKill        MsfRpcMethod = "session.meterpreter_session_kill"
	SessionMeterpreterTabs               MsfRpcMethod = "session.meterpreter_tabs"
	SessionMeterpreterRunSingle          MsfRpcMethod = "session.meterpreter_run_single"
	SessionMeterpreterScript             MsfRpcMethod = "session.meterpreter_script"
	SessionMeterpreterDirectorySeparator MsfRpcMethod = "session.meterpreter_directory_separator"
	SessionCompatibleModules             MsfRpcMethod = "session.compatible_modules"
)

type PluginManager

type PluginManager struct {
	// contains filtered or unexported fields
}

func NewPluginManager

func NewPluginManager(rpc RPCCaller) *PluginManager

func (*PluginManager) List

func (m *PluginManager) List(ctx context.Context) ([]string, error)

func (*PluginManager) Load

func (m *PluginManager) Load(ctx context.Context, plugin string) error

func (*PluginManager) Unload

func (m *PluginManager) Unload(ctx context.Context, plugin string) error

type RPCCaller

type RPCCaller interface {
	Call(ctx context.Context, method MsfRpcMethod, args ...interface{}) (interface{}, error)
}

type RPCError

type RPCError struct {
	Class   string
	Message string
}

func (*RPCError) Error

func (e *RPCError) Error() string

func (*RPCError) Unwrap

func (e *RPCError) Unwrap() error

type Service

type Service struct {
	Host  string `msgpack:"host" json:"host"`
	Port  int    `msgpack:"port" json:"port"`
	Proto string `msgpack:"proto" json:"proto"`
	Name  string `msgpack:"name" json:"name"`
	State string `msgpack:"state" json:"state"`
	Info  string `msgpack:"info" json:"info"`
}

type Session

type Session struct {
	Type        string `msgpack:"type" json:"type"`
	TunnelLocal string `msgpack:"tunnel_local" json:"tunnel_local"`
	TunnelPeer  string `msgpack:"tunnel_peer" json:"tunnel_peer"`
	ViaExploit  string `msgpack:"via_exploit" json:"via_exploit"`
	ViaPayload  string `msgpack:"via_payload" json:"via_payload"`
	Desc        string `msgpack:"desc" json:"desc"`
	Info        string `msgpack:"info" json:"info"`
	Workspace   string `msgpack:"workspace" json:"workspace"`
	SessionHost string `msgpack:"session_host" json:"session_host"`
	SessionPort int    `msgpack:"session_port" json:"session_port"`
	TargetHost  string `msgpack:"target_host" json:"target_host"`
	Username    string `msgpack:"username" json:"username"`
	UUID        string `msgpack:"uuid" json:"uuid"`
	ExploitUUID string `msgpack:"exploit_uuid" json:"exploit_uuid"`
}

type SessionManager

type SessionManager struct {
	// contains filtered or unexported fields
}

func NewSessionManager

func NewSessionManager(rpc RPCCaller) *SessionManager

func (*SessionManager) CompatibleModules

func (m *SessionManager) CompatibleModules(ctx context.Context, sid string) ([]string, error)

func (*SessionManager) Get

func (m *SessionManager) Get(ctx context.Context, sid string) (*Session, error)

func (*SessionManager) List

func (m *SessionManager) List(ctx context.Context) (map[string]*Session, error)

func (*SessionManager) Stop

func (m *SessionManager) Stop(ctx context.Context, sid string) error

type ShellSession

type ShellSession struct {
	SID string
	// contains filtered or unexported fields
}

func NewShellSession

func NewShellSession(rpc RPCCaller, sid string) *ShellSession

func (*ShellSession) Read

func (s *ShellSession) Read(ctx context.Context) (string, error)

func (*ShellSession) RunWithOutput

func (s *ShellSession) RunWithOutput(ctx context.Context, cmd string, endStrings []string, timeout time.Duration) (string, error)

func (*ShellSession) Upgrade

func (s *ShellSession) Upgrade(ctx context.Context, lhost string, lport int) error

func (*ShellSession) Write

func (s *ShellSession) Write(ctx context.Context, data string) error

type VersionInfo

type VersionInfo struct {
	Version     string `msgpack:"version" json:"version"`
	RubyVersion string `msgpack:"ruby" json:"ruby"`
	APIVersion  string `msgpack:"api" json:"api"`
}

type Vuln

type Vuln struct {
	Host  string `msgpack:"host" json:"host"`
	Name  string `msgpack:"name" json:"name"`
	Port  int    `msgpack:"port" json:"port"`
	Proto string `msgpack:"proto" json:"proto"`
	Refs  string `msgpack:"refs" json:"refs"`
}

type Workspace

type Workspace struct {
	Name string `msgpack:"name" json:"name"`
}

type WorkspaceManager

type WorkspaceManager struct {
	// contains filtered or unexported fields
}

func NewWorkspaceManager

func NewWorkspaceManager(rpc RPCCaller) *WorkspaceManager

func (*WorkspaceManager) Add

func (m *WorkspaceManager) Add(ctx context.Context, name string) error

func (*WorkspaceManager) Current

func (m *WorkspaceManager) Current(ctx context.Context) (*Workspace, error)

func (*WorkspaceManager) Get

func (m *WorkspaceManager) Get(ctx context.Context, name string) (*Workspace, error)

func (*WorkspaceManager) List

func (m *WorkspaceManager) List(ctx context.Context) ([]string, error)

func (*WorkspaceManager) Remove

func (m *WorkspaceManager) Remove(ctx context.Context, name string) error

Directories

Path Synopsis
examples
basic command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL