Skip to main content
Version: 1.4.4

Strings command

The strings command is used to extract strings, URLs, and secrets from a directory of JavaScript files. This is useful for identifying sensitive information and potential API endpoints.

Usage​

js-recon strings -d <directory> [options]

Options​

OptionAliasDescriptionDefaultRequired
--directory <directory>-dDirectory containing JS files.Yes
--output <file>-oJSON file to save the extracted strings.strings.jsonNo
--extract-urls-eExtract URLs from the strings.falseNo
--extracted-url-path <file>Output file for extracted URLs and paths (without extension).extracted_urlsNo
--permutate-pPermutate the URLs and paths found.falseNo
--openapiGenerate an OpenAPI specification from the paths found.falseNo
--scan-secrets-sScan for secrets within the strings.falseNo
--trufflehogRun TruffleHog secret scanner on the output directory.falseNo

A file that fails to parse (truncated download, an HTML error page saved with a .js extension, etc.) is skipped with a warning; extraction still completes for every other file in the directory.

Examples​

Basic usage​

Extract all strings from a directory of JS files and save them to strings.json:

js-recon strings -d /path/to/js-files

Extract URLs​

Extract strings and also identify and save any URLs found within them:

js-recon strings -d /path/to/js-files -e

This will write a new file called extracted_urls.json along with the default strings.json

Scan for secrets​

Extract strings and scan for any potential secrets or sensitive information:

js-recon strings -d /path/to/js-files -s

This will print all the potential finds on the terminal window.

Please note that this process could be memory and compute-intensive, and can take longer to run.

Scan with TruffleHog​

Run TruffleHog as a more comprehensive secret scanner on the output directory:

js-recon strings -d output/ --trufflehog

TruffleHog must be installed separately before using this flag:

# macOS
brew install trufflehog

# Linux / macOS (install script)
curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh

Automatic installation of TruffleHog on first use of --trufflehog is being explored for a future release, to remove this manual step.

You can combine both secret scanners in a single run:

js-recon strings -d output/ -s --trufflehog

Generate OpenAPI specification​

Extract URLs and paths, and then generate an OpenAPI specification:

js-recon strings -d /path/to/js-files -e --openapi

This will generate the default strings.json, the extracted_urls.json file with URLs and paths in simple JSON format, and the extracted_urls-openapi.json file. The extracted_urls-openapi.json can be imported into API clients like Postman, Bruno, etc.

Permutate URLs and Paths​

The --permutate (-p) flag generates new potential endpoints by combining the base of found URLs with all discovered paths. This requires the -e flag to be active.

For example, if the tool finds the URL https://api.example.com/v1/users and the path /v2/orders, it will generate https://api.example.com/v2/orders.

js-recon strings -d /path/to/js-files -e -p

The permuted URLs will be saved to extracted_urls.txt along with strings.json and extracted_urls.json

Secret detection patterns​

When --scan-secrets is active, each extracted string is matched against the following regex patterns. Findings are printed to the terminal; no output file is written.

Pattern nameWhat it matches
Cloudinarycloudinary:// URL
Firebase URL*.firebaseio.com hostname
Slack Tokenxox[p|b|o|a]-... bearer tokens
RSA private keyPEM header -----BEGIN RSA PRIVATE KEY-----
SSH (DSA) private keyPEM header -----BEGIN DSA PRIVATE KEY-----
SSH (EC) private keyPEM header -----BEGIN EC PRIVATE KEY-----
PGP private key blockPEM header -----BEGIN PGP PRIVATE KEY BLOCK-----
Amazon AWS Access Key IDAKIA[0-9A-Z]{16}
AWS Client ID(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}
Amazon MWS Auth Tokenamzn.mws.<uuid>
Facebook Access TokenEAACEdEose0cBA...
Facebook OAuth / Client ID / Secret KeyFacebook credential patterns
GitHubGitHub token near github keyword
Generic API Keyapi_key near a 32–45-char alphanumeric value
Generic Secretsecret near a 32–45-char alphanumeric value
Google API Key / GCP / Drive / Gmail / YouTubeAIza[0-9A-Za-z-_]{35}
Google Cloud Platform OAuth*.apps.googleusercontent.com
Google OAuth Access Tokenya29.*
Google (GCP) Service-accountJSON "type": "service_account"
Heroku API KeyHeroku UUID pattern
LinkedIn Client ID / Secret KeyLinkedIn credential patterns
MailChimp API Key<32-hex>-us<N>
Mailgun API Keykey-<32 alphanumeric>
Password in URLCredentials embedded in a URL (proto://user:pass@host)
PayPal Braintree Access Tokenaccess_token$production$...
Picatic / Stripe / Stripe Restricted API Keysk_live_... / rk_live_...
Slack Webhookhooks.slack.com/services/T.../B.../...
Square Access Token / OAuth Secretsq0atp-... / sq0csp-...
Twilio API KeySK[0-9a-fA-F]{32}
Twitter Access Token / OAuthTwitter credential patterns
OpenAI User API Key / Project Key / Service Keysk-...T3BlbkFJ... variants
Wakatimewaka_<uuid>
Artifactory API Token / PasswordAKC... / AP... prefixes
Authorization Basic / BearerRaw basic ... / bearer ... header values
AWS MWS Keyamzn.mws.<uuid>
Base64Common base64 preambles (eyJ, YTo, aHR0cHM6L, etc.)
Basic Auth Credentials://user:pass@host pattern
Cloudinary Basic Authcloudinary://<id>:<secret>@<cloud>
MD5 Hash32-character hex string

Note: patterns like Generic API Key, Generic Secret, Base64, and MD5 Hash have a high false-positive rate and should be treated as leads rather than confirmed findings.