_______ _
/ / ___/____ ___ (_)___ ___ _____
__ / /\__ \/ __ `__ \/ / __ \/ _ \/ ___/
/ /_/ /___/ / / / / / / / / / / __/ /
\____//____/_/ /_/ /_/_/_/ /_/\___/_/
v0.01v
by Tevger Xanê (Tavgar El Ahmed)
Bijî Kurdistan
JSMiner began as a small command line tool for scraping JavaScript, HTML and related files to search for common patterns such as email addresses or JWT tokens. Over time it has grown into a more full-featured utility. The latest versions parse JavaScript into an AST to detect values stored in variables or built from string concatenation. HTTP requests now include a browser-style User-Agent header so more sites will serve their JavaScript correctly. The project is written in Go and distributed under the AGPL‑3.0 license.
go install github.com/tavgar/JSMiner/cmd/jsminer@latest
go build ./cmd/jsminer
This produces a binary named jsminer.
jsminer [flags] [URL|PATH|-]
Flags may appear before or after the input path or URL.
Flags:
-formatoutput format,prettyorjson(defaultjson).-safesafe mode - ignore non-JS files and patterns that aren't JavaScript specific (defaultfalse).-allowallowlist file. Sources whose names end with any suffix listed in this file are ignored.-rulesextra regex rules YAML file.-endpointsreturn only HTTP endpoints (default includes all matches)-postsreturn HTTP POST request endpoints with any parameters-externalfollow external scripts and imports (defaulttrue)-renderrender pages with headless Chrome (defaulttrue, set-render=falseto disable; Chrome/Chromium must be installed)-longsecretdetect generic long secrets (disabled by default). Enable to search for high-entropy strings that may represent API keys.-outputwrite output to file instead of stdout.-quietsuppress startup banner.-proxyrun as HTTP/HTTPS proxy on the specified address (e.g.:8080).-targetsfile with additional URLs/paths to scan, one per line.-pluginscomma-separated list of Go plugins providing custom rules.-insecureskip TLS certificate verification for HTTPS requests (defaulttrue).-headerHTTP header inKey: Valueform. May be specified multiple times.
Using -render requires Chrome or Chromium to be installed on your system.
The binary includes a small set of power rules enabled by default. These
rules detect common items such as phone numbers, IPv6 addresses and generic
file paths. IPv6 matches are validated with Go's net.ParseIP to reduce false
positives. Supplying a file with -rules adds to this default set.
The file supplied via -rules must be a YAML mapping where each key is the
pattern name and the value is a Go regular expression. The file is parsed using
gopkg.in/yaml.v3. Example:
phone: "\\d{3}-\\d{3}-\\d{4}"
ipv6: "[0-9a-fA-F:]+"
path: "(?:/[A-Za-z0-9._-]+)+|[A-Za-z]:\\(?:[^\\\s]+\\)*[^\\\s]+"See examples/rules.yaml for a sample file.
A URL, filesystem path or - for stdin must be provided, or use -targets to supply multiple inputs. The program exits with status 1 when matches are found.
Each match also includes a severity level.
When scanning a single input, the JSON output omits the source field.
Package scan exposes Extractor.ScanReaderWithEndpoints to collect HTTP
endpoint strings inside JavaScript sources. Endpoint matches are returned with
the pattern name endpoint_url for absolute URLs and endpoint_path for
relative paths. Endpoint extraction is enabled by default. Pass the
-endpoints flag to filter output to endpoints only. The extractor recognizes
protocol-relative references and relative paths beginning with ./ or ../.
Cross-domain scripts and imports are followed by default. Pass -external=false to restrict scanning to the same domain.
Package scan also provides Extractor.ScanReaderPostRequests to capture
endpoints used in HTTP POST requests. The function returns any associated
parameters when available. Use the -posts flag to output only POST request
endpoints with their parameters.
Additional rules can be compiled as Go plugins. Build the plugin with
go build -buildmode=plugin -o entropy.so ./examples/entropy
Load it at runtime with the -plugins flag:
jsminer -plugins entropy.so file.js
See examples/entropy for a simple entropy based rule.
Running with -proxy starts an HTTP/HTTPS proxy that scans traffic as you
browse. Configure your browser to use the proxy address and trust the proxy's
certificate to intercept HTTPS responses.
-
Download the CA certificate used by goproxy with:
curl -L https://raw.githubusercontent.com/elazarl/goproxy/v1.7.2/ca.pem -o goproxy-ca.pem
Alternatively, generate your own CA and replace this file.
-
Import
goproxy-ca.peminto your browser's Authorities certificate store.- Firefox: Settings → Certificates → View Certificates… → Authorities → Import.
- Chrome: Settings → Privacy and Security → Security → Manage certificates → Authorities → Import.
-
Start the proxy:
jsminer -proxy :8080
Matches will stream to stdout or to the file specified with -output.
go test ./...
This project is licensed under the terms of the GNU Affero General Public License v3.0. See the LICENSE file for more details.