zlib

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2015 License: Apache-2.0 Imports: 21 Imported by: 10

Documentation

Index

Constants

View Source
const (
	SMTP_COMMAND = "STARTTLS\r\n"
	POP3_COMMAND = "STLS\r\n"
	IMAP_COMMAND = "a001 STARTTLS\r\n"
)
View Source
const (
	CONNECTION_EVENT_CONNECT_NAME    = "connect"
	CONNECTION_EVENT_READ_NAME       = "read"
	CONNECTION_EVENT_WRITE_NAME      = "write"
	CONNECTION_EVENT_TLS_NAME        = "tls_handshake"
	CONNECTION_EVENT_HEARTBLEED_NAME = "heartbleed"
	CONNECTION_EVENT_EHLO_NAME       = "ehlo"
	CONNECTION_EVENT_STARTTLS_NAME   = "starttls"
	CONNECTION_EVENT_MAIL_BANNER     = "mail_banner"
	CONNECTION_EVENT_MODBUS          = "modbus"
	CONNECTION_EVENT_FTP             = "ftp"
	CONNECTION_EVENT_SSH_NAME        = "ssh"
)
View Source
const (
	FunctionCodeMEI = FunctionCode(0x2B)
)

Variables

View Source
var ConnectEventType = EventType{
	TypeName:         CONNECTION_EVENT_CONNECT_NAME,
	GetEmptyInstance: newConnectEvent,
}
View Source
var EHLOEventType = EventType{
	TypeName:         CONNECTION_EVENT_EHLO_NAME,
	GetEmptyInstance: newEHLOEvent,
}
View Source
var FTPBannerEventType = EventType{
	TypeName:         CONNECTION_EVENT_FTP,
	GetEmptyInstance: func() EventData { return new(FTPBannerEvent) },
}
View Source
var HTTPGetEventType = EventType{
	TypeName:         "http_get",
	GetEmptyInstance: func() EventData { return new(HTTPGETEvent) },
}
View Source
var HeartbleedEventType = EventType{
	TypeName:         CONNECTION_EVENT_HEARTBLEED_NAME,
	GetEmptyInstance: newHeartbleedEvent,
}
View Source
var MailBannerEventType = EventType{
	TypeName:         CONNECTION_EVENT_MAIL_BANNER,
	GetEmptyInstance: func() EventData { return new(MailBannerEvent) },
}
View Source
var ModbusEventType = EventType{
	TypeName:         CONNECTION_EVENT_MODBUS,
	GetEmptyInstance: func() EventData { return new(ModbusEvent) },
}
View Source
var ModbusFunctionEncapsulatedInterface = FunctionCode(0x2B)
View Source
var ModbusHeaderBytes = []byte{
	0x13, 0x37,
	0x00, 0x00,
}
View Source
var ReadEventType = EventType{
	TypeName:         CONNECTION_EVENT_READ_NAME,
	GetEmptyInstance: func() EventData { return new(ReadEvent) },
}
View Source
var SMTPHelpEventType = EventType{
	TypeName:         "smtp_help",
	GetEmptyInstance: func() EventData { return new(SMTPHelpEvent) },
}
View Source
var SSHEventType = EventType{
	TypeName:         CONNECTION_EVENT_SSH_NAME,
	GetEmptyInstance: func() EventData { return new(SSHEvent) },
}
View Source
var StartTLSEventType = EventType{
	TypeName:         CONNECTION_EVENT_STARTTLS_NAME,
	GetEmptyInstance: func() EventData { return new(StartTLSEvent) },
}
View Source
var (
	TLSHandshakeEventType = EventType{
		TypeName:         CONNECTION_EVENT_TLS_NAME,
		GetEmptyInstance: newTLSHandshakeEvent,
	}
)
View Source
var WriteEventType = EventType{
	TypeName:         CONNECTION_EVENT_WRITE_NAME,
	GetEmptyInstance: newWriteEvent,
}

Functions

func NewGrabMarshaler

func NewGrabMarshaler() processing.Marshaler

func NewGrabTargetDecoder

func NewGrabTargetDecoder(reader io.Reader) processing.Decoder

func NewGrabWorker

func NewGrabWorker(config *Config) processing.Worker

func RegisterEventType

func RegisterEventType(t EventType)

func WriteOutput

func WriteOutput(grabChan chan Grab, doneChan chan int, config *OutputConfig)

Types

type Config

