rnd

package
v0.0.0-...-aeaa209 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EgressDestinationIPv4 = "1.1.1.1"

EgressDestinationIPv4 defines an internet-reachable IPv4 address (currently cloudflare)

View Source
var EgressDestinationIPv6 = "[2606:4700:4700::1111]"

EgressDestinationIPv6 defines an internet-reachable IPv6 address (currently cloudflare)

View Source
var MatchHostname = regexp.MustCompile(`^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$`)

MatchHostname is a regular expression for validating hostnames

View Source
var MatchIPv4 = regexp.MustCompile(`^(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))$`)

MatchIPv4 is a regular expression for validating IPv4 addresses

View Source
var MatchIPv6 = regexp.MustCompile(`^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?$`)

MatchIPv6 is a regular expression for validating IPv6 addresses

View Source
var ObfuscationKey32 uint32 = 0x50505050

ObfuscationKey32 provides an XOR key for encoding

View Source
var ObfuscationKey32Bytes = [4]byte{}

ObfuscationKey32Bytes are the 32-bit XOR key as a byte array

View Source
var ObfuscationKey64 uint64 = 0x5050505050505050

ObfuscationKey64 provides an XOR key for encoding

View Source
var ObfuscationKey64Bytes = [8]byte{}

ObfuscationKey64Bytes are the 64-bit XOR key as a byte array

View Source
var SMB1NegotiateProtocolRequest = []byte{}/* 216 elements not displayed */

SMB1NegotiateProtocolRequest is a SMB1 request that advertises support for SMB2

View Source
var SMB1OnlyNegotiateProtocolRequest = []byte{}/* 194 elements not displayed */

SMB1OnlyNegotiateProtocolRequest is a SMB1 request

View Source
var SMB1SessionSetupNTLMSSP = []byte{}/* 160 elements not displayed */

SMB1SessionSetupNTLMSSP is a SMB1 SessionSetup NTLMSSP request

View Source
var SMB2SessionSetupNTLMSSP = []byte{}/* 166 elements not displayed */

SMB2SessionSetupNTLMSSP is a SMB2 SessionSetup NTLMSSP request

View Source
var SMBReadTimeout = time.Second * 2

SMBReadTimeout sets a default timeout for read operations

Functions

func AddressCountFromCIDR

func AddressCountFromCIDR(cidr string) (uint64, error)

AddressCountFromCIDR parses a CIDR and returns the numnber of included IP addresses

func AddressesFromCIDR

func AddressesFromCIDR(cidr string, out chan string, quit chan int) error

AddressesFromCIDR parses a CIDR and writes individual IPs to a channel

func Bytes2IPv4

func Bytes2IPv4(ipb []byte) string

Bytes2IPv4 converts a byte array to an IPv4 addresse

func BytesToTimestamp

func BytesToTimestamp(b []byte) time.Time

BytesToTimestamp converts an 8-byte array to a timestamp

func CrackPorts

func CrackPorts(pspec string) ([]int, error)

CrackPorts turns a comma-delimited port list into an array

func EnsureTrailingDot

func EnsureTrailingDot(s string) string

EnsureTrailingDot returns a copy of the string with a trailing dot, if one does not exist

func GetEgressAddress

func GetEgressAddress(dst string) string

GetEgressAddress return the IPv4 or IPv6 address used to route to the specified destination

func IPv42Bytes

func IPv42Bytes(ips string) ([]byte, error)

IPv42Bytes converts an IPv4 address to a byte array

func IPv42UInt

func IPv42UInt(ips string) (uint32, error)

IPv42UInt converts IPv4 addresses to unsigned integers

func IPv42UIntLE

func IPv42UIntLE(ips string) (uint32, error)

IPv42UIntLE converts IPv4 addresses to unsigned integers (little endian)

func ObfuscateBytes4

func ObfuscateBytes4(b []byte) []byte

ObfuscateBytes4 XORs a 4-byte array with the obfuscation key

func ObfuscateBytes8

func ObfuscateBytes8(b []byte) []byte

ObfuscateBytes8 XORs a 8-byte array with the obfuscation key

func ObfuscateIPv4FromBytesToBytes

func ObfuscateIPv4FromBytesToBytes(ipb []byte) []byte

ObfuscateIPv4FromBytesToBytes XORs an IPv4 byte array with the obfuscation key

func ObfuscateIPv4FromBytesToString

func ObfuscateIPv4FromBytesToString(ipb []byte) string

ObfuscateIPv4FromBytesToString XORs an IPv4 string with the obfuscation key, returning a string

func ObfuscateIPv4FromStringToBytes

func ObfuscateIPv4FromStringToBytes(ip string) []byte

ObfuscateIPv4FromStringToBytes XORs an IPv4 string with the obfuscation key, returning bytes

func ObfuscateIPv4FromStringToString

func ObfuscateIPv4FromStringToString(ip string) string

ObfuscateIPv4FromStringToString XORs an IPv4 string with the obfuscation key, returning a string

