Skip to main content

Shodan-style CLI for the SecurityTrails API

Project description

sectra

Shodan-style CLI for the SecurityTrails API.

sectra is a lightweight, command-line client for SecurityTrails. It is built for quick lookups and scripting, with JSON output and optional response caching to save quota.

Features

  • Shodan-style CLI for common SecurityTrails endpoints
  • JSON or pretty output
  • Optional on-disk caching for GET requests
  • Generic request passthrough for any endpoint

Install

pip install sectra

Authentication

Set your API key in the environment:

export SECURITYTRAILS=YOUR_KEY

Or persist it in a config file:

sectra init --key YOUR_KEY

Usage

sectra --help
sectra ping
sectra usage
sectra domain example.com
sectra subdomains example.com
sectra whois example.com
sectra history-dns example.com A
sectra ip-whois 8.8.8.8

Search

sectra domains-search --query "ns = 'ns1.yahoo.com'"
sectra domains-stats --query "ns = 'ns1.yahoo.com'"
sectra ips-search --query "ip:8.8.8.0/24"
sectra ips-stats --query "ip:8.8.8.0/24"
sectra sql-query --query "select * from domains where apex_domain = 'example.com' limit 5"

Auto pagination

For endpoints that return a scroll_id, you can automatically fetch additional pages.

sectra domains-search --query "ns = 'ns1.yahoo.com'" --pages 3
sectra ips-search --query "ip:8.8.8.0/24" --all
sectra sql-query --query "select * from domains limit 100" --all

Aggregated pagination output

If you prefer a single JSON output for multiple pages, use --aggregate with --pages or --all.

sectra domains-search --query "ns = 'ns1.yahoo.com'" --pages 3 --aggregate
sectra ips-search --query "ip:8.8.8.0/24" --all --aggregate
sectra sql-query --query "select * from domains limit 100" --all --aggregate

SQL API

The SQL API is a separate production endpoint (replacing the old DSLv2 prototype) and is not included in retail packages. You need a SQL API subscription to use it.

sectra sql-query --query "SELECT domain.hostname FROM hosts WHERE domain.apex = 'google.com'"
sectra sql-scroll SCROLL_ID

ASI / V2 APIs

sectra projects
sectra assets-search PROJECT_ID --data '{"query":{"match_all":{}}}'
sectra assets-find PROJECT_ID --params '{"size":10}'
sectra asset PROJECT_ID ASSET_ID
sectra asset-exposures PROJECT_ID ASSET_ID
sectra asset-filters PROJECT_ID
sectra asset-tag-apply PROJECT_ID ASSET_ID critical
sectra asset-tag-remove PROJECT_ID ASSET_ID critical
sectra asset-tags-bulk PROJECT_ID ASSET_ID --data '{"tags":["critical","prod"]}'
sectra project-tags PROJECT_ID
sectra tag-task PROJECT_ID TASK_ID
sectra tags-bulk-assets PROJECT_ID --data '{"tags":["prod"],"asset_ids":["id1","id2"]}'
sectra exposures PROJECT_ID
sectra exposure-assets PROJECT_ID SIGNATURE_ID
sectra static-assets PROJECT_ID
sectra static-assets-bulk PROJECT_ID --data '{"assets":[{"asset_id":"id1","fields":{"note":"owned"}}]}'
sectra company-associated-ips example.com
sectra action-report PROJECT_ID report_type
sectra asi-risks PROJECT_ID
sectra asi-risks-history PROJECT_ID --params '{"page":1}'

Caching

By default, GET responses are cached on disk to reduce repeated API usage.

sectra --cache-ttl 3600 domain example.com
sectra --no-cache domain example.com

Cache location: ~/.cache/sectra (or XDG_CACHE_HOME).

Output formats

sectra --output pretty domain example.com
sectra --output json domain example.com
sectra --output raw domain example.com

Generic request

sectra request GET /domain/example.com
sectra request POST /domains/list --data '{"query":"ns = \'ns1.yahoo.com\'"}'

Configuration

  • Config: ~/.config/sectra/config.json (or XDG_CONFIG_HOME)
  • Cache: ~/.cache/sectra (or XDG_CACHE_HOME)

Development

pip install -e .
sectra --help

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sectra-0.2.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sectra-0.2.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file sectra-0.2.0.tar.gz.

File metadata

  • Download URL: sectra-0.2.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sectra-0.2.0.tar.gz
Algorithm Hash digest
SHA256 921f2fc2b6f1316cfc7f61b5504f93b3b5b4c471e074605be91057349e52865c
MD5 26850cd290cd8e62e24bb93656f3c760
BLAKE2b-256 d37174b4c5e1ee883368561a5f8e34835de0099956abe3f069f29065b901e0ac

See more details on using hashes here.

File details

Details for the file sectra-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: sectra-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sectra-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 881feb25f785f3568dcdcfeec2e27bb3801f5843e6350a2911c2129aad8578ee
MD5 15c81620e01d3034de786948b98ab658
BLAKE2b-256 e61d5f46a3a56ed1b096d1bc357e22bae7f4eba39b3bf95583acf7281506f2fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page