Skip to content

Latest commit

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

 ██╗███████╗██╗ ██╗ █████╗ ██╗ ██╗██╗ ██╗
██║██╔════╝██║ ██║██╔══██╗██║ ██║██║ ██╔╝
██║███████╗███████║███████║██║ █╗ ██║█████╔╝
██ ██║╚════██║██╔══██║██╔══██║██║███╗██║██╔═██╗
╚█████╔╝███████║██║ ██║██║ ██║╚███╔███╔╝██║ ██╗
╚════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚═╝ ╚═╝

JavaScript Secret Scanner · v3.0

BashLicenseAuthor

Context-aware credential detection · Entropy scoring · JS chain discovery · Endpoint probing · SARIF/HTML/Nuclei output


What is JSHawk?

JSHawk is an advanced JavaScript security scanner for bug bounty hunters and penetration testers. It downloads and deeply analyzes JavaScript files from a target domain, detecting exposed credentials, API keys, database URLs, private keys, and other secrets using 60+ patterns with Shannon entropy scoring to eliminate false positives.

Two tools, one mission:

ToolDescription
JSHawk.shBash CLI — deep recon, Wayback, source maps, endpoint probing
Browser Extension (In Review)Real-time passive scanning as you browse, with endpoint probing

Features we offer

JS Chain Discovery

When JSHawk fetches app.js and finds /beam.js, /chunk.abc.js, or import('./auth') inside it — it automatically fetches and scans those too, recursively, up to 3 levels deep. Webpack chunk manifests are parsed to reconstruct all lazy-loaded module URLs. Most tools only scan the JS files linked directly from HTML.

Context-Aware Scoring

Every finding is scored not just by entropy, but by its surrounding code context. A secret inside a config = { ... } block or production environment object is rated critical. The same value inside a comment tagged // example or // TODO is suppressed. No other open-source JS scanner does context scoring.

Endpoint Probing with Session Auth

JSHawk extracts API routes from JS (/api/v1/users, /graphql, fetch('/admin/...')) and fetches each one using your actual session cookies, then scans the JSON responses for leaked secrets. Authenticated endpoints that return real data get scanned — not just the JS source.

Diff Mode — Only New Findings

--diff compares current scan against ~/.jshawk/fingerprints.db (SHA-256 hashes of all previously seen secrets) and only reports secrets it has never seen before. Essential for daily CI/CD scanning without alert fatigue.

False Positive Management

--fp-add <value> permanently marks a value as a known-safe false positive. It is silently suppressed in every future scan, forever. Maintain your own per-company exclusion list.

SARIF 2.1.0 Output

Structured results in SARIF format — plug directly into GitHub Code Scanning, GitLab SAST, or any SARIF-compatible CI pipeline. No glue code needed.

HTML Report

Self-contained single-file HTML report with dark theme, sortable findings table, entropy scores, and clickable source URLs. Share with clients or include in pentest reports.

Nuclei Template Export

Every finding becomes a ready-to-use Nuclei template YAML targeting the specific pattern that was found. Feed them straight into nuclei -t jshawk_results/nuclei/ to re-verify at scale.


Installation

# Clone
git clone https://github.com/Mah3Sec/JSHawk.git
cd JSHawk
# Make executable
chmod +x JSHawk.sh
# Optional: install globally
sudo ln -s "$(pwd)/JSHawk.sh" /usr/local/bin/jshawk
# Verify
jshawk --help

Dependencies:bash, curl, python3 (for source maps + HTML report), awk, grep


Quick Start

# Basic scan
jshawk target.com
# Full recon — Wayback + source maps + live validation + HTML report
jshawk target.com --wayback --source-maps --validate --html
# CI/CD — only new findings, SARIF output, exit 1 if found
jshawk target.com --diff --sarif --quiet
# Bug bounty — subdomain list + scope control + wordlist for ffuf
jshawk target.com -s subdomains.txt --scope scope.txt --wordlist --threads 30
# Authenticated endpoint probing
jshawk target.com --probe-endpoints --probe-cookies cookies.txt
# Export everything for further tooling
jshawk target.com --nuclei --wordlist --format json