func RandomBytes

func RandomBytes(numbytes int) []byte

RandomBytes generates a random byte sequence of the requested length

func RandomizeObfuscationKeys

func RandomizeObfuscationKeys()

RandomizeObfuscationKeys resets the default obfuscation keys

func SMB1ExtractNativeFieldsFromSessionSetupReply

func SMB1ExtractNativeFieldsFromSessionSetupReply(blob []byte, info map[string]string)

SMB1ExtractNativeFieldsFromSessionSetupReply tries to extract NativeOS/NativeLM fields from a SMB1 session setup response

func SMB2ExtractFieldsFromNegotiateReply

func SMB2ExtractFieldsFromNegotiateReply(blob []byte, info map[string]string)

SMB2ExtractFieldsFromNegotiateReply extracts useful fields from the SMB2 negotiate response

func SMB2ExtractSIDFromSessionSetupReply

func SMB2ExtractSIDFromSessionSetupReply(blob []byte, info map[string]string)

SMB2ExtractSIDFromSessionSetupReply tries to extract the SessionID and Signature from a SMB2 reply

func SMB2NegotiateProtocolRequest

func SMB2NegotiateProtocolRequest(dst string) []byte

SMB2NegotiateProtocolRequest generates a new Negotiate request with the specified target name

func SMB2ParseNegotiateContext

func SMB2ParseNegotiateContext(t int, data []byte, info map[string]string)

SMB2ParseNegotiateContext decodes fields from the SMB2 Negotiate Context values

func SMBExtractFieldsFromSecurityBlob

func SMBExtractFieldsFromSecurityBlob(blob []byte, info map[string]string)

SMBExtractFieldsFromSecurityBlob extracts fields from the NTLMSSP response

func SMBExtractValueFromOffset

func SMBExtractValueFromOffset(blob []byte, idx int) ([]byte, int, error)

SMBExtractValueFromOffset peels a field out of a SMB buffer

func SMBReadFrame

func SMBReadFrame(conn net.Conn, t time.Duration) ([]byte, error)

SMBReadFrame reads the netbios header then the full response

func SMBSendData

func SMBSendData(conn net.Conn, data []byte) error

SMBSendData writes a SMB request to a socket

func SanitizeStringForJSON

func SanitizeStringForJSON(str string) string

SanitizeStringForJSON scrubs a given string of invalid UTF8 for JSON encoding

func SeedMathRand

func SeedMathRand()

SeedMathRand seeds the PRNG for things like transaction IDs

func TimestampToBytes

func TimestampToBytes(t time.Time) []byte

TimestampToBytes converts a timestamp to an 8-byte array

func TrimName

func TrimName(name string) string

TrimName removes null bytes and trims leading and trailing spaces from a string

func U64SliceToSeq

func U64SliceToSeq(s []uint64) string

U64SliceToSeq turns an array of ints into a hex string

func UInt2IPv4

func UInt2IPv4(ipi uint32) string

UInt2IPv4 converts unsigned integers to IPv4 addresses

func ValidIP

func ValidIP(addr string) bool

ValidIP returns a true/false on whether the input is a valid IPv4 or IPv6 address

func ValidIP4

func ValidIP4(addr string) bool

ValidIP4 returns a true/false on whether the input is a valid IPv4 address

func ValidIP6

func ValidIP6(addr string) bool

ValidIP6 returns a true/false on whether the input is a valid IPv6 address

func ValidPort

func ValidPort(pnum int) bool

ValidPort determines if a port number is valid

func XorBytesWithBytes

func XorBytesWithBytes(src []byte, key []byte) []byte

XorBytesWithBytes xor encodes a byte array with another byte array

Types

type CounterPredictor

type CounterPredictor struct {
	MinRep int
	MinLen int
	// contains filtered or unexported fields
}

CounterPredictor tries to predict the next sequence based on a detected cyclical pattern

func NewCounterPredictor

func NewCounterPredictor(rep int, len int) *CounterPredictor

NewCounterPredictor returns a new instance of the predictor

func (*CounterPredictor) Check

func (c *CounterPredictor) Check(v uint64) ([]uint64, error)

Check submits a new value and returns the list of missing sequences if any

func (*CounterPredictor) GetCycle

func (c *CounterPredictor) GetCycle() []uint64

GetCycle returns the predicted cycle

func (*CounterPredictor) GetSampleCount

func (c *CounterPredictor) GetSampleCount() int

GetSampleCount returns the number of samples stored

func (*CounterPredictor) Previous

func (c *CounterPredictor) Previous(v uint64) (uint64, error)

Previous rolls back to the prior session ID using the predicted counter

func (*CounterPredictor) Ready

func (c *CounterPredictor) Ready() bool

Ready indicates if the predictor has calculted the cycle

func (*CounterPredictor) SubmitSample

func (c *CounterPredictor) SubmitSample(v uint64) bool

SubmitSample is used to train the predictor

Jump to

Keyboard shortcuts

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