utils

package
v1.2.7-sp3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: AGPL-3.0 Imports: 80 Imported by: 6

Documentation

Overview

Package bytefmt contains helper methods and constants for converting to and from a human-readable byte format.

bytefmt.ByteSize(100.5*bytefmt.MEGABYTE) // "100.5M"
bytefmt.ByteSize(uint64(1024)) // "1K"

sshclient implements an ssh client

Index

Examples

Constants

View Source
const (
	BYTE = 1 << (10 * iota)
	KILOBYTE
	MEGABYTE
	GIGABYTE
	TERABYTE
	PETABYTE
	EXABYTE
)
View Source
const (
	AllSepcialChars = ",./<>?;':\"[]{}`~!@#$%^&*()_+-=\\|"
	LittleChar      = "abcdefghijklmnopqrstuvwxyz"
	BigChar         = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	NumberChar      = "1234567890"
)
View Source
const CRLF = "\r\n"
View Source
const DefaultDateFormat = "2006-01-02"
View Source
const DefaultTimeFormat = "2006_01_02-15_04_05"
View Source
const DefaultTimeFormat2 = "20060102_15_04_05"

Variables

View Source
var BashCompleteScriptTpl = `` /* 1147-byte string literal not displayed */
View Source
var GBKSafeString = codec.GBKSafeString
View Source
var GbkToUtf8 = codec.GbkToUtf8
View Source
var ParseStringToInts = ParseStringToPorts
View Source
var (
	TargetIsLoopback = Errorf("loopback")
)
View Source
var Utf8ToGbk = codec.Utf8ToGbk
View Source
var WaitBySignal = func(fn func(), sigs ...os.Signal) {
	sigC := NewSignalChannel(sigs...)
	defer signal.Stop(sigC)

	for {
		select {
		case <-sigC:
			log.Warn("recv signal abort")
			fn()
			return
		}
	}
}
View Source
var WaitReleaseBySignal = func(fn func()) {
	sigC := NewSignalChannel(os.Interrupt, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL)
	defer signal.Stop(sigC)

	for {
		select {
		case <-sigC:
			log.Warn("recv signal abort")
			fn()
			return
		}
	}
}
View Source
var ZshCompleteScriptTpl = `` /* 1072-byte string literal not displayed */

Functions

func AddressFamilyUint32ToString

func AddressFamilyUint32ToString(i uint32) string

func AppendDefaultPort added in v1.2.3

func AppendDefaultPort(raw string, port int) string

AppendDefaultPort returns host:port format. If the port is already specified in the host, it will be returned directly. wss -> 443 ws -> 80 http -> 80 https -> 443

func AsciiBytesToRegexpMatchedRunes

func AsciiBytesToRegexpMatchedRunes(in []byte) []rune

func AsciiBytesToRegexpMatchedString

func AsciiBytesToRegexpMatchedString(in []byte) string

func AsciiEqualFold

func AsciiEqualFold(s, t string) bool

AsciiEqualFold is strings.EqualFold, ASCII only. It reports whether s and t are equal, ASCII-case-insensitively.

func AsciiToLower

func AsciiToLower(s string) (lower string, ok bool)

asciiToLower returns the lowercase version of s if s is ASCII and printable, and whether or not it was.

func BKDRHash

func BKDRHash(str []byte) uint32

BKDR Hash Function

func BufioReadLine

func BufioReadLine(reader *bufio.Reader) ([]byte, error)

func ByteCountBinary

func ByteCountBinary(b int64) string

func ByteCountDecimal

func ByteCountDecimal(b int64) string

func ByteSize

func ByteSize(bytes uint64) string

ByteSize returns a human-readable byte string of the form 10M, 12.5K, and so forth. The following units are available:

E: Exabyte
P: Petabyte
T: Terabyte
G: Gigabyte
M: Megabyte
K: Kilobyte
B: Byte

The unit that results in the smallest number greater than or equal to 1 is always chosen.

func BytesClone

func BytesClone(raw []byte) (newBytes []byte)

func CacheFunc added in v1.2.7

func CacheFunc[T any](t time.Duration, f func() (T, error)) func() (T, error)

CacheFunc do cache and retry It's used for unstable func.

func CalcFaviconHash

func CalcFaviconHash(urlRaw string) (string, error)

func CalcMd5

func CalcMd5(items ...interface{}) string

func CalcSSDeepStability

func CalcSSDeepStability(req ...[]byte) (float64, error)

稳定性定义为最远距离 / 最低分数

func CalcSha1

func CalcSha1(items ...interface{}) string

func CalcSha1WithSuffix

func CalcSha1WithSuffix(items []interface{}, suffix string) string

func CalcSha256 added in v1.2.8

func CalcSha256(items ...interface{}) string

func CalcSimHashStability

func CalcSimHashStability(req ...[]byte) (float64, error)

计算 simhash 稳定性

func CalcSimilarity

func CalcSimilarity(raw ...[]byte) float64

func CalcTextSubStringStability

func CalcTextSubStringStability(raw ...[]byte) (float64, error)

func ChanStringToSlice

func ChanStringToSlice(c chan string) (result []string)

func ConcatPorts

func ConcatPorts(ports []int) string

func ConnExpect

func ConnExpect(c net.Conn, timeout time.Duration, callback func([]byte) bool) (bool, error)

func ConvertTextFileToYakFuzztagByPath

func ConvertTextFileToYakFuzztagByPath(file_bin_path string) (string, error)

func ConvertToStringSlice

func ConvertToStringSlice(raw ...interface{}) (r []string)

func CopyBytes

func CopyBytes(rsp []byte) []byte

func CopyMapInterface

func CopyMapInterface(i map[string]interface{}) map[string]interface{}

func DataVerbose

func DataVerbose(i interface{}) string

func DatetimePretty

func DatetimePretty() string

func DatetimePretty2

func DatetimePretty2() string

func Debug

func Debug(f func())

func DebugMockGMHTTP added in v1.2.3

func DebugMockGMHTTP(ctx context.Context, handler func(req []byte) []byte) (string, int)

func DebugMockHTTP

func DebugMockHTTP(rsp []byte) (string, int)

func DebugMockHTTP2 added in v1.2.3

func DebugMockHTTP2(ctx context.Context, handler func(req []byte) []byte) (string, int)

func DebugMockHTTPEx added in v1.2.3

func DebugMockHTTPEx(handle func(req []byte) []byte) (string, int)

func DebugMockHTTPExContext added in v1.2.3

func DebugMockHTTPExContext(ctx context.Context, handle func(req []byte) []byte) (string, int)

func DebugMockHTTPHandlerFunc added in v1.2.4

func DebugMockHTTPHandlerFunc(handlerFunc http.HandlerFunc) (string, int)

func DebugMockHTTPHandlerFuncContext added in v1.2.4

func DebugMockHTTPHandlerFuncContext(ctx context.Context, handlerFunc http.HandlerFunc) (string, int)

func DebugMockHTTPSEx added in v1.2.3

func DebugMockHTTPSEx(handle func(req []byte) []byte) (string, int)

func DebugMockHTTPSKeepAliveEx added in v1.2.7

func DebugMockHTTPSKeepAliveEx(handle func(req []byte) []byte) (string, int)

func DebugMockHTTPServerWithContext added in v1.2.3

func DebugMockHTTPServerWithContext(ctx context.Context, https bool, h2 bool, gmtlsFlag bool, keepAlive bool, handle func([]byte) []byte) (string, int)

func DebugMockHTTPWithTimeout

func DebugMockHTTPWithTimeout(du time.Duration, rsp []byte) (string, int)

func DebugMockTCP added in v1.2.7

func DebugMockTCP(rsp []byte) (string, int)

func DebugMockTCPEx added in v1.2.7

