A lightweight Bash script for extracting domain names from a certificate database and checking their availability.
This script is designed to fetch domains associated with a specific target domain (e.g., nasa.gov) from the Certificate Transparency Logs (using crt.sh) and then identify which of these domains are actively responding.
- curl: For fetching data from crt.sh.
- jq: For processing and filtering JSON responses.
- sed: For text processing.
- httpx: For checking active domains.
- jq: Install using your package manager (e.g.,
sudo apt install jqfor Ubuntu/Debian). - httpx: Install via Homebrew or Go:
go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest
- Clone the script or copy it into a file (e.g.,
scan_domains.sh). - Make the script executable:
chmod +x scan_domains.sh
- Run the script:
./scan_domains.sh
-
Target Domain Setup: The script uses the
TARGET_DOMAINvariable to specify the domain of interest (e.g.,nasa.gov). -
Fetch Domains: The script queries
crt.shto retrieve subdomains of the target domain in JSON format and extracts their names usingjq. Duplicate entries are removed, and wildcard entries (e.g.,*.example.com) are cleaned usingsed. -
Filter Active Domains: The extracted domains are checked for activity using
httpx, and only active domains are saved to a separate file. -
Output Files:
- domains.txt: Contains all the domains retrieved from crt.sh.
- alive_domains.txt: Contains only the domains that are actively responding.
domains.txt: List of all fetched domains from crt.sh.alive_domains.txt: List of domains that are alive (responding).
After running the script, you will see the following messages:
Fetched domains saved to domains.txt
Active domains saved to alive_domains.txtTo change the target domain, modify the TARGET_DOMAIN variable in the script:
TARGET_DOMAIN=".yourdomain.com"- Ensure you have an active internet connection as the script fetches data from crt.sh.
- Make sure the required tools (
curl,jq,sed,httpx) are installed and accessible from your PATH.
This script is intended for educational and lawful use only. Ensure you have permission to scan domains and comply with all applicable laws and policies.