{"id":30015948,"url":"https://github.com/hmgle/httpseal","last_synced_at":"2025-09-08T05:11:13.663Z","repository":{"id":306089009,"uuid":"1024948250","full_name":"hmgle/httpseal","owner":"hmgle","description":"HTTPSeal is a Linux command-line tool for intercepting and analyzing HTTPS traffic from specific processes using namespace isolation and DNS hijacking","archived":false,"fork":false,"pushed_at":"2025-08-16T15:00:47.000Z","size":218,"stargazers_count":48,"open_issues_count":0,"forks_count":3,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-16T17:18:01.022Z","etag":null,"topics":["linux","mitm","network-monitoring"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hmgle.png","metadata":{"files":{"readme":"README-zh.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-23T13:42:50.000Z","updated_at":"2025-08-16T15:00:50.000Z","dependencies_parsed_at":"2025-07-23T16:27:14.760Z","dependency_job_id":"3363d110-75a9-495d-a50b-fa6aa73e2901","html_url":"https://github.com/hmgle/httpseal","commit_stats":null,"previous_names":["hmgle/httpseal"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/hmgle/httpseal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmgle%2Fhttpseal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmgle%2Fhttpseal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmgle%2Fhttpseal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmgle%2Fhttpseal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hmgle","download_url":"https://codeload.github.com/hmgle/httpseal/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmgle%2Fhttpseal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274135710,"owners_count":25228209,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["linux","mitm","network-monitoring"],"created_at":"2025-08-05T20:02:23.737Z","updated_at":"2025-09-08T05:11:13.647Z","avatar_url":"https://github.com/hmgle.png","language":"Go","readme":"# HTTPSeal\n\n[English](README.md) | 简体中文\n\nHTTPSeal 是一个 Linux 命令行工具，使用命名空间隔离和 DNS 劫持技术来拦截和分析特定进程的 HTTPS/HTTP 流量。\n\n## 演示\n\n[![asciicast](https://asciinema.org/a/730013.svg)](https://asciinema.org/a/730013)\n\n\u003e **注意**：演示中显示的任何 API 密钥已被删除和失效以确保安全。\n\n## 关于项目名称\n\n**HTTPSeal** 结合了 \"HTTP/HTTPS\" 和 \"Seal\"（海豹），这个名字是对传奇网络分析工具 **Wireshark** 🦈 的致敬。当 Wireshark 在整个网络海洋中狩猎时，HTTPSeal 是专门的海洋猎手，专注于隔离进程区域内的 HTTP/HTTPS 流量。\n\n## 核心优势\n\n🎯 **独特的进程隔离**：与全局代理工具（mitmproxy、Burp）不同，HTTPSeal 只影响它启动的进程 - 对系统或其他应用程序零影响\n\n⚡ **零配置**：目标应用无需代理设置或修改 - 只需用 HTTPSeal 运行它们即可自动拦截\n\n🔐 **高级证书管理**：完全自动的 CA 处理，支持 XDG 兼容的持久存储（默认：`$XDG_CONFIG_HOME/httpseal/ca/`）- 证书在会话间重用以获得更好性能\n\n🔧 **Linux 原生架构**：专为 Linux 构建，使用命名空间隔离、用户命名空间和绑定挂载实现最大安全性和效率\n\n🦈 **Wireshark 集成**：HTTP 镜像服务器创建解密 HTTPS 流量的实时明文 HTTP 副本 - 在 Wireshark 中零复杂度分析 TLS 1.3 流量\n\n📊 **多种输出格式**：原生 HAR（HTTP Archive）支持用于浏览器开发工具，以及 JSON、CSV 和文本格式与智能双重日志系统\n\n🌐 **SOCKS5**：内置 SOCKS5 代理支持带身份验证，可绕过网络限制\n\n## 架构\n\nHTTPSeal 结合多种 Linux 技术创建隔离的 HTTPS/HTTP 拦截：\n\n1. **挂载命名空间隔离**：使用带 UID 映射的用户命名空间（`unshare --map-root-user`）实现隔离的文件系统视图\n2. **DNS 劫持**：替换 `/etc/resolv.conf` 将 DNS 查询重定向到本地服务器\n3. **IP 地址映射**：将域名映射到 localhost 地址（127.0.0.0/8 范围）\n4. **HTTPS 代理**：拦截 443 端口流量并执行 MITM 解密\n5. **HTTP 代理**：拦截 80 端口的明文 HTTP 流量（启用时）\n6. **证书颁发机构**：动态生成和缓存目标域的证书（仅 HTTPS）\n7. **自动 CA 集成**：在隔离命名空间中合并 HTTPSeal CA 与系统 CA 包\n8. **环境配置**：设置 SSL/TLS 环境变量以实现无缝证书使用\n\n## 系统要求\n\n- **操作系统**：Linux（内核 3.8+ 支持用户命名空间）\n- **Linux 权限**：\n  - `CAP_NET_BIND_SERVICE`：用于绑定特权端口（80、443）\n  - HTTPSeal 使用用户命名空间 UID 映射进行挂载操作（无需 `CAP_SYS_ADMIN`）\n\n## 安装\n\n### 从源码构建\n\n```bash\n# 克隆仓库\ngit clone https://github.com/hmgle/httpseal.git\ncd httpseal\n\n# 构建二进制文件\nmake build\n\n# 安装并设置所需权限\nsudo make install\n```\n\n### 手动安装\n\n```bash\n# 构建\ngo build -o httpseal ./cmd/httpseal\n\n# 安装二进制文件\nsudo cp httpseal /usr/local/bin/\n\n# 设置所需权限（仅需要 CAP_NET_BIND_SERVICE）\nsudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/httpseal\n```\n\n## 使用方法\n\n### 基本用法\n\n```bash\n# 拦截 HTTPS 流量（默认行为）\nhttpseal -- wget https://api.github.com/users/octocat\n\n# 拦截 HTTP 流量（需要 --enable-http 标志）\nhttpseal --enable-http -- curl http://httpbin.org/get\n\n# 同时拦截 HTTPS 和 HTTP 流量\nhttpseal --enable-http -- curl -v https://httpbin.org/get http://httpbin.org/headers\n```\n\n### 高级用法\n\n```bash\n# 详细模式显示所有流量详细信息\nhttpseal -v --enable-http -- curl -v https://httpbin.org/get\n\n# 超详细模式 - 显示所有响应主体包括二进制内容\nhttpseal -vv -- curl https://httpbin.org/get\n\n# 使用 -vv 作为超详细模式的快捷方式（等同于旧的 -V 标志）\nhttpseal -vv -- wget https://baidu.com\n\n# 保存流量到 JSON 格式文件\nhttpseal --enable-http -o traffic.json --format json -- wget http://httpbin.org/get\n\n# 以 HAR 格式保存流量用于浏览器开发工具分析\nhttpseal -o performance.har --format har -- curl https://api.github.com/users/octocat\n\n# 使用 SOCKS5 代理绕过限制\nhttpseal --socks5-addr 127.0.0.1:1080 -- curl https://www.google.com\n\n# 🦈 Wireshark 集成 - 镜像 HTTPS 和 HTTP 流量\nhttpseal --enable-http --enable-mirror -- curl https://api.github.com/users/octocat\n\n# 配置文件使用\nhttpseal --config ./my-config.json -- curl https://api.github.com/users/octocat\n```\n\n## 🌊 Wireshark 集成（HTTP 镜像）\n\nHTTPSeal 具有**革命性的 HTTP 镜像服务器**功能，可创建解密 HTTPS 流量和明文 HTTP 流量的实时 HTTP 副本，实现无缝的 Wireshark 分析，无需复杂的 TLS 证书配置。\n\n### 工作原理\n\n```\n客户端 → HTTPSeal (HTTPS 代理) → 真实服务器\n             ↓\n    HTTP 镜像服务器 (localhost:8080)\n             ↓\n        Wireshark 捕获\n```\n\n### Wireshark 快速开始\n\n```bash\n# 终端 1：启动 Wireshark 并在环回接口上捕获\nwireshark -i lo -f \"tcp port 8080\"\n\n# 终端 2：启用镜像运行 HTTPSeal\nhttpseal --enable-mirror -- curl https://api.github.com/users/octocat\n```\n\n## 📋 配置文件支持\n\nHTTPSeal 支持遵循 XDG 基础目录规范的 JSON 配置文件：\n\n### 默认配置位置\n\n```bash\n# XDG 兼容路径（按顺序检查）\n$XDG_CONFIG_HOME/httpseal/config.json\n~/.config/httpseal/config.json\n./.httpseal/config.json  # 备用\n```\n\n### 配置文件示例\n\n```json\n{\n  \"verbose\": true,\n  \"output_file\": \"traffic.har\",\n  \"output_format\": \"har\",\n  \"log_level\": \"normal\",\n  \"file_log_level\": \"verbose\",\n  \"enable_http\": true,\n  \"enable_mirror\": true,\n  \"mirror_port\": 8080,\n  \"socks5_enabled\": true,\n  \"socks5_address\": \"127.0.0.1:1080\",\n  \"connection_timeout\": 60,\n  \"max_body_size\": 4096,\n  \"filter_domains\": [\"api.github.com\", \"httpbin.org\"],\n  \"ca_dir\": \"./my-ca\",\n  \"keep_ca\": true\n}\n```\n\n## 🌐 SOCKS5 代理支持\n\nHTTPSeal 包含完整的 SOCKS5 代理支持用于上游连接，非常适合绕过网络限制或通过 VPN 路由流量：\n\n```bash\n# 启用默认地址的 SOCKS5 (127.0.0.1:1080)\nhttpseal --socks5 -- curl https://www.google.com\n\n# 自定义 SOCKS5 地址（自动启用 SOCKS5）\nhttpseal --socks5-addr 192.168.1.100:1080 -- wget https://github.com\n\n# 带身份验证的 SOCKS5\nhttpseal --socks5-addr 127.0.0.1:1080 --socks5-user myuser --socks5-pass mypass -- curl https://api.github.com\n```\n\n## 📊 输出格式和日志\n\nHTTPSeal 提供多种输出格式和复杂的日志控制：\n\n### 输出格式\n\n1. **HAR (HTTP Archive) 格式** - 适用于浏览器开发工具和性能分析\n2. **JSON 格式** - 用于程序化分析的结构化数据\n3. **CSV 格式** - 兼容电子表格的完整数据\n4. **文本格式** - 人类可读的控制台输出\n\n### 双重日志系统\n\n```bash\n# 控制台和文件使用不同级别\nhttpseal --log-level minimal --file-log-level verbose -o detailed.log -- curl https://api.github.com\n\n# 日志级别：none, minimal, normal, verbose\n# 静默模式需要输出文件\nhttpseal -q -o traffic.json -- curl https://api.github.com\n```\n\n## 🛠️ 完整命令行参考\n\n```bash\nhttpseal [选项] -- \u003c命令\u003e [参数...]\n\n网络选项:\n      --dns-ip string           DNS 服务器 IP 地址 (默认 \"127.0.53.1\")\n      --dns-port int           DNS 服务器端口 (默认 53)\n      --proxy-port int         HTTPS 代理端口 (默认 443)\n      --connection-timeout int  客户端连接空闲超时秒数 (默认 30)\n\n证书管理:\n      --ca-dir string          证书颁发机构目录 (默认: $XDG_CONFIG_HOME/httpseal/ca/)\n      --keep-ca                退出后保留 CA 目录\n\nHTTP 流量拦截:\n      --enable-http            启用 HTTP 流量拦截 (默认: 禁用)\n      --http-port int          HTTP 代理端口 (默认 80)\n\nSOCKS5 代理支持:\n      --socks5                 启用默认地址的 SOCKS5 代理 (127.0.0.1:1080)\n      --socks5-addr string     SOCKS5 代理地址 (自动启用 SOCKS5)\n      --socks5-user string     SOCKS5 用户名\n      --socks5-pass string     SOCKS5 密码\n\nWireshark 集成:\n      --enable-mirror          启用 HTTP 镜像服务器用于 Wireshark 分析\n      --mirror-port int        HTTP 镜像服务器端口 (默认 8080)\n\n输出选项:\n  -o, --output string          将流量输出到文件\n      --format string          输出格式: text, json, csv, har (默认 \"text\")\n      --log-level string       控制台日志级别: none, minimal, normal, verbose\n  -q, --quiet                  静默模式 (需要 -o)\n  -v, --verbose                启用详细输出 (-v 详细, -vv 超详细)\n\n过滤和限制:\n      --filter-domain strings        仅记录这些域的流量\n      --max-body-size int            最大响应主体大小 (字节, 0=无限制)\n\n配置:\n  -c, --config string          配置文件路径\n\n其他选项:\n  -h, --help                   显示帮助信息\n      --version                显示版本\n```\n\n## 证书管理\n\nHTTPSeal 提供**智能、自动化的证书管理**和持久存储以获得最佳性能：\n\n### 持久 CA 目录\n\nHTTPSeal 现在默认使用 **XDG 兼容的持久 CA 目录**：\n\n- **默认位置**：`$XDG_CONFIG_HOME/httpseal/ca/`（通常是 `~/.config/httpseal/ca/`）\n- **自动创建**：首次运行时创建目录并设置正确权限\n- **证书重用**：在会话间重用相同的 CA 和域证书\n- **性能提升**：消除频繁访问域的证书重新生成\n- **优雅回退**：如果持久路径不可用则回退到临时目录\n\n## 开发\n\n### 项目结构\n\n```\nhttpseal/\n├── cmd/httpseal/           # 主应用程序入口点\n├── pkg/\n│   ├── cert/              # 证书颁发机构和管理\n│   ├── dns/               # DNS 服务器组件\n│   ├── logger/            # 增强日志功能\n│   ├── mirror/            # HTTP 镜像服务器\n│   ├── namespace/         # 进程包装和命名空间处理\n│   ├── proxy/             # HTTPS 代理服务器\n│   └── mount/             # OverlayFS 挂载操作\n└── internal/\n    └── config/            # 配置结构\n```\n\n### 开发命令\n\n```bash\n# 构建带竞态检测的开发版本\nmake dev\n\n# 运行测试\nmake test\n\n# 代码质量检查\nmake fmt      # 格式化代码\nmake vet      # 运行 go vet\nmake lint     # 代码检查 (需要 golangci-lint)\n\n# 依赖和清理\nmake deps     # 安装/更新依赖\nmake clean    # 清理构建产物\n\n# 实用命令\nmake run-example  # 运行 wget 示例\nmake check-caps   # 检查已安装的权限\nmake help         # 显示所有可用目标\n```\n\n## 优势和限制\n\n### 核心优势\n\n✅ **双协议支持**：处理 HTTPS（带 TLS 解密）和明文 HTTP 流量拦截\n\n✅ **进程特定隔离**：仅拦截 HTTPSeal 启动的进程流量 - 无系统范围影响\n\n✅ **零配置**：目标应用无需代理设置或代码修改\n\n✅ **命名空间安全**：使用 Linux 挂载命名空间实现安全隔离，不污染系统环境\n\n✅ **自动证书处理**：在隔离环境中完全自动的 CA 证书管理 - 无需手动安装\n\n✅ **透明拦截**：应用程序正常连接到域名，不知道被监控\n\n### 限制\n\n❌ **仅限 Linux**：完全依赖平台 - 无法在 Windows、macOS 或其他系统上工作\n\n❌ **DNS 解析依赖**：使用硬编码 IP 或自定义 DNS 的应用可能绕过拦截\n\n❌ **单进程范围**：无法拦截非 HTTPSeal 启动的进程流量\n\n❌ **端口独占**：运行期间阻止 localhost:443 上的其他 HTTPS 服务\n\n### 最佳使用场景\n\n🎯 **完美适用于**：\n\n- **Linux 开发和调试**，零配置和自动证书管理\n- **CLI 工具流量分析**（`wget`、`curl`、自定义应用）\n- **基于 HAR 的性能分析**，集成浏览器开发工具\n- **Wireshark 驱动的网络分析**，零 TLS 复杂度\n- **CI/CD 管道集成**，结构化日志和会话跟踪\n- **安全研究**，需要进程隔离和全面流量分析\n\n🚫 **不适用于**：\n\n- 跨平台开发（仅限 Linux）\n- 交互式请求/响应修改\n- 生产环境监控\n- 大容量或企业级流量分析\n- Web 浏览器流量（请使用内置浏览器开发工具）\n\n## 安全考虑\n\n\u003e ⚠️ **安全声明**：HTTPSeal 专为开发和测试环境设计。虽然经过充分测试，但它执行 MITM 操作，应仅用于授权测试目的。请勿在生产环境或敏感数据中使用。\n\n- **仅用于授权测试**：HTTPSeal 对网络流量执行 MITM 攻击\n- **仅限开发环境**：专为开发和测试场景设计\n- **权限模型**：仅需要 `CAP_NET_BIND_SERVICE` 用于特权端口绑定\n- **命名空间隔离**：更改包含在进程命名空间内并自动清理\n- **无系统修改**：HTTPSeal 从不修改系统的证书存储或全局网络设置\n\n## 贡献\n\n1. Fork 仓库\n2. 创建功能分支 (`git checkout -b feature/amazing-feature`)\n3. 提交更改 (`git commit -m 'Add some amazing feature'`)\n4. 推送到分支 (`git push origin feature/amazing-feature`)\n5. 打开 Pull Request\n\n## 许可证\n\n本项目根据 MIT 许可证授权 - 请参阅 LICENSE 文件了解详情。\n\n## 免责声明\n\nHTTPSeal 仅用于合法开发、调试和授权安全测试目的。用户有责任确保使用此工具时遵守适用的法律法规。\n\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmgle%2Fhttpseal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhmgle%2Fhttpseal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmgle%2Fhttpseal/lists"}