func DebugMockTCPEx(handleFunc handleTCPFunc) (string, int)

func DebugMockTCPHandlerFuncContext added in v1.2.7

func DebugMockTCPHandlerFuncContext(ctx context.Context, handlerFunc handleTCPFunc) (string, int)

func DomainToURLFilter

func DomainToURLFilter(domain string) (*regexp.Regexp, error)

func DownloadFile

func DownloadFile(client *http.Client, u string, localFile string, every1s ...func(float64)) error

func DumpFileWithTextAndFiles

func DumpFileWithTextAndFiles(raw string, divider string, files ...string) (string, error)

func DumpHTTPRequest added in v1.2.6

func DumpHTTPRequest(req *http.Request, loadBody bool) ([]byte, error)

DumpHTTPRequest dumps http request to bytes **NO NOT HANDLE SMUGGLE HERE!** Transfer-Encoding is handled vai req.TransferEncoding / req.Header["Transfer-Encoding"] Content-Length is handled vai req.ContentLength / req.Header["Content-Length"] if Transfer-Encoding existed, check body chunked? if not, encode it if Transfer-Encoding and Content-Length existed at same time, use transfer-encoding

func DumpHTTPResponse added in v1.2.6

func DumpHTTPResponse(rsp *http.Response, loadBody bool, wr ...io.Writer) ([]byte, error)

DumpHTTPResponse dumps http response to bytes if loadBody is true, it will load body to memory

transfer-encoding is a special header

func DumpHostFileWithTextAndFiles

func DumpHostFileWithTextAndFiles(raw string, divider string, files ...string) (string, error)

func EnableDebug added in v1.2.3

func EnableDebug()

func Error

func Error(i interface{}) error

func Errorf

func Errorf(origin string, args ...interface{}) error

func EscapeInvalidUTF8Byte

func EscapeInvalidUTF8Byte(s []byte) string

func ExtractHost

func ExtractHost(raw string) string

func ExtractHostPort

func ExtractHostPort(raw string) string

func ExtractMapValueBool added in v1.2.3

func ExtractMapValueBool(m any, key string) bool

func ExtractMapValueGeneralMap added in v1.2.3

func ExtractMapValueGeneralMap(m any, key string) map[string]any

func ExtractMapValueInt added in v1.2.3

func ExtractMapValueInt(m any, key string) int

func ExtractMapValueRaw added in v1.2.3

func ExtractMapValueRaw(m any, key string) any

func ExtractMapValueString added in v1.2.3

func ExtractMapValueString(m any, key string) string

func ExtractRawPath

func ExtractRawPath(target string) string

func ExtractStrContextByKeyword

func ExtractStrContextByKeyword(raw []byte, res []string) []string

func ExtractTitleFromHTMLTitle

func ExtractTitleFromHTMLTitle(s string, defaultValue string) string

func FileLineReader

func FileLineReader(file string) (chan []byte, error)

func FixForParseIP

func FixForParseIP(host string) string

func FixHTTPRequestForGolangNativeHTTPClient added in v1.2.6

func FixHTTPRequestForGolangNativeHTTPClient(req *http.Request)

FixHTTPRequestForGolangNativeHTTPClient utils.Read/DumpRequest is working as pair... if u want to use transport(golang native) do this `FixHTTPRequestForGolangNativeHTTPClient` helps because golang native transport will encode chunked body again

func FixHTTPRequestForHTTPDo

func FixHTTPRequestForHTTPDo(r *http.Request) (*http.Request, error)

func FixHTTPRequestForHTTPDoWithHttps

func FixHTTPRequestForHTTPDoWithHttps(r *http.Request, isHttps bool) (*http.Request, error)

func FixHTTPResponseForGolangNativeHTTPClient added in v1.2.6

func FixHTTPResponseForGolangNativeHTTPClient(ins *http.Response)

func FixJsonRawBytes

func FixJsonRawBytes(rawBytes []byte) []byte

func FloatSecondDuration

func FloatSecondDuration(f float64) time.Duration

func Format

func Format(raw string, data map[string]string) string

func GetAllFiles

func GetAllFiles(path string) (fileNames []string, err error)

func GetCClassByIPv4

func GetCClassByIPv4(s string) (string, error)

func GetCachedLog added in v1.2.2

func GetCachedLog() (res []string)

func GetConnectedToHostPortFromHTTPRequest added in v1.2.6

func GetConnectedToHostPortFromHTTPRequest(t *http.Request) (string, error)

func GetCurrentDate

func GetCurrentDate() (time.Time, error)

func GetCurrentWeekMonday

func GetCurrentWeekMonday() (time.Time, error)

func GetDate

func GetDate(t time.Time) (time.Time, error)

func GetDefaultGMTLSConfig added in v1.2.3

func GetDefaultGMTLSConfig(i float64) *gmtls.Config

func GetDefaultTLSConfig added in v1.2.3

func GetDefaultTLSConfig(i float64) *tls.Config

func GetFileAbsDir

func GetFileAbsDir(filePath string) (string, error)

func GetFileAbsPath

func GetFileAbsPath(filePath string) (string, error)

func GetFileMd5

func GetFileMd5(filepath string) string

func GetFileModTime

func GetFileModTime(path string) int64

func GetFirstExcludedHighPort

func GetFirstExcludedHighPort(excluded ...string) int

func GetFirstExistedExecutablePath

func GetFirstExistedExecutablePath(paths ...string) string

func GetFirstExistedFile

func GetFirstExistedFile(paths ...string) string

func GetFirstExistedFileE

func GetFirstExistedFileE(paths ...string) (string, error)

func GetFirstExistedPath

func GetFirstExistedPath(paths ...string) string

func GetFirstExistedPathE

func GetFirstExistedPathE(paths ...string) (string, error)

func GetHomeDir

func GetHomeDir() (string, error)

func GetHomeDirDefault

func GetHomeDirDefault(d string) string

func GetLastElement added in v1.2.8

func GetLastElement[T any](list []T) T

func GetLatestFile

func GetLatestFile(dir, suffix string) (filename string, err error)

func GetLocalIPAddress

func GetLocalIPAddress() string

func GetLocalIPAddressViaIface

func GetLocalIPAddressViaIface() string

func GetMachineCode

func GetMachineCode() string

func GetNExcludeExcludeHighPort

func GetNExcludeExcludeHighPort(n int, excluded ...string) []int

func GetRandomAvailableTCPPort

func GetRandomAvailableTCPPort() int

func GetRandomAvailableUDPPort

func GetRandomAvailableUDPPort() int

func GetRandomIPAddress

func GetRandomIPAddress() string

func GetRandomLocalAddr

func GetRandomLocalAddr() string

func GetSameSubStrings

func GetSameSubStrings(raw ...string) []string

func GetSameSubStringsRunes

func GetSameSubStringsRunes(text1, text2 []rune) [][]rune

func GetSystemDnsServers added in v1.2.3

func GetSystemDnsServers() ([]string, error)

func GetSystemMachineCode

func GetSystemMachineCode() (_ string, err error)

func GetSystemNameServerList

func GetSystemNameServerList() ([]string, error)

func GetUnexportedField

func GetUnexportedField(field reflect.Value) interface{}

func GetWeekStartMonday

func GetWeekStartMonday(t time.Time) (time.Time, error)

func GetWeekStartSunday

func GetWeekStartSunday() (time.Time, error)

func GzipCompress

func GzipCompress(i interface{}) ([]byte, error)

func GzipDeCompress

func GzipDeCompress(ret []byte) ([]byte, error)

func HTTPPacketIsLargerThanMaxContentLength

func HTTPPacketIsLargerThanMaxContentLength(res interface{}, maxLength int) bool

func HandleStdout

