gomsf

package module
v0.0.0-...-744de63 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 9 Imported by: 0

README

gomsf

Build Status Go Reference

Golang based RPC client to communicate with Metasploit

https://docs.rapid7.com/metasploit/rpc-api

⚠ This is experimental and subject to breaking changes.

Starting the RPC Server for Metasploit

msfrpcd -U user -P pass

Connecting to the RPC Server

client, err := gomsf.New("0.0.0.0:55553")
if err != nil {
    panic(err)
}
if err := client.Login("user", "pass"); err != nil {
    panic(err)
}
defer client.Logout()

Encode data with an encoder

encoded, err := client.Module.Encode("AAAA", "x86/shikata_ga_nai", &gomsf.EncodeOptions{
    Format: "c",
})
if err != nil {
    panic(err)
}
fmt.Printf("%s\n", encoded)

This will encode 'AAAA' with shikata_ga_nai, and prints the following c code:

unsigned char buf[] =
"\xbb\xc6\xee\x4d\x66\xd9\xee\xd9\x74\x24\xf4\x58\x33\xc9\xb1"
"\x02\x31\x58\x12\x83\xe8\xfc\x03\x9e\xe0\xaf\x93\x5f\xbc\x6e"
"\x1d";

Get infos about a module

info, err := client.Module.Info(gomsf.ExploitType, "windows/smb/ms08_067_netapi")
if err != nil {
    panic(err)
}

fmt.Printf("Name: %s\n", info.Name)
fmt.Printf("Rank: %s\n", info.Rank)

This gives us the metadata of ms08_067_netapi

Name: MS08-067 Microsoft Server Service Relative Path Stack Corruption
Rank: great

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthManager

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

func (*AuthManager) Login

func (am *AuthManager) Login(user, pass string) (string, error)

func (*AuthManager) Logout

func (am *AuthManager) Logout() error

type Auxiliary

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

func (Auxiliary) Get

func (m Auxiliary) Get(name string) (interface{}, error)

func (Auxiliary) Set

func (m Auxiliary) Set(name string, value interface{}) error

type Client

type Client struct {
	Auth     *AuthManager
	Consoles *ConsoleManager
	Core     *CoreManager
	Health   *HealthManager
	Plugins  *PluginManager
	Jobs     *JobManager
	Module   *ModuleManager
	Sessions *SessionManager
	// contains filtered or unexported fields
}

func New

func New(address string, optFns ...func(o *ClientOptions)) (*Client, error)

func (*Client) APIVersion

func (c *Client) APIVersion() string

func (*Client) Authenticated

func (c *Client) Authenticated() bool

func (*Client) HealthCheck

func (c *Client) HealthCheck() error

func (*Client) Login

func (c *Client) Login(user, pass string) error

Login logs in by calling the 'auth.login' API. The authentication token will expire after 5 minutes, but will automatically be rewnewed when you make a new RPC request.

func (*Client) Logout

func (c *Client) Logout() error

func (*Client) ReLogin

func (c *Client) ReLogin() error

ReLogin attempts to login again with the last known user name and password

type ClientOptions

type ClientOptions struct {
	Timeout         time.Duration
	ProxyURL        string
	TLSClientConfig *tls.Config
	Token           string
	SSL             bool
	APIVersion      string
}

type Console

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

func (*Console) Destroy

func (c *Console) Destroy() error

Destroy destroys the console

func (*Console) Read

func (c *Console) Read() (*rpc.ConsoleReadRes, error)

Read reads data from the console

func (*Console) SessionDetach

func (c *Console) SessionDetach() error

SessionDetach detachs the current meterpreter or shell session

func (*Console) SessionKill

func (c *Console) SessionKill() error

SessionKill kills all active meterpreter or shell sessions

func (*Console) Tabs

func (c *Console) Tabs(line string) ([]string, error)

func (*Console) Write

func (c *Console) Write(command string) error

Write writes data to the console.

type ConsoleManager

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

func (*ConsoleManager) Console

func (cm *ConsoleManager) Console() (*Console, error)

Console creates a new framework console instance

func (*ConsoleManager) Destroy

func (cm *ConsoleManager) Destroy(consoleID string) error

Destroy destroys an active console

func (*ConsoleManager) List

func (cm *ConsoleManager) List() (*rpc.ConsoleListRes, error)

List lists active consoles

type CoreManager

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

func (*CoreManager) Stop

func (c *CoreManager) Stop() error

Stop stops the core

func (*CoreManager) Version

func (c *CoreManager) Version() (*rpc.CoreVersionRes, error)

type EncodeOptions

