utils

package
v3.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TopPorts1000 = "" /* 3813-byte string literal not displayed */
	TopPorts100  = "" /* 393-byte string literal not displayed */
	TopPorts10   = "21-23,80,139,443,445,3306,3389,8080"
)
View Source
var Socks5Proxy string

Functions

func BigIntToIPV6

func BigIntToIPV6(i *big.Int) string

BigIntToIPV4 将大整数格式的IP地址转换为点分格式

func CheckDomain

func CheckDomain(domain string) bool

func CheckFileExist

func CheckFileExist(filepath string) bool

CheckFileExist 检测文件或目录是否存在

func CheckIP

func CheckIP(ip string) bool

CheckIP 通过正则检查是否是ipv4或ipv6地址

func CheckIPLocationInChinaMainLand

func CheckIPLocationInChinaMainLand(ipLocation string) bool

CheckIPLocationInChinaMainLand 根据IP归属地判断是否是属于中国大陆的IP地区

func CheckIPLocationInChinaOther

func CheckIPLocationInChinaOther(ipLocation string) bool

CheckIPLocationInChinaOther 根据IP归属地判断是否是属于中国非大陆地区

func CheckIPLocationOutsideChina

func CheckIPLocationOutsideChina(ipLocation string) bool

CheckIPLocationOutsideChina 根据IP归属地判断是否是属于非中国区域

func CheckIPOrSubnet

func CheckIPOrSubnet(ip string) bool

CheckIPOrSubnet 通过正则检查是否是ipv4、ipv6地址或CIDR

func CheckIPV4

func CheckIPV4(ip string) bool

func CheckIPV4Subnet

func CheckIPV4Subnet(ip string) bool

CheckIPV4Subnet 检查是否是ipv4地址段

func CheckIPV6

func CheckIPV6(ip string) bool

CheckIPV6 检查是否是ipv6地址

func CheckIPV6Subnet

func CheckIPV6Subnet(ip string) bool

func CompareStringSlices

func CompareStringSlices(s1, s2 []string, isSort bool) bool

func DownloadFile

func DownloadFile(url, dstPathFile string) (bool, error)

DownloadFile 下载文件

func FormatPorts added in v3.2.0

func FormatPorts(ports []int) string

FormatPorts 将端口号切片格式化为端口列表字符串

func FormatTargetByPortList added in v3.2.0

func FormatTargetByPortList(target string, portList []int) string

func GetClientIp

func GetClientIp() (ip string, err error)

GetClientIp 获取客户端IP

func GetDomainName

func GetDomainName(domain string) string

func GetDomainPort

func GetDomainPort(domain string) int

func GetFaviconSuffixUrl

func GetFaviconSuffixUrl(u string) string

GetFaviconSuffixUrl 获取favicon文件的后缀名称

func GetFaviconSuffixUrlFile

func GetFaviconSuffixUrlFile(u string) string

GetFaviconSuffixUrlFile 获取favicon文件名

func GetIPV6CIDRParsedFormat

func GetIPV6CIDRParsedFormat(ip string) string

GetIPV6CIDRParsedFormat 将IPv6地址段进行格式化(缩写)

func GetIPV6FullFormat

func GetIPV6FullFormat(ip string) string

GetIPV6FullFormat 将IPv6地址进行格式化(完全展开格式)

func GetIPV6ParsedFormat

func GetIPV6ParsedFormat(ip string) string

GetIPV4ParsedFormat 将IPv6地址进行格式化(缩写)

func GetIPV6SubnetC

func GetIPV6SubnetC(ip string) string

GetIPV6SubnetC 生成IPv6的C段掩码地址

func GetOutBoundIP

func GetOutBoundIP() (ip string, err error)

GetOutBoundIP 获取本机出口IP

func GetProtocol

func GetProtocol(host string, Timeout int64) (protocol string)

GetProtocol 检测URL协议

func GetProxyHttpClient

func GetProxyHttpClient(isProxy bool) *http.Client

GetProxyHttpClient 获取代理的http client

func GetRandomString2

func GetRandomString2(n int) string

GetRandomString2 生成指定长度的随机字符串

func GetTempPNGPathFileName

func GetTempPNGPathFileName() (pathFileName string)

GetTempPNGPathFileName 获取一个临时文件名,后缀为PNG

func GetTempPathDirName

func GetTempPathDirName() (pathDirName string)

GetTempPathDirName 获取一个临时目录

func GetTempPathFileName

func GetTempPathFileName() (pathFileName string)

GetTempPathFileName 获取一个临时文件名

func GetThirdpartyBinNameByPlatform

func GetThirdpartyBinNameByPlatform(binShortName BinShortName) (binPlatformName string)

GetThirdpartyBinNameByPlatform 根据当前运行平台及架构,生成指定的文件名称

func IPV4ToUInt32

func IPV4ToUInt32(ip string) uint32

IPV4ToUInt32 将点分格式的IP地址转换为UINT32

func IPV6DoubleInt64ToString

func IPV6DoubleInt64ToString(highSum, lowSum uint64) string

func IPV6Prefix64ToUInt64

func IPV6Prefix64ToUInt64(ip string) uint64

IPV6Prefix64ToUInt64 将IPv6地址段的Prefix段(前64位)转换为uint64

func IPV6ToBigInt

func IPV6ToBigInt(ipString string) *big.Int

IPV6ToBigInt 将点分格式的IP地址转换为大整数

func IPV6ToDoubleInt64

func IPV6ToDoubleInt64(ipString string) (uint64, uint64)

