Documentation
¶
Index ¶
- type Config
- type HttpxClient
- type Option
- func WithBody(body string) Option
- func WithCustomHost(host string) Option
- func WithFaviconMMH3() Option
- func WithFollowRedirects() Option
- func WithHeaders(headers []string) Option
- func WithMethod(method string) Option
- func WithPath(path string) Option
- func WithPorts(ports []string) Option
- func WithProxy(proxy string) Option
- func WithRateLimit(rateLimit int) Option
- func WithResponseBodySize(size int) Option
- func WithRetries(retries int) Option
- func WithShowStatistics() Option
- func WithTechDetect() Option
- func WithThreads(threads int) Option
- func WithTimeout(timeout int) Option
- type Result
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// 请求配置
Method string
Path string
Body string
Headers []string
CustomHost string
Timeout int
FollowRedirects bool
// 探测配置
Threads int
RateLimit int
Retries int
Ports []string
TechDetect bool
Favicon bool
// 网络配置
Proxy string
// 响应体配置
ResponseBodySize int
// 输出配置
ShowStatistics bool
}
Config 封装 httpx 探测的所有可配置项,与上游 runner.Options 解耦
type HttpxClient ¶
type HttpxClient struct {
// contains filtered or unexported fields
}
HttpxClient 封装 projectdiscovery/httpx 的探测客户端
func NewHttpxClient ¶
func NewHttpxClient(opts ...Option) *HttpxClient
NewHttpxClient 创建一个新的 HttpxClient,支持通过 Option 函数自定义配置
Example ¶
示例:创建 HTTP 探测客户端,配置线程数、技术检测、跟随重定向
package main
import (
"fmt"
"github.com/polite-007/toolbox/httpx"
)
func main() {
_ = httpx.NewHttpxClient(
httpx.WithThreads(50),
httpx.WithTechDetect(),
httpx.WithFollowRedirects(),
)
fmt.Println("httpx client created")
}
Output: httpx client created
Example (HeaderMerge) ¶
示例:组合使用 Headers 和 CustomHost(验证追加不覆盖)
package main
import (
"fmt"
"github.com/polite-007/toolbox/httpx"
)
func main() {
_ = httpx.NewHttpxClient(
httpx.WithHeaders([]string{"X-Token: abc123"}),
httpx.WithCustomHost("internal.example.com"),
)
fmt.Println("httpx client created")
}
Output: httpx client created
Example (WithProxy) ¶
示例:使用代理和自定义端口创建客户端
package main
import (
"fmt"
"github.com/polite-007/toolbox/httpx"
)
func main() {
_ = httpx.NewHttpxClient(
httpx.WithProxy("http://127.0.0.1:7890"),
httpx.WithPorts([]string{"80", "443", "8080"}),
httpx.WithFaviconMMH3(),
)
fmt.Println("httpx client created")
}
Output: httpx client created
type Option ¶
type Option func(*Config)
Option 配置函数类型
func WithCustomHost ¶
WithCustomHost 设置自定义 Host 头(追加模式,可与 WithHeaders 共存)
func WithHeaders ¶
WithHeaders 设置自定义请求头(追加模式,可与 WithCustomHost 共存)
func WithResponseBodySize ¶
WithResponseBodySize 设置响应体最大读取和保存大小(字节)
type Result ¶
type Result struct {
Timestamp time.Time // 探测时间
Input string // 原始输入(host:port 或 URL)
URL string // 探测的 URL
FinalURL string // 重定向后的最终 URL
Scheme string // http/https
Host string // Host 头
HostIP string // 目标 IP
Port string // 端口
Path string // 请求路径
Method string // 请求方法
StatusCode int // HTTP 状态码
Title string // 页面标题
WebServer string // Server 头
ContentType string // Content-Type
ContentLength int // 响应体长度
Location string // 重定向 Location
ResponseTime string // 响应耗时
Technologies []string // 识别到的技术栈
CDN bool // 是否 CDN
CDNName string // CDN 名称
CDNType string // CDN 类型
HTTP2 bool // 是否 HTTP/2
WebSocket bool // 是否 WebSocket
Pipeline bool // 是否 HTTP pipeline
VHost bool // 是否虚拟主机
FavIconMMH3 string // favicon mmh3 hash
FavIconMD5 string // favicon md5 hash
JarmHash string // JARM 指纹
A []string // A 记录
AAAA []string // AAAA 记录
CNAMEs []string // CNAME 记录
Error string // 错误信息字符串
Failed bool // 是否探测失败
Err error // 探测错误
ResponseBody string // 响应体(截取前 4KB)
SubjectCN string // TLS 证书 Subject Common Name
SubjectOrg []string // TLS 证书 Subject Organization
}
Result 表示一条 HTTP 探测结果,封装了上游 runner.Result 的常用字段, 避免业务代码直接依赖原生 httpx 库类型。
Click to show internal directories.
Click to hide internal directories.