All Flags

Targeting

FlagDescription
<domain>Target domain or full URL
-s, --subdomains FILEFile of subdomains/URLs (one per line)
--scope FILEOnly scan URLs matching patterns in this file

Discovery

FlagDefaultDescription
--deep-crawlonFollow JS refs inside JS files (chain discovery)
--chain-depth N3How many levels deep to follow JS→JS refs
--waybackoffQuery Wayback Machine for historical JS snapshots
--source-mapsoffDownload .map files and reconstruct original source
--no-deep-crawlDisable chain discovery (faster)

Detection

FlagDefaultDescription
-e, --entropy N3.5Entropy threshold — below this = placeholder, skipped
--contextonContext-aware scoring (suppresses test/example values)
--no-contextReport everything regardless of context
-c, --custom-regexAdd custom patterns interactively
-l, --list-patternsList all built-in patterns

Endpoint Probing

FlagDescription
--probe-endpointsFetch discovered API routes and scan responses
--probe-cookies FILESession cookies file for authenticated probing
--probe-headers FILEAuth headers file (e.g. Authorization: Bearer ...)

Validation

FlagDescription
--validateLive-confirm findings via provider APIs (AWS, GitHub, Stripe, OpenAI)

Output

FlagDescription
-o, --output DIROutput directory (default: jshawk_results/)
--format FORMATtxt | json | both | sarif | html
--sarifSARIF 2.1.0 output for GitHub/GitLab CI
--htmlSelf-contained HTML report
--wordlistExport discovered endpoints as wordlist
--nucleiExport findings as Nuclei template YAML
--silentMachine-readable output only
-q, --quietSuppress all non-finding output
--no-colorDisable colors (for log files)
-v, --verboseShow context lines and debug info

Performance

FlagDefaultDescription
-t, --threads N15Parallel download threads
--rate-limit MS0Delay between requests in milliseconds
--resumeoffResume an interrupted scan

Diff & False Positives

FlagDescription
--diffOnly report findings not seen in previous scans
--fp-add SECRETMark a value as a false positive (suppressed forever)
--fp-listList all known false positives
--fp-clearClear all false positives

Proxy & Auth

