telnet

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0, ISC Imports: 9 Imported by: 0

Documentation

Overview

Package telnet provides a zgrab2 module that scans for telnet daemons. Default Port: 23 (TCP)

The --max-read-size flag allows setting a ceiling to the number of bytes that will be read for the banner.

The scan negotiates the options and attempts to grab the banner, using the same behavior as the original zgrab.

The output contains the banner and the negotiated options, in the same format as the original zgrab.

Index

Constants

View Source
const (
	// IAC means INTERPRET AS COMMAND.
	IAC = byte(0xff)

	// DONT means don't use these options.
	DONT = byte(0xfe)

	// DO means do use these options.
	DO = byte(0xfd)

	// WONT means these options won't be used.
	WONT = byte(0xfc)

	// WILL means these options will be used.
	WILL = byte(0xfb)

	// GO_AHEAD is the special go ahead command.
	GO_AHEAD = byte(0xf9)

	// IAC_CMD_LENGTH gives the length of the special IAC command (inclusive).
	IAC_CMD_LENGTH = 3

	// READ_BUFFER_LENGTH is the size of the read buffer.
	READ_BUFFER_LENGTH = 8209
)

RFC 854 - https://tools.ietf.org/html/rfc854

Variables

This section is empty.

Functions

func GetTelnetBanner

func GetTelnetBanner(logStruct *TelnetLog, conn net.Conn, maxReadSize int) (err error)

GetTelnetBanner attempts to negotiate the options and fetch the telnet banner over the given connection, reading at most maxReadSize bytes.

func NegotiateOptions

func NegotiateOptions(logStruct *TelnetLog, conn net.Conn) error

NegotiateOptions attempts to negotiate the connection options over the given connection.

func RegisterModule

func RegisterModule()

RegisterModule registers the zgrab2 module.

Types

type Flags

type Flags struct {
	zgrab2.BaseFlags
	MaxReadSize int  `long:"max-read-size" description:"Set the maximum number of bytes to read when grabbing the banner" default:"65536"`
	Banner      bool `long:"force-banner" description:"Always return banner if it has non-zero bytes"`
	Verbose     bool `long:"verbose" description:"More verbose logging, include debug fields in the scan results"`
}

Flags holds the command-line configuration for the Telnet scan module. Populated by the framework.

func (*Flags) Help

func (flags *Flags) Help() string

Help returns the module's help string.

func (*Flags) Validate

func (flags *Flags) Validate(args []string) error

Validate checks that the flags are valid. On success, returns nil. On failure, returns an error instance describing the error.

type Module

type Module struct {
}

Module implements the zgrab2.Module interface.

func (*Module) Description

func (module *Module) Description() string

Description returns an overview of this module.

func (*Module) NewFlags

func (module *Module) NewFlags() interface{}

NewFlags returns a default Flags object.

func (*Module) NewScanner

func (module *Module) NewScanner() zgrab2.Scanner

NewScanner returns a new Scanner instance.

type Scanner

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

Scanner implements the zgrab2.Scanner interface.

func (*Scanner) GetName

func (scanner *Scanner) GetName() string

GetName returns the Scanner name defined in the Flags.

func (*Scanner) GetTrigger

func (scanner *Scanner) GetTrigger() string

GetTrigger returns the Trigger defined in the Flags.

func (*Scanner) Init

func (scanner *Scanner) Init(flags zgrab2.ScanFlags) error

Init initializes the Scanner.

func (*Scanner) InitPerSender

func (scanner *Scanner) InitPerSender(senderID int) error

InitPerSender initializes the scanner for a given sender.

func (*Scanner) Protocol

func (scanner *Scanner) Protocol() string

Protocol returns the protocol identifier of the scan.

func (*Scanner) Scan

func (scanner *Scanner) Scan(target zgrab2.ScanTarget) (zgrab2.ScanStatus, interface{}, error)

Scan connects to the target (default port TCP 23) and attempts to grab the Telnet banner.

type TelnetLog

type TelnetLog struct {
	// Banner is the telnet banner returned by the server.
	Banner string `json:"banner,omitempty"`

	// Will is the list of options that the server says that it will use.
	Will []TelnetOption `json:"will,omitempty"`

	// Do is the list of options that the server requests that the client use.
	Do []TelnetOption `json:"do,omitempty"`

	// Wont is the list of options that the server says it will *not* use.
	Wont []TelnetOption `json:"wont,omitempty"`

	// Dont is the list of options that the server requests the client *not* use.
	Dont []TelnetOption `json:"dont,omitempty"`
}

TelnetLog is the output of the telnet grab.

type TelnetOption

type TelnetOption uint16

TelnetOption provides mappings of telnet option enum values to/from their friendly names.

func (*TelnetOption) MarshalJSON

func (opt *TelnetOption) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON-encoded friendly name of the telnet option.

func (*TelnetOption) Name

func (opt *TelnetOption) Name() string

Name gets the friendly name of the TelnetOption (or "unknown" if it is not recognized).

func (*TelnetOption) UnmarshalJSON

func (opt *TelnetOption) UnmarshalJSON(b []byte) error

UnmarshalJSON returns the TelnetOption enum value from its JSON-encoded friendly name.

Jump to

Keyboard shortcuts

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