type EncodeOptions struct {
	Format       string `structs:"format,omitempty"`        // Encoding format
	Badchars     string `structs:"badchars,omitempty"`      // Bad characters
	Platform     string `structs:"platform,omitempty"`      // Platform
	Arch         string `structs:"arch,omitempty"`          // Architecture
	ECount       int    `structs:"ecount,omitempty"`        // Number of times to encode
	Inject       bool   `structs:"inject,omitempty"`        // Enable injection
	Template     string `structs:"template,omitempty"`      // The template file (an executable)
	TemplatePath string `structs:"template_path,omitempty"` // Template path
	Addshellcode string `structs:"addshellcode,omitempty"`  // Custom shellcode
}

type Evasion

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

func (Evasion) Get

func (m Evasion) Get(name string) (interface{}, error)

func (*Evasion) Payloads

func (e *Evasion) Payloads() ([]string, error)

func (Evasion) Set

func (m Evasion) Set(name string, value interface{}) error

type Exploit

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

func (Exploit) Get

func (m Exploit) Get(name string) (interface{}, error)

func (*Exploit) Payloads

func (e *Exploit) Payloads() ([]string, error)

func (Exploit) Set

func (m Exploit) Set(name string, value interface{}) error

type HealthManager

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

func (*HealthManager) Check

func (hm *HealthManager) Check() error

type JobManager

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

func (*JobManager) Info

func (jm *JobManager) Info(jobID string) (*rpc.JobInfoRes, error)

func (*JobManager) List

func (jm *JobManager) List() (*rpc.JobListRes, error)

func (*JobManager) Stop

func (jm *JobManager) Stop(jobID string) error

type MeterpreterSession

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

func (*MeterpreterSession) Modules

func (s *MeterpreterSession) Modules() ([]string, error)

func (*MeterpreterSession) Read

func (ms *MeterpreterSession) Read() (string, error)

func (*MeterpreterSession) Stop

func (s *MeterpreterSession) Stop()

func (*MeterpreterSession) Write

func (ms *MeterpreterSession) Write(command string) error

type ModuleManager

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

func (*ModuleManager) Architectures

func (mm *ModuleManager) Architectures() ([]string, error)

func (*ModuleManager) Auxiliaries

func (mm *ModuleManager) Auxiliaries() ([]string, error)

func (*ModuleManager) CompatibleSessions

func (mm *ModuleManager) CompatibleSessions(moduleName string) ([]string, error)

func (*ModuleManager) Encode

func (mm *ModuleManager) Encode(data string, encoderModule string, options *EncodeOptions) ([]byte, error)

func (*ModuleManager) Encoders

func (mm *ModuleManager) Encoders() ([]string, error)

func (*ModuleManager) Evasions

func (mm *ModuleManager) Evasions() ([]string, error)

func (*ModuleManager) Execute

func (mm *ModuleManager) Execute(moduleType ModuleType, moduleName string, options map[string]interface{}) (*rpc.ModuleExecuteRes, error)

func (*ModuleManager) Exploits

func (mm *ModuleManager) Exploits() ([]string, error)

func (*ModuleManager) Info

func (mm *ModuleManager) Info(moduleType ModuleType, moduleName string) (*rpc.ModuleInfoRes, error)

func (*ModuleManager) InfoHTML

func (mm *ModuleManager) InfoHTML(moduleType ModuleType, moduleName string) (string, error)

func (*ModuleManager) Nops

func (mm *ModuleManager) Nops() ([]string, error)

func (*ModuleManager) Payloads

func (mm *ModuleManager) Payloads() ([]string, error)

func (*ModuleManager) Platforms

func (mm *ModuleManager) Platforms() (*rpc.ModulePlatformsRes, error)

func (*ModuleManager) Posts

func (mm *ModuleManager) Posts() ([]string, error)

func (*ModuleManager) UseAuxiliary

func (mm *ModuleManager) UseAuxiliary(moduleName string) (*Auxiliary, error)

func (*ModuleManager) UseExploit

func (mm *ModuleManager) UseExploit(moduleName string) (*Exploit, error)

func (*ModuleManager) UsePost

func (mm *ModuleManager) UsePost(moduleName string) (*Post, error)

type ModuleType

type ModuleType string
const (
	ExploitType   ModuleType = "exploit"
	AuxiliaryType ModuleType = "auxiliary"
	PostType      ModuleType = "post"
	PayloadType   ModuleType = "payload"
	EvasionType   ModuleType = "evasion"
)

type Payload

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

func (Payload) Get

func (m Payload) Get(name string) (interface{}, error)

func (Payload) Set

func (m Payload) Set(name string, value interface{}) error

type PluginManager

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

func (*PluginManager) List

func (pm *PluginManager) List() ([]string, error)

func (*PluginManager) Load

func (pm *PluginManager) Load(name string, options map[string]string) error

func (*PluginManager) UnLoad

func (pm *PluginManager) UnLoad(name string) error

type Post

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

func (Post) Get

func (m Post) Get(name string) (interface{}, error)

func (Post) Set

func (m Post) Set(name string, value interface{}) error

type SessionManager

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

Directories

Path Synopsis
_examples
rpc

Jump to

Keyboard shortcuts

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