javascript - 从安全服务器拦截 javascript 文件并使用本地文件

标签 javascript fiddler

我试图拦截一个提供 JS 文件的 https 请求并使用我的本地文件。 使用 fiddler 工具,我能够成功拦截所有 http 请求服务的文件。 但无法对 https 文件执行此操作。 注意:我已将 JS 文件保存在本地服务器中。我只是使用了直接路径,如 C:\test\test.js

最佳答案

您是否启用了解密 HTTPS 流量选项?

Fiddler2 具有解密、查看和修改 HTTPS 安全流量以进行调试的功能。 解密功能默认处于禁用状态。
默认情况下, session 列表将仅显示 HTTPS 加密字节流经的 CONNECT 隧道。

通过单击工具 > Fiddler 选项 > HTTPS勾选解密 HTTPS 流量框来启用流量解密选项。

更新:
您可能想顺便从您的代理发送备用 JavaScript(而不是更改源以包含用户本地计算机上的脚本文件)。

此外,正如 EricLaw 在对此答案的评论中所指出的:
您还需要查看 Fiddler 的AutoResponder 选项卡,它允许您从本地磁盘返回文件,而不是将请求传输到服务器
在此选项卡上,您可以输入匹配规则和操作字符串,如果请求 URI 与匹配规则匹配,Fiddler 将执行操作。

<小时/>

额外(因为有评论称不能这样做,因为这会违背 https 的目的)

Q: The HTTPS protocol was designed to prevent traffic viewing and tampering. Given that, how can Fiddler2 debug HTTPS traffic?

A: Fiddler2 relies on a "man-in-the-middle" approach to HTTPS interception. To your web browser, Fiddler2 claims to be the secure web server, and to the web server, Fiddler2 mimics the web browser. In order to pretend to be the web server, Fiddler2 dynamically generates a HTTPS certificate.

Fiddler's certificate is not trusted by your web browser (since Fiddler is not a Trusted Root Certification authority), and hence while Fiddler2 is intercepting your traffic, you'll see a HTTPS error message in your browser.

顺便说一下,这并不是一个新概念,mitmproxy据我所知可以做到。

希望这有帮助!

关于javascript - 从安全服务器拦截 javascript 文件并使用本地文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16021760/

相关文章:

javascript - 从 api 获取的数据不会作为 props 传递给嵌套组件

javascript - 根据浏览器宽度用 <tr> 替换 <td>

http - 使用 fiddler 更改方案

c# - 测试我的 wcf 服务时出现错误 415

javascript - D3 - 如何处理 JSON 数据结构?

javascript - Angular等待服务函数Ajax完成

javascript - 如何使用 jquery 删除字符串中的以下符号/特殊字符 ¶

asp.net - 在 Fiddler 中看不到 WebClient post 请求

c# - HttpClient 正在发送额外的 cookie

https - IE6&7 导致 "This page contains both secure and nonsecure items"的原因