IPV6ToDoubleInt64 ipv6转换为两个int64

func MD5

func MD5(s string) string

func MD5Bytes

func MD5Bytes(b []byte) string

func MakePath

func MakePath(filepath string) bool

MakePath 创建目录,如果目录存在则直接返回

func MarshalTargetMap added in v3.2.0

func MarshalTargetMap(targetMap map[string]string) string

func MergeMapStringInt

func MergeMapStringInt(dstMap map[string]int, srcMap map[string]int)

func MergeTarget added in v3.2.0

func MergeTarget(targets ...string) string

func ParseHost

func ParseHost(u string) string

ParseHost 将http://a.b.c:80/这种url去除不相关的字符,返回主机名

func ParseHostPort

func ParseHostPort(u string) (string, int)

ParseHostPort 将http://a.b.c:80/这种url去除不相关的字符,返回主机名,端口号

func ParseHostUrl

func ParseHostUrl(u string) (isIpv6 bool, ip string, port int)

ParseHostUrl ipv4/v6地址格式识别的通用函数,用于识别ipv4,ipv4:port,ipv6,[ipv6],[ipv6]:port的形式

func ParseIP

func ParseIP(ip string) (ipResults []string)

ParseIP 将IP地址、IP地址段、IP地址范围解析为IP地址列表,支持ipv4/ipv6

func ParsePortList added in v3.2.0

func ParsePortList(portList string) []int

ParsePortList 解析端口列表字符串为单个端口号

func ReSizeAndCropPicture

func ReSizeAndCropPicture(srcFile, dstFile string, width, height int) bool

ReSizeAndCropPicture 对图片文件尺寸缩放、剪裁

func ReSizePicture

func ReSizePicture(srcFile, dstFile string, width, height int) bool

ReSizePicture 对图片文件尺寸缩放

func RemoveDuplicatesAndSort added in v3.1.0

func RemoveDuplicatesAndSort(arr []string) []string

RemoveDuplicatesAndSort 将字符串数组转换为小写,去除重复元素并排序

func RemoveDuplicationElement

func RemoveDuplicationElement(arr []string) []string

RemoveDuplicationElement 去除重复切片元素

func ReturnListTypedTargetMap added in v3.2.0

func ReturnListTypedTargetMap(typeKey string, targets []string) (targetMap map[string]string)

func ReturnTypedTargetMap added in v3.2.0

func ReturnTypedTargetMap(typeKey string, target string) (targetMap map[string]string)

func SHA512

func SHA512(s string) string

func SetToSlice

func SetToSlice(setMap map[string]struct{}) (list []string)

SetToSlice 将Set(由map模拟实现)结果转化为列表结果

func SetToSliceBigInt

func SetToSliceBigInt(setMap map[*big.Int]struct{}) (list []*big.Int)

SetToSliceBigInt 将Set(由map模拟实现)结果转化为列表结果

func SetToSliceInt

func SetToSliceInt(setMap map[int]struct{}) (list []int)

SetToSliceInt 将Set(由map模拟实现)结果转化为列表结果

func SetToSliceStringInt

func SetToSliceStringInt(setMap map[string]int) (list []string)

SetToSliceStringInt 将Set(由map模拟实现)结果转化为列表结果

func SetToSliceUInt

func SetToSliceUInt(setMap map[uint32]struct{}) (list []uint32)

SetToSliceUInt 将Set(由map模拟实现)结果转化为列表结果

func SetToString

func SetToString(setMap map[string]struct{}) string

SetToString 将Set(由map模拟实现)结果转化为拼结的字符

func SortTimeMap

func SortTimeMap(m map[time.Time]string, isDesc bool) []string

func SplitPort added in v3.2.0

func SplitPort(portList string, sliceNumber int) []string

func UInt32ToIPV4

func UInt32ToIPV4(ip uint32) string

UInt32ToIPV4 将UINT32格式的IP地址转换为点分格式

func UnmarshalTargetMap added in v3.2.0

func UnmarshalTargetMap(content string) (targetMap map[string]string)

func WrapperTCP

func WrapperTCP(network, address string, timeout time.Duration) (net.Conn, error)

func WrapperTCPWithSocks5

func WrapperTCPWithSocks5(network, address string, forward *net.Dialer) (net.Conn, error)

Types

type BinShortName

type BinShortName string
const (
	MassDns      BinShortName = "massdns"
	Nuclei       BinShortName = "nuclei"
	Worker       BinShortName = "worker"
	Server       BinShortName = "server"
	Httpx        BinShortName = "httpx"
	Subfinder    BinShortName = "subfinder"
	Fingerprintx BinShortName = "fingerprintx"
	Gogo         BinShortName = "gogo"
	Zombie       BinShortName = "zombie"
)

type Pair

type Pair struct {
	Key   string
	Value int
}

type PairList

type PairList []Pair

func SortMapByValue

func SortMapByValue(mapData map[string]int, descSort bool) (r PairList)

SortMapByValue 对map[string]int按value排序,返回k,v的列表

func (PairList) Len

func (p PairList) Len() int

func (PairList) Less

func (p PairList) Less(i, j int) bool

func (PairList) Swap

func (p PairList) Swap(i, j int)

type TldExtract added in v3.2.0

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

func NewTldExtract added in v3.2.0

func NewTldExtract() TldExtract

NewTldExtract 创建TldExtract对象

func (*TldExtract) ExtractFLD added in v3.2.0

func (t *TldExtract) ExtractFLD(url string) (fldDomain string)

ExtractFLD 从url或domain中提取FLD

Jump to

Keyboard shortcuts

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