#!/usr/bin/bash #dig +short -t txt _dmarc.google.com # Initialize variables with default values VERBOSE=false IP="" DOMAINNAME="" JSON=false GET_PUBLIC_IP=false INTERNAL_ZONE="" # Define a usage/help menu usage() { echo "Usage: $0 [-i IP] [-d DOMAINNAME]" echo " -i ip IP" echo " -d domain Domain Name" echo " -j json Output" echo " -p Get Public IP (ifconfig.co)" echo " -z Internal zone file to attempt the AXFR Zone Transfer" exit 1 } # Parse options using getopts # A colon (:) BEFORE the string turns on silent error handling # A colon (:) AFTER a character means that flag requires an argument while getopts "vi:d:jpz:" opt; do case "${opt}" in v) VERBOSE=true ;; i) IP="${OPTARG}" ;; d) DOMAINNAME="${OPTARG}" ;; j) JSON=true ;; p) GET_PUBLIC_IP=true ;; z) INTERNAL_ZONE="${OPTARG}" ;; *) usage ;; esac done # Shift off the parsed options so $1, $2, etc., refer to any remaining positional arguments shift $((OPTIND - 1)) # --- Validation: Check if either -i OR -d is present --- #if [ -z "$IP" ] && [ -z "$DOMAINNAME" ]; then # echo "Error: You must provide either the -i or -d flag." >&2 # usage #fi if [ -n "$DOMAINNAME" ]; then echo "A Records" dig -t A +short $DOMAINNAME echo echo "AAAA Records" dig -t AAAA +short $DOMAINNAME echo echo "TXT Records" dig -t TXT +short $DOMAINNAME echo echo "DMARC" RESULT=$(dig -t TXT +short _dmarc.$DOMAINNAME) if [ -n "$RESULT" ]; then echo -e "\U0002705" echo "$RESULT" else echo -e "\U000274C" fi echo echo "SPF" RESULT=$(dig -t TXT +short $DOMAINNAME | grep -E '^"v=spf1\b.*"') if [ -n "$RESULT" ]; then echo -e "\U0002705" echo "$RESULT" else echo -e "\U000274C" fi echo echo "MX" dig -t MX +short $DOMAINNAME echo echo "NS" dig -t NS +short $DOMAINNAME echo echo "SOA" dig -t SOA +short $DOMAINNAME echo echo "AXFR Zone Transfer" for i in $(dig -t NS +short $DOMAINNAME); do echo $i dig -t AXFR +short "@$i" "$DOMAINNAME" done echo if [ -n "$INTERNAL_ZONE" ]; then echo "AXFR Internal Zone Transfer" dig -t AXFR +short $INTERNAL_ZONE "@$DOMAINNAME" echo fi echo "PING 4" ping -4 -c 2 $DOMAINNAME echo echo "PING 6" ping -6 -c 2 $DOMAINNAME echo fi if $GET_PUBLIC_IP; then echo "Current IPv4" curl -4 https://ifconfig.co/json echo echo "Current IPv6" curl -6 https://ifconfig.co/json echo fi if [ -n "$IP" ]; then whois $IP echo "Reverve DNS search" dig -x $IP echo echo "Details IPv4" ifconfig_out=$(curl -4s "https://ifconfig.co/json?ip=$IP") echo "$ifconfig_out" read -r lat lon < <( printf '%s\n' "$ifconfig_out" | awk -F': ' ' /"latitude"/ { lat=$2; gsub(/[,"]/, "", lat) } /"longitude"/ { lon=$2; gsub(/[,"]/, "", lon) } END { print lat, lon } ' ) echo echo "GeoIp Google Maps:" echo "https://maps.google.com/?q=$lat,$lon" #echo "Details IPv6" #curl -6 https://ifconfig.co/json?ip=$IP #echo fi