telshell

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 License: MIT Imports: 15 Imported by: 0

README

TelShell

Tiny Telnet shell server in Go

alt text

Download

Grab latest release from here

Usage

./telshell -listen=:5000

Use -help to get help about additional params

Documentation

Index

Constants

View Source
const MaxLoginChars = 32

Variables

View Source
var (
	CL      = byte(0xD)
	RF      = byte(0xA)
	NulChar = byte(0x0)
	CLRF    = "\r\n"
)
View Source
var (
	DefaultShell = "/bin/sh"
	ShellArgs    = app.FlagsArray{}
)
View Source
var (
	ErrServerStarted    = errors.New("server is already started")
	ErrServerNotStarted = errors.New("server not started")
)

Functions

func IsCLRF

func IsCLRF(buff []byte) bool

func TrimCLRF

func TrimCLRF(buff []byte) []byte

TrimCLRF trims CL, RF and nul terminator characters

Types

type AuthShellHandler

type AuthShellHandler struct {
	IOParams
	// contains filtered or unexported fields
}

AuthShellHandler is shell handler that requires username and password

func NewAuthShellHandler

func NewAuthShellHandler(params IOParams, shell string, args ...string) AuthShellHandler

NewAuthShellHandler creates new authorized shell handler

func (AuthShellHandler) Handle

func (h AuthShellHandler) Handle(ctx context.Context, rw io.ReadWriter) error

Handle implements telshell.Handler

type Handler

type Handler interface {
	Handle(ctx context.Context, rw io.ReadWriter) error
}

Handler is TCP request handler

type IOParams added in v1.1.0

type IOParams struct {
	BufferSize         uint
	ReplaceLineEndings bool
}

type Server

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

Server is telnet server used for serving requests

func NewServer

func NewServer(handlers ...Handler) *Server

NewServer creates new server with specified handlers.

Each handler executes one by one for each new connection

func (*Server) SetLogger

func (s *Server) SetLogger(l *zap.Logger)

SetLogger sets logger

func (*Server) Start

func (s *Server) Start(ctx context.Context, addr string) (err error)

Start starts server

func (*Server) Stop

func (s *Server) Stop() error

Stop stops the server

type ShellHandler

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

ShellHandler provides shell access via Telnet

func NewShellHandler

func NewShellHandler(params IOParams, shell string, args ...string) ShellHandler

NewShellHandler creates a new shell handler

func (ShellHandler) Handle

func (s ShellHandler) Handle(ctx context.Context, rw io.ReadWriter) error

Handle implements telshell.Handler

type TerminalWrapper

type TerminalWrapper struct {
	IOParams
	// contains filtered or unexported fields
}

func NewTerminalWrapper

func NewTerminalWrapper(log *zap.SugaredLogger, client io.ReadWriter, params IOParams) TerminalWrapper

func (TerminalWrapper) Listen

func (w TerminalWrapper) Listen(ctx context.Context, cmd *exec.Cmd) error

type WelcomeHandler

type WelcomeHandler struct{}

func (WelcomeHandler) Handle

func (h WelcomeHandler) Handle(_ context.Context, rw io.ReadWriter) error

Directories

Path Synopsis
cmd
internal
app

Jump to

Keyboard shortcuts

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