utils

package
v0.0.0-...-0b9a7cd Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: Apache-2.0 Imports: 37 Imported by: 14

Documentation

Index

Constants

View Source
const (
	DefaultMode            int = 0
	SliceByLine            int = 1
	SliceByIP              int = 2
	SliceByPort            int = 3
	SliceByIPAndPort       int = 4
	DefaultIpSliceNumber   int = 64
	DefaultPortSliceNumber int = 1000

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

Variables

View Source
var Socks5Proxy string

Functions

func AesDecryptCBC

func AesDecryptCBC(encrypted []byte, key []byte) (decrypted []byte)

func AesDecryptCFB

func AesDecryptCFB(encrypted []byte, key []byte) (decrypted []byte)

func AesDecryptECB

func AesDecryptECB(encrypted []byte, key []byte) (decrypted []byte)

func AesEncryptCBC

func AesEncryptCBC(origData []byte, key []byte) (encrypted []byte)

func AesEncryptCFB

func AesEncryptCFB(origData []byte, key []byte) (encrypted []byte)

func AesEncryptECB

func AesEncryptECB(origData []byte, key []byte) (encrypted []byte)

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 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 DownloadFile

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

DownloadFile 下载文件

func FindDomain

func FindDomain(content string) []string

FindDomain 从字符串中提取域名

func FindIPV4

func FindIPV4(content string) []string

FindIPV4 从字符串中提取出所有的ipv4地址

func FormatHostUrl

func FormatHostUrl(protocol, host string, port int) string

FormatHostUrl 将ipv4/v6生成url格式,ipv6生成url时,必须增加[]

func GenerateRSAKey

func GenerateRSAKey(bits int) (err error, publicKeyText []byte, privateKeyText []byte)

GenerateRSAKey 生成RSA私钥和公钥,保存到文件中

func GenerateRSAKeyFile

func GenerateRSAKeyFile(bits int, savedKeyFilePath string) (err error)

GenerateRSAKeyFile 生成RSA私钥和公钥,保存到文件中

func GetClientIp

func GetClientIp() (ip string, err error)

GetClientIp 获取客户端IP

func GetFaviconSuffixUrl

func GetFaviconSuffixUrl(u string) string

GetFaviconSuffixUrl 获取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 IPV6Prefix64ToUInt64

func IPV6Prefix64ToUInt64(ip string) uint64

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

func IPV6ToBigInt

func IPV6ToBigInt(ipString string) *big.Int

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

func MD5

func MD5(s string) string

func MD5V3

func MD5V3(str string) string

func MakePath

func MakePath(filepath string) bool

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

func MergeMapStringInt

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

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 RSADecrypt

func RSADecrypt(cipherText []byte, keyFilePathName string) (plainText []byte, err error)

RSADecrypt RSA解密

func RSADecryptFromPemText

func RSADecryptFromPemText(cipherText []byte, pemFileText []byte) (plainText []byte, err error)

RSADecryptFromPemText RSA解密

func RSAEncrypt

func RSAEncrypt(plainText []byte, keyFilePathName string) (cipherText []byte, err error)

RSAEncrypt RSA加密

func RSAEncryptFromPemText

func RSAEncryptFromPemText(plainText []byte, pemFileText []byte) (cipherText []byte, err error)

RSAEncryptFromPemText RSA加密

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 RemoveDuplicationElement

func RemoveDuplicationElement(arr []string) []string

RemoveDuplicationElement 去除重复切片元素

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 UInt32ToIPV4

func UInt32ToIPV4(ip uint32) string

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

func Unzip

func Unzip(archiveFile, dstPath string) error

Unzip 解压zip文件

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 (
	ObserverWard BinShortName = "observer_ward"
	MassDns      BinShortName = "massdns"
	Xray         BinShortName = "xray"
	Nuclei       BinShortName = "nuclei"
	Worker       BinShortName = "worker"
	Httpx        BinShortName = "httpx"
	Subfinder    BinShortName = "subfinder"
	Fingerprintx BinShortName = "fingerprintx"
	Gogo         BinShortName = "gogo"
)

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 TaskSlice

type TaskSlice struct {
	IpTarget        []string
	DomainTarget    []string
	Port            string
	TaskMode        int
	IpSliceNumber   int
	PortSliceNumber int
}

TaskSlice 任务切分

func NewTaskSlice

func NewTaskSlice() *TaskSlice

NewTaskSlice 创建任务切分对象

func (*TaskSlice) DoDomainSlice

func (t *TaskSlice) DoDomainSlice() (target []string)

DoDomainSlice 对域名任务目标进行切分 只支持0,1两种模式

func (*TaskSlice) DoIpSlice

func (t *TaskSlice) DoIpSlice() (target []string, port []string)

DoIpSlice 对IP任务目标进行切分 支持0-4共5种切分模式

Jump to

Keyboard shortcuts

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