func HandleStdout(ctx context.Context, handle func(string)) error

func HostPort

func HostPort(host string, port interface{}) string

func HttpDumpWithBody

func HttpDumpWithBody(i interface{}, body bool) ([]byte, error)

func HttpGet

func HttpGet(url string) ([]byte, error)

func HttpGetWithRetry

func HttpGetWithRetry(retry int, url string) ([]byte, error)

func HttpShow

func HttpShow(i interface{}) []byte

func IContains

func IContains(s, sub string) bool

func IPv4ToCClassNetwork

func IPv4ToCClassNetwork(s string) (string, error)

func IPv4ToUint32

func IPv4ToUint32(ip net.IP) (uint32, error)

func IPv4ToUint64

func IPv4ToUint64(ip string) (int64, error)

func IStringContainsAnyOfSubString

func IStringContainsAnyOfSubString(s string, subs []string) bool

func InDebugMode

func InDebugMode() bool

func InetAtoN

func InetAtoN(ip net.IP) int64

func InetNtoA

func InetNtoA(ip int64) net.IP

func InitialCapitalizationEachWords

func InitialCapitalizationEachWords(str string) string

每个单词首字母大写

func InsertSliceItem added in v1.2.8

func InsertSliceItem[T comparable](slices []T, e T, index int) []T

func Int64SliceToIntSlice

func Int64SliceToIntSlice(i []int64) []int

func IntArrayContains

func IntArrayContains(array []int, element int) bool

func IntLargerZeroOr

func IntLargerZeroOr(s ...int) int

func IntSliceToInt64Slice

func IntSliceToInt64Slice(i []int) []int64

func InterfaceToBoolean added in v1.2.4

func InterfaceToBoolean(i any) bool

func InterfaceToBytes

func InterfaceToBytes(i interface{}) (result []byte)

func InterfaceToBytesSlice

func InterfaceToBytesSlice(i interface{}) [][]byte

func InterfaceToGeneralMap

func InterfaceToGeneralMap(params interface{}) (finalResult map[string]interface{})

func InterfaceToInt added in v1.2.4

func InterfaceToInt(i any) int

func InterfaceToMap

func InterfaceToMap(i interface{}) map[string][]string

func InterfaceToMapInterface

func InterfaceToMapInterface(i interface{}) map[string]interface{}

func InterfaceToMapInterfaceE

func InterfaceToMapInterfaceE(i interface{}) (map[string]interface{}, error)

func InterfaceToQuotedString

func InterfaceToQuotedString(i interface{}) string

func InterfaceToSliceInterface added in v1.2.2

func InterfaceToSliceInterface(i interface{}) []any

func InterfaceToSliceInterfaceE added in v1.2.2

func InterfaceToSliceInterfaceE(i interface{}) ([]any, error)

func InterfaceToString

func InterfaceToString(i interface{}) string

func InterfaceToStringSlice

func InterfaceToStringSlice(i interface{}) (result []string)

func IsASCIIPrint

func IsASCIIPrint(s string) bool

isASCIIPrint returns whether s is ASCII and printable according to https://tools.ietf.org/html/rfc20#section-4.2.

func IsCommonHTTPRequestMethod added in v1.2.7

func IsCommonHTTPRequestMethod(i any) bool

func IsDir

func IsDir(path string) bool

func IsFile

func IsFile(path string) bool

func IsGzip

func IsGzip(raw []byte) bool

func IsGzipBytes

func IsGzipBytes(i interface{}) bool

func IsHttpOrHttpsUrl added in v1.2.4

func IsHttpOrHttpsUrl(raw string) bool

func IsIPv4

func IsIPv4(raw string) bool

func IsIPv6

func IsIPv6(raw string) bool

func IsImage

func IsImage(i []byte) bool

func IsJSON

func IsJSON(raw string) (string, bool)

func IsLinux added in v1.2.3

func IsLinux() bool

func IsLoopback

func IsLoopback(t string) bool

func IsMac added in v1.2.3

func IsMac() bool

func IsNil added in v1.2.8

func IsNil(input any) bool

func IsPortAvailable

func IsPortAvailable(host string, p int) bool

func IsPortAvailableWithUDP

func IsPortAvailableWithUDP(host string, p int) bool

func IsPrivateIP

func IsPrivateIP(ip net.IP) bool

func IsProtobuf

func IsProtobuf(raw []byte) bool

func IsStrongPassword

func IsStrongPassword(s string) bool

func IsTCPPortAvailable

func IsTCPPortAvailable(p int) bool

func IsTCPPortAvailableWithLoopback

func IsTCPPortAvailableWithLoopback(p int) bool

func IsTCPPortOpen

func IsTCPPortOpen(host string, p int) bool

func IsUDPPortAvailable

func IsUDPPortAvailable(p int) bool

func IsUDPPortAvailableWithLoopback

func IsUDPPortAvailableWithLoopback(p int) bool

func IsValidCIDR

func IsValidCIDR(raw string) bool

func IsValidDomain

func IsValidDomain(raw string) bool

func IsValidFloat

func IsValidFloat(raw string) bool

func IsValidHostsRange

func IsValidHostsRange(raw string) bool

func IsValidInteger

func IsValidInteger(raw string) bool

func IsValidPortsRange

func IsValidPortsRange(ports string) bool

func IsWindows added in v1.2.3

func IsWindows() bool

func JavaTimeFormatter

func JavaTimeFormatter(t time.Time, formatter string) string

func Jsonify

func Jsonify(i interface{}) []byte

func LastLine

func LastLine(s []byte) []byte

func LoopEvery1sBreakUntil

func LoopEvery1sBreakUntil(until func() bool)

func MapGetBool

func MapGetBool(m map[string]interface{}, key string) bool

func MapGetBoolOr

func MapGetBoolOr(m map[string]interface{}, key string, value bool) bool

func MapGetFirstRaw

func MapGetFirstRaw(m map[string]interface{}, key ...string) interface{}

func MapGetFloat32

func MapGetFloat32(m map[string]interface{}, key string) float32

func MapGetFloat32Or

func MapGetFloat32Or(m map[string]interface{}, key string, value float32) float32

func MapGetFloat64

func MapGetFloat64(m map[string]interface{}, key string) float64

func MapGetFloat64Or

func MapGetFloat64Or(m map[string]interface{}, key string, value float64) float64

func MapGetInt

func MapGetInt(m map[string]interface{}, key string) int

func MapGetInt64

func MapGetInt64(m map[string]interface{}, key string) int64

func MapGetInt64Or

func MapGetInt64Or(m map[string]interface{}, key string, value int64) int64

func MapGetIntEx added in v1.2.2

func MapGetIntEx(m map[string]interface{}, key ...string) int

func MapGetIntOr

func MapGetIntOr(m map[string]interface{}, key string, value int) int

func MapGetMapRaw

func MapGetMapRaw(m map[string]interface{}, key string) map[string]interface{}

func MapGetMapRawOr

func MapGetMapRawOr(m map[string]interface{}, key string, value map[string]interface{}) map[string]interface{}

func MapGetRaw

func MapGetRaw(m map[string]interface{}, key string) interface{}

func MapGetRawOr

func MapGetRawOr(m map[string]interface{}, key string, value interface{}) interface{}

func MapGetString

func MapGetString(m map[string]interface{}, key string) string

func MapGetString2

func MapGetString2(m map[string]string, key string) string

func MapGetStringByManyFields added in v1.2.4

func MapGetStringByManyFields(m map[string]interface{}, key ...string) string

func MapGetStringOr

func MapGetStringOr(m map[string]interface{}, key string, value string) string

func MapGetStringOr2

func MapGetStringOr2(m map[string]string, key string, value string) string

func MapGetStringSlice added in v1.2.7

