Git Product home page Git Product logo

whistle's Introduction

whistle logo

whistle

NPM version node version Test coverage npm download NPM count License

Mac 或 Windows 系统推荐使用客户端版本:https://github.com/avwo/whistle-client

Whistle 是基于 Node 实现的跨平台抓包调试工具,其主要特点:

  1. 完全跨平台:支持 Mac、Windows 等桌面系统,且支持服务端等命令行系统
  2. 功能强大(理论上可以对请求做任意修改)
    • 支持作为 HTTP、HTTPS、SOCKS 代理及反向代理
    • 支持抓包及修改 HTTP、HTTPS、HTTP2、WebSocket、TCP 请求
    • 支持重放及构造 HTTP、HTTPS、HTTP2、WebSocket、TCP 请求
    • 支持设置上游代理、PAC 脚本、Hosts、延迟(限速)请求响应等
    • 支持查看远程页面的 console 日志及 DOM 节点
    • 支持用 Node 开发插件扩展功能,也可以作为独立 npm 包引用
  3. 操作简单
    • 直接通过浏览器查看抓包、修改请求
    • 所有修改操作都可以通过配置方式实现(类似系统 Hosts),并支持分组管理
    • 项目可以自带代理规则配置并一键设置到本地 Whistle 代理,也可以通过定制插件简化操作

一键安装

