https://github.com/PotatoMaster101/WpkSnoop
A .NET tool that searches and extracts Webpack chunk loaders from JS files
https://github.com/PotatoMaster101/WpkSnoop
dotnet webpack webpack-chunk webpack-chunk-loader webpack-tool
Last synced: 9 months ago
JSON representation
A .NET tool that searches and extracts Webpack chunk loaders from JS files
- Host: GitHub
- URL: https://github.com/PotatoMaster101/WpkSnoop
- Owner: PotatoMaster101
- License: gpl-3.0
- Created: 2025-01-22T14:39:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-28T06:00:34.000Z (about 1 year ago)
- Last Synced: 2025-05-08T22:00:00.486Z (about 1 year ago)
- Topics: dotnet, webpack, webpack-chunk, webpack-chunk-loader, webpack-tool
- Language: C#
- Homepage:
- Size: 210 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://opensource.org/license/gpl-3-0)
[](https://github.com/PotatoMaster101/WpkSnoop/actions/workflows/dotnet.yml)
# WpkSnoop
A .NET tool that searches and extracts Webpack chunk loaders from `.js` files.
The extractor supports:
- Chunk loader that uses an object expression (e.g., `{100: "chunk1", 101: "chunk2"}[e] + ".js"`)
- Chunk loader that uses `if` statements (e.g., `if (100 === e) return "chunk.js"`)
- Chunk loader that uses ternary operator (`?:`) (e.g., `100 === e ? "chunk.js" : ...`)
- Chunk loader that uses `switch` statement (e.g., `switch (e) { case 100: return "chunk.js" }`)
- Chunk loader that uses array lookup (e.g., `["chunk1.js", "chunk2.js"][e]`)
For an overview of how this works read [DOC.md](DOC.md).
**Note**: I don't intend to continue developing this tool any further, as there are better alternatives available, such as [jxscout](https://github.com/francisconeves97/jxscout). This project began as a research experiment to explore chunk detection algorithms, and it's reached its conclusion.
## Building
Build with [.NET](https://dotnet.microsoft.com/en-us/).
```
dotnet publish src/WpkSnoop.Cli/WpkSnoop.Cli.csproj -c Release -o .
```
You might receive some JINT warning when compiling as native AOT but the tool seems to work fine after some testing.
## Usage
```
Description:
Webpack Chunk Loader Extractor
Usage:
wpksnoop [options]
Arguments:
Path to the JS file containing the chunk loader
Options:
-d, --dir Specifies that the path is a directory path
-v, --verbose Specifies verbose output
-H, --header Specifies the HTTP headers for chunk file GET requests
-D, --domain Specifies the base URL for chunk file GET requests
-x, --proxy Specifies the proxy URL for chunk file GET requests
-k, --insecure Specifies to not validate HTTPS certificates for chunk file GET requests
-t, --threads Specifies the number of threads to use [default: 2147483647]
--version Show version information
-?, -h, --help Show help and usage information
```
## Examples
Sample JS files can be found under `tests/WpkSnoop.Core.Test/Samples/`. They are used to test different chunk loaders generated by Webpack.
### Single `.js` File
```
wpksnoop tests/WpkSnoop.Core.Test/Samples/small.js
```
### Directory With `.js` Files
```
wpksnoop -d tests/WpkSnoop.Core.Test/Samples/
```
### Sending GET Requests
Used to send all the found chunk loader entries to a site.
```
wpksnoop tests/WpkSnoop.Core.Test/Samples/small.js -D 'https://example.com/chunks/'
```
The chunk loader entries can also go through a proxy, useful for using tools like burp.
```
wpksnoop tests/WpkSnoop.Core.Test/Samples/small.js -v -D 'https://example.com/chunks/' -x 'http://localhost:8080'
```
HTTP headers can be added by using `-H`.
```
wpksnoop tests/WpkSnoop.Core.Test/Samples/small.js -v -D 'https://example.com/chunks/' -H 'Cookie: 1' -H 'Cookie: 2'
```
## Generate Webpack Files
Sample Webpack project used for testing can be found under `webpack/`. Generate Webpack files by:
```
cd webpack
npm install
npm run build
```
The generated Webpack files will be under `webpack/dist/`.
## Limitations
See [issues](https://github.com/PotatoMaster101/WpkSnoop/issues?q=is%3Aissue%20state%3Aopen%20author%3APotatoMaster101).