func MapGetStringSlice(m map[string]interface{}, key string) []string

func MapQueryToString

func MapQueryToString(values map[string][]string) string

map[string][]string to query

func MapStringGet

func MapStringGet(m map[string]string, key string) string

func MapStringGetOr

func MapStringGetOr(m map[string]string, key string, value string) string

func MapToStruct added in v1.2.6

func MapToStruct(input map[string]interface{}, output interface{}) error

func MarshalHTTPRequest

func MarshalHTTPRequest(req *http.Request) ([]byte, error)

func MatchAllOfGlob

func MatchAllOfGlob(
	i interface{}, re ...string) bool

func MatchAllOfRegexp

func MatchAllOfRegexp(
	i interface{},
	re ...string) bool

func MatchAllOfSubString

func MatchAllOfSubString(i interface{}, re ...string) bool

func MatchAnyOfGlob

func MatchAnyOfGlob(
	i interface{}, re ...string) bool

func MatchAnyOfRegexp

func MatchAnyOfRegexp(
	i interface{},
	re ...string) bool

func MatchAnyOfSubString

func MatchAnyOfSubString(i interface{}, re ...string) bool

func Max

func Max(x, y int) int

func MaxByte

func MaxByte(x, y byte) byte

func MaxInt64

func MaxInt64(x, y int64) int64

func MergeGeneralMap added in v1.2.2

func MergeGeneralMap(ms ...map[string]any) map[string]any

func MergeStringMap

func MergeStringMap(ms ...map[string]string) map[string]string

func Min

func Min(x, y int) int

func MinByte

func MinByte(x, y byte) byte

func MinInt64

func MinInt64(x, y int64) int64

func Mmh3Hash32

func Mmh3Hash32(raw []byte) string

func MustUnmarshalJson added in v1.2.4

func MustUnmarshalJson[T any](raw []byte) *T

func NetworkByteOrderBytesToUint16 added in v1.2.4

func NetworkByteOrderBytesToUint16(r []byte) uint16

func NetworkByteOrderUint16ToBytes added in v1.2.3

func NetworkByteOrderUint16ToBytes(i any) []byte

func NetworkByteOrderUint32ToBytes added in v1.2.3

func NetworkByteOrderUint32ToBytes(i any) []byte

func NetworkByteOrderUint64ToBytes added in v1.2.3

func NetworkByteOrderUint64ToBytes(i any) []byte

func NetworkByteOrderUint8ToBytes added in v1.2.3

func NetworkByteOrderUint8ToBytes(i any) []byte

func NewBlockParser

func NewBlockParser(reader io.Reader) *blockParser

func NewDebounce added in v1.2.8

func NewDebounce(wait float64) func(f func())

func NewDefaultGMTLSConfig

func NewDefaultGMTLSConfig() *gmtls.Config

func NewDefaultHTTPClient

func NewDefaultHTTPClient() *http.Client

func NewDefaultHTTPClientWithProxy

func NewDefaultHTTPClientWithProxy(proxy string) *http.Client

func NewDefaultTLSClient

func NewDefaultTLSClient(conn net.Conn) *tls.Conn

func NewDefaultTLSConfig

func NewDefaultTLSConfig() *tls.Config

func NewDialer added in v1.2.4

func NewDialer()

func NewNetConnFromReadWriter

func NewNetConnFromReadWriter()

func NewSignalChannel

func NewSignalChannel(targetSignal ...os.Signal) chan os.Signal

func NewThrottle added in v1.2.8

func NewThrottle(wait float64) func(f func())

func ParseCStyleBinaryRawToBytes

func ParseCStyleBinaryRawToBytes(raw []byte) []byte

func ParseHTTPRequestLine added in v1.2.6

func ParseHTTPRequestLine(line string) (method, requestURI, proto string, ok bool)

ParseHTTPRequestLine parses "GET /foo HTTP/1.1" into its three parts.

func ParseHTTPResponseLine added in v1.2.6

func ParseHTTPResponseLine(line string) (string, int, string, bool)

ParseHTTPResponseLine parses `HTTP/1.1 200 OK` into its ports

func ParseHostToAddrString

func ParseHostToAddrString(host string) string

func ParseIPNetToRange

func ParseIPNetToRange(n *net.IPNet) (int64, int64, error)

func ParseLines

func ParseLines(raw string) chan string

func ParsePortToProtoPort added in v1.2.6

func ParsePortToProtoPort(port int) (string, int)

func ParseStringToGeneralMap added in v1.2.3

func ParseStringToGeneralMap(i any) map[string]any

func ParseStringToHostPort

func ParseStringToHostPort(raw string) (host string, port int, err error)

func ParseStringToHosts

func ParseStringToHosts(raw string) []string

func ParseStringToLines

func ParseStringToLines(raw string) []string

func ParseStringToPorts

func ParseStringToPorts(ports string) []int

ParseStringToPorts 负数端口代表了是 UDP 扫描端口

func ParseStringToRawLines

func ParseStringToRawLines(raw string) []string

func ParseStringToUrl added in v1.2.6

func ParseStringToUrl(s string) *url.URL

func ParseStringToUrlParams

func ParseStringToUrlParams(i interface{}) string

func ParseStringToUrls

func ParseStringToUrls(targets ...string) []string

func ParseStringToUrlsWith3W

func ParseStringToUrlsWith3W(sub ...string) []string

func ParseStringToVisible

func ParseStringToVisible(raw interface{}) string

func ParseStringUrlToUrlInstance

func ParseStringUrlToUrlInstance(s string) (*url.URL, error)

func ParseStringUrlToWebsiteRootPath

func ParseStringUrlToWebsiteRootPath(s string) string

func PathExists

func PathExists(path string) (bool, error)

func PrettifyListFromStringSplitEx

func PrettifyListFromStringSplitEx(Raw string, sep ...string) (targets []string)

PrettifyListFromStringSplitEx split string using given sep if no sep given sep = []string{",", "|"}

func PrettifyListFromStringSplited

func PrettifyListFromStringSplited(Raw string, sep string) (targets []string)

func PrintCurrentGoroutineRuntimeStack

func PrintCurrentGoroutineRuntimeStack()

func ProtoHostPort added in v1.2.6

func ProtoHostPort(proto string, host string, port int) string

func RandNumberStringBytes

func RandNumberStringBytes(n int) string

func RandSample

func RandSample(n int, material ...string) string

func RandSecret

func RandSecret(n int) string

func RandStringBytes

func RandStringBytes(n int) string

RandStringBytes return length `n` alphabet random string

func ReadConnUntil added in v1.2.8

func ReadConnUntil(conn net.Conn, timeout time.Duration, sep ...byte) ([]byte, error)

func ReadConnWithTimeout

func ReadConnWithTimeout(r net.Conn, timeout time.Duration) ([]byte, error)

func ReadHTTPRequestFromBufioReader added in v1.2.6

func ReadHTTPRequestFromBufioReader(reader *bufio.Reader) (*http.Request, error)

func ReadHTTPRequestFromBytes added in v1.2.6

func ReadHTTPRequestFromBytes(raw []byte) (*http.Request, error)

func ReadHTTPResponseFromBufioReader added in v1.2.6

func ReadHTTPResponseFromBufioReader(reader *bufio.Reader, req *http.Request) (*http.Response, error)

func ReadHTTPResponseFromBytes added in v1.2.6

func ReadHTTPResponseFromBytes(raw []byte, req *http.Request) (*http.Response, error)

func ReadLineEx

func ReadLineEx(reader io.Reader) (string, int64, error)

func ReadN

func ReadN(reader io.Reader, n int) ([]byte, error)

func ReadWithContextTickCallback

func ReadWithContextTickCallback(ctx context.Context, rc io.Reader, callback func([]byte) bool, interval time.Duration)

