utils

package
v0.0.0-...-7fb8fc3 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2019 License: Apache-2.0 Imports: 17 Imported by: 164

Documentation

Index

Constants

View Source
const (
	// IPv4RE is a regular expression that will match an IPv4 address.
	IPv4RE = "((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.]){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"

	// SUBRE is a regular expression that will match on all subdomains once the domain is appended.
	SUBRE = "(([a-zA-Z0-9]{1}|[_a-zA-Z0-9]{1}[_a-zA-Z0-9-]{0,61}[a-zA-Z0-9]{1})[.]{1})+"
)
View Source
const (
	// UserAgent is the default user agent used by Amass during HTTP requests.
	UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36"

	// Accept is the default HTTP Accept header value used by Amass.
	Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"

	// AcceptLang is the default HTTP Accept-Language header value used by Amass.
	AcceptLang = "en-US,en;q=0.8"
)

Variables

This section is empty.

Functions

func AnySubdomainRegex

func AnySubdomainRegex() *regexp.Regexp

AnySubdomainRegex returns a Regexp object initialized to match any DNS subdomain name.

func CIDRSubset

func CIDRSubset(cidr *net.IPNet, addr string, num int) []net.IP

CIDRSubset returns a subset of the IP addresses contained within the cidr parameter with num elements around the addr element.

func CheckCookie

func CheckCookie(urlString string, cookieName string) bool

CheckCookie checks if a cookie exists in the cookie jar for a given host

func CopyCookies

func CopyCookies(src string, dest string)

CopyCookies copies cookies from one domain to another. Some of our data sources rely on shared auth tokens and this avoids sending extra requests to have the site reissue cookies for the other domains.

func CopyString

func CopyString(src string) string

CopyString return a new string variable with the same value as the parameter.

func HexString

func HexString(b []byte) string

HexString returns a string that is the hex representation of the byte slice parameter.

func IPv6NibbleFormat

func IPv6NibbleFormat(ip string) string

IPv6NibbleFormat expects an IPv6 address in the ip parameter and returns the address in nibble format.

func IsIPv4

func IsIPv4(ip net.IP) bool

IsIPv4 returns true when the provided net.IP address is an IPv4 address.

func IsIPv6

func IsIPv6(ip net.IP) bool

IsIPv6 returns true when the provided net.IP address is an IPv6 address.

func NetFirstLast

func NetFirstLast(cidr *net.IPNet) (net.IP, net.IP)

NetFirstLast return the first and last IP address of the provided CIDR/netblock.

func NetHosts

func NetHosts(cidr *net.IPNet) []net.IP

NetHosts returns a slice containing all the IP addresses within the CIDR provided by the parameter. This implementation was obtained/modified from the following: https://gist.github.com/kotakanbe/d3059af990252ba89a82

func NewUniqueElements

func NewUniqueElements(orig []string, add ...string) []string

NewUniqueElements removes elements that have duplicates in the original or new elements.

func RangeHosts

func RangeHosts(start, end net.IP) []net.IP

RangeHosts returns all the IP addresses (inclusive) between the start and stop addresses provided by the parameters.

func RemoveAsteriskLabel

func RemoveAsteriskLabel(s string) string

RemoveAsteriskLabel returns the provided DNS name with all asterisk labels removed.

func RequestWebPage

func RequestWebPage(urlstring string, body io.Reader, hvals map[string]string, uid, secret string) (string, error)

RequestWebPage returns a string containing the entire response for the urlstring parameter when successful.

func ReverseIP

func ReverseIP(ip string) string

ReverseIP returns an IP address that is the ip parameter with the numbers reversed.

func SubdomainRegex

func SubdomainRegex(domain string) *regexp.Regexp

SubdomainRegex returns a Regexp object initialized to match subdomain names that end with the domain provided by the parameter.

func UniqueAppend

func UniqueAppend(orig []string, add ...string) []string

UniqueAppend behaves like the Go append, but does not add duplicate elements.

Types

type ParseCIDRs

type ParseCIDRs []*net.IPNet