已安装 brew 的 PC,可以省略以下 1、2 步骤,直接通过以下方式一键安装:brew install whistle && w2 start --init(arm64 平台尝试用 brew install node && npm i -g whistle && w2 start --init

  1. 安装 Node(建议安装最新的 LTS 版本,如已安装忽略此步骤):https://nodejs.org/
  2. 一键安装,在命令行执行以下命令:
    npm i -g whistle && w2 start --init

    上述命令会先全局安装 Whistle 的 npm 包后,启动 Whistle 并设置系统全局代理,以及安装系统根证书,目前一键安装只支持 Mac & Windows 系统,其它系统按照下面 手动安装 的方式操作。

    如果安装过程时报错 Bad CPU type in executable,在命令执行 arch -x86_64 zsh 再重新执行一键安装命令。

  3. 一键安装过程中注意事项:
    • Mac 需要两次输入开机密码或指纹验证

      输入开机密码

      输入指纹
    • Windows 需要最后点击 “是(Y)” 确认

      点击 是(Y)

如果需要自定义代理配置或根证书(如设置其它代理,根证书或代理白名单等)可以通过以下命令实现:

  1. w2 proxy 设置系统全局代理:https://wproxy.org/whistle/proxy.html
  2. w2 ca 设置系统根证书:https://wproxy.org/whistle/proxy.html

也可以用下面 手动安装 方式。

手动安装

非 Mac & Windows 系统或一键安装失败可以按下面方式设置代理和安装根证书:

  1. 设置代理:https://wproxy.org/whistle/install.html
  2. 安装根证书:https://wproxy.org/whistle/webui/https.html

快速上手

安装成功后,用 Chrome 打开链接 http://local.whistlejs.com 即可看到 Whistle 的抓包配置界面:

抓包界面

image

详细用法参见:Whistle 帮助文档

通过 SwitchyOmega 设置代理

安装 SwitchyOmega

打开 Chrome 扩展商店进行安装 https://chrome.google.com/webstore/detail/proxy-switchyomega/padekgcemlokbadohgkifijomclgjgif

配置 SwitchyOmega

全局代理如果会影响到某些客户端的请求(客户端设置了 ssl pinning),也可以使用 Chrome 插件设置代理(只对 Chrome 生效):

可以通过 w2 proxy off 关闭全局代理

  1. 设置 Whistle 代理

  2. 选择 Whistle 代理

    image

安全设置

  1. 通过启动参数给管理界面设置用户名密码:w2 restart -n yourusername -w yourpassword
  2. 通过插件给经过代理的请求设置用户名密码:https://github.com/whistle-plugins/whistle.proxyauth

License

MIT

whistle's People

Contributors

avwo avatar cathaysia avatar cryushio avatar cuijinyu avatar echopi avatar elvinn avatar gcaufy avatar hannibalkcc avatar heng1025 avatar hex-ci avatar hhhuangqiong avatar hiyangguo avatar hxfdarling avatar jayin avatar jinjiezhao avatar kinka avatar kkeybbs avatar krabswong avatar leezq avatar m3x2 avatar marvin1023 avatar subying avatar wavinflag avatar winderica avatar xiekeyi98 avatar yangchendoit avatar yuduxyz avatar zeakhold avatar zhishaofei3 avatar zsi2017 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

whistle's Issues

Mac terminal curl / wget / node 无法代理

浏览器中设置了系统代理之后, 可以代理
但是当使用curl / wget 或者 node中使用request, 则无法代理

使用 proxifier全局代理之后, nodejs 陷入死循环

请问有什么好的解决方案吗?

Mac 关闭whistle之后无法联网

w2 start 之后可以正常联网
w2 stop 访问网页会提示“代理服务器出现问题,或者地址有误。”
请问还需要怎么设置?

是否有启动配置文件?

我在文档中 安装启动 章节,没有看到启动 w2 的配置,所有的启停相关命令都是在命令行下直接完成。

我建议可以维护一个针对项目启动的配置文件,在 w2 start 的时候可以默认指定,帮助用户减化命令行下的启动命令输入。

chrome 环境下 使用whistle 无法捕获https请求

chrome版本: "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"

whistle 版本: 1.4.20

错误信息: NET::ERR_CERT_AUTHORITY_INVALID

根证书已经安装

电脑也重启了

whistle restart -A 也试过了

tnpm i whistle -g 也尝试过了

目前的情况是 http 可以捕获 https 不行

weinre 是根据什么判断 html 的?

系统是 mac,没开防火墙,使用weinre时,targets 是none,貌似要写手动写weinre的 js 才可以用,

<script src="http://x.x.x.x:8901/target/target-script-min.js#anonymous"></script>

ui相关的js代码看不懂

最近在学习您的项目, 但是whistle/biz/webui/htdocs/js/index.js这个文件看着不像是原文件啊, 应该是经过压缩处理的吧? 可否把源码开放出来?

端口占用时,建议优化提示

目前启动whistle的时候, 如果端口被占用, 会直接抛出js错误。 建议优化提示

simon  sudo whistle start
Date: 2016-03-30 14:12:07.645
Error: listen EADDRINUSE :::8899
    at Object.exports._errnoException (util.js:856:11)
    at exports._exceptionWithHostPort (util.js:879:20)
    at Server._listen2 (net.js:1227:14)
    at listen (net.js:1263:10)
    at Server.listen (net.js:1359:5)
    at EventEmitter.app.listen (/usr/local/lib/node_modules/whistle/node_modules/express/lib/application.js:595:24)
    at proxy (/usr/local/lib/node_modules/whistle/lib/index.js:197:19)
    at init (/usr/local/lib/node_modules/whistle/index.js:3:25)
    at Command.<anonymous> (/usr/local/lib/node_modules/whistle/node_modules/starting/lib/bootstrap.js:10:4)
    at Command.listener (/usr/local/lib/node_modules/whistle/node_modules/starting/node_modules/commander/index.js:289:8)

HTPPS Error: connect ECONNREFUSED

Date: 2016-08-03 01:08:28.490
Error: connect ECONNREFUSED 218.30.108.181:443
at Object.exports._errnoException (util.js:870:11)
at exports._exceptionWithHostPort (util.js:893:20)
at TCPConnectWrap.afterConnect as oncomplete

mac whistle 长时间放置后挂掉了

TypeError: Cannot read property 'on' of undefined
at Object.fork (/usr/local/lib/node_modules/whistle/node_modules/pfork/lib/index.js:79:14)
at loadPlugin (/usr/local/lib/node_modules/whistle/lib/plugins/index.js:214:5)
at /usr/local/lib/node_modules/whistle/lib/plugins/index.js:323:5
at Array.forEach (native)
at loadPlugins (/usr/local/lib/node_modules/whistle/lib/plugins/index.js:319:11)
at getRulesFromPlugins (/usr/local/lib/node_modules/whistle/lib/plugins/index.js:337:3)
at getRulesMgr (/usr/local/lib/node_modules/whistle/lib/plugins/index.js:504:3)
at EventEmitter.pluginMgr.getResRules (/usr/local/lib/node_modules/whistle/lib/plugins/index.js:515:3)
at ServerResponse.res.response (/usr/local/lib/node_modules/whistle/lib/inspectors/res.js:365:15)
at ClientRequest. (/usr/local/lib/node_modules/whistle/lib/inspectors/res.js:332:25)

iPhone上安装证书时有坑

作者应该强调下要用Safari下载安装证书,因为我之前用Chrome下载会提示文件没有对应的打开方式,换成微信传文件,同时提示没有对应的打开方式。 后来试了下Safari就会提示安装了。这个地方好坑,费了我一个多小时。

某种格式的pac文件没法work

举个例子:

var FindProxyForURL = function(init, profiles) {
    return function(url, host) {
        "use strict";
        var result = init, scheme = url.substr(0, url.indexOf(":"));
        do {
            result = profiles[result];
            if (typeof result === "function") result = result(url, host, scheme);
        } while (typeof result !== "string" || result.charCodeAt(0) === 43);
        return result;
    };
}("+google", {
    "+google": function(url, host, scheme) {
        "use strict";
        if (/(?:^|\.)google\.com$/.test(host)) return "+internal-vf";
        return "DIRECT";
    },
    "+internal-vf": function(url, host, scheme) {
        "use strict";
        if (host === "127.0.0.1" || host === "::1" || host.indexOf(".") < 0) return "DIRECT";
        return "PROXY 127.0.0.1:8123";
    }
});

这是从chrome 插件 SwitchyOmega 导出来的,是正确的 javascript 代码,但是在 whistle 下无法工作

pc上chrome安装证书无效

环境
os: windows 7 64bit
nodejs:v5.10.0

qq 20161124145836
如图,在pc上访问https站点时被知证书无效。
@安装证书rootCA.crt时,确认保存在受信任的根证书颁发机构中,问题出现在pc上,Android和iOS都正常,麻烦 @avwo 解答,多谢:)