FlagDescription
--proxy URLHTTP/SOCKS5 proxy (e.g. Burp Suite: http://127.0.0.1:8080)
--header "K: V"Add custom request header (repeatable)
--insecureDisable TLS verification

Detection Patterns (60+)

CategoryPatterns
CloudAWS Access Key, AWS Secret Key, Google API Key, Azure Storage Key, Azure Connection String, Firebase URL + API Key, GCP Service Account, DigitalOcean Token, Heroku API Key
VCS / CI-CDGitHub Token, GitHub PAT, GitLab Token, npm Token, Jenkins Token, Travis CI Token, CircleCI Token
PaymentStripe Live Secret, Stripe Live Public, Stripe Restricted Key, PayPal Client, Braintree Key, Shopify Admin Token, Shopify API Secret, Square Access Token
CommunicationSlack Bot/User/App Token, Slack Webhook, SendGrid Key, Twilio SID, Twilio Auth Token, Mailgun Key, Mailchimp Key, Discord Bot Token, Discord Webhook, Telegram Bot Token
AI ProvidersOpenAI API Key, Anthropic API Key, HuggingFace Token, Replicate API Key
DatabaseDatabase URL (MySQL/Postgres/MongoDB/Redis/AMQP), Hardcoded DB Password
SecretsJWT Token, JWT Secret, Private Key (PEM), SSH Private Key, Encryption Key, Hardcoded Password, Generic API Key, Generic Secret Key
NetworkInternal IP (10.x/192.168.x/172.16-31.x), Private Subnet CIDR, Basic Auth in URL, S3 Bucket URL
AuthAuth0 Client Secret, Okta API Token, OAuth Client Secret, Mapbox Token
MonitoringSentry DSN, Datadog API Key, New Relic License Key, Amplitude API Key
CustomUser-defined patterns via --custom-regex or ~/.jshawk/custom_patterns.txt

All patterns are gated by Shannon entropy ≥ 3.5 (configurable) so placeholder values like YOUR_KEY_HERE, xxxxxxxxxxxx, 00000000000 are never reported.


Output Structure

jshawk_results/target.com_20240415_143022/
├── scan_info.json # Scan metadata
├── js_files/ # All downloaded JS files
├── findings/
│ └── secrets.txt # Pipe-delimited findings (TYPE|SECRET|FILE|URL|LINE|RISK|ENTROPY|CONTEXT)
├── endpoints/
│ ├── discovered_paths.txt # All API routes found in JS
│ └── probe_results.txt # HTTP status codes from endpoint probing
├── source_maps/ # Reconstructed original source files
├── reports/
│ ├── jshawk.json # Structured JSON report
│ ├── jshawk.sarif # SARIF 2.1.0 for CI/CD
│ ├── jshawk_report.html # Self-contained HTML report
│ └── endpoints_wordlist.txt # Endpoints for ffuf/dirsearch
├── nuclei/ # Nuclei template YAML per finding
└── logs/ # Download logs and debug info

CI/CD Integration

# GitHub Actions
- name: JSHawk JS Secret Scanrun: | chmod +x JSHawk.sh ./JSHawk.sh ${{ env.TARGET }} --diff --sarif --quietcontinue-on-error: true
- name: Upload SARIFuses: github/codeql-action/upload-sarif@v3with:
sarif_file: jshawk_results/*/reports/jshawk.sarif
# GitLab CI
jshawk_scan:
script:
- jshawk $TARGET --diff --sarif --quiet
artifacts:
reports:
sast: jshawk_results/*/reports/jshawk.sarif

Exit codes:

  • 0 — Clean, no findings
  • 1 — Findings detected
  • 2 — Scan error

Browser Extension

The JSHawk browser extension brings real-time secret scanning to Chrome and Firefox.

Install: Load unpacked from extension/ folder in chrome://extensions

Features:

  • Passive auto-scan — every JS file that loads gets scanned automatically
  • On-demand SCAN button — deep scan all JS on the current page
  • JS chain discovery — follows /beam.js, webpack chunks, lazy imports
  • Endpoint probing — fetches API routes with your session cookies
  • 65+ patterns with entropy scoring
  • Custom signatures saved permanently
  • Session-persistent findings (survive service worker restarts)
  • SARIF/JSON export + one-click bug bounty Markdown reports

Screenshots:

FindingsEndpointsPatterns
Real-time critical/high/medium findings with source URLsAPI routes with HTTP status + LEAKED badge65+ built-in patterns + custom regex editor

Compared to alternatives

FeatureJSHawk v3SecretFinderLinkFindertruffleHog
JS chain discovery✅ 3 levels deep
Context-aware scoringPartial
Endpoint probing✅ with auth
Wayback Machine
Source map recon
Diff mode
SARIF output
HTML report
Nuclei export
False positive mgmtPartial
Browser extension
No Python req✅ (pure bash)

Legal

For authorized security testing only. You are responsible for ensuring you have permission to test any system you scan. JSHawk is provided as-is for educational and professional security research purposes.


Author

Mahendra Purbia (@Mah3Sec)

If JSHawk helped you find a bug, a shoutout or a star is appreciated.


Built for the community · MIT License

About

JSHawk is a powerful, context-aware JavaScript security scanner that hunts for exposed credentials, API keys, and sensitive information in JavaScript files with surgical precision.

Resources

Stars

17 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages