utils

package
v1.1.27 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 44 Imported by: 0

Documentation

Overview

credit vscan

Index

Constants

View Source
const (
	LevelInfo = iota
	LevelSuccess
	LevelFailed
	LevelWarning
	LevelError
	LevelFatal
	LevelDebug
)
View Source
const (
	INT_MAX = int(^uint(0) >> 1)
	INT_MIN = ^INT_MAX
)

Variables

View Source
var (
	Client           *http.Client
	ClientNoRedirect *http.Client
)

Functions

func AddDataToTable added in v1.1.14

func AddDataToTable(table *tablewriter.Table, data []string)

func AddStringToString

func AddStringToString(x string, seps []string, y string) []string

func ApiDeDuplicate added in v1.1.24

func ApiDeDuplicate(RootPath string, filename string)

func CheckFinger added in v1.1.8

func CheckFinger(finger string, title string, Url string, contentType string, location string, respBody []byte, statusCode int) []string

func ConfigInit added in v1.1.19

func ConfigInit()

func Debug

func Debug(format string, args ...interface{})

func DecodeData added in v1.1.19

func DecodeData(s string) ([]byte, error)

func DecodePattern added in v1.1.19

func DecodePattern(s string) ([]byte, error)

func DirBrute

func DirBrute(baseUrl string, dir string) []string

func DisplayHeader

func DisplayHeader(Url string, Method string)

func Error

func Error(format string, args ...interface{})

func Errorf

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

func Failed

func Failed(format string, args ...interface{})

func Fatal

func Fatal(format string, args ...interface{})

func FilReadUrl added in v1.1.20

func FilReadUrl(filename string) []string

func FileReadLine added in v1.1.20

func FileReadLine(filename string) []string

func FileWrite added in v1.1.9

func FileWrite(filename string, format string, args ...interface{})

func FindFaviconURL

func FindFaviconURL(urlStr string) (string, error)

func FingerScan added in v1.1.8

func FingerScan(url string, method string, followRedirect bool) (string, string, string, string, string, []byte, int)

func FirstCharToUpper

func FirstCharToUpper(Name string) string

func GenerateWeakPassword

func GenerateWeakPassword() []string

func GetCurrentTime added in v1.1.26

func GetCurrentTime() string

func GetStructCodeMap added in v1.1.19

func GetStructCodeMap() map[int][]byte

解析 nmap-service-probes 中匹配规则字符串,转换成 golang 中可以进行编译的字符串

  e.g.
	(1) pattern: \0\xffHi
		decoded: []byte{0, 255, 72, 105} 4len

	(2) pattern: \\0\\xffHI
		decoded: []byte{92, 0, 92, 120, 102, 102, 72, 105} 8len

	(3) pattern: \x2e\x2a\x3f\x2b\x7b\x7d\x28\x29\x5e\x24\x7c\x5c
		decodedStr: \.\*\?\+\{\}\(\)\^\$\|\\

func HalfCharToUpper

func HalfCharToUpper(Name string) string

func HighLight

func HighLight(data string, keywords []string, fingers []string, Url string)

func HttpGetServerHeader

func HttpGetServerHeader(Url string, NeedTitle bool, Method string) (string, string, string, error)

func IconDetect

func IconDetect(Url string) (string, error)

func ImportantApiJudge added in v1.1.19

func ImportantApiJudge(ApiResult string, Url string)

func Info

func Info(format string, args ...interface{})

func InitHttp

func InitHttp()

func InitHttpClient

func InitHttpClient(ThreadsNum int, DownProxy string, Timeout time.Duration) error

func IsVuePath

func IsVuePath(Path string) bool

func LastCharToUpper

func LastCharToUpper(Name string) string

func LogBeautify added in v1.1.8

func LogBeautify(x string, colorAttr color.Attribute, y string, level int)

func MapToJson

func MapToJson(param map[string][]string) string

func Max

func Max(nums ...int) int

func MightBeChineseName

func MightBeChineseName(Name string) bool

func MightBeIdentityCard

func MightBeIdentityCard(IdentityCard string) bool

func MightBePhone

func MightBePhone(Phone string) bool

func Min

func Min(nums ...int) int

func Mmh3Hash32

func Mmh3Hash32(raw []byte) string

func Normalize

func Normalize(Path string, RootPath string) string

func PortScan added in v1.1.19

func PortScan(IpRange string, PortRange string)

func PrintFinger

func PrintFinger(Url string, Depth int)

func PrintTable added in v1.1.11

func PrintTable(Url string, key string, data []SensitiveData)

func Quote

func Quote(x string) string

func RandomString added in v1.1.7

func RandomString(length int) string

func RemoveDuplicateElement

func RemoveDuplicateElement(originals interface{}) (interface{}, error)

func RemoveDuplicatesString added in v1.1.20

func RemoveDuplicatesString(arr []string) []string

func ReplaceWithTable

func ReplaceWithTable(input string) string

func ScanWithIpAndPort added in v1.1.19

func ScanWithIpAndPort(addr []ProtocolInfo)

func SecList added in v1.1.11

func SecList() string

func SensitiveInfoCollect

func SensitiveInfoCollect(Url string, Content string, filename string)

func SetHeaders added in v1.1.27

func SetHeaders(req *http.Request)

func ShowInfo

func ShowInfo()

func SimHash added in v1.1.8

func SimHash(input []byte) uint64

func Spider

func Spider(RootPath string, Url string, depth int, filename string, myMap mapset.Set) error

func StandBase64

func StandBase64(braw []byte) []byte

func StringListToInterfaceList

func StringListToInterfaceList(tmpList []string) []interface{}

func Success

func Success(format string, args ...interface{})

func TranslateToEnglish