func ReadWithLen

func ReadWithLen(r io.Reader, length int) ([]byte, int)

func RegisterDefaultTLSConfigGenerator added in v1.2.3

func RegisterDefaultTLSConfigGenerator(h func() (*tls.Config, *gmtls.Config, *tls.Config, *gmtls.Config, []byte, []byte))

func RemoveBOM

func RemoveBOM(raw []byte) []byte

func RemoveBOMForString

func RemoveBOMForString(raw string) string

func RemoveRepeatStringSlice

func RemoveRepeatStringSlice(slc []string) []string

元素去重

func RemoveRepeatStringSliceByLoop

func RemoveRepeatStringSliceByLoop(slc []string) []string

func RemoveRepeatStringSliceByMap

func RemoveRepeatStringSliceByMap(slc []string) []string

func RemoveRepeatUintSlice

func RemoveRepeatUintSlice(slc []uint) []uint

元素去重

func RemoveRepeatUintSliceByLoop

func RemoveRepeatUintSliceByLoop(slc []uint) []uint

func RemoveRepeatUintSliceByMap

func RemoveRepeatUintSliceByMap(slc []uint) []uint

func RemoveRepeatedWithStringSlice

func RemoveRepeatedWithStringSlice(slice []string) []string

func RemoveSliceItem added in v1.2.8

func RemoveSliceItem[T comparable](slice []T, s T) []T

func RemoveUnprintableChars

func RemoveUnprintableChars(raw string) string

func RemoveUnprintableCharsWithReplace

func RemoveUnprintableCharsWithReplace(raw string, handle func(i byte) string) string

func RemoveUnprintableCharsWithReplaceItem

func RemoveUnprintableCharsWithReplaceItem(raw string) string

func Retry added in v1.2.7

func Retry(times int, f func() error) error

func RetryWithExpBackOff added in v1.2.7

func RetryWithExpBackOff(f func() error) error

func RetryWithExpBackOffEx added in v1.2.7

func RetryWithExpBackOffEx(times int, begin int, f func() error) error

func SSDeepHash

func SSDeepHash(raw []byte) string

func SaveFile

func SaveFile(raw interface{}, filePath string) error

func SetUnexportedField

func SetUnexportedField(field reflect.Value, value interface{})

func ShouldRemoveZeroContentLengthHeader added in v1.2.6

func ShouldRemoveZeroContentLengthHeader(s string) bool

func ShuffleInt

func ShuffleInt(slice []int)

func ShuffleString

func ShuffleString(slice []string)

func SimHash

func SimHash(raw []byte) uint64

func SimilarStr

func SimilarStr(str1 []rune, str2 []rune) (int, int, int)

return the len of longest string both in str1 and str2 and the positions in str1 and str2

func SliceGroup

func SliceGroup(origin []string, groupSize int) [][]string

func SnakeString

func SnakeString(s string) string

func SocketTypeUint32ToString

func SocketTypeUint32ToString(i uint32) string

func Spinlock added in v1.2.3

func Spinlock(t float64, h func() bool) error

func SplitHostsToPrivateAndPublic

func SplitHostsToPrivateAndPublic(hosts ...string) (privs, pub []string)

func StableReader

func StableReader(conn io.Reader, timeout time.Duration, maxSize int) []byte

func StableReaderEx

func StableReaderEx(conn net.Conn, timeout time.Duration, maxSize int) []byte

func StarAsWildcardToRegexp

func StarAsWildcardToRegexp(prefix string, target string) (*regexp.Regexp, error)

func StartCacheLog added in v1.2.2

func StartCacheLog(ctx context.Context, n int)

func StringAfter

func StringAfter(value string, a string) string

func StringArrayContains

func StringArrayContains(array []string, element string) bool

func StringArrayFilterEmpty

func StringArrayFilterEmpty(array []string) []string

func StringArrayIndex

func StringArrayIndex(array []string, element string) int

func StringArrayMerge

func StringArrayMerge(t ...[]string) []string

func StringAsFileParams

func StringAsFileParams(target interface{}) []byte

func StringBefore

func StringBefore(value string, a string) string

func StringContainsAllOfSubString

func StringContainsAllOfSubString(s string, subs []string) bool

func StringContainsAnyOfSubString

func StringContainsAnyOfSubString(s string, subs []string) bool

func StringGlobArrayContains

func StringGlobArrayContains(array []string, element string, seps ...rune) bool

func StringHasPrefix

func StringHasPrefix(s string, prefix []string) bool

func StringLowerAndTrimSpace

func StringLowerAndTrimSpace(raw string) string

func StringOr

func StringOr(s ...string) string

func StringReverse

func StringReverse(s string) string

Reverse the string

func StringSliceContain

func StringSliceContain(s interface{}, raw string) (result bool)

func StringSliceContainsAll

func StringSliceContainsAll(o []string, elements ...string) bool

func StringSplitAndStrip

func StringSplitAndStrip(raw string, sep string) []string

func StringSubStringArrayContains added in v1.2.3

func StringSubStringArrayContains(array []string, element string) bool

func StringToAsciiBytes

func StringToAsciiBytes(s string) []byte

func Tick1sWithTimeout

func Tick1sWithTimeout(timeout time.Duration, falseToBreak func() bool) (exitedByCondition bool)

func TickEvery1s

func TickEvery1s(falseToBreak func() bool)

func TickWithTimeout

func TickWithTimeout(timeout, interval time.Duration, falseToBreak func() bool) (exitedByCondition bool)

func TickWithTimeoutContext

func TickWithTimeoutContext(ctx context.Context, timeout, interval time.Duration, falseToBreak func() bool) (exitedByCondition bool)

func TimeoutContext

func TimeoutContext(d time.Duration) context.Context

func TimeoutContextSeconds

func TimeoutContextSeconds(d float64) context.Context

func TimestampMs

func TimestampMs() int64

func TimestampNano

func TimestampNano() int64

func TimestampSecond

func TimestampSecond() int64

func ToBytes

func ToBytes(s string) (uint64, error)

ToBytes parses a string formatted by ByteSize as bytes. Note binary-prefixed and SI prefixed units both mean a base-2 units KB = K = KiB = 1024 MB = M = MiB = 1024 * K GB = G = GiB = 1024 * M TB = T = TiB = 1024 * G PB = P = PiB = 1024 * T EB = E = EiB = 1024 * P

func ToLowerAndStrip

func ToLowerAndStrip(s string) string

func ToMapParams

func ToMapParams(params any) (map[string]any, error)

func ToMegabytes

func ToMegabytes(s string) (uint64, error)

ToMegabytes parses a string formatted by ByteSize as megabytes.

func ToNsServer

func ToNsServer(server string) string

func TrimFileNameExt

func TrimFileNameExt(raw string) string

func TryCloseChannel added in v1.2.2

func TryCloseChannel(i any)

func Uint32ToIPv4

func Uint32ToIPv4(ip uint32) net.IP

func UnsafeBytesToString added in v1.2.6

func UnsafeBytesToString(b []byte) string

func UnsafeStringToBytes added in v1.2.6

func UnsafeStringToBytes(s string) []byte

func UrlJoinParams

func UrlJoinParams(i string, params ...interface{}) string

func VersionClean added in v1.2.3

func VersionClean(v string) string

func VersionCompare

func VersionCompare(v1, v2 string) (int, error)

VersionCompare 泛用形的版本比较,传入(p1,p2 string), p1>p2返回1,nil, p1<p2返回-1,nil, p1==p2返回0,nil, 比较失败返回 -2,err

func VersionEqual

func VersionEqual(v1, v2 string) bool

VersionEqual v1 等于 v2 返回 true

func VersionGreater

