cli

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

  • Package cmd @Author: zhizhuo @IDE:GoLand @File: banner.go @Date: 2025/2/20 下午3:39*

Package cli 是 gxx 的命令行前端:参数解析、目标加载、进度与终端显示。

识别与结果输出全部由 SDK 完成,命令行的 JSON / CSV / TXT / Socket 输出与 SDK 的 Writer 是同一套实现和同一种数据结构。

Package cli 命令行参数解析。

参数解析只依赖标准库 flag:SDK 与 CLI 共用的 types 包不再为一个字符串切片 引入第三方命令行框架及其传递依赖。

Index

Constants

This section is empty.

Variables

View Source
 _______  ___  _
/  __\  \/\  \//
| |  _\  / \  / 
| |_///  \ /  \ 
\____/__/\/__/\\`) + "\n\n\t\tVersion: " + defaultVersion +
	"\n\t\tAuthor: " + defaultAuthor +
	"\n\t\tBuild: " + getBuildDate()

Banner 程序启动时显示的横幅

View Source
var ErrHelp = flag.ErrHelp

ErrHelp 表示用户请求了帮助信息;用法已输出,调用方应以 0 退出。

Functions

func LoadTargets added in v1.5.0

func LoadTargets(options *Options) ([]string, int, error)

LoadTargets 返回去重后的扫描目标,保持输入顺序。

命令行目标优先于目标文件。文件每行一个目标,空行与 # 开头的注释行被跳过。 去重按资产入口判断:协议、主机、端口相同且路径与查询串相同的写法只保留第一个 (http://a.com 与 http://A.com:80/ 是同一个入口;http 与 https 是不同的资产)。

func OutputFormat added in v1.5.0

func OutputFormat(jsonOutput bool, outputPath string) sdk.OutputFormat

OutputFormat 确定输出格式:-json 优先,其余按扩展名识别,默认 txt。

func Run

func Run(ctx context.Context, options *Options) error

Run 执行批量扫描;初始化或扫描失败时返回错误,由入口决定退出码。

Types

type Options added in v1.5.0

type Options struct {
	Targets         []string // -u:扫描目标
	TargetsFile     string   // -f:目标文件,每行一个
	Threads         int      // -t:目标并发数
	RuleThreads     int      // -rt:指纹规则并发数
	Output          string   // -o:输出文件
	JSONOutput      bool     // -json:强制 JSON Lines 输出
	SockOutput      string   // -sock:Unix socket 输出
	Proxy           string   // -proxy:代理地址
	RuleFile        string   // -p:单个规则文件
	RuleDir         string   // -pf:规则目录
	Timeout         int      // -timeout:请求超时(秒)
	Rate            int      // -rate:全部请求的总速率上限(次/秒),0 不限制
	RateMinute      int      // -rpm:全部请求的总速率上限(次/分钟),0 不限制
	HostRate        int      // -host-rate:单台主机的速率上限(次/秒),0 不限制
	HostRatePerPort bool     // -host-rate-per-port:每主机限速按端口分别计算
	Debug           bool     // -debug
	NoFileLog       bool     // -no-file-log
}

Options 命令行选项。

func NewCmdOptions

func NewCmdOptions() (*Options, error)

NewCmdOptions 解析进程命令行参数。

func ParseCmdOptions added in v1.4.0

func ParseCmdOptions(args []string, out io.Writer) (*Options, error)

ParseCmdOptions 解析给定参数;用法与提示写入 out。

Jump to

Keyboard shortcuts

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