Front-End JavaScript Reverse Engineering
Overview
Modern web applications move security logic (request signing, anti-bot
tokens, risk scoring) into the browser. Reversing that logic is a discipline
with its own order of operations: observing traffic first, capturing the
relevant code path, rebuilding the logic in a controlled local environment,
and only then patching or decoding. Jumping straight to breakpoints or
deobfuscation is how reversers burn hours on the wrong code.
This skill provides a five-phase workflow — Observe → Capture → Rebuild →
Patch → Decode — plus the execution discipline (evidence-first, artifact
per task, minimal patches) that keeps the process reproducible. It is
tool-agnostic: the same workflow runs on Chrome DevTools, Playwright,
puppeteer, or any CDP-capable driver, and on any runtime rebuilt in Node.js.
Source: cherry-picked and translated from zhaoxuya520/reverse-skill
(skills/js-reverse, MIT license). MCP-specific tool bindings were
generalized to standard browser/CDP tooling.
When to Use
Trigger phrases:
- "reverse the signing logic of this request"
- "how is this frontend token generated"
- "analyze obfuscated JS behavior"
- "rebuild a client-side algorithm in Node"
- "patch a JS function to verify a hypothesis"
- "deobfuscate control flow of a web SDK"
Use this skill when:
- A request carries a signature, token, or header you must reproduce or
understand (for security review, testing, or interoperability).
- Obfuscated or minified client code hides the algorithm.
- You need to confirm behavior before writing a rewrite (verify the real
runtime, never assume from source shape).
Prerequisites
- Chrome (or Chromium) with DevTools; Playwright/puppeteer if scripting.
- Node.js 18+ for local rebuilds.
- A beautifier (prettier or js-beautify) and a proficient code editor.
Workflow
Phase 1: Observe
- Open DevTools → Network, filter by the target request type; identify the
target request URL.
- Open the initiator chain / call stack of that request to find the entry
function.
- Locate the script that issues the request: find the JS file URL, then the
function name and approximate line in the Sources panel.
- Take notes on the request header names you must reproduce and their current
values.
Phase 2: Capture
- Break-on-XHR first: enable XHR breakpoints on the target URL so the
stack lands at the exact call site — the most direct capture point.
- Use light runtime observation: console-log the arguments each step of the
chain receives, not the whole call graph.
- Capture: the function name, the values in scope at the call site,
and when the computed value is added to the request.
Phase 3: Rebuild
- Rebuild the captured call chain as a local Node.js script.
- Evidence-based only: never invent
window, document, crypto, or
localStorage behavior — introduce browser globals you actually saw being
read (via the DevTools console or a strace of properties accessed).
- If the code needs a browser environment, run Playwright and evaluate the
rebuilt logic inside the page context for parity.
- Structure the script so each step prints its output: this exposes the first
divergence immediately.
Phase 4: Patch
- Apply one minimal patch per failure: on the first error or first
divergence, patch the smallest thing that resolves it, retest, log.
- Never mass-edit the target logic before it runs locally.
- Patches are for verification (fix an undefined var, seed a needed value),
not for finishing a half-rebuild.
Phase 5: Decode / DeepDive
- Only after the rebuild runs end-to-end does deobfuscation make sense:
beautify the captured scope of the algorithm and restore control flow
(switch dispatch → if/else) guided by the observed behavior.
- Extract the business logic: key derivation, signing steps, or token field
semantics.
- Downgradeable: if the task only needs the signing result (not long-term
reuse of the algorithm chain), phase 5 can stop at "locally reproduced the
value" without full control-flow recovery.
Execution Rules
- Every task produces artifacts — the script, the capture log, the patch
list. A task with no artifacts is not done.
- Final state per artifact: the runnable rebuilt script with the minimal
patches and a list of every divergence observed and its resolution.
- No unexplained tool calls: every automation action must map to a step in
this workflow.
- Fallbacks: when a capability has no implementation (e.g. deserializer
missing), fall back to the documented generic mechanism instead of
stopping.
- Evidence-first: any claim about what the code does requires a recorded
run or a captured value.
Hands-On Example
Rebuild a captured signing function in Node and confirm the digest matches
the traffic (Phase 3 — Rebuild). In a scratch directory, install the library
with npm install crypto-js, then reproduce the observed hash:
node -e "const C=require('crypto-js'); console.log(C.MD5('a=1&t=1').toString())"
# 1f16f5f46ff3c3b478e870f6446cf656
node -e "const C=require('crypto-js'); console.log(C.HmacSHA256('data','k').toString())"
# 98755ce7a0d431b5...
Verified with Node 22 + crypto-js 4.2.0 (output above). A digest match
between your rebuild and the recorded request proves you reproduced the exact
computation — the same evidence used in Phase 4 to confirm a patched script
preserves behavior.
Verification
Run this self-check before claiming completion:
When NOT to Use
- The logic is server-side only (no browser involvement) — protocol analysis
is the right tool.
- The target is real WebAssembly — use WASM tooling and
dsl-vm-reverse for
JS VM targets separately.
- The JavaScript is malware (phishing pages, droppers, exploit kits) — use
deobfuscating-javascript-malware instead; this skill targets legitimate
app signing logic, not malicious payloads.
- You only need to call the endpoint, not reproduce its algorithm — a
recorded replay may be sufficient, though context-bound tokens will break.
Anti-Rationalization Table
| Rationalization |
Reality |
| "I'll go straight to the deobfuscator." |
Deobfuscating before you have a local, running rebuild tells you nothing about what to look at. Rebuild first. |
| "I'll read the whole obfuscated file before patching." |
You only need the captured execution path. Mass-reading is slower and wrong-reasoning fodder. |
| "I invented a window object to make it run." |
Invented environment masks the real divergence and can produce a value that only appears right. |
| "The value looks plausible, so it's correct." |
Middle values are invisible; only a compared output proves correctness. |
| "One patch fixed everything." |
One error, one patch — a giant patch hides multiple divergences you will not understand later. |
1---2name: js-reverse3description: 'Use when front-end JavaScript reverse engineering for web apps and anti-bot4 engines: observe request flows, capture logic via hooks or breakpoints, rebuild5 in a local Node environment, apply minimal patches, and decode obfuscated signing6 algorithms. Use when analyzing request signing chains, obfuscated SDKs, or client-side7 protection logic.'8domain: cybersecurity9subdomain: web-application-security10tags:11- javascript12- reverse-engineering13- deobfuscation14- anti-bot15- web-application-security16- devtools17- signing-algorithm18version: '1.0'19author: oyi7720license: Apache-2.021nist_csf:22- DE.AE-0223- RS.AN-0324- ID.RA-0125category: cybersecurity26metadata:27 source: https://skillmd.com/skills/oyi77/js-reverse28---293031# Front-End JavaScript Reverse Engineering3233## Overview3435Modern web applications move security logic (request signing, anti-bot36tokens, risk scoring) into the browser. Reversing that logic is a discipline37with its own order of operations: observing traffic first, capturing the38relevant code path, rebuilding the logic in a controlled local environment,39and only then patching or decoding. Jumping straight to breakpoints or40deobfuscation is how reversers burn hours on the wrong code.4142This skill provides a five-phase workflow — Observe → Capture → Rebuild →43Patch → Decode — plus the execution discipline (evidence-first, artifact44per task, minimal patches) that keeps the process reproducible. It is45tool-agnostic: the same workflow runs on Chrome DevTools, Playwright,46puppeteer, or any CDP-capable driver, and on any runtime rebuilt in Node.js.4748Source: cherry-picked and translated from `zhaoxuya520/reverse-skill`49(`skills/js-reverse`, MIT license). MCP-specific tool bindings were50generalized to standard browser/CDP tooling.5152## When to Use5354**Trigger phrases:**55- "reverse the signing logic of this request"56- "how is this frontend token generated"57- "analyze obfuscated JS behavior"58- "rebuild a client-side algorithm in Node"59- "patch a JS function to verify a hypothesis"60- "deobfuscate control flow of a web SDK"6162Use this skill when:6364- A request carries a signature, token, or header you must reproduce or65 understand (for security review, testing, or interoperability).66- Obfuscated or minified client code hides the algorithm.67- You need to confirm behavior before writing a rewrite (verify the real68 runtime, never assume from source shape).6970## Prerequisites7172- Chrome (or Chromium) with DevTools; Playwright/puppeteer if scripting.73- Node.js 18+ for local rebuilds.74- A beautifier (prettier or js-beautify) and a proficient code editor.7576## Workflow7778### Phase 1: Observe7980- Open DevTools → Network, filter by the target request type; identify the81 target request URL.82- Open the initiator chain / call stack of that request to find the entry83 function.84- Locate the script that issues the request: find the JS file URL, then the85 function name and approximate line in the Sources panel.86- Take notes on the request header names you must reproduce and their current87 values.8889### Phase 2: Capture9091- **Break-on-XHR first**: enable XHR breakpoints on the target URL so the92 stack lands at the exact call site — the most direct capture point.93- Use light runtime observation: console-log the arguments each step of the94 chain receives, not the whole call graph.95- Capture: the function name, the values in scope at the call site,96 and when the computed value is added to the request.9798### Phase 3: Rebuild99100- Rebuild the captured call chain as a local Node.js script.101- Evidence-based only: never invent `window`, `document`, `crypto`, or102 `localStorage` behavior — introduce browser globals you actually saw being103 read (via the DevTools console or a strace of properties accessed).104- If the code needs a browser environment, run Playwright and evaluate the105 rebuilt logic inside the page context for parity.106- Structure the script so each step prints its output: this exposes the first107 divergence immediately.108109### Phase 4: Patch110111- Apply **one minimal patch per failure**: on the first error or first112 divergence, patch the smallest thing that resolves it, retest, log.113- Never mass-edit the target logic before it runs locally.114- Patches are for verification (fix an undefined var, seed a needed value),115 not for finishing a half-rebuild.116117### Phase 5: Decode / DeepDive118119- Only after the rebuild runs end-to-end does deobfuscation make sense:120 beautify the captured scope of the algorithm and restore control flow121 (switch dispatch → if/else) guided by the observed behavior.122- Extract the business logic: key derivation, signing steps, or token field123 semantics.124- **Downgradeable**: if the task only needs the signing result (not long-term125 reuse of the algorithm chain), phase 5 can stop at "locally reproduced the126 value" without full control-flow recovery.127128## Execution Rules129130- Every task produces artifacts — the script, the capture log, the patch131 list. A task with no artifacts is not done.132- Final state per artifact: the runnable rebuilt script with the minimal133 patches and a list of every divergence observed and its resolution.134- No unexplained tool calls: every automation action must map to a step in135 this workflow.136- Fallbacks: when a capability has no implementation (e.g. deserializer137 missing), fall back to the documented generic mechanism instead of138 stopping.139- Evidence-first: any claim about what the code does requires a recorded140 run or a captured value.141142## Hands-On Example143144Rebuild a captured signing function in Node and confirm the digest matches145the traffic (Phase 3 — Rebuild). In a scratch directory, install the library146with `npm install crypto-js`, then reproduce the observed hash:147148```bash149node -e "const C=require('crypto-js'); console.log(C.MD5('a=1&t=1').toString())"150# 1f16f5f46ff3c3b478e870f6446cf656151152node -e "const C=require('crypto-js'); console.log(C.HmacSHA256('data','k').toString())"153# 98755ce7a0d431b5...154```155156Verified with Node 22 + crypto-js 4.2.0 (output above). A digest match157between your rebuild and the recorded request proves you reproduced the exact158computation — the same evidence used in Phase 4 to confirm a patched script159preserves behavior.160161## Verification162163Run this self-check before claiming completion:164165- [ ] Target request URL and initiator chain are documented.166- [ ] Break-on-XHR or equivalent capture produced the full function chain167 with observed values.168- [ ] The rebuilt Node/Playwright script reproduces the target value without169 invented browser behavior.170- [ ] Each patch is minimal, logged, and justified (one error → one patch).171- [ ] The final value is compared live against a real page capture and172 matches.173- [ ] If the task needed control-flow recovery: the deobfuscated version174 recompiles/reruns and produces the same output.175176## When NOT to Use177178- The logic is server-side only (no browser involvement) — protocol analysis179 is the right tool.180- The target is real WebAssembly — use WASM tooling and `dsl-vm-reverse` for181 JS VM targets separately.182- The JavaScript is malware (phishing pages, droppers, exploit kits) — use183 `deobfuscating-javascript-malware` instead; this skill targets legitimate184 app signing logic, not malicious payloads.185- You only need to call the endpoint, not reproduce its algorithm — a186 recorded replay may be sufficient, though context-bound tokens will break.187188## Anti-Rationalization Table189190| Rationalization | Reality |191|---|---|192| "I'll go straight to the deobfuscator." | Deobfuscating before you have a local, running rebuild tells you nothing about what to look at. Rebuild first. |193| "I'll read the whole obfuscated file before patching." | You only need the captured execution path. Mass-reading is slower and wrong-reasoning fodder. |194| "I invented a window object to make it run." | Invented environment masks the real divergence and can produce a value that only appears right. |195| "The value looks plausible, so it's correct." | Middle values are invisible; only a compared output proves correctness. |196| "One patch fixed everything." | One error, one patch — a giant patch hides multiple divergences you will not understand later. |