func VersionGreater(v1, v2 string) bool

VersionGreater v1 大于 v2 返回 true

func VersionGreaterEqual

func VersionGreaterEqual(v1, v2 string) bool

VersionGreaterEqual v1 大于等于 v2 返回 true

func VersionLess

func VersionLess(v1, v2 string) bool

VersionLess v1 小于 v2 返回true

func VersionLessEqual

func VersionLessEqual(v1, v2 string) bool

VersionLessEqual v1 小于等于 v2 返回true

func WaitConnect

func WaitConnect(addr string, timeout float64) error

func WaitRoutinesFromSlice added in v1.2.6

func WaitRoutinesFromSlice[T any](arg []T, job func(T))

func ZlibCompress

func ZlibCompress(i interface{}) ([]byte, error)

func ZlibDeCompress

func ZlibDeCompress(ret []byte) ([]byte, error)

Types

type AtomicBool

type AtomicBool int32

AtomicBool is an atomic Boolean Its methods are all atomic, thus safe to be called by multiple goroutines simultaneously Note: When embedding into a struct, one should always use *AtomicBool to avoid copy

Example
cond := NewAtomicBool() // default to false
cond.Set()              // set to true
cond.IsSet()            // returns true
cond.UnSet()            // set to false
cond.SetTo(true)        // set to whatever you want
Output:

func NewAtomicBool

func NewAtomicBool() *AtomicBool

New creates an AtomicBool with default to false

func NewBool

func NewBool(ok bool) *AtomicBool

NewBool creates an AtomicBool with given default value

func (*AtomicBool) IsSet

func (ab *AtomicBool) IsSet() bool

IsSet returns whether the Boolean is true

func (*AtomicBool) Set

func (ab *AtomicBool) Set()

Set sets the Boolean to true

func (*AtomicBool) SetTo

func (ab *AtomicBool) SetTo(yes bool)

SetTo sets the boolean with given Boolean

func (*AtomicBool) SetToIf

func (ab *AtomicBool) SetToIf(old, new bool) (set bool)

SetToIf sets the Boolean to new only if the Boolean matches the old Returns whether the set was done

func (*AtomicBool) UnSet

func (ab *AtomicBool) UnSet()

UnSet sets the Boolean to false

type BruteDictParser

type BruteDictParser struct {
	UserDictFile, PassDictFile *os.File
	UserDict, PassDict         *bufio.Scanner
	// contains filtered or unexported fields
}

func NewBruteDictParser

func NewBruteDictParser(userDict, passDict string) (*BruteDictParser, error)

func (*BruteDictParser) Next

func (b *BruteDictParser) Next() (*UserPassPair, error)

type BufferedPeekableConn

type BufferedPeekableConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewPeekableNetConn

func NewPeekableNetConn(r net.Conn) *BufferedPeekableConn

func (*BufferedPeekableConn) GetBuf

func (b *BufferedPeekableConn) GetBuf() []byte

func (*BufferedPeekableConn) GetOriginConn

func (b *BufferedPeekableConn) GetOriginConn() net.Conn

func (*BufferedPeekableConn) GetReader

func (b *BufferedPeekableConn) GetReader() io.Reader

func (*BufferedPeekableConn) Peek

func (b *BufferedPeekableConn) Peek(i int) ([]byte, error)

func (*BufferedPeekableConn) PeekByte

func (b *BufferedPeekableConn) PeekByte() (byte, error)

func (*BufferedPeekableConn) PeekUint16

func (b *BufferedPeekableConn) PeekUint16() uint16

func (*BufferedPeekableConn) Read

func (b *BufferedPeekableConn) Read(buf []byte) (int, error)

func (*BufferedPeekableConn) SetBuf

func (b *BufferedPeekableConn) SetBuf(buf []byte)

type BufferedPeekableReader

type BufferedPeekableReader struct {
	io.Reader
	// contains filtered or unexported fields
}

func NewPeekableReader

func NewPeekableReader(r io.Reader) *BufferedPeekableReader

func (*BufferedPeekableReader) GetBuf

func (b *BufferedPeekableReader) GetBuf() []byte

func (*BufferedPeekableReader) GetReader

func (b *BufferedPeekableReader) GetReader() io.Reader

func (*BufferedPeekableReader) Peek

func (b *BufferedPeekableReader) Peek(i int) ([]byte, error)

func (*BufferedPeekableReader) Read

func (b *BufferedPeekableReader) Read(buf []byte) (int, error)

func (*BufferedPeekableReader) SetBuf

func (b *BufferedPeekableReader) SetBuf(buf []byte)

type BufferedPeekableReaderWriter

type BufferedPeekableReaderWriter struct {
	io.ReadWriter
	// contains filtered or unexported fields
}

func NewPeekableReaderWriter

func NewPeekableReaderWriter(r io.ReadWriter) *BufferedPeekableReaderWriter

func (*BufferedPeekableReaderWriter) GetBuf

func (b *BufferedPeekableReaderWriter) GetBuf() []byte

func (*BufferedPeekableReaderWriter) GetReader

func (b *BufferedPeekableReaderWriter) GetReader() io.Reader

func (*BufferedPeekableReaderWriter) Peek

func (b *BufferedPeekableReaderWriter) Peek(i int) ([]byte, error)

func (*BufferedPeekableReaderWriter) Read

func (b *BufferedPeekableReaderWriter) Read(buf []byte) (int, error)

func (*BufferedPeekableReaderWriter) SetBuf

func (b *BufferedPeekableReaderWriter) SetBuf(buf []byte)

type CircularQueue added in v1.2.2

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

func NewCircularQueue added in v1.2.2

func NewCircularQueue(capacity int) *CircularQueue

func (*CircularQueue) GetElements added in v1.2.2

func (q *CircularQueue) GetElements() []interface{}

func (*CircularQueue) Push added in v1.2.2

func (q *CircularQueue) Push(x interface{})

type CoolDown

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

func NewCoolDown

func NewCoolDown(d time.Duration) *CoolDown

func NewCoolDownContext

func NewCoolDownContext(d time.Duration, ctx context.Context) *CoolDown

func (*CoolDown) Do

func (c *CoolDown) Do(f func())

func (*CoolDown) DoOr

func (c *CoolDown) DoOr(f func(), fallback func())

func (*CoolDown) Reset

func (c *CoolDown) Reset(d time.Duration)

type CustomWriter added in v1.2.8

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

func NewWriter added in v1.2.8

func NewWriter(f func(p []byte) (n int, err error)) *CustomWriter

func (*CustomWriter) Write added in v1.2.8

func (c *CustomWriter) Write(p []byte) (n int, err error)

type DelayWaiter

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

delay with range

func NewDelayWaiter

func NewDelayWaiter(min int32, max int32) (*DelayWaiter, error)

func (*DelayWaiter) Wait

func (d *DelayWaiter) Wait()

func (*DelayWaiter) WaitWithProbabilityPercent

func (d *DelayWaiter) WaitWithProbabilityPercent(raw float64)

type FileInfo

type FileInfo struct {
	BuildIn os.FileInfo
	Path    string
	Name    string
	IsDir   bool
}

func ReadDir

func ReadDir(p string) ([]*FileInfo, error)

func ReadDirWithLimit

func ReadDirWithLimit(p string, limit int) ([]*FileInfo, error)

func ReadDirsRecursively

func ReadDirsRecursively(p string) ([]*FileInfo, error)

func ReadFilesRecursively

func ReadFilesRecursively(p string) ([]*FileInfo, error)

func ReadFilesRecursivelyWithLimit

func ReadFilesRecursivelyWithLimit(p string, limit int) ([]*FileInfo, error)

type FloatSecondsDelayWaiter

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

delay with range

func NewFloatSecondsDelayWaiter

