Created
March 15, 2026 16:27
-
-
Save besmirzanaj/695ea518c38ce20142ca65b32e386d03 to your computer and use it in GitHub Desktop.
chaos-query.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # | |
| # chaos-query.sh - Query DNS servers using CHAOS class TXT records | |
| # Author: Besmir Zaanaj | |
| # | |
| # Usage: | |
| # ./chaos-query.sh <dns_server_ip_or_name> [record] | |
| # | |
| # Examples: | |
| # ./chaos-query.sh 8.8.8.8 | |
| # ./chaos-query.sh 1.1.1.1 version.bind | |
| # ./chaos-query.sh 9.9.9.9 id.server | |
| set -euo pipefail | |
| if ! command -v dig >/dev/null 2>&1; then | |
| echo "Error: dig not found in PATH" >&2 | |
| exit 1 | |
| fi | |
| if [[ $# -lt 1 ]]; then | |
| echo "Usage: $0 <dns_server> [record]" >&2 | |
| exit 1 | |
| fi | |
| DNS_SERVER="$1" | |
| RECORD="${2:-all}" | |
| # Helper to run a single CHAOS TXT query | |
| chaos_query() { | |
| local name="$1" | |
| echo "=== ${name} @ ${DNS_SERVER} ===" | |
| dig +short -t TXT -c CHAOS "${name}" @"${DNS_SERVER}" || true | |
| echo | |
| } | |
| case "${RECORD}" in | |
| all) | |
| # Common CHAOS records supported by BIND/CoreDNS etc. | |
| chaos_query "version.bind" # Software/version | |
| chaos_query "hostname.bind" # Server hostname | |
| chaos_query "id.server" # Anycast/instance ID | |
| chaos_query "authors.bind" # software version generally | |
| ;; | |
| version.bind|hostname.bind|id.server|authors.bind) | |
| chaos_query "${RECORD}" | |
| ;; | |
| *) | |
| # Allow arbitrary CHAOS TXT name | |
| chaos_query "${RECORD}" | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment