惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recent Commits to openclaw:main
Recent Commits to openclaw:main
P
Palo Alto Networks Blog
C
Cybersecurity and Infrastructure Security Agency CISA
C
Cisco Blogs
Cyberwarzone
Cyberwarzone
S
Schneier on Security
T
Threatpost
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Scott Helme
Scott Helme
T
Tor Project blog
P
Privacy & Cybersecurity Law Blog
V
Vulnerabilities – Threatpost
L
Lohrmann on Cybersecurity
T
The Exploit Database - CXSecurity.com
Know Your Adversary
Know Your Adversary
The Hacker News
The Hacker News
Security Latest
Security Latest
A
Arctic Wolf
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Vercel News
Vercel News
WordPress大学
WordPress大学
美团技术团队
C
Cyber Attacks, Cyber Crime and Cyber Security
罗磊的独立博客
Microsoft Security Blog
Microsoft Security Blog
量子位
H
Help Net Security
Webroot Blog
Webroot Blog
月光博客
月光博客
S
SegmentFault 最新的问题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Schneier on Security
Schneier on Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
IT之家
IT之家
H
Hacker News: Front Page
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Jina AI
Jina AI
云风的 BLOG
云风的 BLOG
J
Java Code Geeks
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Last Week in AI
Last Week in AI
C
CXSECURITY Database RSS Feed - CXSecurity.com
Spread Privacy
Spread Privacy
S
Security @ Cisco Blogs
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
D
Darknet – Hacking Tools, Hacker News & Cyber Security

逸思杂陈

家用网络 vlan 单线复用 Linux 平台 intel UHD 6xx 核显 openvino 探索 UI 区域检测的 vibe coding 复盘 esim 使用相关 阻止 bilibili 网页自动关注 Hexo 版本更新与技术债务 配置 Linux 作为主力操作系统 在 Linux 虚拟机中使用 PyAutoGUI 做自动化 语言的力量 联想笔记本 BIOS 跳过检测强制降级 redroid “设备未获得play保护机制认证” 问题 在 iOS 上访问安卓应用 在 VSCode 中用 Rust 刷LeetCode 跨域的那些事 HomeBrew 与无 root 权限 Linux 环境包管理 给 macOS 词典增加生词本功能 关闭子进程打开的文件描述符 容器内进程优雅退出 Python 循环变量泄露与延迟绑定 bash 语法备忘 MySQL 自定义数据库路径
mitmproxy 使用
Jay.Run · 2026-03-20 · via 逸思杂陈

做 LLM Agent 开发时,经常要查看模型的请求与响应,需要一个便捷的工具。
mitmproxy 是一个功能强大的开源中间人代理,通常用于网络调试、分析 HTTP 和 HTTPS 流量。

安装

  1. 访问 https://www.mitmproxy.org/ ,根据指引安装,不同系统有区别
    • 也可以使用 pip install mitmproxy 安装
  2. 配置证书,用于解析 https,参考 https://docs.mitmproxy.org/stable/concepts/certificates/

使用

包含以下命令

  • mitmdump:支持将捕获的数据导出到文件,类似tcpdump
  • mitmproxy:TUI 实时查看、修改和调试流量
  • mitmweb:webui 实时查看、修改和调试流量(一般推荐用这个)

使用步骤

  1. 启动 mitmweb
  2. 设置代理环境变量:ALL_PROXY,
1
2
3
4
5
6
~ ❯ mitmweb -p 8082 -s ~/projects/scripts/mitmproxy_fix_unicode.py
[15:26:42.046] Loading script /Users/ruan/projects/scripts/mitmproxy_fix_unicode.py
[15:26:42.047] HTTP(S) proxy listening at *:8082.
[15:26:42.047] Web server listening at http:
load: 11.06 cmd: mitmweb 3541 waiting 0.55u 0.19s
[15:42:34.333][[::1]:62868] client connect

python 证书相关问题

python 的 http 客户端有自己的证书处理逻辑,仅安装证书到系统还不能生效
需要额外设置环境变量

1
2
3
4
5
6
7
8

cat $(python -c "import certifi; print(certifi.where())") \
~/.mitmproxy/mitmproxy-ca-cert.pem > ~/.mitmproxy/py-certifi-combined-ca.pem


SSL_CERT_FILE=/Users/ruan/.mitmproxy/py-certifi-combined-ca.pem
REQUESTS_CA_BUNDLE=/Users/ruan/.mitmproxy/py-certifi-combined-ca.pem
HTTPS_PROXY=https://localhost:8082

webui 的 json 中文显示问题

需要附加脚本:mitmweb -s ~/projects/scripts/mitmproxy_fix_unicode.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22


import json
from mitmproxy import contentviews


class PrettyJsonChinese(contentviews.Contentview):
name = "JSON (中文)"
syntax_highlight = "yaml"

def prettify(self, data: bytes, metadata: contentviews.Metadata) -> str:
decoded = json.loads(data)
return json.dumps(decoded, indent=4, ensure_ascii=False, sort_keys=False)

def render_priority(self, data: bytes, metadata: contentviews.Metadata) -> float:

if metadata.content_type and "json" in metadata.content_type:
return 2
return 0

contentviews.add(PrettyJsonChinese)

让 json request 和 response 能够自动换行

使用 tampermokey 脚本 修改 webui