dnsclient

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTimeout         = errors.New("{{if .Config.Debug}}DNS Timeout{{end}}")
	ErrClosed          = errors.New("dns session closed")
	ErrInvalidResponse = errors.New("invalid response")
	ErrInvalidIndex    = errors.New("invalid start/stop index")
	ErrEmptyResponse   = errors.New("empty response")
	ErrInvalidMsg      = errors.New("invalid dns message")
)
View Source
var (
	// ErrInvalidRcode - Returned when the response code is not a success
	ErrInvalidRcode = errors.New("invalid rcode")
)

Functions

This section is empty.

Types

type DNSOptions

type DNSOptions struct {
	QueryTimeout       time.Duration
	RetryWait          time.Duration
	RetryCount         int
	MaxErrors          int
	WorkersPerResolver int
	ForceBase32        bool
	NoTXT              bool
	ForceResolvConf    string
	ForceResolvers     string
}

DNSOptions - c2 specific options

func ParseDNSOptions

func ParseDNSOptions(c2URI *url.URL) *DNSOptions

ParseDNSOptions - Parse c2 specific options

type DNSResolver

type DNSResolver interface {
	Address() string
	A(string) ([]byte, time.Duration, error)
	AAAA(string) ([]byte, time.Duration, error)
	TXT(string) ([]byte, time.Duration, error)
}

Abstraction on top of miekg/dns and net/dns

func NewGenericResolver

func NewGenericResolver(address string, port string, retryWait time.Duration, retries int, timeout time.Duration, parent string) DNSResolver

NewGenericResolver - Instantiate a new generic resolver

func NewSystemResolver

func NewSystemResolver() DNSResolver

NewSystemResolver - Initialize a new system resolver

type DNSResult

type DNSResult struct {
	Data []byte
	Err  error
}

DNSResult - Result of a DNSWork unit

type DNSWork

type DNSWork struct {
	QueryType uint16
	Domain    string
	Wg        *sync.WaitGroup
	Results   chan *DNSResult
}

DNSWork - Single unit of work for DNSWorker

type DNSWorker

type DNSWorker struct {
	Metadata *ResolverMetadata
	Ctrl     chan struct{}
	// contains filtered or unexported fields
}

DNSWorker - Used for parallel send/recv

func (*DNSWorker) Start

func (w *DNSWorker) Start(id int, recvQueue <-chan *DNSWork, sendQueue <-chan *DNSWork)

Start - Starts with worker with a given queue

type GenericResolver

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

GenericResolver - Cross-platform Go DNS resolver

func (*GenericResolver) A

func (r *GenericResolver) A(domain string) ([]byte, time.Duration, error)

A - Query for A records

func (*GenericResolver) AAAA

func (r *GenericResolver) AAAA(domain string) ([]byte, time.Duration, error)

AAAA - Query for AAAA records

func (*GenericResolver) Address

func (r *GenericResolver) Address() string

Address - Return the address of the resolver

func (*GenericResolver) TXT

func (r *GenericResolver) TXT(domain string) ([]byte, time.Duration, error)

TXT - Query for TXT records

type ResolverMetadata

type ResolverMetadata struct {
	Address      string
	EnableBase58 bool
	Metrics      []time.Duration
	Errors       int
}

ResolverMetadata - Metadata for the resolver

type SliverDNSClient

type SliverDNSClient struct {
	WorkersPerResolver int
	// contains filtered or unexported fields
}

SliverDNSClient - The DNS client context

func DNSStartSession

func DNSStartSession(parent string, opts *DNSOptions) (*SliverDNSClient, error)

DNSStartSession - Attempt to establish a connection to the DNS server of 'parent'

func NewDNSClient

func NewDNSClient(parent string, opts *DNSOptions) *SliverDNSClient

NewDNSClient - Initialize a new DNS client, generally you should use DNSStartSession instead of this function, this is exported mostly for unit testing

func (*SliverDNSClient) CloseSession

func (s *SliverDNSClient) CloseSession() error

Close - Close the dns session

func (*SliverDNSClient) ReadEnvelope

func (s *SliverDNSClient) ReadEnvelope() (*pb.Envelope, error)

ReadEnvelope - Recv an envelope from the server

func (*SliverDNSClient) SessionInit

func (s *SliverDNSClient) SessionInit() error

SessionInit - Initialize DNS session

func (*SliverDNSClient) SplitBuffer

func (s *SliverDNSClient) SplitBuffer(msg *dnspb.DNSMessage, encoder encoders.Encoder, data []byte) ([]string, error)

SplitBuffer - There's probably a fancy way to calculate this with math and shit but it's much easier to just encode bytes and check the length until we hit the limit

func (*SliverDNSClient) WriteEnvelope

func (s *SliverDNSClient) WriteEnvelope(envelope *pb.Envelope) error

WriteEnvelope - Send an envelope to the server

type SystemResolver

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

SystemResolver -

func (*SystemResolver) A

func (r *SystemResolver) A(domain string) ([]byte, time.Duration, error)

A - Query for A records

func (*SystemResolver) AAAA

func (r *SystemResolver) AAAA(domain string) ([]byte, time.Duration, error)

AAAA - Query for AAAA records

func (*SystemResolver) Address

func (r *SystemResolver) Address() string

Address - Returns the address of the resolver

func (*SystemResolver) TXT

func (r *SystemResolver) TXT(domain string) ([]byte, time.Duration, error)

TXT - Query for TXT records

Jump to

Keyboard shortcuts

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