type Config struct {
	// Connection
	Port               uint16
	Timeout            time.Duration
	Senders            uint
	ConnectionsPerHost uint

	// Encoding
	Encoding string

	// TLS
	TLS           bool
	TLSVersion    uint16
	Heartbleed    bool
	RootCAPool    *x509.CertPool
	CBCOnly       bool
	SChannelOnly  bool
	DHEOnly       bool
	ExportsOnly   bool
	ExportsDHOnly bool
	FirefoxOnly   bool
	FirefoxNoDHE  bool
	ChromeOnly    bool
	ChromeNoDHE   bool
	SafariOnly    bool
	SafariNoDHE   bool
	NoSNI         bool

	// SSH
	SSH SSHScanConfig

	// Banners and Data
	Banners  bool
	SendData bool
	Data     []byte
	Raw      bool

	// Mail
	SMTP       bool
	IMAP       bool
	POP3       bool
	SMTPHelp   bool
	EHLODomain string
	EHLO       bool
	StartTLS   bool

	// FTP
	FTP bool

	// Modbus
	Modbus bool

	// Error handling
	ErrorLog *zlog.Logger

	// Go Runtime Config
	GOMAXPROCS int
}

type Conn

type Conn struct {

	// Encoding type
	ReadEncoding string
	// contains filtered or unexported fields
}

Implements the net.Conn interface

func (*Conn) CheckHeartbleed

func (c *Conn) CheckHeartbleed(b []byte) (int, error)

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) EHLO

func (c *Conn) EHLO(domain string) error

func (*Conn) GetFTPBanner

func (c *Conn) GetFTPBanner() error

func (*Conn) GetModbusResponse

func (c *Conn) GetModbusResponse() (res ModbusResponse, err error)

func (*Conn) IMAPBanner

func (c *Conn) IMAPBanner(b []byte) (int, error)

func (*Conn) IMAPStartTLSHandshake

func (c *Conn) IMAPStartTLSHandshake() error

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

Layer in the regular conn methods

func (*Conn) POP3Banner

func (c *Conn) POP3Banner(b []byte) (int, error)

func (*Conn) POP3StartTLSHandshake

func (c *Conn) POP3StartTLSHandshake() error

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

func (*Conn) ReadMin

func (c *Conn) ReadMin(res []byte, bytes int) (cnt int, err error)

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

func (*Conn) SMTPBanner

func (c *Conn) SMTPBanner(b []byte) (int, error)

func (*Conn) SMTPHelp

func (c *Conn) SMTPHelp() error

func (*Conn) SMTPStartTLSHandshake

func (c *Conn) SMTPStartTLSHandshake() error

Do a STARTTLS handshake

func (*Conn) SSHHandshake

func (c *Conn) SSHHandshake() error

func (*Conn) SendModbusEcho

func (c *Conn) SendModbusEcho() (int, error)

func (*Conn) SetCAPool

func (c *Conn) SetCAPool(pool *x509.CertPool)

func (*Conn) SetCBCOnly

func (c *Conn) SetCBCOnly()

func (*Conn) SetChromeCiphers

func (c *Conn) SetChromeCiphers()

func (*Conn) SetChromeNoDHECiphers

func (c *Conn) SetChromeNoDHECiphers()

func (*Conn) SetDHEOnly

func (c *Conn) SetDHEOnly()

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

func (*Conn) SetDomain

func (c *Conn) SetDomain(domain string)

func (*Conn) SetExportsDHOnly

func (c *Conn) SetExportsDHOnly()

func (*Conn) SetExportsOnly

func (c *Conn) SetExportsOnly()

func (*Conn) SetFirefoxCiphers

func (c *Conn) SetFirefoxCiphers()

func (*Conn) SetFirefoxNoDHECiphers

func (c *Conn) SetFirefoxNoDHECiphers()

func (*Conn) SetNoSNI

func (c *Conn) SetNoSNI()

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

func (*Conn) SetSChannelOnly

func (c *Conn) SetSChannelOnly()

func (*Conn) SetSafariCiphers

func (c *Conn) SetSafariCiphers()

func (*Conn) SetSafariNoDHECiphers

func (c *Conn) SetSafariNoDHECiphers()

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

func (*Conn) States

func (c *Conn) States() []ConnectionEvent

func (*Conn) TLSHandshake

func (c *Conn) TLSHandshake() error

Extra method - Do a TLS Handshake and record progress

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

Delegate here, but record all the things

type ConnectEvent

type ConnectEvent struct {
}

func (*ConnectEvent) GetType

func (ce *ConnectEvent) GetType() EventType

func (*ConnectEvent) MarshalJSON

func (ce *ConnectEvent) MarshalJSON() ([]byte, error)

func (*ConnectEvent) UnmarshalJSON

func (ce *ConnectEvent) UnmarshalJSON([]byte) error

type ConnectionEvent

type ConnectionEvent struct {
	Data  EventData
	Error error
}

func (*ConnectionEvent) MarshalJSON

func (ce *ConnectionEvent) MarshalJSON() ([]byte, error)

func (*ConnectionEvent) UnmarshalJSON

