Quickstart Guide
This guide will help you start intercepting and deobfuscating bet365.com’s JavaScript in minutes.Make sure you’ve completed the Installation steps before proceeding.
Overview
The workflow consists of three main steps:- Start mitmproxy to intercept traffic
- Launch a browser configured to use the proxy
- Navigate to bet365.com and view deobfuscated output
Step 1: Start mitmproxy
Start the mitmproxy server with the custom Python addon:What does the Python addon do?
What does the Python addon do?
The
download-payload.py addon:- Filters requests to the
/Api/1/Blobendpoint - Detects obfuscated JavaScript by looking for the pattern
(function(){ var _0x123a= - Saves received obfuscated code to the
output/directory - Runs
refactor-obfuscated-code-jscodeshift.jsto deobfuscate the code - Replaces the obfuscated response with deobfuscated code
- Wraps the output with pre-transform and post-transform code
mitmproxy will start listening on
http://localhost:8080 by default. Keep this terminal window open while intercepting traffic.Step 2: Launch Browser with Proxy
You need to launch a browser configured to route traffic through mitmproxy.- macOS
- Linux
- Windows
- Opens Chrome with a custom profile in
./chrome-profile - Routes all traffic through mitmproxy on port 8080
- Enables verbose logging (useful for debugging)
Browser Flags Explained
| Flag | Purpose |
|---|---|
--proxy-server=http://localhost:8080 | Routes all traffic through mitmproxy |
--enable-logging | Enables Chrome’s debug logging |
--v=1 | Sets verbose logging level |
--user-data-dir=$(pwd)/chrome-profile | Uses separate Chrome profile to avoid conflicts |
Step 3: Accept mitmproxy Certificate
On first launch, you need to install mitmproxy’s SSL certificate:Navigate to mitm.it
In the proxy-configured browser, go to http://mitm.it
Download Certificate
Click on your operating system (macOS, Linux, Windows) to download the certificate
Step 4: Visit bet365.com
Navigate to https://bet365.com in your proxy-configured browser. As the page loads:- mitmproxy intercepts requests to
/Api/1/Blob - Obfuscated JavaScript is detected and saved
- The deobfuscation process runs automatically
- Deobfuscated code replaces the obfuscated version
- Your browser receives and executes the deobfuscated code
Step 5: View Output Files
All intercepted files are saved in theoutput/ directory:
*-received-*.js- Original obfuscated JavaScript from bet365*-deobfuscated-*.js- Deobfuscated output (intermediate step)*-sent-*.js- Final code sent to browser (includes pre/post transforms)
Viewing Console Output
If you started Chrome with--enable-logging --v=1, console output is logged to a file:
Development Workflow
For active development on the deobfuscation transformations, use this workflow:This watches all
*.js files (except obfuscated-original.js and deobfuscated.js) and recompiles the deobfuscation transform on changes.Useful Tools
AST Explorer
Essential for manipulating JavaScript AST. Visualize and test transformations interactively.
Unminify
Formats comma operators well, which are heavily used in bet365’s obfuscated code.
Clear Cache Extension
Useful Chrome extension for clearing cache from toolbar or with keyboard shortcuts.
Understanding the Deobfuscation Process
The deobfuscation applies 11 transformation passes (numbered 0-10):Apply transformations
Each transformation file (0.js through 10.js) modifies the AST:
- Simplifying expressions
- Inlining variables
- Resolving array access
- Removing dead code
Troubleshooting
mitmproxy not intercepting traffic
mitmproxy not intercepting traffic
- Verify mitmproxy is running: check the terminal for “Proxy server listening”
- Confirm browser is using proxy: visit http://mitm.it - if it loads, proxy is working
- Check firewall settings: ensure localhost:8080 is allowed
SSL certificate errors
SSL certificate errors
- Install mitmproxy certificate from http://mitm.it
- On macOS: Add to Keychain and set to “Always Trust”
- On Linux: Add to system certificate store
- Restart browser after installing certificate
No output files generated
No output files generated
- Check that you’re visiting bet365.com (not a different domain)
- Verify the filter in
download-payload.pymatches the endpoint - Look for errors in the mitmproxy terminal
- Ensure the
output/directory exists and is writable
Deobfuscation fails
Deobfuscation fails
bet365 frequently rotates their obfuscated code. The current transformations may not work with the latest version.
- Check the
obfuscated/directory for similar historical versions - The CI/CD pipeline tracks when bet365 updates their code
- You may need to adjust transformation rules for new obfuscation patterns
Chrome profile conflicts
Chrome profile conflicts
If you see “Profile in use” errors:Or use a different profile directory:
Next Steps
Now that you have the basics working, explore:Deobfuscation Process
Learn how the deobfuscation pipeline works in detail
Transform Scripts
Understand each AST transformation step
AST Manipulation
Study the AST manipulation techniques
Development Workflow
Learn the complete development workflow
