Skip to content

JavaScript Analysis Masterclass - Part 1

Collecting a target's JavaScript with Burp, the Wayback Machine and the Archive.org CDX API, then analysing it statically for endpoints and secrets.

Published
Categories
Bug BountyLinuxPenetration Testing
JavaScript Analysis Masterclass - Part 1
JavaScript Analysis Masterclass - Part 1 Watch on YouTube

JavaScript files are more than just scripts powering a web application. They’re often a direct window into an app’s logic, structure, and sometimes even its vulnerabilities.

In this guide, we’re diving deep into how to analyze JavaScript files for security bugs, covering static analysis techniques, collection strategies, and how to extract real signals from buried code. This is your full walkthrough, from recon to secrets, tokens, and hidden endpoints.

Why JavaScript Files Matter

JavaScript runs in the browser, which means you, the hacker, have access to all its logic. If it’s in the JS, it’s yours to read, and potentially abuse.

Inside .js files, you’ll commonly find:

  • Hidden or undocumented API endpoints
  • Hardcoded API keys or secrets
  • Internal logic like auth flows, role validators, or pricing mechanisms
  • DOM-based XSS vectors through innerHTML, eval(), document.write()
  • Debug flags, hidden configurations, and beta features

Step 1: Collecting JavaScript Files

The first step is to pull in as many JS files related to your target as possible. Here are the methods you should be using:

Method 1: Burp Suite

  • Set target scope in Burp
  • Browse manually through the app
  • Navigate to Target > Site Map
  • Filter by MIME type script and extension .js
  • Copy all URLs to a file js-burp.txt

Method 2: Wayback Machine (WaybackURLs)

This pulls archived JS files, even if they’re no longer linked.

bash
##install it
go install github.com/tomnomnom/waybackurls@latest

##run it
echo 'example.com' | waybackurls | grep '\.js$' | sort -u > js-wayback.txt

Method 3: Archive.org CDX API

bash
curl -G "https://web.archive.org/cdx/search/cdx" \
  --data-urlencode "url=*.example.com/*" \
  --data-urlencode "output=text" \
  --data-urlencode "fl=original" | grep '\.js$' > js-cdx.txt

Then validate:

bash
cat js-cdx.txt | httpx -mc 200 -o js-live.txt

Step 2: Static Analysis

Grepping for Secrets

Run a grep loop to look for common leaked variables:

bash
cat js.txt | while read url; do
  echo "[+] Scanning: $url"
  curl -s "$url" | grep -Eio 'apikey|token|auth|secret|password|jwt' && echo "--- Found in $url ---"
done

LinkFinder

Extract hidden endpoints:

bash
##install it
git clone https://github.com/GerbenJavado/LinkFinder.git
cd LinkFinder
pip3 install -r requirements.txt

#run it
python3 linkfinder.py -i https://example.com/1.js -o cli

jsleak

Grab secrets, keys, and AWS creds:

bash
##install it
go install github.com/0xTeles/jsleak/v2/jsleak@latest

##run it
cat live-js.txt | jsleaks -s -l -k

Local Storage Audit

Use DevTools > Application > LocalStorage or run:

javascript
localStorage.getItem('token')
sessionStorage.getItem('auth')

Look for: token, jwt, role, user_info, etc.


Bonus: JWT Discovery

If you spot this:

javascript
const token = jwt.sign(payload, 'hardcoded-secret');

You may be able to forge your own token, escalate privileges, or access another user’s data.


Automated JS Recon (Nuclei)

bash
nuclei -l js.txt -t ~/nuclei-templates/exposures/ -o js_bugs.txt

Or use a loop to download and scan offline:

python
while IFS= read -r link; do
    wget "$link"
done < js.txt
grep -r -E "aws_access_key|apikey|secret|token|auth|config|admin" *.js

Wrap-Up: Recon Toolkit

ToolPurpose
BurpSuiteManual JS harvesting
WaybackHistorical assets
CDX APIDeep archive extraction
LinkFinderEndpoint discovery
jsleakSecret/token extraction
GrepManual confirmation
NucleiAutomated exposure scans

conclusion

And there you have it, the full breakdown of how to hunt down vulnerabilities hiding in JavaScript files.

From passive recon to active file scraping… from manual grep to full-blown secret and endpoint extraction. This is the recon phase real hunters use to build leads that pay off.

You’re not just scanning files. You’re reading logic, reverse-engineering patterns, and building the map no one else sees.

In Part 2, we’re going deeper into the code.
Live debugging. Logic tampering. Obfuscation. Exploits.
You’ll see how JavaScript really breaks.

If you found this guide helpful, hit that like, drop a comment, and subscribe for more raw hacker workflow.