whistle 2.9.99 → 2.9.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-en_US.md +68 -279
- package/README.md +71 -277
- package/assets/js/worker.js +1 -1
- package/assets/menu.html +5 -0
- package/assets/modal.html +5 -0
- package/assets/tab.html +5 -0
- package/bin/ca/cli.js +5 -2
- package/bin/util.js +12 -12
- package/biz/webui/cgi-bin/compose-data.js +50 -0
- package/biz/webui/cgi-bin/composer.js +88 -53
- package/biz/webui/cgi-bin/util.js +2 -0
- package/biz/webui/htdocs/index.html +1 -1
- package/biz/webui/htdocs/js/index.js +43 -43
- package/biz/webui/lib/index.js +15 -7
- package/index.js +8 -0
- package/lib/config.js +8 -2
- package/lib/handlers/http-proxy.js +3 -3
- package/lib/https/h2.js +16 -12
- package/lib/https/index.js +25 -19
- package/lib/inspectors/data.js +1 -5
- package/lib/inspectors/log.js +6 -5
- package/lib/inspectors/req.js +2 -2
- package/lib/inspectors/res.js +18 -11
- package/lib/plugins/index.js +5 -1
- package/lib/plugins/load-plugin.js +48 -56
- package/lib/rules/dns.js +1 -1
- package/lib/rules/index.js +132 -65
- package/lib/rules/protocols.js +2 -0
- package/lib/rules/rules.js +28 -10
- package/lib/rules/util.js +1 -1
- package/lib/socket-mgr.js +6 -11
- package/lib/tunnel.js +26 -22
- package/lib/upgrade.js +5 -9
- package/lib/util/common.js +43 -1
- package/lib/util/file-writer-transform.js +4 -2
- package/lib/util/http-mgr.js +3 -2
- package/lib/util/index.js +121 -74
- package/lib/util/patch.js +5 -5
- package/lib/util/whistle-transform.js +2 -1
- package/package.json +5 -6
package/README-en_US.md
CHANGED
|
@@ -7,290 +7,79 @@
|
|
|
7
7
|
# whistle
|
|
8
8
|
[](https://npmjs.org/package/whistle)
|
|
9
9
|
[](http://nodejs.org/download/)
|
|
10
|
-
[](https://codecov.io/gh/avwo/whistle)
|
|
11
10
|
[](https://npmjs.org/package/whistle)
|
|
12
11
|
[](https://www.npmjs.com/package/whistle)
|
|
13
|
-
[](https://www.npmjs.com/package/whistle)
|
|
13
|
+
|
|
14
|
+
[中文](./README.md) · English
|
|
15
|
+
|
|
16
|
+
Whistle is a cross-platform network packet capture and debugging tool based on Node.js, with:
|
|
17
|
+
1. **Powerful**
|
|
18
|
+
- Supports multiple proxy modes such as HTTP proxy, HTTPS proxy, Socks proxy, and reverse proxy
|
|
19
|
+
- Supports viewing and modifying HTTP, HTTPS, HTTP/2, WebSocket, and TCP requests/responses
|
|
20
|
+
- Built-in multiple common debugging tools:
|
|
21
|
+
- Weinre: View the DOM structure of the remote page,
|
|
22
|
+
- Console: View the console log of the remote page,
|
|
23
|
+
- Composer: Replay and edit requests
|
|
24
|
+
2. **Simple operation**
|
|
25
|
+
- Supports modifying requests/responses by configuring rules
|
|
26
|
+
- Provides a one-stop GUI interface for viewing packet capture, configuring rules, managing plug-ins, and operating Weinre/Console/Composer, etc.
|
|
27
|
+
3. **Extensible**
|
|
28
|
+
- Supports extending rules and interface functions through plug-ins
|
|
29
|
+
- Supports being referenced by projects as NPM packages
|
|
30
|
+
4. **Cross-platform**
|
|
31
|
+
- Supports desktop systems such as macOS, Windows, and Linux (Ubuntu/Fedora)
|
|
32
|
+
- Supports interfaceless Linux servers
|
|
18
33
|
|
|
19
34
|
# Installation
|
|
20
35
|
|
|
21
|
-
**
|
|
22
|
-
|
|
23
|
-
>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
1. Install Whistle
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
<img alt="Click Yes (Y)" width="420" src="https://user-images.githubusercontent.com/11450939/168846905-384e0540-e02f-46de-81d7-e395a496f032.jpeg">
|
|
69
|
-
</details>
|
|
70
|
-
|
|
71
|
-
<details>
|
|
72
|
-
<summary>Mac You need to enter the power-on password or fingerprint verification</summary>
|
|
73
|
-
<img alt="Enter the power-on password" width="330" src="https://user-images.githubusercontent.com/11450939/176977027-4a7b06a0-64f6-4580-b983-312515e9cd4e.png">
|
|
74
|
-
<img alt="Enter fingerprint" width="330" src="https://user-images.githubusercontent.com/11450939/168847123-e66845d0-6002-4f24-874f-b6943f7f376b.png">
|
|
75
|
-
</details>
|
|
76
|
-
|
|
77
|
-
For how to install the root certificate on other terminals such as mobile phones, please refer to the complete document: https://wproxy.org/whistle/webui/https.html
|
|
78
|
-
|
|
79
|
-
### Setting up a proxy
|
|
80
|
-
|
|
81
|
-
**There are four ways to use Windows PC or Mac PC. You can choose one of them according to your actual situation:**
|
|
82
|
-
|
|
83
|
-
1. **[Recommended]** Set up a proxy by installing the Chrome plug-in SwitchyOmega: https://chromewebstore.google.com/detail/proxy-switchyomega/padekgcemlokbadohgkifijomclgjgif
|
|
84
|
-
|
|
85
|
-
> Chrome App Store requires a VPN. If you cannot access it, please install it manually: https://proxy-switchyomega.com/download/
|
|
86
|
-
|
|
87
|
-
<details>
|
|
88
|
-
<summary>SwitchyOmega setting method example diagram</summary>
|
|
89
|
-
<img width="620" alt="image" src="https://github.com/user-attachments/assets/24016b7c-8f2a-45a3-9dc8-5ef3ddf46233" /><img width="180" alt="image" src="https://github.com/user-attachments/assets/43afd3cd-5c17-4d6a-82d0-20a7ef2e0d99" />
|
|
90
|
-
</details>
|
|
91
|
-
|
|
92
|
-
2. Set the system proxy through the command line:
|
|
93
|
-
|
|
94
|
-
```. sh
|
|
95
|
-
w2 proxy
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
> You can also specify the IP (default `127.0.0.1`) and port: `w2 proxy "10.x.x.x:8888"`, and use `w2 proxy 0` to turn off the system proxy setting
|
|
99
|
-
|
|
100
|
-
3. Set the proxy directly on the client, such as FireFox, WeChat developer tools, etc., which have built-in proxy setting functions
|
|
101
|
-
<details>
|
|
102
|
-
<summary>FireFox proxy setting example image</summary>
|
|
103
|
-
<img width="1100" alt="image" src="https://github.com/user-attachments/assets/98c1ec5d-4955-4e23-a49a-c1015b128d9d" />
|
|
104
|
-
</details>
|
|
105
|
-
4. Set up a proxy through Proxifier (for clients that cannot set up a proxy and do not use a system proxy): https://www.proxifier.com/docs/win-v4/http-proxy.html
|
|
106
|
-
|
|
107
|
-
**Linux setting path: Settings > Network > VPN > Network Proxy > Manual**
|
|
108
|
-
<details>
|
|
109
|
-
<summary>Linux proxy setting example image</summary>
|
|
110
|
-
<img width="1000" alt="image" src="https://github.com/user-attachments/assets/e9441d32-c818-4446-8be6-0fa3df3aed86" />
|
|
111
|
-
</details>
|
|
112
|
-
|
|
113
|
-
**Mobile devices such as mobile phones need to configure the current `Wi-Fi` proxy, taking iOS as an example:**
|
|
114
|
-
<details>
|
|
115
|
-
<summary>iOS proxy settings example image</summary>
|
|
116
|
-
<img width="1000" alt="image" src="https://github.com/user-attachments/assets/e97dc311-2ace-4287-b6b0-0247b13974a9" />
|
|
117
|
-
</details>
|
|
118
|
-
|
|
119
|
-
# Use
|
|
120
|
-
|
|
121
|
-
After installing Whistle according to the above steps, open the link http://local.whistlejs.com on the Chrome browser, and you can see the following operation interface:
|
|
122
|
-
|
|
123
|
-
<img width="1200" alt="network" src="https://github.com/user-attachments/assets/3186e76a-486a-4e61-98a1-2d4b4f91fad0" />
|
|
124
|
-
|
|
125
|
-
<img width="1200" alt="rules" src="https://github.com/user-attachments/assets/2e336403-4810-48e5-91c1-6f22dcda7388" />
|
|
126
|
-
|
|
127
|
-
Among them, Network is the interface for viewing packet capture, Rules is the configuration rule, Values is the configuration data interface (used with Rules), and Plugins is the list of installed plugins.
|
|
128
|
-
|
|
129
|
-
### Interface functions
|
|
130
|
-
|
|
131
|
-
<details>
|
|
132
|
-
<summary>Replay request</summary>
|
|
133
|
-
<img width="800" alt="image" src="https://github.com/user-attachments/assets/9f8276ac-e089-427b-97f4-becac250ae5e" />
|
|
134
|
-
</details>
|
|
135
|
-
|
|
136
|
-
<details>
|
|
137
|
-
<summary>Edit or construct request</summary>
|
|
138
|
-
<img width="1200" alt="image" src="https://github.com/user-attachments/assets/f2a5b088-72b6-4098-8ba6-3e42f15f3ad8" />
|
|
139
|
-
</details>
|
|
140
|
-
|
|
141
|
-
For other interface functions, see the full document: https://wproxy.org/whistle/webui/
|
|
142
|
-
|
|
143
|
-
### Rule functions
|
|
144
|
-
|
|
145
|
-
Whistle rules can be seen as an extension of the following system hosts rules:
|
|
146
|
-
|
|
147
|
-
``` txt
|
|
148
|
-
# One domain name corresponds to one IP
|
|
149
|
-
127.0.0.1 localhost
|
|
150
|
-
::1 localhost
|
|
151
|
-
# Multiple domain names correspond to one IP
|
|
152
|
-
10.2.55.3 www.test.com www.example.com
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
The system hosts rules have a single function, only supporting DNS modification and domain name matching, and there are DNS cache problems, which cannot meet daily work needs. Whistle rules extend the functions of system hosts rules. In terms of matching methods, they not only support domain name matching, path matching, wildcard matching, regular matching, etc., but also support further filtering by request method, response status code, request (response) header, request content, etc.; in terms of functions, they not only support DNS modification, but also support port modification, CNAME, proxy setting, request URL modification, request method, response status code, request header, response header, request content, response content, etc. In theory, everything in HTTP request can be modified. The format of Whistle rules is:
|
|
156
|
-
|
|
157
|
-
1. Default format
|
|
158
|
-
|
|
159
|
-
``` txt
|
|
160
|
-
pattern operation
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
2. Support matching multiple operations
|
|
164
|
-
|
|
165
|
-
``` txt
|
|
166
|
-
pattern operation1 operation2 ...
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
3. Support filters
|
|
170
|
-
|
|
171
|
-
``` txt
|
|
172
|
-
pattern operation1 operation2 ... includeFilter://filterPattern1 ... excludeFilter://filterPatternN ...
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
> Multiple filters are in an or relationship, that is, one of the conditions must be met
|
|
176
|
-
|
|
177
|
-
4. Support position swap (prerequisite: operation and pattern are not URLs or domain names at the same time)
|
|
178
|
-
|
|
179
|
-
``` txt
|
|
180
|
-
operation pattern [filters ...]
|
|
181
|
-
operation pattern1 pattern2 ... [filters ...]
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
5. Support line breaks
|
|
185
|
-
|
|
186
|
-
``` txt
|
|
187
|
-
line`
|
|
188
|
-
operation
|
|
189
|
-
pattern1
|
|
190
|
-
pattern2 ...
|
|
191
|
-
[filters ...]
|
|
192
|
-
`
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
Specific examples are as follows:
|
|
196
|
-
|
|
197
|
-
##### Modify DNS (set Hosts)
|
|
198
|
-
|
|
199
|
-
1. Domain name matching
|
|
200
|
-
|
|
201
|
-
``` txt
|
|
202
|
-
www.test.com 127.0.0.1
|
|
203
|
-
# Support port
|
|
204
|
-
www.test.com 127.0.0.1:8080
|
|
205
|
-
# CNAME function (port optional)
|
|
206
|
-
www.test.com host://www.example.com:8181
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
> Unlike the system hosts rule, the Whistle rule adopts **left-to-right mapping** and **top-to-bottom priority** by default, but the operation and pattern can be swapped when they are different URLs or domain names, so it is also compatible with the system hosts rule, that is: `127.0.0.1:8080 www.test.com`
|
|
210
|
-
|
|
211
|
-
2. Path matching
|
|
212
|
-
|
|
213
|
-
``` txt
|
|
214
|
-
www.test.com/path/to 127.0.0.1:8080
|
|
215
|
-
# Support with protocol
|
|
216
|
-
https://www.test.com/path/to 127.0.0.1:8080
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
3. Wildcard matching
|
|
220
|
-
|
|
221
|
-
``` txt
|
|
222
|
-
# Domain name wildcard, matching test.com All descendant domain names of
|
|
223
|
-
**.test.com 127.0.0.1:8080
|
|
224
|
-
# Support wildcards for domain names with protocols
|
|
225
|
-
https://**.test.com 127.0.0.1:8080
|
|
226
|
-
# Path wildcards (* is a legal character for paths, so add ^ in front to tell Whistle that it is a wildcard)
|
|
227
|
-
^**.test.com/*/path/to 127.0.0.1:8080
|
|
228
|
-
# Support wildcards for paths with protocols
|
|
229
|
-
^https://**.test.com/*/path/to 127.0.0.1:8080
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
> `*`, `**`, `***` have different matching ranges, for details, see the full document: https://wproxy.org/whistle/pattern.html
|
|
233
|
-
|
|
234
|
-
4. Regular matching
|
|
235
|
-
|
|
236
|
-
``` txt
|
|
237
|
-
# The internal `/` can be escaped, which is equivalent to `new RegExp('^https?://\w+\.test\.com')`
|
|
238
|
-
/^https?://\w+\.test\.com/ 127.0.0.1:8080
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
5. Filter matching
|
|
242
|
-
|
|
243
|
-
``` txt
|
|
244
|
-
# `pattern` is the same as the domain name, path, and regular expression above, indicating that in addition to matching `pattern`, the request header `cookie` must also contain `env=test`
|
|
245
|
-
pattern 127.0.0.1:8080 includeFilter://reqH.cookie=/env=test/
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
##### Modify form data
|
|
249
|
-
|
|
250
|
-
``` txt
|
|
251
|
-
# Modify the value of the `test` field in the form
|
|
252
|
-
pattern reqMerge://test=123
|
|
253
|
-
|
|
254
|
-
# Delete the `abc` field in the form
|
|
255
|
-
pattern delete://reqBody.abc
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
##### Set the cross-domain response header
|
|
259
|
-
|
|
260
|
-
``` txt
|
|
261
|
-
# Taking path matching as an example, set the cross-domain response header Access-Control-Allow-Origin: * and exclude OPTION requests
|
|
262
|
-
pattern resCors://* excludeFilter://m:option
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
For all rules, see the full document: https://wproxy.org/whistle/rules/
|
|
266
|
-
|
|
267
|
-
### Install the plugin
|
|
268
|
-
|
|
269
|
-
The plugin needs to be installed through the command line:
|
|
270
|
-
|
|
271
|
-
``` sh
|
|
272
|
-
w2 i whistle.inspect whistle.vase
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
> The above plug-in function introduction and source code: [https://github.com/whistle-plugins](https://github.com/whistle-plugins), the client can be installed through the interface: [https://github.com/avwo/whistle-client](https://github.com/avwo/whistle-client)
|
|
276
|
-
|
|
277
|
-
After installation, you can see these two plug-ins in the Plugins of the management interface:
|
|
278
|
-
|
|
279
|
-
<details>
|
|
280
|
-
<summary>Plugin list example image</summary>
|
|
281
|
-
<img width="1000" alt="image" src="https://github.com/user-attachments/assets/ec018691-c7a9-415e-9809-bf079694c024" />
|
|
282
|
-
</details>
|
|
283
|
-
|
|
284
|
-
Each plug-in can add two rule protocols by default:
|
|
285
|
-
|
|
286
|
-
``` txt
|
|
287
|
-
whistle.inspect://xxx
|
|
288
|
-
inspect://xxx
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
> By configuring the custom rules of the plug-in, the matching request can be forwarded to the plug-in specified hook implements custom functions. If not needed, you can also set `"hideLongProtocol": true` or `"hideShortProtocol": true` in `whistleConfig` of `package.json` of the plugin to hide the corresponding rule protocol
|
|
292
|
-
|
|
293
|
-
In addition to extending rules, the plugin also supports extending the Whistle interface, as well as providing operation interfaces, built-in rules and other functions. For installation, use and development of the plugin, please refer to the complete document: https://wproxy.org/whistle/plugins.html
|
|
36
|
+
**Whistle client is recommended for desktop systems such as macOS, Windows, and Linux (Ubuntu/Fedora): [https://github.com/avwo/whistle-client](https://github.com/avwo/whistle-client)**
|
|
37
|
+
|
|
38
|
+
> You can skip the **installation** step by using Whistle client
|
|
39
|
+
|
|
40
|
+
For environments such as Linux servers without interfaces, please follow the 4 steps below:
|
|
41
|
+
|
|
42
|
+
1. **Install Whistle**, it is recommended to install it with NPM: `npm i -g whistle` (Node.js needs to be installed first: https://nodejs.org/)
|
|
43
|
+
> It also supports installation through brew: `brew install whistle` (brew needs to be installed first: https://brew.sh/)
|
|
44
|
+
2. **Start Whistle**, execute the command line: `w2 start`
|
|
45
|
+
3. **Install the root certificate**, execute the command line: `w2 ca`
|
|
46
|
+
> The root certificate installation process may require manual confirmation:
|
|
47
|
+
>
|
|
48
|
+
> <details>
|
|
49
|
+
> <summary>Windows needs to click the last "Yes (Y)" confirm</summary>
|
|
50
|
+
> <img alt="Click Yes (Y)" width="420" src="https://user-images.githubusercontent.com/11450939/168846905-384e0540-e02f-46de-81d7-e395a496f032.jpeg">
|
|
51
|
+
> </details>
|
|
52
|
+
>
|
|
53
|
+
> <details>
|
|
54
|
+
> <summary>macOS requires a power-on password or fingerprint verification</summary>
|
|
55
|
+
> <img alt="Enter power-on password" width="330" src="https://user-images.githubusercontent.com/11450939/176977027-4a7b06a0-64f6-4580-b983-312515e9cd4e.png">
|
|
56
|
+
> <img alt="Enter fingerprint" width="330" src="https://user-images.githubusercontent.com/11450939/168847123-e66845d0-6002-4f24-874f-b6943f7f376b.png">
|
|
57
|
+
> </details>
|
|
58
|
+
>
|
|
59
|
+
|
|
60
|
+
4. **Set proxy**, command line execution: `w2 proxy`
|
|
61
|
+
> macOS may need to enter the lock screen password when setting up the proxy for the first time
|
|
62
|
+
>
|
|
63
|
+
> Set a specified IP or port: `w2 proxy "10.x.x.x:8888"`
|
|
64
|
+
>
|
|
65
|
+
> Turn off system proxy: `w2 proxy 0`
|
|
66
|
+
>
|
|
67
|
+
> Other ways to set proxy:
|
|
68
|
+
>
|
|
69
|
+
> 1. **[Recommended]** Install Chrome plug-in ZeroOmega Set up a proxy: https://chromewebstore.google.com/detail/proxy-switchyomega-3-zero/pfnededegaaopdmhkdmcofjmoldfiped (If you cannot access it, you can install it manually: https://chrome.zzzmh.cn/info/pfnededegaaopdmhkdmcofjmoldfiped)
|
|
70
|
+
>
|
|
71
|
+
> 2. Set up a proxy directly on the client, such as FireFox, WeChat developer tools, etc., which have built-in proxy settings
|
|
72
|
+
>
|
|
73
|
+
> <details>
|
|
74
|
+
> <summary>FireFox proxy settings example image</summary>
|
|
75
|
+
> <img width="1000" alt="image" src="https://github.com/user-attachments/assets/98c1ec5d-4955-4e23-a49a-c1015b128d9d" />
|
|
76
|
+
> </details>
|
|
77
|
+
>
|
|
78
|
+
> 3. Through Proxifier Setting up a proxy (for clients that cannot set up a proxy and do not use a system proxy): https://www.proxifier.com/docs/win-v4/http-proxy.html
|
|
79
|
+
>
|
|
80
|
+
|
|
81
|
+
# Getting Started
|
|
82
|
+
For detailed usage instructions, please refer to: https://wproxy.org/en/docs/getting-started.html
|
|
294
83
|
|
|
295
84
|
# License
|
|
296
85
|
|