func NewFloatSecondsDelayWaiter(min, max float64) (*FloatSecondsDelayWaiter, error)

func NewFloatSecondsDelayWaiterSingle

func NewFloatSecondsDelayWaiterSingle(min float64) (*FloatSecondsDelayWaiter, error)

func (*FloatSecondsDelayWaiter) Wait

func (d *FloatSecondsDelayWaiter) Wait()

func (*FloatSecondsDelayWaiter) WaitWithProbabilityPercent

func (d *FloatSecondsDelayWaiter) WaitWithProbabilityPercent(raw float64)

type HTTPPacketFilter

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

func NewHTTPPacketFilter

func NewHTTPPacketFilter() *HTTPPacketFilter

func (*HTTPPacketFilter) Conditions

func (j *HTTPPacketFilter) Conditions() []string

func (*HTTPPacketFilter) Hash

func (h *HTTPPacketFilter) Hash() string

func (*HTTPPacketFilter) IsAllowed

func (h *HTTPPacketFilter) IsAllowed(req *http.Request, rsp *http.Response) bool

func (*HTTPPacketFilter) Remove

func (i *HTTPPacketFilter) Remove(name string)

func (*HTTPPacketFilter) SetAllowForRequestHeader

func (j *HTTPPacketFilter) SetAllowForRequestHeader(header, regexp string)

func (*HTTPPacketFilter) SetAllowForRequestPath

func (j *HTTPPacketFilter) SetAllowForRequestPath(regexp string)

func (*HTTPPacketFilter) SetAllowForRequestRaw

func (j *HTTPPacketFilter) SetAllowForRequestRaw(regexp string)

func (*HTTPPacketFilter) SetAllowForResponseHeader

func (j *HTTPPacketFilter) SetAllowForResponseHeader(header, regexp string)

func (*HTTPPacketFilter) SetAllowForResponseRaw

func (j *HTTPPacketFilter) SetAllowForResponseRaw(regexp string)

func (*HTTPPacketFilter) SetRejectForRequestHeader

func (j *HTTPPacketFilter) SetRejectForRequestHeader(header, regexp string)

func (*HTTPPacketFilter) SetRejectForRequestPath

func (j *HTTPPacketFilter) SetRejectForRequestPath(regexp string)

func (*HTTPPacketFilter) SetRejectForRequestRaw

func (j *HTTPPacketFilter) SetRejectForRequestRaw(regexp string)

func (*HTTPPacketFilter) SetRejectForResponseHeader

func (j *HTTPPacketFilter) SetRejectForResponseHeader(header, regexp string)

func (*HTTPPacketFilter) SetRejectForResponseRaw

func (j *HTTPPacketFilter) SetRejectForResponseRaw(regexp string)

type HostPortClassifier

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

func NewHostPortClassifier

func NewHostPortClassifier() *HostPortClassifier

func (*HostPortClassifier) AddHostPort

func (h *HostPortClassifier) AddHostPort(tag string, hosts []string, ports []string, ttl time.Duration) error

func (*HostPortClassifier) FilterTagByHostPort

func (h *HostPortClassifier) FilterTagByHostPort(host string, port int) []string

type HostsFilter

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

func NewHostsFilter

func NewHostsFilter(excludeHosts ...string) *HostsFilter

func (*HostsFilter) Add

func (f *HostsFilter) Add(block ...string)

func (*HostsFilter) Contains

func (f *HostsFilter) Contains(target string) bool

type LimitRate

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

func NewLimitRate

func NewLimitRate(d time.Duration) *LimitRate

func (*LimitRate) WaitUntilNextAsync

func (l *LimitRate) WaitUntilNextAsync()

func (*LimitRate) WaitUntilNextAsyncWithFallback

func (l *LimitRate) WaitUntilNextAsyncWithFallback(f func())

func (*LimitRate) WaitUntilNextSync

func (l *LimitRate) WaitUntilNextSync()

type MatchedRule

type MatchedRule struct {
	Matched *regexp.Regexp
}

func ParseNmapServiceMatchedRule

func ParseNmapServiceMatchedRule(raw []byte) []*MatchedRule

type MergeErrors added in v1.2.6

type MergeErrors []error

func (MergeErrors) Error added in v1.2.6

func (m MergeErrors) Error() string

type OrderedMap added in v1.2.3

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

func NewOrderedMap added in v1.2.3

func NewOrderedMap() *OrderedMap

func (*OrderedMap) Delete added in v1.2.3

func (om *OrderedMap) Delete(key string)

func (*OrderedMap) Get added in v1.2.3

func (om *OrderedMap) Get(key string) (int, bool)

func (*OrderedMap) Print added in v1.2.3

func (om *OrderedMap) Print()

func (*OrderedMap) Set added in v1.2.3

func (om *OrderedMap) Set(key string, value int)

type PathForest

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

func GeneratePathTrees

func GeneratePathTrees(l ...string) (*PathForest, error)

func (*PathForest) Output

func (p *PathForest) Output() []*pathNode

type PathNodes

type PathNodes []*pathNode

type PortScanTarget

type PortScanTarget struct {
	Targets []string
	TCPPort string
	UDPPort string
}

func SplitHostsAndPorts

func SplitHostsAndPorts(hosts, ports string, portGroupSize int, proto string) []PortScanTarget

func (*PortScanTarget) String

func (t *PortScanTarget) String() string

type PortsFilter

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

func NewPortsFilter

func NewPortsFilter(blocks ...string) *PortsFilter

func (*PortsFilter) Add

func (f *PortsFilter) Add(block ...string)

func (*PortsFilter) Contains

func (f *PortsFilter) Contains(port int) bool

type ProbeRule

type ProbeRule struct {
	Type    ProtoType
	Payload []byte
	Matched []*MatchedRule
}

func ParseNmapServiceProbeRule

func ParseNmapServiceProbeRule(raw []byte) []*ProbeRule

type ProtoType

type ProtoType string
var (
	TCPProbe ProtoType = "tcp"
	UDPProbe ProtoType = "udp"
)

type Quake360Client

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

func NewQuake360Client

func NewQuake360Client(apiKey string) *Quake360Client

func (*Quake360Client) QueryNext

func (q *Quake360Client) QueryNext(start, size int, queries ...string) (*gjson.Result, error)

func (*Quake360Client) UserInfo

func (q *Quake360Client) UserInfo() (*quakeUserInfo, error)

type SSHClient

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

func SSHDial

func SSHDial(network, addr string, config *ssh.ClientConfig) (*SSHClient, error)

SSHDial starts a client connection to the given SSH server. This is wrap the ssh.SSHDial

func SSHDialWithKey

func SSHDialWithKey(addr, user, keyfile string) (*SSHClient, error)

SSHDialWithKey starts a client connection to the given SSH server with key authmethod.

func SSHDialWithKeyWithPassphrase

func SSHDialWithKeyWithPassphrase(addr, user, keyfile string, passphrase string) (*SSHClient, error)

SSHDialWithKeyWithPassphrase same as SSHDialWithKey but with a passphrase to decrypt the private key

func SSHDialWithPasswd

func SSHDialWithPasswd(addr, user, passwd string) (*SSHClient, error)

SSHDialWithPasswd starts a client connection to the given SSH server with passwd authmethod.

func (*SSHClient) Close

func (c *SSHClient) Close() error

func (*SSHClient) Cmd

func (c *SSHClient) Cmd(cmd string) *SSHRemoteScript

Cmd create a command on client

func (*SSHClient) CopyLocalFileToRemote

func (c *SSHClient) CopyLocalFileToRemote(srcFilePath string, dstFilePath string) error

Copy local file to remote

func (*SSHClient) CopyRemoteFileToLocal