ParseCIDRs implements the flag.Value interface.

func (*ParseCIDRs) Set

func (p *ParseCIDRs) Set(s string) error

Set implements the flag.Value interface.

func (*ParseCIDRs) String

func (p *ParseCIDRs) String() string

type ParseIPs

type ParseIPs []net.IP

ParseIPs implements the flag.Value interface.

func (*ParseIPs) Set

func (p *ParseIPs) Set(s string) error

Set implements the flag.Value interface.

func (*ParseIPs) String

func (p *ParseIPs) String() string

type ParseInts

type ParseInts []int

ParseInts implements the flag.Value interface.

func (*ParseInts) Set

func (p *ParseInts) Set(s string) error

Set implements the flag.Value interface.

func (*ParseInts) String

func (p *ParseInts) String() string

type ParseStrings

type ParseStrings []string

ParseStrings implements the flag.Value interface.

func (*ParseStrings) Set

func (p *ParseStrings) Set(s string) error

Set implements the flag.Value interface.

func (*ParseStrings) String

func (p *ParseStrings) String() string

type Queue

type Queue struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Queue implements a FIFO data structure.

func NewQueue

func NewQueue() *Queue

NewQueue returns a Queue FIFO data structure.

func (*Queue) Append

func (q *Queue) Append(data interface{})

Append adds the data to the end of the Queue.

func (*Queue) Empty

func (q *Queue) Empty() bool

Empty return true if the Queue is empty.

func (*Queue) Len

func (q *Queue) Len() int

Len returns the current length of the Queue

func (*Queue) Next

func (q *Queue) Next() (interface{}, bool)

Next returns the data at the front of the Queue.

type Semaphore

type Semaphore interface {
	// Acquire blocks until num resource counts have been obtained
	Acquire(num int)

	// TryAcquire attempts to obtain num resource counts without blocking
	TryAcquire(num int) bool

	// Release causes num resource counts to be released
	Release(num int)
}

Semaphore is the interface for the several types of semaphore implemented by Amass.

func NewSimpleSemaphore

func NewSimpleSemaphore(max int) Semaphore

NewSimpleSemaphore returns a SimpleSemaphore initialized to max resource counts.

func NewTimedSemaphore

func NewTimedSemaphore(max int, delay time.Duration) Semaphore

NewTimedSemaphore returns a TimedSemaphore initialized to max resource counts and delay release frequency.

type SimpleSemaphore

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

SimpleSemaphore implements a synchronization object type capable of being a counting semaphore.

func (*SimpleSemaphore) Acquire

func (s *SimpleSemaphore) Acquire(num int)

Acquire blocks until num resource counts have been obtained.

func (*SimpleSemaphore) Release

func (s *SimpleSemaphore) Release(num int)

Release causes num resource counts to be released.

func (*SimpleSemaphore) TryAcquire

func (s *SimpleSemaphore) TryAcquire(num int) bool

TryAcquire attempts to obtain num resource counts without blocking. The method returns true when successful in acquiring the resource counts.

type StringFilter

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

StringFilter implements an object that performs filtering of strings to ensure that only unique items get through the filter.

func NewStringFilter

func NewStringFilter() *StringFilter

NewStringFilter returns an initialized StringFilter.

func (*StringFilter) Duplicate

func (sf *StringFilter) Duplicate(s string) bool

Duplicate checks if the name provided has been seen before by this filter.

type TimedSemaphore

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

TimedSemaphore implements a synchronization object type capable of being a counting semaphore.

func (*TimedSemaphore) Acquire

func (t *TimedSemaphore) Acquire(num int)

Acquire blocks until num resource counts have been obtained.

func (*TimedSemaphore) Release

func (t *TimedSemaphore) Release(num int)

Release causes num resource counts to be released.

func (*TimedSemaphore) TryAcquire

func (t *TimedSemaphore) TryAcquire(num int) bool

TryAcquire attempts to obtain num resource counts without blocking. The method returns true when successful in acquiring the resource counts.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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