scan

package
v1.778.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsHttpxAvailable

func IsHttpxAvailable(clientId string) bool

IsHttpxAvailable checks if httpx is available in the system Returns true if httpx is available (either through clientId path or system PATH)

func IsNmapAvailable

func IsNmapAvailable(clientId string) bool

IsNmapAvailable checks if nmap is available in the system Returns true if nmap is available (either through clientId path or system PATH)

func IsNucleiAvailable

func IsNucleiAvailable(clientId string) bool

IsNucleiAvailable checks if nuclei is available in the system Returns true if nuclei is available (either through clientId path or system PATH)

func IsSubfinderAvailable

func IsSubfinderAvailable(clientId string) bool

IsSubfinderAvailable checks if subfinder is available in the system Returns true if subfinder is available (either through clientId path or system PATH)

func IsZapAvailable

func IsZapAvailable(clientId string) bool

IsZapAvailable checks if ZAP is available in the system Returns true if ZAP is available (either through clientId path or system PATH)

Types

type HttpxHost

type HttpxHost struct {
	Timestamp        string   `json:"timestamp,omitempty"`
	Hash             string   `json:"hash,omitempty"`
	Port             string   `json:"port,omitempty"`
	URL              string   `json:"url"`
	Input            string   `json:"input,omitempty"`
	Title            string   `json:"title,omitempty"`
	Scheme           string   `json:"scheme,omitempty"`
	Webserver        string   `json:"webserver,omitempty"`
	ContentType      string   `json:"content_type,omitempty"`
	Method           string   `json:"method,omitempty"`
	Host             string   `json:"host,omitempty"`
	Path             string   `json:"path,omitempty"`
	FavIconMMH3      string   `json:"favicon_mmh3,omitempty"`
	StatusCode       int      `json:"status_code,omitempty"`
	ContentLength    int      `json:"content_length,omitempty"`
	Words            int      `json:"words,omitempty"`
	Lines            int      `json:"lines,omitempty"`
	Failed           bool     `json:"failed,omitempty"`
	TLSData          string   `json:"tls,omitempty"`
	CSPData          string   `json:"csp,omitempty"`
	VHost            bool     `json:"vhost,omitempty"`
	WebSocket        bool     `json:"websocket,omitempty"`
	Technologies     []string `json:"technologies,omitempty"`
	A                []string `json:"a,omitempty"`
	CNAMEs           []string `json:"cname,omitempty"`
	ChainStatusCodes []int    `json:"chain_status_codes,omitempty"`
}

HttpxHost represents a single host probed by httpx

type HttpxScanProvider

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

func NewHttpxScanProvider

func NewHttpxScanProvider(clientId string) (*HttpxScanProvider, error)

func (*HttpxScanProvider) GetResultSummary

func (p *HttpxScanProvider) GetResultSummary(result string) string

GetResultSummary generates a short summary of the scan result

func (*HttpxScanProvider) ParseResult

func (p *HttpxScanProvider) ParseResult(rawResult string) (string, error)

func (*HttpxScanProvider) Scan

func (p *HttpxScanProvider) Scan(target string, command string) (string, error)
Example

Example demonstrates how to use the HttpxScanProvider

provider, err := NewHttpxScanProvider("")
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}

// Scan a URL
rawResult, err := provider.Scan("https://example.com", "-u %s -json")
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}

// Parse the result
result, err := provider.ParseResult(rawResult)
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}

var scanResult HttpxScanResult
json.Unmarshal([]byte(result), &scanResult)

fmt.Printf("Found %d hosts\n", scanResult.Summary.TotalHosts)

type HttpxScanResult

type HttpxScanResult struct {
	Hosts   []HttpxHost  `json:"hosts"`
	Summary HttpxSummary `json:"summary"`
}

HttpxScanResult represents the complete httpx scan result

type HttpxSummary

type HttpxSummary struct {
	TotalHosts   int            `json:"totalHosts"`
	ByStatusCode map[string]int `json:"byStatusCode"`
	ByScheme     map[string]int `json:"byScheme"`
	WithTech     int            `json:"withTech"`
}

HttpxSummary provides a summary of the scan results

type InstallProgress

