JavaScript analysis
- Noise
- Light active
- Reads
urls/clean.txthttp/live.txt- Writes
js/live.txtjs/files/js/endpoints.txtjs/secrets.jsonl
Scope checkActive phase. Check the program policy first. Send traffic only to in-scope assets, at the rate the program allows.
Modern front ends ship the whole API map to the browser. A React or Angular bundle contains every route the app can call, including routes for features your account cannot see: admin actions, beta features, internal tools. It may also contain hostnames for staging APIs and, now and then, keys that should never have left the server.
Downloading JS files is a handful of normal GET requests. The analysis itself runs on your machine.
| Tool | Noise | Role | Status |
|---|---|---|---|
| jsluice | Passive | Parses JS syntax trees to extract URLs, paths and secrets. Runs on local files | Maintained |
| LinkFinder | Light active | Regex endpoint extraction from a JS URL or file | Old, still useful |
| xnLinkFinder | Light active | Endpoints and parameter names from URLs, files or Burp exports | Maintained |
| SecretFinder | Light active | Regex-based key and token finder for JS | Old, many false positives |
| getJS, subjs | Light active | Collect every JS URL a page references | Maintained |
| sourcemapper | Passive | Rebuilds the original source tree from a .map file |
Works |
| GAP | Passive | Burp and Caido extension that pulls endpoints and params from proxied traffic | Maintained |
When to skip a file
Section titled “When to skip a file”vendor.js, chunk-vendors.js, and react-dom.js are the libraries, not the app. They are full of paths that do not exist on this server. Prefer app.*.js, main.*.js, routes.*.js, and the numbered chunks the app actually loads, such as 124.js or settings-tab.js. Leave Google Tag Manager, Sentry, Intercom, and files from cdn.jsdelivr.net or cdnjs.cloudflare.com out of the endpoint extract.
What a bundle string proves
Section titled “What a bundle string proves”Path from jsluice
Section titled “Path from jsluice”/api/v2/users/exportjsluice pulled that string out of js/files/4f2a9e10bc8351da.js. The client builds or calls /api/v2/users/export. It does not mean the server mounts that path, or that an anonymous caller can use it. Request it. A JSON 401, 403, or 405 means a handler is listening. A 200 whose body is the same HTML shell as a nonsense path means the browser router owns it. A 404 on GET, POST, and OPTIONS means it is not mounted here. Save the dead path in your notes and keep it out of the scanner list.
Publishable key
Section titled “Publishable key”pk_live_51HzN48ExampleKeyString99js/secrets.jsonl matched a Stripe publishable key. Stripe expects that prefix in the browser. The server secret prefix is sk_live_. A pk_live_ match is not a leak by itself. The same goes for a Google Maps browser key, a Firebase config, and a Sentry DSN.
Staging hostname
Section titled “Staging hostname”api-staging.example.comThe hostname is hardcoded in a config object in the bundle. It does not mean public DNS resolves it, or that you can reach it from the internet. Put it through phase 4 before you treat it as a live host. If it does not resolve, keep the name for virtual host tests.
Convincing duds
Section titled “Convincing duds”sourceMappingURL with no map
Section titled “sourceMappingURL with no map”A bundle ends in //# sourceMappingURL=app.js.map. The bundler emitted the comment. The deploy often deletes the .map file before it publishes. Request the map URL. Only a 200 is the original source tree.
Client route that returns the shell
Section titled “Client route that returns the shell”/admin/users/view returns 200 and the same index.html as /, often with <div id="root"></div>. That path is a client route. Drop it from the API list.
Trade-offs
Section titled “Trade-offs”Regex tools split a concatenated path into /api/v1/ and /export. jsluice keeps the path the code actually builds. Use jsluice on the files you downloaded. Use LinkFinder when you only want a quick look at one URL.
Step by step
Section titled “Step by step”-
Collect JavaScript URLs from the URL list and from a fresh crawl.
Terminal window # Pull .js URLs out of the cleaned URL listgrep -Ei '\.js(\?|$)' urls/clean.txt | sort -u > js/urls.txtThe cleaned URL list only holds JS that archives or the crawler already saw. getJS and subjs fetch each live page and read its
<script>tags, which catches bundles added since the last crawl.Terminal window # Collect script URLs from every live host, merge with what you havecat http/live.txt | getJS --complete 2>/dev/null | anew js/urls.txtcat http/live.txt | subjs | anew js/urls.txtTerminal window # Keep only JS files that still return 200httpx -l js/urls.txt -mc 200 -rl 30 -silent > js/live.txt -
Download them once. Analyzing local copies is faster, repeatable, and lets you grep later. The file name is a hash of the URL, and
js/index.tsvmaps it back.Terminal window # Download each JS file to js/files/ and record which URL it came fromwhile read -r u; doh=$(printf '%s' "$u" | sha1sum | cut -c1-16)curl -sk --max-time 20 "$u" -o "js/files/$h.js" && printf '%s\t%s\n' "$h" "$u" >> js/index.tsvsleep 0.1done < js/live.txt -
Extract endpoints with jsluice. It understands JavaScript syntax, so it finds paths built by string concatenation and
fetch()calls that regex tools miss.Terminal window # Extract URLs and paths from every downloaded filejsluice urls js/files/*.js | jq -r '.url' | sort -u > js/endpoints.txtFor a quick look at one remote file, LinkFinder still does the job:
Terminal window # Print endpoints found in one JS filepython3 linkfinder.py -i https://app.example.com/static/main.js -o cli -
Collect parameter names with xnLinkFinder. It writes endpoints and a separate list of parameter names, which phase 10 uses as a custom wordlist.
Terminal window # Links and parameter names from all live JS URLs, scoped to the targetxnLinkFinder -i js/live.txt -sf example.com -o js/xnl-links.txt -op js/xnl-params.txt -
Hunt for secrets.
Terminal window # jsluice's secret patterns across every filejsluice secrets js/files/*.js > js/secrets.jsonlTerminal window # SecretFinder on one file; expect false positivespython3 SecretFinder.py -i https://app.example.com/static/main.js -o cliTerminal window # Simple grep for common key shapes and internal hostsgrep -EHo "(AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{35}|sk_live_[0-9a-zA-Z]{24,}|xox[baprs]-[0-9A-Za-z-]+|[a-z0-9.-]+\.(internal|corp|local)\b)" js/files/*.js | sort -u -
Look for source maps. A source map rebuilds the original source tree, with comments and file names. Check for the reference comment, then for the
.mapfile itself.Terminal window # Files that reference a source mapgrep -l 'sourceMappingURL=' js/files/*.jsTerminal window # Try the .map next to each JS file and keep the ones that existsed 's/$/.map/' js/live.txt | httpx -mc 200 -silent -o js/sourcemaps.txtIf one exists, open it in the browser’s DevTools Sources panel, or rebuild the tree on disk with
sourcemapper.Terminal window # Rebuild the original source tree from a live .mapsourcemapper -url https://app.example.com/static/main.js.map -output js/source/mainRead the recovered tree like code review: auth checks, feature flags, admin-only routes.
-
Enumerate webpack chunks. A webpack entry bundle holds a map from chunk id to the hashed filename of each lazy-loaded chunk. The logged-out crawl never loads most of them, but the map names them all. Pull the map out of the entry bundle, build the chunk URLs, and download them, then analyse the chunks the same way as the rest.
Terminal window # Pull the chunk-id to filename map out of the entry bundlegrep -Eo '\{([0-9]+:"[a-f0-9]+",?)+\}' js/files/main.*.js | tr ',' '\n' | grep -Eo '[0-9]+:"[a-f0-9]+"'Terminal window # Build and fetch each chunk URL from the ids and hashes you foundwhile IFS=: read -r id hash; doh=$(echo "$hash" | tr -d '"')curl -sk "https://app.example.com/static/js/$id.$h.chunk.js" -o "js/files/chunk-$id.js"done < js/chunk-map.txtThe exact filename template (
[id].[hash].chunk.js,[id].[hash].js, or similar) differs per build. Read one<script>tag or network request in the browser to see the real pattern before you loop. -
Scan the JS host with nuclei. The
exposurestemplates match source maps,.envfiles, config and key patterns served next to the bundles, which catches exposures the endpoint tools skip.Terminal window # Run exposure templates against the hosts that serve JSnuclei -l js/live.txt -tags exposure -rl 30 -silent -o js/nuclei-exposures.txt -
Use GAP during manual browsing. Install GAP in Burp or Caido and run it on the site map after you click through the app. It collects endpoints and parameters from every response you have seen, including ones loaded after login.
How the output feeds the next phase
Section titled “How the output feeds the next phase”js/endpoints.txtadds API routes for phase 10 and phase 11.js/xnl-params.txtbecomes a target-specific parameter wordlist.- Internal hostnames found in JS go back into
subs/all.txtand through phase 4.
Common mistakes
Section titled “Common mistakes”- Analyzing only
main.js. Lazy-loaded chunks (chunk-4f2a.js) hold admin and settings pages. - Analyzing the logged-out bundle only. Some apps serve a different bundle after login.
- Reporting public keys as leaks.
- Running regex-only tools on minified code and trusting that they found everything.
- Routes containing
admin,internal,debug,impersonate,export,role,permission,feature - Feature flag names next to routes, such as
isBetaEnabledguarding/api/v2/billing/refund - Hostnames for staging or internal APIs:
api-staging.example.com,*.internal.example.com - Exposed source maps on production
- Keys with a server-side prefix:
sk_live_,AKIA, private key headers,xoxb- - GraphQL operation names, which hint at the schema even when introspection is off
Next, find the parameters those routes accept in phase 10.
Open local graph around this page
Linked from here
- Recon Methodology: How Real Hunters Map a TargetBug Hunting
- The file journey modelFile Upload
- Recon & Target SelectionIDOR Hunting
- Following up on 403 Forbidden responsesRecon Atlas
- Verifying JavaScript endpointsRecon Atlas
- Continuous monitoringRecon Atlas
- URL and endpoint discoveryRecon Atlas
- Technology fingerprintingRecon Atlas
- OSINT and leaksRecon Atlas
- Working one program deeplyRecon Atlas
- Synthetic program profilesRecon Atlas
- Finding the socketWebSocket
Recon AtlasFor authorized testing only. Your scope is the map edge.