func TranslateToEnglish(Name string) (string, string, string, string)

func UrlFilter added in v1.1.16

func UrlFilter(Url string) bool

func UrlFormated added in v1.1.19

func UrlFormated(lines []string) []string

func Warning

func Warning(format string, args ...interface{})

func WriteToCsv added in v1.1.14

func WriteToCsv(filename string, data []string)

Types

type Config added in v1.1.19

type Config struct {
	Rarity   int
	Routines int

	SendTimeout time.Duration
	ReadTimeout time.Duration

	NULLProbeOnly bool
	UseAllProbes  bool
	SSLAlwaysTry  bool
}

VScan 探测时的参数配置

type Details added in v1.1.19

type Details struct {
	ProbeName     string `json:"probe_name"`
	ProbeData     string `json:"probe_data"`
	MatchMatched  string `json:"match_matched"`
	IsSoftMatched bool   `json:"soft_matched"`
}

详细的结果数据(包含具体的 Probe 和匹配规则信息)

type Directive added in v1.1.19

type Directive struct {
	DirectiveName string
	Flag          string
	Delimiter     string
	DirectiveStr  string
}

type Extras added in v1.1.19

type Extras struct {
	VendorProduct   string `json:"vendor_product,omitempty"`
	Version         string `json:"version,omitempty"`
	Info            string `json:"info,omitempty"`
	Hostname        string `json:"hostname,omitempty"`
	OperatingSystem string `json:"operating_system,omitempty"`
	DeviceType      string `json:"device_type,omitempty"`
	CPE             string `json:"cpe,omitempty"`
}

对应 NMap versioninfo 信息

type Fingerprint

type Fingerprint struct {
	Cms      string
	Method   string
	Location string
	Keyword  []string
}

type IpHash added in v1.1.23

type IpHash struct {
	Ip   string
	Hash uint64
}

type Match added in v1.1.19

type Match struct {
	IsSoft bool

	Service     string
	Pattern     string
	VersionInfo string

	PatternCompiled *regexp2.Regexp
}

nmap-service-probes 中每一条规则

func (*Match) MatchPattern added in v1.1.19

func (m *Match) MatchPattern(response []byte) bool

对获取到的 Banner 进行匹配

func (*Match) ParseVersionInfo added in v1.1.19

func (m *Match) ParseVersionInfo(response []byte) Extras

type Packjson

type Packjson struct {
	Fingerprint []Fingerprint
}

type Pair

type Pair struct {
	Key   string
	Value int
}

type PairList

type PairList []Pair

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 Probe added in v1.1.19

type Probe struct {
	Name        string
	Data        string
	DecodedData []byte
	Protocol    string

	Ports    string
	SSLPorts string

	TotalWaitMS  int
	TCPWrappedMS int
	Rarity       int
	Fallback     string

	Matchs *[]Match
}

探针规则,包含该探针规则下的服务匹配条目和其他探测信息

func (*Probe) ContainsPort added in v1.1.19

func (p *Probe) ContainsPort(testPort int) bool

func (*Probe) ContainsSSLPort added in v1.1.19

func (p *Probe) ContainsSSLPort(testPort int) bool

type ProbesRarity added in v1.1.19

type ProbesRarity []Probe

ProbesRarity 用于使用 sort 对 Probe 对象按 Rarity 属性值进行排序

func (ProbesRarity) Len added in v1.1.19

func (ps ProbesRarity) Len() int

func (ProbesRarity) Less added in v1.1.19

func (ps ProbesRarity) Less(i, j int) bool

func (ProbesRarity) Swap added in v1.1.19

func (ps ProbesRarity) Swap(i, j int)

type ProtocolInfo added in v1.1.19

type ProtocolInfo struct {
	Ip   string
	Port int
}

type Result added in v1.1.19

type Result struct {
	Target
	Service `json:"service"`

	Timestamp int32  `json:"timestamp"`
	Error     string `json:"error"`
}

输出的结果数据

type SensitiveData added in v1.1.11

type SensitiveData struct {
	Content string
	Entropy float64
}

func DeduplicateByContent added in v1.1.11

func DeduplicateByContent(data []SensitiveData) []SensitiveData

type Service added in v1.1.19

type Service struct {
	Target

	Name        string `json:"name"`
	Protocol    string `json:"protocol"`
	Banner      string `json:"banner"`
	BannerBytes []byte `json:"banner_bytes"`

	Extras  `json:"extras"`
	Details `json:"details"`
}

获取的端口服务信息

type ServiceInfo added in v1.1.19

type ServiceInfo struct {
	Addr   string
	Banner string
}

type Target added in v1.1.19

type Target struct {
	IP       string `json:"ip"`
	Port     int    `json:"port"`
	Protocol string `json:"protocol"`
}

待探测的目标端口

func (*Target) GetAddress added in v1.1.19

func (t *Target) GetAddress() string

type VScan added in v1.1.19

type VScan struct {
	Exclude string

	Probes []Probe

	ProbesMapKName map[string]Probe
}

func (*VScan) Explore added in v1.1.19

func (v *VScan) Explore(target Target, config *Config) (Result, error)

VScan 探测目标端口函数,返回探测结果和错误信息 1. probes ports contains port 2. probes sslports contains port 3. probes ports contains port use ssl try to

func (*VScan) Init added in v1.1.19

func (v *VScan) Init()

从文件中解析并加载 Probes 初始化 VScan 实例

type Worker added in v1.1.19

type Worker struct {
	In     chan Target
	Out    chan Result
	Config *Config
}

func (*Worker) Start added in v1.1.19

func (w *Worker) Start(v *VScan, wg *sync.WaitGroup)

Jump to

Keyboard shortcuts

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