mole

package
v0.0.0-...-d5b31fc Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: MIT Imports: 15 Imported by: 0

README

Mole

a reverse HTTP-Compatible RPC framework

Scenario

  • expose your local http servers behind NAT or Firewall to internet
  • visit your local http API (eg: docker unix socket) from internet without any local ports listening
  • write a reverse connection & shell trojan ;-)
  • more ...

Features

  • Private Control Protocol
  • Reverse RPC

Usage

See:

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FILE_UUID = "/etc/.mole.uuid"
)
View Source
var (
	HEADER = []byte("MOLE")
)

Functions

func Encode

func Encode(msg []byte) []byte

Types

type Agent

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

func NewAgent

func NewAgent(cfg *Config) *Agent

func (*Agent) Accept

func (a *Agent) Accept() (net.Conn, error)

implement net.Listener interface (process the cached worker connection in the pool)

func (*Agent) Addr

func (a *Agent) Addr() net.Addr

func (*Agent) Close

func (a *Agent) Close() error

func (*Agent) HandleWorkerConn

func (a *Agent) HandleWorkerConn(conn net.Conn) error

put the worker connection to the pool

func (*Agent) Join

func (a *Agent) Join() error

func (*Agent) Serve

func (a *Agent) Serve() error

func (*Agent) ServeApis

func (a *Agent) ServeApis() error

ServeApis serve agent-local http or backend http services

func (*Agent) ServeProtocol

func (a *Agent) ServeProtocol() error

type ClusterAgent

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

ClusterAgent is a runtime agent object within master lifttime

func (*ClusterAgent) Client

func (ca *ClusterAgent) Client() *http.Client

Client obtain a http client for an agent with customized dialer

func (*ClusterAgent) Dial

func (ca *ClusterAgent) Dial(network, addr string) (net.Conn, error)

Dial specifies the dial function for creating unencrypted TCP connections within the http.Client

type Config

type Config struct {
	Role    Role     // both
	Listen  string   // master only
	Master  *url.URL // agent only
	Backend *url.URL // agent only
}

func ConfigFromEnv

func ConfigFromEnv() (*Config, error)

type Decoder

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

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns a new protocol decoder that reads from r.

func (*Decoder) Buffered

func (d *Decoder) Buffered() []byte

func (*Decoder) Decode

func (d *Decoder) Decode() (*command, error)

Decode reads the next protocol-encoded command from reader Note that Decode() is not concurrency safe.

type Master

type Master struct {
	sync.RWMutex // protect agents map
	// contains filtered or unexported fields
}

func NewMaster

func NewMaster(cfg *Config) *Master

func (*Master) AddAgent

func (m *Master) AddAgent(id string, conn net.Conn)

func (*Master) Agent

func (m *Master) Agent(id string) *ClusterAgent

the caller should check the returned ClusterAgent is not nil otherwise the agent hasn't connected to the cluster

func (*Master) Agents

func (m *Master) Agents() map[string]*ClusterAgent

func (*Master) CloseAgent

func (m *Master) CloseAgent(id string)

func (*Master) FreshAgent

func (m *Master) FreshAgent(id string)

func (*Master) Serve

func (m *Master) Serve() error

type Role

type Role string
var (
	RoleMaster Role = "master"
	RoleAgent  Role = "agent"
)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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