Documentation
¶
Overview ¶
sshproxyplus is a tool to proxy SSH sessions while recording the behavior in real time.
The tool comes with a companion web-server that allows one to view a proxied session in real-time and to reply previous sessions.
There proxy is managed by a controller interface that can be configured directly via code, or over a socket via signed commands.
Index ¶
- Constants
- func GenerateSigner() (ssh.Signer, error)
- type ChannelFilterFunc
- type ControllerHMAC
- type ControllerMessage
- type EventCallback
- type EventCallbackFunc
- type LoggerInterface
- type ProxyContext
- func (proxy *ProxyContext) Activate()
- func (proxy *ProxyContext) AddProxyUser(user *ProxyUser) string
- func (proxy *ProxyContext) AddSessionToSessionList(session *SessionContext)
- func (proxy *ProxyContext) AddSessionToUserList(session *SessionContext)
- func (proxy *ProxyContext) AddSessionViewer(viewer *proxySessionViewer)
- func (proxy *ProxyContext) AuthenticateUser(username, password string) (error, *ProxyUser)
- func (proxy *ProxyContext) Deactivate()
- func (proxy *ProxyContext) GetDefaultRemoteHost() string
- func (proxy *ProxyContext) GetProxyUser(username, password string, cloneUser bool) (error, *ProxyUser, bool)
- func (proxy *ProxyContext) GetSessionViewer(key string) *proxySessionViewer
- func (proxy *ProxyContext) HandleClientConn(client_conn *ssh.ServerConn, client_channels <-chan ssh.NewChannel, ...)
- func (proxy *ProxyContext) Initialize(defaultSigner ssh.Signer)
- func (proxy *ProxyContext) IsActive() bool
- func (proxy *ProxyContext) ListAllActiveSessions() []string
- func (proxy *ProxyContext) ListAllActiveUserSessions(user string) []string
- func (proxy *ProxyContext) ListAllSessions() []string
- func (proxy *ProxyContext) ListAllUserSessions(user string) []string
- func (proxy *ProxyContext) MakeSessionViewerForSession(user_key string, password string, session string) (error, *proxySessionViewer)
- func (proxy *ProxyContext) MakeSessionViewerForUser(username, password string) (error, *proxySessionViewer)
- func (proxy *ProxyContext) RemoveExpiredSessions()
- func (proxy *ProxyContext) RemoveProxyUser(username string, password string) error
- func (proxy *ProxyContext) RemoveSessionViewer(key string)
- func (proxy *ProxyContext) StartProxy()
- func (proxy *ProxyContext) Stop()
- type ProxyController
- func (controller *ProxyController) ActivateProxy(proxyID uint64) error
- func (controller *ProxyController) AddChannelFilterToUser(proxyID uint64, username, password string, function *ChannelFilterFunc) (error, string)
- func (controller *ProxyController) AddEventCallbackToUser(proxyID uint64, username, password string, callback *EventCallback) (error, string)
- func (controller *ProxyController) AddExistingProxy(proxy *ProxyContext) uint64
- func (controller *ProxyController) AddProxy(proxy *ProxyContext) uint64
- func (controller *ProxyController) AddProxyFromJSON(data []byte) (error, uint64)
- func (controller *ProxyController) AddUserToProxy(proxyID uint64, user *ProxyUser) (error, string)
- func (controller *ProxyController) CreateProxy() uint64
- func (controller *ProxyController) CreateSessionViewer(proxyID uint64, username, password, sessionKey string) (error, *proxySessionViewer)
- func (controller *ProxyController) CreateUserSessionViewer(proxyID uint64, username, password string) (error, *proxySessionViewer)
- func (controller *ProxyController) DeactivateProxy(proxyID uint64) error
- func (controller *ProxyController) DestroyProxy(proxyID uint64) (err error)
- func (controller *ProxyController) ExportControllerAsJSON() ([]byte, error)
- func (controller *ProxyController) GetNextProxyID() uint64
- func (controller *ProxyController) GetProxy(proxyID uint64) (proxy *ProxyContext, err error)
- func (controller *ProxyController) GetProxyViewerBySessionKey(proxyID uint64, sessionKey string) (error, *proxySessionViewer)
- func (controller *ProxyController) GetProxyViewerByUsername(proxyID uint64, username string) (error, *proxySessionViewer)
- func (controller *ProxyController) GetProxyViewerByViewerKey(proxyID uint64, viewerKey string) (error, *proxySessionViewer)
- func (controller *ProxyController) GetProxyViewers(proxyID uint64) (error, map[string]*proxySessionViewer)
- func (controller *ProxyController) GetProxyViewersAsList(proxyID uint64) (error, []*proxySessionViewer)
- func (controller *ProxyController) GetProxyViewersBySessionKey(proxyID uint64, sessionKey string) (error, []*proxySessionViewer)
- func (controller *ProxyController) GetProxyViewersByUsername(proxyID uint64, username string) (error, []*proxySessionViewer)
- func (controller *ProxyController) Initialize()
- func (controller *ProxyController) InitializeSocket()
- func (controller *ProxyController) Listen()
- func (controller *ProxyController) RemoveChannelFilterFromUser(proxyID uint64, username, password string, function *ChannelFilterFunc) error
- func (controller *ProxyController) RemoveChannelFilterFromUserByKey(proxyID uint64, username, password, key string) error
- func (controller *ProxyController) RemoveEventCallbackFromUser(proxyID uint64, username, password string, callback *EventCallback) error
- func (controller *ProxyController) RemoveEventCallbackFromUserByKey(proxyID uint64, username, password, key string) error
- func (controller *ProxyController) RemoveUserFromProxy(proxyID uint64, username, password string) error
- func (controller *ProxyController) StartProxy(proxyID uint64) error
- func (controller *ProxyController) StartWebServer() error
- func (controller *ProxyController) Stop()
- func (controller *ProxyController) StopProxies()
- func (controller *ProxyController) StopProxy(proxyID uint64) error
- func (controller *ProxyController) StopWebServer()
- func (controller *ProxyController) UpdateProxiesWithCurrentLogger(overwrite bool)
- func (controller *ProxyController) UseNewLogger(logger LoggerInterface)
- func (controller *ProxyController) WriteControllerConfigToFile(filepath string) error
- type ProxyControllerSocket
- type ProxyControllerSocketClient
- type ProxyControllerSocketHandler
- type ProxyControllerSocketTCP
- type ProxyControllerSocketTCPClient
- type ProxyControllerSocketWeb
- type ProxyControllerSocketWebClient
- type ProxyUser
- func (user *ProxyUser) AddChannelFilter(function *ChannelFilterFunc) int
- func (user *ProxyUser) AddEventCallback(callback *EventCallback) int
- func (user *ProxyUser) GetKey() string
- func (user *ProxyUser) RemoveChannelFilter(function *ChannelFilterFunc)
- func (user *ProxyUser) RemoveEventCallback(callback *EventCallback)
- type SessionContext
- func (session *SessionContext) AddEvent(event *SessionEvent) *SessionEvent
- func (session *SessionContext) End()
- func (session *SessionContext) GetID() string
- func (session *SessionContext) GetTimeOffset() int64
- func (session *SessionContext) HandleChannels(dest_conn ssh.Conn, channels <-chan ssh.NewChannel)
- func (session *SessionContext) HandleEvent(event *SessionEvent)
- func (session *SessionContext) InfoAsJSON() string
- func (session *SessionContext) LogEvent(event *SessionEvent)
- func (session *SessionContext) MakeNewSignal() chan int
- func (session *SessionContext) RemoveSignal(signal chan int)
- type SessionEvent
Constants ¶
const ACTIVE_POLLING_DELAY time.Duration = 500 * time.Millisecond
const CONTROLLER_MESSAGE_ACTIVATE_PROXY string = "activate-proxy"
const CONTROLLER_MESSAGE_ADD_CHANNEL_FILTER string = "add-channel-filter"
const CONTROLLER_MESSAGE_ADD_PROXY_USER string = "add-proxy-user"
const CONTROLLER_MESSAGE_ADD_USER_CALLBACK string = "add-user-callback"
const CONTROLLER_MESSAGE_CREATE_PROXY string = "create-proxy"
const CONTROLLER_MESSAGE_DEACTIVATE_PROXY string = "deactivate-proxy"
const CONTROLLER_MESSAGE_DESTROY_PROXY string = "destroy-proxy"
const CONTROLLER_MESSAGE_GET_PROXY_INFO string = "get-proxy-info"
const CONTROLLER_MESSAGE_GET_PROXY_VIEWER string = "get-proxy-viewer"
const CONTROLLER_MESSAGE_GET_PROXY_VIEWERS string = "get-proxy-viewers"
const CONTROLLER_MESSAGE_LIST_PROXIES string = "list-proxies"
const CONTROLLER_MESSAGE_NEW_PROXY_VIEWER string = "new-proxy-viewer"
const CONTROLLER_MESSAGE_REMOVE_CHANNEL_FILTER string = "remove-channel-filter"
const CONTROLLER_MESSAGE_REMOVE_PROXY_USER string = "remove-proxy-user"
const CONTROLLER_MESSAGE_REMOVE_USER_CALLBACK string = "remove-user-callback"
const CONTROLLER_MESSAGE_START_PROXY string = "start-proxy"
const CONTROLLER_MESSAGE_STOP_PROXY string = "stop-proxy"
const EVENT_MESSAGE string = "new-message"
const EVENT_NEW_CHANNEL string = "new-channel"
const EVENT_NEW_REQUEST string = "new-request"
const EVENT_SESSION_START string = "session-start"
const EVENT_SESSION_STOP string = "session-stop"
const EVENT_WINDOW_RESIZE string = "window-resize"
const PROXY_CONTROLLER_SOCKET_PLAIN uint16 = 0
A simple TCP socket with no encryption
const PROXY_CONTROLLER_SOCKET_PLAIN_WEBSOCKET uint16 = 1
A HTTP websocket with no encryption It can be used with web servers
const PROXY_CONTROLLER_SOCKET_TLS uint16 = 2
A simple socket wrapped in TLS
const PROXY_CONTROLLER_SOCKET_TLS_WEBSOCKET uint16 = 3
A HTTPS websocket that can be used with web servers
const SESSION_LIST_FN string = ".session_list"
const SESSION_VIEWER_EXPIRATION = -1
const SESSION_VIEWER_SECRET_LEN = 64
const SESSION_VIEWER_TYPE_LIST = 1
const SESSION_VIEWER_TYPE_SINGLE = 0
const SIGNAL_NEW_MESSAGE int = 1
const SIGNAL_SESSION_END int = 0
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ChannelFilterFunc ¶
type ChannelFilterFunc struct {
// contains filtered or unexported fields
}
type ControllerHMAC ¶
A signed message for the controller. The Message is a JSON blob The HMAC is a signed hash of the Message
func (*ControllerHMAC) Verify ¶
func (messageWrapper *ControllerHMAC) Verify(key []byte) (error, ControllerMessage)
type ControllerMessage ¶
type ControllerMessage struct { MessageType string ProxyData []byte `json:"ProxyData,omitempty"` ProxyID uint64 `json:"omitempty"` ViewerSecret string `json:"omitempty"` SessionKey string `json:"omitempty"` Username string `json:"omitempty"` Password string `json:"omitempty"` FilterKey string `json:"omitempty"` CallbackKey string `json:"omitempty"` CallbackURL string `json:"omitempty"` ProxyUser *ProxyUser `json:"omitempty"` FindString []byte `json:"omitempty"` ReplaceString []byte `json:"omitempty"` }
A message for the controller. If a field isn't used for a particular message type, it is omitted.
func (*ControllerMessage) HandleMessage ¶
func (message *ControllerMessage) HandleMessage(controller *ProxyController) []byte
func (*ControllerMessage) Sign ¶
func (message *ControllerMessage) Sign(key []byte) (error, ControllerHMAC)
type EventCallback ¶
type EventCallback struct {
// contains filtered or unexported fields
}
type EventCallbackFunc ¶
type EventCallbackFunc func(SessionEvent)
type LoggerInterface ¶
type ProxyContext ¶
type ProxyContext struct { DefaultRemotePort int DefaultRemoteIP string ListenIP string ListenPort int Log LoggerInterface `json:"-"` SessionFolder string TLSCert string TLSKey string OverridePassword string OverrideUser string WebListenPort int ServerVersion string Users map[string]*ProxyUser RequireValidPassword bool PublicAccess bool Viewers map[string]*proxySessionViewer BaseURI string // contains filtered or unexported fields }
Typically the proxy should be managed via the ProxyController functions and not directly called.
func MakeNewProxy ¶
func MakeNewProxy(signer ssh.Signer) *ProxyContext
func (*ProxyContext) Activate ¶
func (proxy *ProxyContext) Activate()
func (*ProxyContext) AddProxyUser ¶
func (proxy *ProxyContext) AddProxyUser(user *ProxyUser) string
func (*ProxyContext) AddSessionToSessionList ¶
func (proxy *ProxyContext) AddSessionToSessionList(session *SessionContext)
func (*ProxyContext) AddSessionToUserList ¶
func (proxy *ProxyContext) AddSessionToUserList(session *SessionContext)
func (*ProxyContext) AddSessionViewer ¶
func (proxy *ProxyContext) AddSessionViewer(viewer *proxySessionViewer)
func (*ProxyContext) AuthenticateUser ¶
func (proxy *ProxyContext) AuthenticateUser(username, password string) (error, *ProxyUser)
func (*ProxyContext) Deactivate ¶
func (proxy *ProxyContext) Deactivate()
func (*ProxyContext) GetDefaultRemoteHost ¶
func (proxy *ProxyContext) GetDefaultRemoteHost() string
func (*ProxyContext) GetProxyUser ¶
func (*ProxyContext) GetSessionViewer ¶
func (proxy *ProxyContext) GetSessionViewer(key string) *proxySessionViewer
func (*ProxyContext) HandleClientConn ¶
func (proxy *ProxyContext) HandleClientConn(client_conn *ssh.ServerConn, client_channels <-chan ssh.NewChannel, client_requests <-chan *ssh.Request, curSession *SessionContext)
func (*ProxyContext) Initialize ¶
func (proxy *ProxyContext) Initialize(defaultSigner ssh.Signer)
func (*ProxyContext) IsActive ¶
func (proxy *ProxyContext) IsActive() bool
func (*ProxyContext) ListAllActiveSessions ¶
func (proxy *ProxyContext) ListAllActiveSessions() []string
func (*ProxyContext) ListAllActiveUserSessions ¶
func (proxy *ProxyContext) ListAllActiveUserSessions(user string) []string
func (*ProxyContext) ListAllSessions ¶
func (proxy *ProxyContext) ListAllSessions() []string
func (*ProxyContext) ListAllUserSessions ¶
func (proxy *ProxyContext) ListAllUserSessions(user string) []string
func (*ProxyContext) MakeSessionViewerForSession ¶
func (proxy *ProxyContext) MakeSessionViewerForSession(user_key string, password string, session string) (error, *proxySessionViewer)
func (*ProxyContext) MakeSessionViewerForUser ¶
func (proxy *ProxyContext) MakeSessionViewerForUser(username, password string) (error, *proxySessionViewer)
func (*ProxyContext) RemoveExpiredSessions ¶
func (proxy *ProxyContext) RemoveExpiredSessions()
func (*ProxyContext) RemoveProxyUser ¶
func (proxy *ProxyContext) RemoveProxyUser(username string, password string) error
func (*ProxyContext) RemoveSessionViewer ¶
func (proxy *ProxyContext) RemoveSessionViewer(key string)
func (*ProxyContext) StartProxy ¶
func (proxy *ProxyContext) StartProxy()
func (*ProxyContext) Stop ¶
func (proxy *ProxyContext) Stop()
type ProxyController ¶
type ProxyController struct { Proxies map[uint64]*ProxyContext ProxyCounter uint64 // Used to authenticate commands // sent over the controller socket // from a remote server SocketType uint16 SocketHost string TLSKey string TLSCert string WebHost string WebStaticDir string BaseURI string Log LoggerInterface `json:"-"` DefaultSigner ssh.Signer `json:"-"` EventCallbacks map[string]*EventCallback // contains filtered or unexported fields }
The ProxyController object can be managed directly via the software API, or over a controller socket.
It can be used to create and destroy proxies, start and stop proxies, add ProxyUsers to proxies, create filters and callbacks for users, and to host a web interface which can be used to view sessions in real time.
It also provides a socket that can be used to remotely manage the controller. The remote tool must have the same preshared key. The key is used to send HMAC-signed JSON blobs for execution by the controller.
func LoadControllerConfigFromFile ¶
func LoadControllerConfigFromFile(filepath string, signer ssh.Signer) (error, *ProxyController)
func (*ProxyController) ActivateProxy ¶
func (controller *ProxyController) ActivateProxy(proxyID uint64) error
func (*ProxyController) AddChannelFilterToUser ¶
func (controller *ProxyController) AddChannelFilterToUser(proxyID uint64, username, password string, function *ChannelFilterFunc) (error, string)
func (*ProxyController) AddEventCallbackToUser ¶
func (controller *ProxyController) AddEventCallbackToUser(proxyID uint64, username, password string, callback *EventCallback) (error, string)
func (*ProxyController) AddExistingProxy ¶
func (controller *ProxyController) AddExistingProxy(proxy *ProxyContext) uint64
func (*ProxyController) AddProxy ¶
func (controller *ProxyController) AddProxy(proxy *ProxyContext) uint64
func (*ProxyController) AddProxyFromJSON ¶
func (controller *ProxyController) AddProxyFromJSON(data []byte) (error, uint64)
func (*ProxyController) AddUserToProxy ¶
func (controller *ProxyController) AddUserToProxy(proxyID uint64, user *ProxyUser) (error, string)
func (*ProxyController) CreateProxy ¶
func (controller *ProxyController) CreateProxy() uint64
func (*ProxyController) CreateSessionViewer ¶
func (controller *ProxyController) CreateSessionViewer(proxyID uint64, username, password, sessionKey string) (error, *proxySessionViewer)
func (*ProxyController) CreateUserSessionViewer ¶
func (controller *ProxyController) CreateUserSessionViewer(proxyID uint64, username, password string) (error, *proxySessionViewer)
func (*ProxyController) DeactivateProxy ¶
func (controller *ProxyController) DeactivateProxy(proxyID uint64) error
func (*ProxyController) DestroyProxy ¶
func (controller *ProxyController) DestroyProxy(proxyID uint64) (err error)
func (*ProxyController) ExportControllerAsJSON ¶
func (controller *ProxyController) ExportControllerAsJSON() ([]byte, error)
func (*ProxyController) GetNextProxyID ¶
func (controller *ProxyController) GetNextProxyID() uint64
func (*ProxyController) GetProxy ¶
func (controller *ProxyController) GetProxy(proxyID uint64) (proxy *ProxyContext, err error)
func (*ProxyController) GetProxyViewerBySessionKey ¶
func (controller *ProxyController) GetProxyViewerBySessionKey(proxyID uint64, sessionKey string) (error, *proxySessionViewer)
func (*ProxyController) GetProxyViewerByUsername ¶
func (controller *ProxyController) GetProxyViewerByUsername(proxyID uint64, username string) (error, *proxySessionViewer)
func (*ProxyController) GetProxyViewerByViewerKey ¶
func (controller *ProxyController) GetProxyViewerByViewerKey(proxyID uint64, viewerKey string) (error, *proxySessionViewer)
func (*ProxyController) GetProxyViewers ¶
func (controller *ProxyController) GetProxyViewers(proxyID uint64) (error, map[string]*proxySessionViewer)
func (*ProxyController) GetProxyViewersAsList ¶
func (controller *ProxyController) GetProxyViewersAsList(proxyID uint64) (error, []*proxySessionViewer)
func (*ProxyController) GetProxyViewersBySessionKey ¶
func (controller *ProxyController) GetProxyViewersBySessionKey(proxyID uint64, sessionKey string) (error, []*proxySessionViewer)
func (*ProxyController) GetProxyViewersByUsername ¶
func (controller *ProxyController) GetProxyViewersByUsername(proxyID uint64, username string) (error, []*proxySessionViewer)
func (*ProxyController) Initialize ¶
func (controller *ProxyController) Initialize()
func (*ProxyController) InitializeSocket ¶
func (controller *ProxyController) InitializeSocket()
func (*ProxyController) Listen ¶
func (controller *ProxyController) Listen()
func (*ProxyController) RemoveChannelFilterFromUser ¶
func (controller *ProxyController) RemoveChannelFilterFromUser(proxyID uint64, username, password string, function *ChannelFilterFunc) error
func (*ProxyController) RemoveChannelFilterFromUserByKey ¶
func (controller *ProxyController) RemoveChannelFilterFromUserByKey(proxyID uint64, username, password, key string) error
func (*ProxyController) RemoveEventCallbackFromUser ¶
func (controller *ProxyController) RemoveEventCallbackFromUser(proxyID uint64, username, password string, callback *EventCallback) error
func (*ProxyController) RemoveEventCallbackFromUserByKey ¶
func (controller *ProxyController) RemoveEventCallbackFromUserByKey(proxyID uint64, username, password, key string) error
func (*ProxyController) RemoveUserFromProxy ¶
func (controller *ProxyController) RemoveUserFromProxy(proxyID uint64, username, password string) error
func (*ProxyController) StartProxy ¶
func (controller *ProxyController) StartProxy(proxyID uint64) error
func (*ProxyController) StartWebServer ¶
func (controller *ProxyController) StartWebServer() error
func (*ProxyController) Stop ¶
func (controller *ProxyController) Stop()
func (*ProxyController) StopProxies ¶
func (controller *ProxyController) StopProxies()
func (*ProxyController) StopProxy ¶
func (controller *ProxyController) StopProxy(proxyID uint64) error
func (*ProxyController) StopWebServer ¶
func (controller *ProxyController) StopWebServer()
func (*ProxyController) UpdateProxiesWithCurrentLogger ¶
func (controller *ProxyController) UpdateProxiesWithCurrentLogger(overwrite bool)
func (*ProxyController) UseNewLogger ¶
func (controller *ProxyController) UseNewLogger(logger LoggerInterface)
func (*ProxyController) WriteControllerConfigToFile ¶
func (controller *ProxyController) WriteControllerConfigToFile(filepath string) error
type ProxyControllerSocket ¶
type ProxyControllerSocket interface { ListenAndServe(host string, handler ProxyControllerSocketHandler) error Stop() IsPlaintext() bool }
type ProxyControllerSocketHandler ¶
type ProxyControllerSocketHandler func(ProxyControllerSocketClient, ProxyControllerSocket)
type ProxyControllerSocketTCP ¶
type ProxyControllerSocketTCP struct { TLSCert string TLSKey string // contains filtered or unexported fields }
The ProxyControllerSocket is either a socket or a websocket. In either case, the socket can be wrapped in TLS.
A client connects to the socket and sends authenticated messages to ProxyController remotely.
It is the Controller's job to create a valid key when it is required for TLS sessions.
func (*ProxyControllerSocketTCP) IsPlaintext ¶
func (socket *ProxyControllerSocketTCP) IsPlaintext() bool
func (*ProxyControllerSocketTCP) ListenAndServe ¶
func (socket *ProxyControllerSocketTCP) ListenAndServe(host string, handler ProxyControllerSocketHandler) error
func (*ProxyControllerSocketTCP) Stop ¶
func (socket *ProxyControllerSocketTCP) Stop()
type ProxyControllerSocketTCPClient ¶
func (*ProxyControllerSocketTCPClient) ReadLine ¶
func (client *ProxyControllerSocketTCPClient) ReadLine() ([]byte, error)
func (*ProxyControllerSocketTCPClient) SendLine ¶
func (client *ProxyControllerSocketTCPClient) SendLine(data []byte) error
type ProxyControllerSocketWeb ¶
type ProxyControllerSocketWeb struct { TLSCert string TLSKey string // contains filtered or unexported fields }
func (*ProxyControllerSocketWeb) IsPlaintext ¶
func (socket *ProxyControllerSocketWeb) IsPlaintext() bool
func (*ProxyControllerSocketWeb) ListenAndServe ¶
func (socket *ProxyControllerSocketWeb) ListenAndServe(host string, handler ProxyControllerSocketHandler) error
func (*ProxyControllerSocketWeb) Stop ¶
func (socket *ProxyControllerSocketWeb) Stop()
type ProxyControllerSocketWebClient ¶
func (*ProxyControllerSocketWebClient) ReadLine ¶
func (client *ProxyControllerSocketWebClient) ReadLine() ([]byte, error)
func (*ProxyControllerSocketWebClient) SendLine ¶
func (client *ProxyControllerSocketWebClient) SendLine(data []byte) error
type ProxyUser ¶
type ProxyUser struct { Username string Password string RemoteHost string RemoteUsername string RemotePassword string EventCallbacks []*EventCallback `json:"-"` // contains filtered or unexported fields }
A ProxyUser defines the authenticating username and password a client connecting to the proxy must use to authenticate to this user.
Upon successful authentication, the user is proxied to the RemoteHost using the specified RemoteUsername and RemotePassword.
EventCallbacks can be specified via the ProxyController to provide anonymous functions that can be executed on certain events as they occur in a given session. Callbacks occur in goroutines and do not block. An example callback might be a function that calls back to a web hook whenever a specific string is seen.
channelFilters are also specified via the ProxyController and are executed on messages in an established session. They receive data as an argument and return modified data on the other end. These occur in series and block the transfer of data through the proxy. ChannelFilters do not currently distinguish between inbound and outbound traffic. Consequently both ends of the session will be filtered.
func (*ProxyUser) AddChannelFilter ¶
func (user *ProxyUser) AddChannelFilter(function *ChannelFilterFunc) int
func (*ProxyUser) AddEventCallback ¶
func (user *ProxyUser) AddEventCallback(callback *EventCallback) int
func (*ProxyUser) RemoveChannelFilter ¶
func (user *ProxyUser) RemoveChannelFilter(function *ChannelFilterFunc)
func (*ProxyUser) RemoveEventCallback ¶
func (user *ProxyUser) RemoveEventCallback(callback *EventCallback)
type SessionContext ¶
type SessionContext struct {
// contains filtered or unexported fields
}
Every event is also written to a log file as it occurs.
func (*SessionContext) AddEvent ¶
func (session *SessionContext) AddEvent(event *SessionEvent) *SessionEvent
func (*SessionContext) End ¶
func (session *SessionContext) End()
func (*SessionContext) GetID ¶
func (session *SessionContext) GetID() string
func (*SessionContext) GetTimeOffset ¶
func (session *SessionContext) GetTimeOffset() int64
func (*SessionContext) HandleChannels ¶
func (session *SessionContext) HandleChannels(dest_conn ssh.Conn, channels <-chan ssh.NewChannel)
func (*SessionContext) HandleEvent ¶
func (session *SessionContext) HandleEvent(event *SessionEvent)
func (*SessionContext) InfoAsJSON ¶
func (session *SessionContext) InfoAsJSON() string
func (*SessionContext) LogEvent ¶
func (session *SessionContext) LogEvent(event *SessionEvent)
func (*SessionContext) MakeNewSignal ¶
func (session *SessionContext) MakeNewSignal() chan int
func (*SessionContext) RemoveSignal ¶
func (session *SessionContext) RemoveSignal(signal chan int)
type SessionEvent ¶
type SessionEvent struct { Type string `json:"type"` Key string `json:"key,omitempty"` StartTime int64 `json:"start,omitempty"` StopTime int64 `json:"stop,omitempty"` Length int64 `json:"length,omitempty"` TimeOffset int64 `json:"offset,omitempty"` Direction string `json:"direction,omitempty"` Size int `json:"size,omitempty"` Data []byte `json:"data,omitempty"` ClientHost string `json:"client_host,omitempty"` ServHost string `json:"server_host,omitempty"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` TermRows uint32 `json:"term_rows,omitempty"` TermCols uint32 `json:"term_cols,omitempty"` ChannelType string `json:"channel_type,omitempty"` ChannelData []byte `json:"channel_data,omitempty"` RequestType string `json:"request_type,omitempty"` RequestPayload []byte `json:"request_payload,omitempty"` ChannelID int `json:"channel_id,omitempty"` RequestID int `json:"request_id,omitempty"` }
SessionEvents are the meat of an SSH Session. They track the start and stop of a session, when new requests or channels are created, when a window is resized, and when data is transmitted as a message.
func (*SessionEvent) ToJSON ¶
func (event *SessionEvent) ToJSON() string