Overview
The interception workflow uses mitmproxy as a man-in-the-middle proxy to:- Intercept HTTP responses from bet365’s
/Api/1/Blobendpoint - Extract obfuscated JavaScript files from the response
- Run deobfuscation transforms using jscodeshift
- Inject the deobfuscated code back into the browser
Starting the Proxy
Launch mitmproxy
Start the proxy server with the JavaScript interceptor script:This runs:The proxy will start listening on
http://localhost:8080 by default.Launch Chrome with proxy settings
Open a new terminal and start Chrome configured to use the proxy.For macOS:For Linux:For Windows:
The
--user-data-dir flag creates an isolated Chrome profile in ./chrome-profile/. This keeps your personal browsing data separate.How the Interception Works
Thedownload-payload.py script (loaded by mitmproxy) performs the following:
1. Request Filtering
The script filters for specific endpoints:2. Response Parsing
bet365 returns multiple files in a single response, delimited by\x03\x06\x05:
4= JavaScript file5= CSS file
3. Obfuscation Detection
The script checks if a JavaScript file contains obfuscated code:4. On-the-Fly Deobfuscation
When obfuscated code is detected:5. Code Injection
The final step combines:pre-transform-code.js- Debugging helpers and logging functions- Deobfuscated JavaScript - The transformed code
post-transform-code.js- Additional runtime patches
Output Files
All intercepted files are saved to theoutput/ directory with timestamps:
Saving Obfuscated Code for Analysis
To save a copy of the obfuscated code for later analysis:- Searches the
output/directory for JavaScript files starting with(function(){ - Copies the first match to
mitmproxy/src/javascript/obfuscated/ - Creates a symlink at
mitmproxy/src/javascript/obfuscated-new-raw.js
bet365 frequently rotates their obfuscated code. The project maintains a collection of historical versions in
mitmproxy/src/javascript/obfuscated/ for comparison and testing.Debugging Console Output
The--enable-logging --v=1 flags enable Chrome’s debug logging:
pre-transform-code.js).
Configuration Options
You can modify the behavior by editingdownload-payload.py:
| Variable | Default | Description |
|---|---|---|
refactor_script_on_fly | True | Deobfuscate code in real-time vs. using pre-deobfuscated file |
output_all_files | True | Save all intercepted files (CSS, non-obfuscated JS) to output/ |
Recommendations
Use an isolated Chrome profile
Always use
--user-data-dir to create a separate profile for proxy testing. This prevents interference with your normal browsing.Install Clear Cache extension
bet365 heavily caches JavaScript. Install a “Clear Cache” extension and bind it to a keyboard shortcut for quick cache clearing between tests.
Troubleshooting
No Files Intercepted
Symptoms: mitmproxy is running but no files appear inoutput/
Solutions:
- Verify Chrome is using the proxy: Visit
http://mitm.itin the proxied browser - Check if bet365 is using a different endpoint (URL patterns may have changed)
- Clear Chrome cache and reload bet365
SSL Certificate Errors
Symptoms: Chrome shows SSL warnings for bet365 Solutions:- Visit
http://mitm.itin the proxied browser - Download and install the mitmproxy CA certificate for your OS
- Restart Chrome
Obfuscation Pattern Changed
Symptoms: Files are intercepted but not deobfuscated Solutions:- Check if the obfuscation detection string has changed
- Update
obfuscated_start_stringindownload-payload.py - See Deobfuscation Workflow for analyzing new obfuscation patterns
Next Steps
Now that you can intercept requests:- Learn the deobfuscation workflow
- Set up your development environment
- Explore the intercepted files in
output/
