Full domain reconnaissance + live-website secret scanning, in one script.
Frontend build tools quietly bake secrets into public JavaScript bundles, and a domain's wider surface — forgotten subdomains, dangling CNAMEs, open ports, missing email auth, sloppy headers, archived URLs, open buckets — leaks just as much. leakcheck.sh maps the whole surface first, then mirrors what a browser or an attacker can download and scans all of it with TruffleHog (800+ detectors, live verification) and Gitleaks (150+ rules). Every recon artifact lands under site/, so the scanners read it too.
brew install trufflehog gitleaks wget jq
# curl, dig, whois are usually already present
curl -fsSLO https://raw.githubusercontent.com/openhat-security/leakcheck/main/leakcheck.sh
chmod +x leakcheck.shOn Linux, install trufflehog and gitleaks from their GitHub releases, and wget, jq, curl, dig (dnsutils/bind-tools) and whois from your package manager.
The script auto-detects each and skips what's missing:
- Active scanning:
nmap,nc,ffuforgobuster,nuclei,testssl.sh - Fingerprinting:
wafw00f,whatweborwappalyzer - Subdomains:
subfinder,amass,assetfinder,findomain - URL harvesting:
gau,waybackurls - JS extraction:
jsluice,linkfinder,getJS - Extra secret scanners:
kingfisher,nosey_parker,detect-secrets
Set SHODAN_API_KEY to enable Shodan lookups.
./leakcheck.sh https://example.com
./leakcheck.sh --active https://example.com # add intrusive scans (ports, banners, dir brute, nuclei)
./leakcheck.sh -o out https://example.com # save crawl + recon + findings.csv to ./out
./leakcheck.sh --no-subs https://example.com # scan only the given URLs, skip discovered subdomains
./leakcheck.sh https://app.example.com https://admin.example.com
./leakcheck.sh https://example.com && echo clean || echo "LEAKS FOUND"
./leakcheck.sh --help| Flag | Effect |
|---|---|
--active |
Adds scans that touch the target directly: port/banner scan, directory brute force, nuclei, zone-transfer attempts, subdomain brute. Authorized targets only. |
-o DIR / --out DIR |
Keeps the crawled site/ mirror and every recon_<domain>/ artifact in DIR, and streams findings to findings.csv and findings.jsonl there as each one is discovered (so a long or interrupted run still leaves partial results on disk). Without -o, all crawled files are deleted at the end and only the summary prints. |
--no-subs |
Scans only the URLs you pass. By default, every live subdomain discovered during recon is crawled and scanned too. |
Passive recon runs by default. Subdomains discovered via Certificate Transparency (and optional tools) are liveness-probed and the reachable ones are automatically crawled and scanned. Use --no-subs to limit the scan to the exact URLs you pass.
- DNS — every record type, full
ANYdump, DNSSEC, wildcard detection, reverse DNS. - Email auth — SPF, DMARC, common DKIM selectors, BIMI, MX; warns when SPF/DMARC are absent.
- Subdomains — Certificate Transparency (crt.sh, certspotter), plus subfinder/amass/assetfinder/findomain if installed.
- Subdomain takeover — flags dangling CNAMEs pointing at unclaimed providers (GitHub Pages, S3, Heroku, Netlify, Shopify, etc.).
- Ownership — WHOIS for the domain and each resolved IP, ASN/BGP lookup, IP geolocation.
- HTTP posture — security headers (and which are missing), allowed HTTP methods (flags TRACE/XST), CORS origin reflection, WAF detection.
- Tech stack —
Server/X-Powered-By, whatweb/wappalyzer fingerprint, favicon hash for Shodan pivoting. - TLS — certificate dates, issuer and SANs via
openssl. - URLs — robots.txt, sitemap.xml, Wayback Machine, gau/waybackurls, urlscan.io.
- OSINT — Shodan (with
SHODAN_API_KEY), open S3/GCS cloud-bucket name guesses. - GraphQL — introspection probe on
/graphql.
- DNS zone transfer (AXFR) against each nameserver.
- Subdomain brute force (high-signal wordlist), merged into the subdomain list.
- Port scan + service detection (
nmap) and banner grabbing (nc) on open ports. - Directory brute force (
ffuf/gobuster),nucleitemplates (exposures, misconfig, CVEs), full TLS audit (testssl.sh).
- Mirrors each URL two levels deep on the same domain: HTML, JS, CSS, JSON, sourcemaps.
- Fetches
.mapsourcemaps for every JS file, since they often contain original source. - Probes accidental exposures:
/.env*,/.git/config,/__/firebase/init.json,firebase.json,asset-manifest.jsonand similar. - Extracts endpoints and secrets from JS bundles with jsluice/LinkFinder/getJS if present.
- Runs TruffleHog (live key verification) and Gitleaks, plus Kingfisher, Nosey Parker, or detect-secrets if installed. All recon output is scanned too. Each finding is printed and written out the moment it is found, with a live progress line on stderr (
[scan] <tool>: <detector> in <file> — N finding(s) so far) so a long verification pass never looks frozen. - Flags shell environment variables baked into bundles, such as
HOME,PATHandGH_TOKENappearing in JS.
Secrets are never printed in full; output shows only the first few characters. Recon warnings (open zone transfer, wildcard DNS, reflected CORS, missing SPF/DMARC, possible takeover, open buckets, etc.) are summarized under Recon findings at the end of the run.
With -o DIR, the run leaves behind:
DIR/site/— the full crawled mirror plusrecon_<domain>/directories (DNS, subdomains, WHOIS, headers, TLS, etc.).DIR/th.txt,DIR/gl.txt,DIR/th.json,DIR/gl.json— raw TruffleHog/Gitleaks results.DIR/findings.csv— one row per finding, columns:type,detail,file,status,value.typeissecret:trufflehog,secret:gitleaks,bundle:shell-env,exposed-file, orrecon-warning;statusisLIVE,unverified,match, orwarning. Thevaluecolumn contains the full raw secret (properly CSV-escaped) so it can be fed straight into rotation tooling — treat it as sensitive and do not commit it.DIR/findings.jsonl— the same findings as newline-delimited JSON, one object per line.
Both findings files are appended and flushed the instant each finding is discovered, not written once at the end, so a killed or still-running scan leaves the findings seen so far on disk. On completion they are de-duplicated in place; on a fully clean run they are removed so an empty file is never left behind.
| Tag | Meaning |
|---|---|
[LIVE] |
The provider confirmed the key works. Rotate it now. |
[unverified] |
The value matched a pattern but wasn't confirmed live. Firebase AIza… web keys are public by design. |
| Code | Meaning |
|---|---|
0 |
Nothing found |
1 |
Bad usage or missing tools |
2 |
Findings |
Because of these exit codes, it can run as a CI gate after deploys.
- Revoke or rotate the key at the provider first. Deleting it from the site isn't enough, because old bundles stay cached on CDNs and old hosting releases.
- Check the provider's audit logs for use of the key.
- Fix the build so only intended public variables reach the client.
- Redeploy, delete old hosting releases, and run
leakcheck.shagain.
Only scan domains and sites you own or are explicitly authorized to test. Active mode performs intrusive scanning — get written authorization first.
MIT © OpenHat Security