func (ce *ConnectionEvent) UnmarshalJSON(b []byte) error

type Dialer

type Dialer struct {
	Deadline  time.Time
	Timeout   time.Duration
	LocalAddr net.Addr
	DualStack bool
	KeepAlive time.Duration
}

func (*Dialer) Dial

func (d *Dialer) Dial(network, address string) (*Conn, error)

type EHLOEvent

type EHLOEvent struct {
	Domain   string `json:"-"`
	Response string `json:"response"`
}

An EHLOEvent represents the response to an EHLO

func (*EHLOEvent) GetType

func (e *EHLOEvent) GetType() EventType

type EventData

type EventData interface {
	GetType() EventType
}

type EventType

type EventType struct {
	TypeName         string
	GetEmptyInstance func() EventData
}

func EventTypeFromName

func EventTypeFromName(name string) (EventType, error)

func (EventType) MarshalJSON

func (e EventType) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

type ExceptionCode

type ExceptionCode byte

type ExceptionFunctionCode

type ExceptionFunctionCode byte

func (ExceptionFunctionCode) FunctionCode

func (e ExceptionFunctionCode) FunctionCode() FunctionCode

type ExceptionResponse

type ExceptionResponse struct {
	ExceptionFunction FunctionCode `json:"exception_function"`
	ExceptionType     byte         `json:"exception_type"`
}

type FTPBannerEvent

type FTPBannerEvent struct {
	Banner string `json:"banner",omitempty`
}

func (*FTPBannerEvent) GetType

func (f *FTPBannerEvent) GetType() EventType

type FunctionCode

type FunctionCode byte

func (FunctionCode) ExceptionFunctionCode

func (c FunctionCode) ExceptionFunctionCode() ExceptionFunctionCode

func (FunctionCode) IsException

func (c FunctionCode) IsException() bool

type Grab

type Grab struct {
	Host   net.IP            `json:"host"`
	Domain string            `json:"domain"`
	Time   time.Time         `json:"timestamp"`
	Log    []ConnectionEvent `json:"log"`
}

func GrabBanner

func GrabBanner(config *Config, target *GrabTarget) *Grab

func (*Grab) MarshalJSON

func (g *Grab) MarshalJSON() ([]byte, error)

func (*Grab) UnmarshalJSON

func (g *Grab) UnmarshalJSON(b []byte) error

type GrabTarget

type GrabTarget struct {
	Addr   net.IP
	Domain string
}

type GrabWorker

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

GrabWorker implements ztools.processing.Worker

func (*GrabWorker) Done

func (g *GrabWorker) Done()

func (*GrabWorker) Failure

func (g *GrabWorker) Failure() uint

func (*GrabWorker) MakeHandler

func (g *GrabWorker) MakeHandler(id uint) processing.Handler

func (*GrabWorker) RunCount

func (g *GrabWorker) RunCount() uint

func (*GrabWorker) Success

func (g *GrabWorker) Success() uint

func (*GrabWorker) Total

func (g *GrabWorker) Total() uint

type HTTPGETEvent

type HTTPGETEvent struct {
	Headers []string `json:"headers"`
	Body    string   `json:"body"`
}

func (*HTTPGETEvent) GetType

func (h *HTTPGETEvent) GetType() EventType

type HeartbleedEvent

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

func (*HeartbleedEvent) GetType

func (h *HeartbleedEvent) GetType() EventType

func (*HeartbleedEvent) HeartbleedLog

func (h *HeartbleedEvent) HeartbleedLog() *ztls.Heartbleed

func (*HeartbleedEvent) MarshalJSON

func (h *HeartbleedEvent) MarshalJSON() ([]byte, error)

func (*HeartbleedEvent) UnmarshalJSON

func (h *HeartbleedEvent) UnmarshalJSON(b []byte) error

type MEIObject

type MEIObject struct {
	OID   MEIObjectID
	Value string
}

func (*MEIObject) MarshalJSON

func (m *MEIObject) MarshalJSON() ([]byte, error)

type MEIObjectID

type MEIObjectID int
const (
	OIDVendor              MEIObjectID = 0
	OIDProductCode         MEIObjectID = 1
	OIDRevision            MEIObjectID = 2
	OIDVendorURL           MEIObjectID = 3
	OIDProductName         MEIObjectID = 4
	OIDModelName           MEIObjectID = 5
	OIDUserApplicationName MEIObjectID = 6
)

func (*MEIObjectID) Name

func (m *MEIObjectID) Name() string

type MEIObjectSet

type MEIObjectSet []MEIObject

func (*MEIObjectSet) MarshalJSON

func (ms *MEIObjectSet) MarshalJSON() ([]byte, error)

type MEIResponse

