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

推荐订阅源

Recorded Future
Recorded Future
S
Secure Thoughts
D
Docker
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
F
Fortinet All Blogs
月光博客
月光博客
S
Security @ Cisco Blogs
AI
AI
IT之家
IT之家
P
Proofpoint News Feed
Stack Overflow Blog
Stack Overflow Blog
大猫的无限游戏
大猫的无限游戏
N
News and Events Feed by Topic
Hacker News: Ask HN
Hacker News: Ask HN
人人都是产品经理
人人都是产品经理
Recent Announcements
Recent Announcements
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Google Online Security Blog
Google Online Security Blog
K
Kaspersky official blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Proofpoint News Feed
Latest news
Latest news
Webroot Blog
Webroot Blog
GbyAI
GbyAI
L
Lohrmann on Cybersecurity
T
Threat Research - Cisco Blogs
S
Schneier on Security
G
Google Developers Blog
N
News | PayPal Newsroom
C
Check Point Blog
T
Tenable Blog
L
LINUX DO - 最新话题
C
CERT Recently Published Vulnerability Notes
T
Troy Hunt's Blog
Know Your Adversary
Know Your Adversary
SecWiki News
SecWiki News
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
爱范儿
爱范儿
W
WeLiveSecurity
Project Zero
Project Zero
M
MIT News - Artificial intelligence
H
Hacker News: Front Page
Apple Machine Learning Research
Apple Machine Learning Research
V
V2EX
C
Cyber Attacks, Cyber Crime and 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