type InstallProgress struct {
	PatchId         string `json:"patchId"`
	Status          string `json:"status"`
	PercentComplete int    `json:"percentComplete"`
	IsComplete      bool   `json:"isComplete"`
	RebootRequired  bool   `json:"rebootRequired"`
	Error           string `json:"error,omitempty"`
	StartTime       string `json:"startTime"`
	EndTime         string `json:"endTime,omitempty"`
}

InstallProgress represents the installation progress of a patch

type NmapHost

type NmapHost struct {
	IP       string     `json:"ip"`
	Hostname string     `json:"hostname,omitempty"`
	Status   string     `json:"status"`
	Ports    []NmapPort `json:"ports,omitempty"`
	OS       string     `json:"os,omitempty"`
	MACAddr  string     `json:"macAddr,omitempty"`
	Vendor   string     `json:"vendor,omitempty"`
	Latency  string     `json:"latency,omitempty"`
}

NmapHost represents a scanned host

type NmapPort

type NmapPort struct {
	Port    string `json:"port"`
	State   string `json:"state"`
	Service string `json:"service,omitempty"`
	Version string `json:"version,omitempty"`
}

NmapPort represents a scanned port

type NmapScanProvider

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

func NewNmapScanProvider

func NewNmapScanProvider(clientId string) (*NmapScanProvider, error)

func (*NmapScanProvider) GetResultSummary

func (p *NmapScanProvider) GetResultSummary(result string) string

GetResultSummary generates a short summary of the scan result

func (*NmapScanProvider) ParseResult

func (p *NmapScanProvider) ParseResult(rawResult string) (string, error)

func (*NmapScanProvider) Scan

func (p *NmapScanProvider) Scan(target string, command string) (string, error)

type NmapScanResult

type NmapScanResult struct {
	StartTime string     `json:"startTime,omitempty"`
	EndTime   string     `json:"endTime,omitempty"`
	Hosts     []NmapHost `json:"hosts"`
	Summary   string     `json:"summary"`
}

NmapScanResult represents the complete scan result

type NucleiScanProvider

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

func NewNucleiScanProvider

func NewNucleiScanProvider(clientId string) (*NucleiScanProvider, error)

func (*NucleiScanProvider) GetResultSummary

func (p *NucleiScanProvider) GetResultSummary(result string) string

GetResultSummary generates a short summary of the scan result

func (*NucleiScanProvider) ParseResult

func (p *NucleiScanProvider) ParseResult(rawResult string) (string, error)

func (*NucleiScanProvider) Scan

func (p *NucleiScanProvider) Scan(target string, command string) (string, error)
Example

Example demonstrates how to use the NucleiScanProvider

provider, err := NewNucleiScanProvider("")
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}

// Scan a target URL
rawResult, err := provider.Scan("https://example.com", "-u %s -jsonl")
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}

// Parse the result
result, err := provider.ParseResult(rawResult)
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}

var scanResult NucleiScanResult
json.Unmarshal([]byte(result), &scanResult)

fmt.Printf("Found %d vulnerabilities\n", scanResult.Summary.TotalVulnerabilities)

type NucleiScanResult

type NucleiScanResult struct {
	Vulnerabilities []NucleiVulnerability `json:"vulnerabilities"`
	Summary         NucleiSummary         `json:"summary"`
}

NucleiScanResult represents the complete Nuclei scan result

type NucleiSummary

type NucleiSummary struct {
	TotalVulnerabilities int            `json:"totalVulnerabilities"`
	BySeverity           map[string]int `json:"bySeverity"`
	ByType               map[string]int `json:"byType"`
}

NucleiSummary provides a summary of the scan results

type NucleiVulnerability

type NucleiVulnerability struct {
	TemplateID       string                 `json:"templateID"`
	Name             string                 `json:"name"`
	Type             string                 `json:"type"`
	Severity         string                 `json:"severity"`
	Host             string                 `json:"host"`
	MatchedAt        string                 `json:"matchedAt"`
	ExtractedResults []string               `json:"extractedResults,omitempty"`
	IP               string                 `json:"ip,omitempty"`
	Timestamp        string                 `json:"timestamp,omitempty"`
	CurlCommand      string                 `json:"curlCommand,omitempty"`
	Description      string                 `json:"description,omitempty"`
	Reference        []string               `json:"reference,omitempty"`
	Classification   map[string]interface{} `json:"classification,omitempty"`
	Metadata         map[string]interface{} `json:"metadata,omitempty"`
}