type MEIResponse struct {
	ConformityLevel int          `json:"conformity_level"`
	MoreFollows     bool         `json:"more_follows"`
	ObjectCount     int          `json:"object_count"`
	Objects         MEIObjectSet `json:"objects"`
}

type MailBannerEvent

type MailBannerEvent struct {
	Banner string
}

func (*MailBannerEvent) GetType

func (mb *MailBannerEvent) GetType() EventType

func (*MailBannerEvent) MarshalJSON

func (mb *MailBannerEvent) MarshalJSON() ([]byte, error)

func (*MailBannerEvent) UnmarshalJSON

func (mb *MailBannerEvent) UnmarshalJSON(b []byte) error

type ModbusEvent

type ModbusEvent struct {
	Length           int                `json:"length"`
	UnitID           int                `json:"unit_id"`
	Function         FunctionCode       `json:"function_code"`
	Response         []byte             `json:"raw_response"`
	MEIResponse      *MEIResponse       `json:"mei_response,omitempty"`
	ExceptionReponse *ExceptionResponse `json:"exception_response,omitempty"`
}

func (*ModbusEvent) GetType

func (m *ModbusEvent) GetType() EventType

func (*ModbusEvent) IsException

func (m *ModbusEvent) IsException() bool

func (*ModbusEvent) ParseSelf

func (m *ModbusEvent) ParseSelf()

type ModbusException

type ModbusException struct {
	Function      ExceptionFunctionCode
	ExceptionType ExceptionCode
}

type ModbusRequest

type ModbusRequest struct {
	Function FunctionCode
	Data     []byte
}

func (*ModbusRequest) MarshalBinary

func (r *ModbusRequest) MarshalBinary() (data []byte, err error)

type ModbusResponse

type ModbusResponse struct {
	Length   int
	UnitID   int
	Function FunctionCode
	Data     []byte
}

type OutputConfig

type OutputConfig struct {
	OutputFile *os.File
	ErrorLog   *log.Logger
}

type ReadEvent

type ReadEvent struct {
	Response []byte
	// contains filtered or unexported fields
}

func (*ReadEvent) GetType

func (r *ReadEvent) GetType() EventType

func (*ReadEvent) MarshalJSON

func (r *ReadEvent) MarshalJSON() ([]byte, error)

func (*ReadEvent) UnmarshalJSON

func (r *ReadEvent) UnmarshalJSON(b []byte) error

type SMTPHelpEvent

type SMTPHelpEvent struct {
	Response string
}

An SMTPHelpEvent represents sending a "HELP" message over SMTP

func (*SMTPHelpEvent) GetType

func (h *SMTPHelpEvent) GetType() EventType

type SSHEvent

type SSHEvent struct {
	Handshake *ssh.HandshakeLog `json:"handshake"`
}

func (*SSHEvent) GetType

func (s *SSHEvent) GetType() EventType

type SSHScanConfig

type SSHScanConfig struct {
	SSH               bool
	Client            string
	KexAlgorithms     string
	HostKeyAlgorithms string
}

func (*SSHScanConfig) GetClientImplementation

func (sc *SSHScanConfig) GetClientImplementation() (*ssh.ClientImplementation, bool)

func (*SSHScanConfig) MakeConfig

func (sc *SSHScanConfig) MakeConfig() *ssh.Config

func (*SSHScanConfig) MakeHostKeyNameList

func (sc *SSHScanConfig) MakeHostKeyNameList() (ssh.NameList, error)

func (*SSHScanConfig) MakeKexNameList

func (sc *SSHScanConfig) MakeKexNameList() (ssh.NameList, error)

type StartTLSEvent

type StartTLSEvent struct {
	Command  string `json:"-"`
	Response string `json:"response"`
}

A StartTLSEvent represents sending a StartTLS

func (*StartTLSEvent) GetType

func (s *StartTLSEvent) GetType() EventType

type TLSHandshakeEvent

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

HandshakeEvent implements the EventData interface

func (*TLSHandshakeEvent) GetHandshakeLog

func (he *TLSHandshakeEvent) GetHandshakeLog() *ztls.ServerHandshake

func (*TLSHandshakeEvent) GetType

func (he *TLSHandshakeEvent) GetType() EventType

func (*TLSHandshakeEvent) MarshalJSON

func (he *TLSHandshakeEvent) MarshalJSON() ([]byte, error)

func (*TLSHandshakeEvent) UnmarshalJSON

func (he *TLSHandshakeEvent) UnmarshalJSON(b []byte) error

type WriteEvent

type WriteEvent struct {
	Sent  []byte
	Error error
}

func (*WriteEvent) GetType

func (w *WriteEvent) GetType() EventType

func (*WriteEvent) MarshalJSON

func (w *WriteEvent) MarshalJSON() ([]byte, error)

func (*WriteEvent) UnmarshalJSON

func (w *WriteEvent) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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