Core

package
v0.0.0-...-76277b0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const WrTimeout = 5 // 默认读写超时时间(秒)

Variables

View Source
var (
	AliveHosts []string                    // 存活主机列表
	ExistHosts = make(map[string]struct{}) // 已发现主机记录

)
View Source
var (
	LocalScan bool // 本地扫描模式标识
	WebScan   bool // Web扫描模式标识
)

全局变量定义

View Source
var Mutex = &sync.Mutex{}

Mutex 用于保护共享资源的并发访问

View Source
var ProbeString string

Functions

func AddScan

func AddScan(plugin string, info Common.HostInfo, ch *chan struct{}, wg *sync.WaitGroup)

AddScan 添加扫描任务并启动扫描 plugin: 插件名称 info: 目标信息 ch: 并发控制通道 wg: 等待组

func ArrayCountValueTop

func ArrayCountValueTop(arrInit []string, length int, flag bool) (arrTop []string, arrLen []int)

ArrayCountValueTop 统计IP地址段存活数量并返回TOP N结果

func CheckLive

func CheckLive(hostslist []string, Ping bool) []string

CheckLive 检测主机存活状态

func DecodeData

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

func DecodePattern

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

解码模式字符串,处理转义序列

func ExecCommandPing

func ExecCommandPing(ip string) bool

ExecCommandPing 执行系统Ping命令检测主机存活

func IsContain

func IsContain(items []string, item string) bool

IsContain 检查切片中是否包含指定元素

func NoPortScan

func NoPortScan(hostslist []string, ports string) []string

NoPortScan 生成端口列表(不进行扫描) hostslist: 主机列表 ports: 端口范围 返回地址列表

func PortConnect

func PortConnect(addr Addr, results chan<- ScanResult, timeout int64, wg *sync.WaitGroup)

PortConnect 执行单个端口连接检测 addr: 待检测的地址 results: 结果通道 timeout: 超时时间 wg: 等待组

func PortScan

func PortScan(hostslist []string, ports string, timeout int64) []string

PortScan 执行端口扫描 hostslist: 待扫描的主机列表 ports: 待扫描的端口范围 timeout: 超时时间(秒) 返回活跃地址列表

func RunIcmp1

func RunIcmp1(hostslist []string, conn *icmp.PacketConn, chanHosts chan string)

RunIcmp1 使用ICMP批量探测主机存活(监听模式)

func RunIcmp2

func RunIcmp2(hostslist []string, chanHosts chan string)

RunIcmp2 使用ICMP并发探测主机存活(无监听模式)

func RunPing

func RunPing(hostslist []string, chanHosts chan string)

RunPing 使用系统Ping命令并发探测主机存活

func Scan

func Scan(info Common.HostInfo)

Scan 执行扫描主流程 info: 主机信息结构体,包含扫描目标的基本信息

func ScanFunc

func ScanFunc(name *string, info *Common.HostInfo)

ScanFunc 执行扫描插件 name: 插件名称 info: 目标信息

Types

type Addr

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

Addr 表示待扫描的地址

type Directive

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

type Extras

type Extras struct {
	VendorProduct   string
	Version         string
	Info            string
	Hostname        string
	OperatingSystem string
	DeviceType      string
	CPE             string
}

func (*Extras) ToMap

func (e *Extras) ToMap() map[string]string

ToMap 将 Extras 转换为 map[string]string

type Info

type Info struct {
	Address string   // 目标IP地址
	Port    int      // 目标端口
	Conn    net.Conn // 网络连接
	Result  Result   // 探测结果
	Found   bool     // 是否成功识别服务
}

Info 定义单个端口探测的上下文信息

func (*Info) Connect

func (i *Info) Connect(msg []byte) []byte

Connect 发送数据并获取响应

func (*Info) GetInfo

func (i *Info) GetInfo(response []byte, probe *Probe)

GetInfo 分析响应数据并提取服务信息

func (*Info) PortInfo

func (i *Info) PortInfo()

PortInfo 执行端口服务识别的主要逻辑

func (*Info) Read

func (i *Info) Read() ([]byte, error)