NucleiVulnerability represents a single vulnerability found by Nuclei

type OsPatchScanProvider

type OsPatchScanProvider struct {
}

OsPatchScanProvider provides Windows Update functionality using PSWindowsUpdate

func NewOsPatchScanProvider

func NewOsPatchScanProvider(clientId string) (*OsPatchScanProvider, error)

NewOsPatchScanProvider creates a new OsPatchScanProvider instance

func (*OsPatchScanProvider) GetResultSummary

func (p *OsPatchScanProvider) GetResultSummary(result string) string

GetResultSummary generates a short summary of the scan result

func (*OsPatchScanProvider) InstallPatch

func (p *OsPatchScanProvider) InstallPatch(patchId string) (*InstallProgress, error)

InstallPatch installs a specific patch by patch ID (KB number or title)

Example

Example demonstrates how to install a patch

provider, err := NewOsPatchScanProvider("")
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}

// Install a patch
progress, err := provider.InstallPatch("KB1234567")
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}

fmt.Printf("Installation status: %s\n", progress.Status)
fmt.Printf("Reboot required: %v\n", progress.RebootRequired)

func (*OsPatchScanProvider) ListAvailablePatches

func (p *OsPatchScanProvider) ListAvailablePatches() ([]*WindowsPatch, error)

ListAvailablePatches returns all available Windows OS patches that can be installed This queries the Windows Update online service to find patches that are available but not yet installed

Example

Example demonstrates how to use the OsPatchScanProvider to list available patches

provider, err := NewOsPatchScanProvider("")
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}

patches, err := provider.ListAvailablePatches()
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}

fmt.Printf("Available patches: %d\n", len(patches))
for _, patch := range patches {
	fmt.Printf("- %s (KB%s)\n", patch.Title, patch.KB)
}

func (*OsPatchScanProvider) ListInstalledPatches

func (p *OsPatchScanProvider) ListInstalledPatches() ([]*WindowsPatch, error)

ListInstalledPatches returns all recently installed patches, including those with "Pending restart" status This uses Get-WUHistory to read from local cache without querying Windows Update online service

func (*OsPatchScanProvider) ParseResult

func (p *OsPatchScanProvider) ParseResult(rawResult string) (string, error)

ParseResult implements the ScanProvider interface for OS patch scanning For OS patches, the raw result is already in JSON format, so this just returns it as-is

func (*OsPatchScanProvider) Scan

func (p *OsPatchScanProvider) Scan(target string, command string) (string, error)

Scan implements the ScanProvider interface for OS patch scanning The command parameter specifies the scan type: "available", "installed", "all", or "install:<patchId>" The target parameter is not used for OS patch scanning as it scans the local system

type ScanProvider

type ScanProvider interface {
	Scan(target string, command string) (string, error)
	ParseResult(rawResult string) (string, error)
	GetResultSummary(result string) string
}

func GetScanProvider

func GetScanProvider(typ string, clientId string, lang string) (ScanProvider, error)

type SubfinderScanProvider

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

func NewSubfinderScanProvider

func NewSubfinderScanProvider(clientId string) (*SubfinderScanProvider, error)

func (*SubfinderScanProvider) GetResultSummary

func (p *SubfinderScanProvider) GetResultSummary(result string) string

GetResultSummary generates a short summary of the scan result

func (*SubfinderScanProvider) ParseResult

func (p *SubfinderScanProvider) ParseResult(rawResult string) (string, error)

func (*SubfinderScanProvider) Scan

func (p *SubfinderScanProvider) Scan(target string, command string) (string, error)
Example

Example demonstrates how to use the SubfinderScanProvider

provider, err := NewSubfinderScanProvider("")
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}

// Scan a domain
rawResult, err := provider.Scan("example.com", "-d %s -json")
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}

// Parse the result
result, err := provider.ParseResult(rawResult)
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}

var scanResult SubfinderScanResult
json.Unmarshal([]byte(result), &scanResult)

fmt.Printf("Found %d subdomains\n", scanResult.Summary.TotalSubdomains)

type SubfinderScanResult

