utils

package
v0.0.0-...-2f5a5ad Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolICMP = 1 // from golang.org/x/net/internal/iana, can't import Golang internal packages

	ErrNoMagic       = NoMagicError("packet does not contain magic")
	ErrWrongICMPType = WrongICMPTypeError("packet has unexpected ICMP type")
)

Variables

This section is empty.

Functions

func Close

func Close(closable io.Closer)

Utiliy to close an object that implements the `io.Closer` interface. Used over `object.Close()` for automatic error checking.

func DecryptContent

func DecryptContent(rawContent []byte) ([]byte, error)

func GetICMPData

func GetICMPData(conn net.PacketConn) ([]byte, icmp.Type, net.Addr, error)

Returns the decrypted message (C2 command) contained in the ICMP request.

func ICMPDataReceived

func ICMPDataReceived(conn net.PacketConn, target net.IP, sentData []byte) error

Ensure we receive an Echo Reply to confirm that the data has been received on the other end.

Returns an error if data could not be received or if an error occurred while processing the Echo Reply. Otherwise, nil.

func ListenICMP

func ListenICMP(listenAddress string) (net.PacketConn, error)

Creates and returns an ICMP connection to read from and write to.

func SendICMPData

func SendICMPData(conn net.PacketConn, target net.Addr, data []byte) (time.Time, error)

Send a command to the target.

Resource: Simple utility package to send ICMP pings with Go - https://gist.github.com/lmas/c13d1c9de3b2224f9c26435eb56e6ef3

func ValidateICMPPacket

func ValidateICMPPacket(srcAddr net.Addr, dstIP net.IP) error

func XorEncryptDecryptBytes

func XorEncryptDecryptBytes(input, key []byte) (output []byte)

Types

type IncompleteSendError

type IncompleteSendError struct {
	Sent  int
	Total int
}

func (IncompleteSendError) Error

func (e IncompleteSendError) Error() string

type NoMagicError

type NoMagicError string

func (NoMagicError) Error

func (e NoMagicError) Error() string

type WrongICMPTypeError

type WrongICMPTypeError string

func (WrongICMPTypeError) Error

func (e WrongICMPTypeError) Error() string

type WrongReplyCommandError

type WrongReplyCommandError struct {
	Sent     string
	Received string
}

func (WrongReplyCommandError) Error

func (e WrongReplyCommandError) Error() string

type WrongReplyIPError

type WrongReplyIPError struct {
	SrcAddr  net.Addr
	TargetIP net.IP
}

func (WrongReplyIPError) Error

func (e WrongReplyIPError) Error() string

Jump to

Keyboard shortcuts

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