Read 从连接读取响应

func (*Info) Write

func (i *Info) Write(msg []byte) error

Write 写入数据到连接

type Match

type Match struct {
	IsSoft          bool           // 是否为软匹配
	Service         string         // 服务名称
	Pattern         string         // 匹配模式
	VersionInfo     string         // 版本信息格式
	FoundItems      []string       // 找到的项目
	PatternCompiled *regexp.Regexp // 编译后的正则表达式
}

func (*Match) MatchPattern

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

MatchPattern 使用正则表达式匹配响应内容

func (*Match) ParseVersionInfo

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

ParseVersionInfo 解析版本信息并返回额外信息结构

type PortInfoScanner

type PortInfoScanner struct {
	Address string        // 目标IP地址
	Port    int           // 目标端口
	Conn    net.Conn      // 网络连接
	Timeout time.Duration // 超时时间
	// contains filtered or unexported fields
}

PortInfoScanner 定义端口服务识别器

func NewPortInfoScanner

func NewPortInfoScanner(addr string, port int, conn net.Conn, timeout time.Duration) *PortInfoScanner

NewPortInfoScanner 创建新的端口服务识别器实例

func (*PortInfoScanner) Identify

func (s *PortInfoScanner) Identify() (*ServiceInfo, error)

Identify 执行服务识别,返回识别结果

type Probe

type Probe struct {
	Name     string // 探测器名称
	Data     string // 探测数据
	Protocol string // 协议
	Ports    string // 端口范围
	SSLPorts string // SSL端口范围

	TotalWaitMS  int    // 总等待时间
	TCPWrappedMS int    // TCP包装等待时间
	Rarity       int    // 稀有度
	Fallback     string // 回退探测器名称

	Matchs *[]Match // 匹配规则列表
}

func (*Probe) ContainsPort

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

ContainsPort 检查指定端口是否在探测器的端口范围内

type ProbesRarity

type ProbesRarity []Probe

ProbesRarity 用于按稀有度排序的探测器切片

func (ProbesRarity) Len

func (ps ProbesRarity) Len() int

Len 返回切片长度,实现 sort.Interface 接口

func (ProbesRarity) Less

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

Less 比较函数,按稀有度升序排序,实现 sort.Interface 接口

func (ProbesRarity) Swap

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

Swap 交换切片中的两个元素,实现 sort.Interface 接口

type Result

type Result struct {
	Service Service           // 识别出的服务信息
	Banner  string            // 服务横幅
	Extras  map[string]string // 额外信息
	Send    []byte            // 发送的探测数据
	Recv    []byte            // 接收到的响应数据
}

Result 定义单次探测的结果

type ScanResult

type ScanResult struct {
	Address string       // IP地址
	Port    int          // 端口号
	Service *ServiceInfo // 服务信息
}

ScanResult 扫描结果

type ScanTask

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

ScanTask 扫描任务结构体

type Service

type Service struct {
	Name   string            // 服务名称
	Extras map[string]string // 服务的额外属性
}

Service 定义服务的基本信息

type ServiceInfo

type ServiceInfo struct {
	Name    string            // 服务名称,如 http、ssh 等
	Banner  string            // 服务返回的横幅信息
	Version string            // 服务版本号
	Extras  map[string]string // 其他额外信息,如操作系统、产品名等
}

ServiceInfo 定义服务识别的结果信息

type Target

type Target struct {
	IP       string // 目标IP地址
	Port     int    // 目标端口
	Protocol string // 协议类型
}

Target 定义目标结构体

func (*Target) GetAddress

func (t *Target) GetAddress() string

GetAddress 获取目标的完整地址(IP:端口)

type VScan

type VScan struct {
	Exclude        string
	AllProbes      []Probe
	UdpProbes      []Probe
	Probes         []Probe
	ProbesMapKName map[string]Probe
}

func (*VScan) Init

func (v *VScan) Init()

Init 初始化VScan对象

func (*VScan) SetusedProbes

func (v *VScan) SetusedProbes()

设置使用的探测器

Jump to

Keyboard shortcuts

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