type SubfinderScanResult struct {
	Subdomains []SubfinderSubdomain `json:"subdomains"`
	Summary    SubfinderSummary     `json:"summary"`
}

SubfinderScanResult represents the complete Subfinder scan result

type SubfinderSubdomain

type SubfinderSubdomain struct {
	Host   string `json:"host"`
	Input  string `json:"input"`
	Source string `json:"source,omitempty"`
}

SubfinderSubdomain represents a single subdomain found by Subfinder

type SubfinderSummary

type SubfinderSummary struct {
	TotalSubdomains int            `json:"totalSubdomains"`
	BySource        map[string]int `json:"bySource"`
}

SubfinderSummary provides a summary of the scan results

type WindowsPatch

type WindowsPatch struct {
	Title                string `json:"title"`
	KB                   string `json:"kb"`
	Size                 string `json:"size"`
	Status               string `json:"status"`
	Description          string `json:"description"`
	RebootRequired       bool   `json:"rebootRequired"`
	InstalledOn          string `json:"installedOn,omitempty"`
	LastSearchTime       string `json:"lastSearchTime,omitempty"`
	Categories           string `json:"categories,omitempty"`
	IsInstalled          bool   `json:"isInstalled"`
	IsDownloaded         bool   `json:"isDownloaded"`
	IsMandatory          bool   `json:"isMandatory"`
	AutoSelectOnWebSites bool   `json:"autoSelectOnWebSites"`
}

WindowsPatch represents a Windows update patch

type ZapAlert

type ZapAlert struct {
	PluginID    string `json:"pluginid"`
	AlertRef    string `json:"alertRef"`
	Alert       string `json:"alert"`
	Name        string `json:"name"`
	RiskCode    string `json:"riskcode"`
	Confidence  string `json:"confidence"`
	RiskDesc    string `json:"riskdesc"`
	Description string `json:"desc"`
	Instances   []struct {
		URI      string `json:"uri"`
		Method   string `json:"method"`
		Param    string `json:"param"`
		Attack   string `json:"attack"`
		Evidence string `json:"evidence"`
	} `json:"instances"`
	Count     string `json:"count"`
	Solution  string `json:"solution"`
	Reference string `json:"reference"`
	CweID     string `json:"cweid"`
	WascID    string `json:"wascid"`
	SourceID  string `json:"sourceid"`
}

ZapAlert represents a single alert/vulnerability found by ZAP

type ZapScanProvider

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

func NewZapScanProvider

func NewZapScanProvider(clientId string) (*ZapScanProvider, error)

func (*ZapScanProvider) GetResultSummary

func (p *ZapScanProvider) GetResultSummary(result string) string

GetResultSummary generates a short summary of the scan result

func (*ZapScanProvider) ParseResult

func (p *ZapScanProvider) ParseResult(rawResult string) (string, error)

func (*ZapScanProvider) Scan

func (p *ZapScanProvider) Scan(target string, command string) (string, error)
Example

Example demonstrates how to use the ZapScanProvider

provider, err := NewZapScanProvider("")
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}

// Scan a target URL
rawResult, err := provider.Scan("http://example.com", "-cmd -quickurl %s -quickout /dev/stdout")
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}

// Parse the result
result, err := provider.ParseResult(rawResult)
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}

var scanResult ZapScanResult
json.Unmarshal([]byte(result), &scanResult)

fmt.Printf("Found %d alerts\n", scanResult.Summary.TotalAlerts)

type ZapScanResult

type ZapScanResult struct {
	Sites   []ZapSite  `json:"sites"`
	Summary ZapSummary `json:"summary"`
}

ZapScanResult represents the complete ZAP scan result

type ZapSite

type ZapSite struct {
	Name   string     `json:"@name"`
	Host   string     `json:"@host"`
	Port   string     `json:"@port"`
	SSL    string     `json:"@ssl"`
	Alerts []ZapAlert `json:"alerts"`
}

ZapSite represents a scanned site

type ZapSummary

type ZapSummary struct {
	TotalAlerts  int            `json:"totalAlerts"`
	ByRisk       map[string]int `json:"byRisk"`
	ByConfidence map[string]int `json:"byConfidence"`
}

ZapSummary provides a summary of the scan results

Jump to

Keyboard shortcuts

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