==============我是分隔线============
现在问题解决了,麻烦@avwo 关闭这个issue,
解决方法贴在这,供参考

问题原因:域账号无法添加rootCA.crt,至受信任的根证书颁发机构证书列表中

步骤:

  1. 取消证书验证
    1

2.导入证书

3.全选证书目的:打开IE -> Internet选项 -> 内容 -> 证书 ->高级
2

经过以上步骤,问题解决了

DNS Lookup Failed

在mac下,设置网络https代理为127.0.0.1 8899后;
chrome访问,一起正常,抓包也没有问题;
但是使用chrome的插件postman工具发起相同的请求后,提示错误如下:
image

像下面nginx这样转发怎么配置?

    location  ~.*\.(gif|jpg|jpeg|png|bmp|swf|ico|js|css|html)$
    {
        root   html;
        proxy_pass http://127.0.0.1:8080;
    }
    location / {
        root   html;
        proxy_pass http://192.168.30.118:8877;


    }

能否增加配置支持指定配置文件路径

有没有办法做到支持指定配置文件路径?
经常由于重装系统时忘记备份whistleAppData目录,导致配置的hosts文件重装以后全部丢失。
希望能够有自定义配置文件路径的功能。

现在能抓WebSocket的包了吗

想抓websocket的包,但是现在好像还看不到,能看到http和https的包。不知道现在的版本支持抓websocket的包吗?

做代理时异常退出

Error: connect EIO 124.243.193.116:443 - Local (0.0.0.0:0)
at Object.exports._errnoException (util.js:1050:11)
at exports._exceptionWithHostPort (util.js:1073:20)
at internalConnect (net.js:889:16)
at lookupAndConnect (net.js:977:5)
at TLSSocket.realConnect (net.js:945:5)
at TLSSocket.Socket.connect (net.js:903:22)
at TLSSocket.net.Socket.connect (/usr/local/lib/node_modules/whistle/index.js:21:22)
at Object.exports.connect (_tls_wrap.js:1060:12)
at Agent.createConnection (https.js:83:22)
at Agent.createSocket (_http_agent.js:195:26)

编写自定义插件时,无法输出开发log

在开发自定义插件的时候, 遇到一个问题:我想临时输出开发日志, 却没有方法可以输出。

由于插件是由whistle来调用的,whistle对于自定义插件中的console.log等日志信息,没有给予输出,给开发插件带来一定的不便。 建议增加一个whislte的调试模式, 可以便捷地输出自定义插件的相关日志信息, 便于插件开发者调试。

能不能把响应内容替换成时间戳或随机数

比如 test.html 里面有个<script src="test.js"></script>,我想拦截这个test.js,但是因为有缓存,所以浏览器不会发起请求,拦截失败。因此,想要替换成<script src="test.js?时间戳"></script>,这样就能发起请求了。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.