func (c *SSHClient) CopyRemoteFileToLocal(dstFilePath string, srcFilePath string) error

Copy remote file to local

func (*SSHClient) Script

func (c *SSHClient) Script(script string) *SSHRemoteScript

Script

func (*SSHClient) ScriptFile

func (c *SSHClient) ScriptFile(fname string) *SSHRemoteScript

ScriptFile

func (*SSHClient) Shell

func (c *SSHClient) Shell() *SSHRemoteShell

Shell create a noninteractive shell on client.

func (*SSHClient) Terminal

func (c *SSHClient) Terminal(config *TerminalConfig) *SSHRemoteShell

Terminal create a interactive shell on client.

type SSHRemoteScript

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

func (*SSHRemoteScript) Cmd

func (rs *SSHRemoteScript) Cmd(cmd string) *SSHRemoteScript

func (*SSHRemoteScript) Output

func (rs *SSHRemoteScript) Output() ([]byte, error)

func (*SSHRemoteScript) Run

func (rs *SSHRemoteScript) Run() error

Run

func (*SSHRemoteScript) SetStdio

func (rs *SSHRemoteScript) SetStdio(stdout, stderr io.Writer) *SSHRemoteScript

func (*SSHRemoteScript) SmartOutput

func (rs *SSHRemoteScript) SmartOutput() ([]byte, error)

type SSHRemoteScriptType

type SSHRemoteScriptType byte

type SSHRemoteShell

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

func (*SSHRemoteShell) SetStdio

func (rs *SSHRemoteShell) SetStdio(stdin io.Reader, stdout, stderr io.Writer) *SSHRemoteShell

func (*SSHRemoteShell) Start

func (rs *SSHRemoteShell) Start() error

Start start a remote shell on client

type SSHRemoteShellType

type SSHRemoteShellType byte

type Set

type Set[T comparable] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSet added in v1.2.3

func NewSet[T comparable]() *Set[T]

func (*Set[T]) Add

func (s *Set[T]) Add(item T)

Add add

func (*Set[T]) AddList added in v1.2.6

func (s *Set[T]) AddList(items []T)

func (*Set[T]) Clear

func (s *Set[T]) Clear()

Clear removes all items from the set

func (*Set[T]) Has

func (s *Set[T]) Has(item T) bool

Has looks for the existence of an item

func (*Set[T]) IsEmpty

func (s *Set[T]) IsEmpty() bool

IsEmpty checks for emptiness

func (*Set[T]) Len

func (s *Set[T]) Len() int

Len returns the number of items in a set.

func (*Set[T]) List

func (s *Set[T]) List() []T

Set returns a slice of all items

func (*Set[T]) Remove

func (s *Set[T]) Remove(item T)

Remove deletes the specified item from the map

type SizedWaitGroup

type SizedWaitGroup struct {
	Size              int
	WaitingEventCount int
	// contains filtered or unexported fields
}

SizedWaitGroup has the same role and close to the same API as the Golang sync.WaitGroup but adds a limit of the amount of goroutines started concurrently.

func NewSizedWaitGroup

func NewSizedWaitGroup(limit int) *SizedWaitGroup

New creates a SizedWaitGroup. The limit parameter is the maximum amount of goroutines which can be started concurrently.

func (*SizedWaitGroup) Add

func (s *SizedWaitGroup) Add(delta ...int)

Add increments the internal WaitGroup counter. It can be blocking if the limit of spawned goroutines has been reached. It will stop blocking when Done is been called.

See sync.WaitGroup documentation for more information.

func (*SizedWaitGroup) AddWithContext

func (s *SizedWaitGroup) AddWithContext(ctx context.Context, delta ...int) error

AddWithContext increments the internal WaitGroup counter. It can be blocking if the limit of spawned goroutines has been reached. It will stop blocking when Done is been called, or when the context is canceled. Returns nil on success or an error if the context is canceled before the lock is acquired.

See sync.WaitGroup documentation for more information.

func (*SizedWaitGroup) Done

func (s *SizedWaitGroup) Done()

Done decrements the SizedWaitGroup counter. See sync.WaitGroup documentation for more information.

func (*SizedWaitGroup) Wait

func (s *SizedWaitGroup) Wait()

Wait blocks until the SizedWaitGroup counter is zero. See sync.WaitGroup documentation for more information.

type Stack

type Stack[T any] struct {
	// contains filtered or unexported fields
}

func NewStack

func NewStack[T any]() *Stack[T]

Create a new stack

func (*Stack[T]) CreateShadowStack added in v1.2.8

func (this *Stack[T]) CreateShadowStack() func()

CreateShadowStack creates a shadow stack, which can be used to restore the stack to its current state. dont pop the top item of the stack.

func (*Stack[T]) IsEmpty

func (this *Stack[T]) IsEmpty() bool

func (*Stack[T]) Len added in v1.2.8

func (this *Stack[T]) Len() int

Return the number of items in the stack

func (*Stack[T]) Peek

func (this *Stack[T]) Peek() T

View the top item on the stack

func (*Stack[T]) PeekN added in v1.2.8

func (this *Stack[T]) PeekN(n int) T

View the top n item on the stack

func (*Stack[T]) Pop

func (this *Stack[T]) Pop() T

Pop the top item of the stack and return it

func (*Stack[T]) Push

func (this *Stack[T]) Push(value T)

Push a value onto the top of the stack

func (*Stack[T]) Size

func (this *Stack[T]) Size() int

type StringRoundRobinSelector

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

func NewStringRoundRobinSelector

func NewStringRoundRobinSelector(l ...string) *StringRoundRobinSelector

func (*StringRoundRobinSelector) Add

func (s *StringRoundRobinSelector) Add(raw ...string)

func (*StringRoundRobinSelector) Len

func (s *StringRoundRobinSelector) Len() int

func (*StringRoundRobinSelector) List

func (s *StringRoundRobinSelector) List() []string

func (*StringRoundRobinSelector) Next

func (s *StringRoundRobinSelector) Next() string

type TerminalConfig

type TerminalConfig struct {
	Term   string
	Height int
	Weight int
	Modes  ssh.TerminalModes
}

type UserPassPair

type UserPassPair struct {
	Username, Password     string
	UserOffset, PassOffset int64
}

type WebHookServer

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

func NewWebHookServer

func NewWebHookServer(port int, cb func(data interface{})) *WebHookServer

func (*WebHookServer) Addr

func (w *WebHookServer) Addr() string

func (*WebHookServer) Shutdown

func (w *WebHookServer) Shutdown()

func (*WebHookServer) Start

func (w *WebHookServer) Start()

Directories

Path Synopsis
grdp/example
main.go
main.go
rfb.go
Package htmlquery provides extract data from HTML documents using XPath expression.
Package htmlquery provides extract data from HTML documents using XPath expression.
cmd
lowhttp2
Package http2 implements the HTTP/2 protocol.
Package http2 implements the HTTP/2 protocol.
lowhttp2/hpack
Package hpack implements HPACK, a compression format for efficiently representing HTTP header fields in the context of HTTP/2.
Package hpack implements HPACK, a compression format for efficiently representing HTTP header fields in the context of HTTP/2.
cmd
netroute
Originally found in https://github.com/google/gopacket/blob/master/routing/routing.go
Originally found in https://github.com/google/gopacket/blob/master/routing/routing.go
go-shodan
Package shodan is an interface for the Shodan API
Package shodan is an interface for the Shodan API
go-pkcs12
Package pkcs12 implements some of PKCS#12 (also known as P12 or PFX).
Package pkcs12 implements some of PKCS#12 (also known as P12 or PFX).
go-pkcs12/rc2
Package rc2 implements the RC2 cipher
Package rc2 implements the RC2 cipher

Jump to

Keyboard shortcuts

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