信息收集与资产探活工具 httpx 详细安装与使用
httpx是一款高效的HTTP探测工具,用于快速识别Web服务状态、技术栈及关键信息(状态码、标题、服务器类型等)。适用于授权测试、资产梳理及漏洞扫描前置筛选。支持批量探测、多参数输出(如-sc显示状态码、-title获取页面标题),并能与nuclei联动提升扫描效率。工具提供多种安装方式(Go、二进制、Docker),强调合规使用,仅限合法授权场景。典型命令组合可筛选存活资产,匹配特定状态码(如

文章目录
适用场景:授权测试、资产梳理、攻防演练、漏洞扫描前置探活
工具定位:快速判断目标是否存在 Web 服务,并提取状态码、标题、技术栈、响应长度、跳转地址等信息。
合规提醒:本文仅用于合法授权范围内的安全测试、资产管理与学习研究,禁止用于未授权扫描。
本文仅用于合法授权范围内的安全测试、资产管理与学习研究,禁止用于未授权扫描。本文不适合放真实扫描的图例,读者也不要未授权进行测试。
一、httpx 是什么?
httpx 是 ProjectDiscovery 开源的一款 HTTP 探测工具,主要用于对域名、IP、URL、CIDR 等目标进行 Web 服务探活和指纹信息采集。
简单来说,它可以帮我们快速回答以下问题:
这个资产有没有 Web 服务?
访问后返回什么状态码?
页面标题是什么?
使用了什么 Web 服务器?
有没有跳转?
响应长度是多少?
是否支持 HTTPS?
技术栈大概是什么?
在实际工作中,httpx 常作为 nuclei、AWVS、BurpSuite、人工验证之前的资产筛选工具。
二、httpx 的典型用途
1. 资产探活
假设你有一批域名:
example.com
test.example.com
admin.example.com
api.example.com
你不知道哪些真的开了 Web 服务,可以使用 httpx 批量探测。
2. Web 指纹识别
通过状态码、页面标题、Server 头、技术栈等字段,快速判断目标类型。
示例输出:
https://example.com [200] [Apache] [phpMyAdmin]
https://admin.example.com [302] [nginx] [Login]
https://test.example.com [403] [openresty] [Forbidden]
3. 漏洞扫描前置筛选
nuclei 直接扫描全部资产会比较慢,也容易产生无效请求。常见流程如下:
原始资产 → httpx 探活 → 存活 Web → nuclei 扫描
4. 攻防演练资产整理
在 HVV、应急响应、内网梳理中,经常要快速把大量 IP 或域名整理成可访问的 Web 资产列表。
三、安装 httpx
httpx 支持 Go 安装、二进制安装、Docker 安装等方式。下面以常用方式为例。
方式一:Go 安装
go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest
安装完成后查看版本:
httpx -version
方式二:Linux 二进制安装
如果你已经下载好了 Linux 版二进制文件:
chmod +x httpx
sudo mv httpx /usr/local/bin/
httpx -version
如果下载的是压缩包:
unzip httpx_amd64_linux.zip
chmod +x httpx
sudo mv httpx /usr/local/bin/
httpx -version
方式三:Kali 安装注意
Kali 中可能存在 Python 的 httpx 包命令冲突。ProjectDiscovery 的 httpx 在部分 Kali 环境中可能叫:
httpx-toolkit
可以尝试:
httpx-toolkit -h
四、httpx 基础语法
1. 单个目标探测
httpx -u https://example.com
也可以探测不带协议的域名:
httpx -u example.com
httpx 支持 HTTPS 到 HTTP 的智能回退,这对于批量探测非常方便。
2. 批量目标探测
准备目标文件:
cat targets.txt
内容示例:
example.com
test.example.com
https://admin.example.com
http://192.168.1.10
执行批量探测:
httpx -l targets.txt
3. 输出到文件
httpx -l targets.txt -o alive.txt
这样会把存活结果保存到:
alive.txt
五、常用参数详解
httpx 支持状态码、标题、响应长度、内容类型、跳转地址、favicon hash、响应时间、技术识别等多种探测参数。
1. 显示状态码
httpx -l targets.txt -status-code
简写:
httpx -l targets.txt -sc
输出示例:
https://example.com [200]
https://admin.example.com [302]
https://test.example.com [403]
常见状态码含义:
| 状态码 | 含义 |
|---|---|
| 200 | 正常访问 |
| 301 / 302 | 跳转 |
| 401 | 需要认证 |
| 403 | 禁止访问 |
| 404 | 页面不存在 |
| 500 | 服务器内部错误 |
2. 显示页面标题
httpx -l targets.txt -title
输出示例:
https://example.com [Example Domain]
https://admin.example.com [Login]
标题对于快速识别后台、管理系统、网关页面很有用。
3. 显示状态码 + 标题
httpx -l targets.txt -sc -title
这是最常用的组合之一。
4. 显示 Web Server
httpx -l targets.txt -server
输出示例:
https://example.com [nginx]
https://test.example.com [Apache]
5. 显示内容长度
httpx -l targets.txt -content-length
简写:
httpx -l targets.txt -cl
响应长度可以用于发现相似页面、空页面、默认页面或异常响应。
6. 显示内容类型
httpx -l targets.txt -content-type
简写:
httpx -l targets.txt -ct
输出示例:
[text/html]
[application/json]
[application/xml]
7. 显示跳转地址
httpx -l targets.txt -location
适合分析登录跳转、HTTP 跳 HTTPS、后台重定向等情况。
8. 显示技术栈
httpx -l targets.txt -tech-detect
简写:
httpx -l targets.txt -td
输出可能类似:
[nginx, PHP, jQuery]
[Apache, WordPress]
9. 显示响应时间
httpx -l targets.txt -response-time
简写:
httpx -l targets.txt -rt
适合判断目标延迟、异常卡顿、边缘节点情况。
六、最常用实战命令
1. 标准资产探活命令
httpx -l targets.txt -sc -title -server -td -cl -rt -o httpx_result.txt
参数含义:
| 参数 | 含义 |
|---|---|
-sc |
显示状态码 |
-title |
显示页面标题 |
-server |
显示 Web Server |
-td |
技术栈识别 |
-cl |
响应长度 |
-rt |
响应时间 |
-o |
输出到文件 |
2. 跟随跳转
httpx -l targets.txt -follow-redirects -sc -title -location
适合处理:
http://example.com → https://example.com
/admin → /login
3. 只保留 200 状态码
httpx -l targets.txt -sc -title -mc 200
-mc 表示 match code,也就是匹配指定状态码。
4. 匹配多个状态码
httpx -l targets.txt -sc -title -mc 200,301,302,401,403
这些状态码通常都值得关注:
| 状态码 | 价值 |
|---|---|
| 200 | 正常页面 |
| 301 / 302 | 跳转页面 |
| 401 | 认证入口 |
| 403 | 权限控制、目录限制或后台入口 |
5. 过滤 404
httpx -l targets.txt -sc -title -fc 404
-fc 表示 filter code,即过滤指定状态码。
6. 探测 IP 段常见端口
准备 ips.txt:
192.168.1.1
192.168.1.2
192.168.1.3
执行:
httpx -l ips.txt -ports 80,443,8080,8000,8888 -sc -title
七、httpx 与 nuclei 联动
httpx 常作为 nuclei 的前置探活工具。
1. 先用 httpx 探活
httpx -l targets.txt -sc -title -td -o alive.txt
2. 再用 nuclei 扫描
nuclei -l alive.txt -o nuclei_result.txt
3. 推荐安全速率
nuclei -l alive.txt -rate-limit 5 -c 5 -o nuclei_safe_result.txt
这样可以减少对目标的压力,降低误报和误伤风险。
八、完整工作流示例
场景:对授权域名资产进行 Web 探活
假设目标范围已经授权:
example.com
test.example.com
admin.example.com
api.example.com
第一步:准备目标文件
vim targets.txt
内容:
example.com
test.example.com
admin.example.com
api.example.com
第二步:执行 httpx 探活
httpx -l targets.txt \
-sc -title -server -td -cl -rt -follow-redirects \
-o httpx_result.txt
第三步:查看结果
cat httpx_result.txt
示例:
https://example.com [200] [Example Domain] [nginx] [text/html] [1256] [120ms]
https://admin.example.com [302] [Login] [nginx] [PHP] [892] [98ms]
https://api.example.com [200] [API Gateway] [openresty] [application/json] [421] [80ms]
第四步:筛选有效资产
筛选 200 状态码资产:
cat httpx_result.txt | grep "\[200\]"
只保留 URL:
cat httpx_result.txt | awk '{print $1}' > alive_urls.txt
第五步:交给 nuclei
nuclei -l alive_urls.txt -rate-limit 5 -c 5 -o nuclei_result.txt
九、输出 JSON 结果
如果后续要做自动化处理,可以输出 JSON:
httpx -l targets.txt -json -sc -title -td -server -o httpx_result.json
JSON 结果适合接入:
- Python 脚本
- 资产管理平台
- Elasticsearch
- 数据库
- 自动化扫描流水线
十、常见问题
1. httpx 命令不存在
检查路径:
which httpx
如果没有输出,说明没有放入系统 PATH。
解决:
chmod +x httpx
sudo mv httpx /usr/local/bin/
httpx -version
2. 执行提示 Permission denied
说明没有执行权限:
chmod +x httpx
3. Kali 中的 httpx 不是 ProjectDiscovery 的 httpx
可能和 Python 的 httpx 包冲突,可以尝试:
httpx-toolkit -h
4. 结果太多怎么办?
可以用状态码过滤:
httpx -l targets.txt -mc 200,301,302,401,403 -sc -title
或者过滤无效状态码:
httpx -l targets.txt -fc 404,500
5. 目标响应慢怎么办?
可以降低并发,减少误判:
httpx -l targets.txt -threads 20 -timeout 10 -retries 2
十一、推荐目录结构
/opt/sec-tools/
├── targets/
│ └── targets.txt
├── results/
│ ├── httpx_result.txt
│ └── nuclei_result.txt
└── logs/
创建目录:
mkdir -p /opt/sec-tools/{targets,results,logs}
常用命令:
httpx -l /opt/sec-tools/targets/targets.txt \
-sc -title -server -td -cl -rt -follow-redirects \
-o /opt/sec-tools/results/httpx_result.txt
十二、常用命令速查表
| 目的 | 命令 |
|---|---|
| 单个目标探测 | httpx -u https://example.com |
| 批量探活 | httpx -l targets.txt |
| 显示状态码 | httpx -l targets.txt -sc |
| 显示标题 | httpx -l targets.txt -title |
| 显示技术栈 | httpx -l targets.txt -td |
| 显示 Server | httpx -l targets.txt -server |
| 显示响应长度 | httpx -l targets.txt -cl |
| 跟随跳转 | httpx -l targets.txt -follow-redirects |
| 只匹配 200 | httpx -l targets.txt -mc 200 |
| 过滤 404 | httpx -l targets.txt -fc 404 |
| 输出 JSON | httpx -l targets.txt -json -o result.json |
| 保存结果 | httpx -l targets.txt -o alive.txt |
十三、安全与合规提醒
httpx 虽然主要是探活工具,但仍然会向目标发起 HTTP 请求。使用时必须注意:
- 只扫描自己拥有或已授权的目标。
- 不要对第三方系统进行未授权扫描。
- 控制并发和速率。
- 不要在生产系统高峰期进行大规模探测。
- 保留授权范围、测试时间和日志。
推荐安全参数:
httpx -l targets.txt -threads 20 -rate-limit 10 -timeout 10 -retries 1
十四、总结
httpx 是资产探活阶段非常实用的工具。它的核心价值不是“发现漏洞”,而是快速整理出真正存在 Web 服务的资产,并提取有价值的基础信息。
典型流程如下:
资产列表
↓
httpx 探活
↓
筛选存活 Web
↓
nuclei / AWVS / Burp / 人工验证
↓
输出报告
在日常攻防、资产管理、HVV、漏洞扫描前置工作中,httpx 可以显著提高效率,减少无效扫描目标,是安全测试人员必备的基础工具之一。
openEuler 是由开放原子开源基金会孵化的全场景开源操作系统项目,面向数字基础设施四大核心场景(服务器、云计算、边缘计算、嵌入式),全面支持 ARM、x86、RISC-V、loongArch、PowerPC、SW-64 等多样性计算架构
更多推荐

所有评论(0)