JS reverse engineering and algorithm analysis: complete closed loop from packet capture to Frida-RPC call
written in front
Friends who have done mobile crawlers know that hybrid apps often hide their core encryption logic in the web layer or native layer, making it almost impossible to restore parameters simply by capturing packets. This article takes you through a complete reverse route: From Web layer packet capture and debugging of the hybrid App, to Algorithm tracking and obfuscation restoration, and finally using Frida-RPC to directly call the encryption algorithm inside the App to generate a signature. The entire process is lightweight and reusable, helping you completely solve the pain point of "cannot follow the encryption parameters".
1. Getting started with packet capture for Hybrid App
The essence of a hybrid application is "WebView + native container". The Web layer is responsible for page rendering, using HTTP/HTTPS, and can usually capture packets; the native layer is responsible for calling hardware capabilities, local storage and some algorithms; the two communicate through Bridge. If you want to debug this type of application, the first step is to get access to WebView.
1.1 Quick overview of typical architecture
There is not much difference between the common Hybrid frameworks on the market. Let’s take a quick look at their characteristics:
1.2 What is Bridge communication?
Before officially starting debugging, it is necessary to take a look at the data transfer method inside the hybrid application, which can help us quickly locate key functions later.
The encryption parameters of many Apps are passed through something likebridge.invokeNative('calcApiSign', ...)The method is returned by the native layer. After understanding the Bridge communication mechanism, we can accurately intercept these calls at the Web layer.
2. Chrome DevTools remote debugging practice
The most direct tool for debugging the web layer is Chrome DevTools, but the target App must turn on the WebView debugging mode in advance** - if the App is not open, we can use Frida to temporarily "force open" it.
2.1 Preparation
- Android device/emulator has "USB debugging" enabled
- The computer has ADB and the latest version of Chrome browser installed
- Get the package name of the target App (you can use
adb shell dumpsys window | grep mCurrentFocusquick view)
2.2 Three-step connection and enable debugging
Frida script to temporarily enable WebView debuggingenable-webview.js:
How to run:
After execution, refreshchrome://inspectpage, you can see the WebView list of the target App.
2.3 Advanced WebView debugging: two essential skills
Tip 1: Global Hook packet capture (bypassing proxy restrictions and WebWorker)
Some apps disable WebView's HTTP/S proxy, or hide requests in WebWorker, making them invisible to the Network panel. At this time, you can use DevTools' Sources → Snippets to inject the global Hook script:
After injection, all requests that go through XHR and Fetch will be clearly printed in the Console and are no longer restricted by agents or workers.
Tip 2: One-click search algorithm keywords
Capture packets to get encryption parameters (such as commonsign、token、authetc.), the next step is to quickly find the code that generates them.
Operating steps:
- Open DevTools’ Sources → Search in files (shortcut key
Ctrl+Shift+F/Cmd+Option+F) - Enter keyword search according to priority:
- The parameter name itself:
sign、calcSign、generateSignature - Common encryption libraries:
CryptoJS、AES、MD5、SHA - Coding related:
Base64、encodeURIComponent(commonly used for secondary encoding)
- Select the file from the search results, right-click Reveal in Navigator to quickly locate the obfuscated code location; right-click Deobfuscate source to automatically format the obfuscated code to improve readability.
Combined with call stack tracing, the core function that generates the signature can usually be locked.
3. Frida-RPC: Directly call the App’s internal algorithm
Sometimes, the JavaScript-level code is obfuscated, or the encryption logic is simply placed in the native layer..soCurry, static restoration is extremely difficult. The most labor-saving way at this time is to directly "borrow" the algorithm function that has been packaged inside the App. Frida-RPC can help you "export" these functions to external scripts (such as Python, Node.js), and you only need to pass parameters to get the results.
3.1 Build Frida-RPC service
Assume we have located the native Java class that generates the API signature:com.target.app.util.SecurityUtils, which has a static methodcalcApiSign(Map<String, String> params). Now export it as an RPC interface.
Frida side scriptfrida-rpc-server.js:
3.2 Python side client encapsulation
To facilitate reuse, we can encapsulate a general Python RPC client class:
After running, even if you have no ideacalcApiSignThe internal implementation can also generate correct signatures directly in Python, seamlessly connecting with crawlers or testing tools.
4. Summary
This article provides a set of lightweight and reusable hybrid App reverse workflow:
- Packet capture debugging: Use Frida to force WebView debugging to be enabled, and cooperate with the global Hook script to capture all web layer requests while ignoring proxy restrictions and Worker isolation.
- Algorithm positioning: Use DevTools’ global search and call stack analysis to quickly find the entry point for generating encryption parameters.
- Quick call: If the code is too confusing or the logic is loaded in the native layer, directly "borrow" the algorithm function inside the App through Frida-RPC, and the external script can generate an encrypted signature of any parameter with one click.
If you encounter a packed .so library, you can further combine it with Unidbg to simulate the execution of Native logic on the PC; if it is WebAssembly, you can use tools such as wasm-decompile to decompile and perform static analysis. The entire solution is as flexible as building blocks and is sufficient to meet the reverse needs of most hybrid apps.

