Skip to content

Instantly share code, notes, and snippets.

@elitan
Created January 1, 2024 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elitan/c08f2ebd1c688711b83a7387d28b01f7 to your computer and use it in GitHub Desktop.
Save elitan/c08f2ebd1c688711b83a7387d28b01f7 to your computer and use it in GitHub Desktop.
Find active snapback domains from IIS
#!/bin/bash
# URL containing the list of domains and dates
URL="https://data.internetstiftelsen.se/bardate_domains.txt"
echo "Starting script..."
echo "Downloading domain list from $URL..."
# Download the file and sort the entries by date
sorted_entries=$(curl -s "$URL" | sort)
echo "Download and sorting complete. Beginning to check each domain in parallel..."
# Function to check a single domain
check_domain() {
entry=$1
domain=$(echo "$entry" | awk '{print $1}')
date=$(echo "$entry" | awk '{print $2}')
# Perform a curl request with a timeout of 5 seconds
response=$(curl -I --max-time 10 "$domain" 2>/dev/null)
# Check if the response contains a 2xx or 3xx status code
if echo "$response" | grep -q "HTTP/.* [23]"; then
echo "Domain $domain (Date: $date) is active (2xx/3xx status code found)."
fi
}
# Export the function to make it available to parallel processes
export -f check_domain
# Use xargs to run check_domain in parallel
echo "$sorted_entries" | xargs -n1 -P200 -I {} bash -c 'check_domain "$@"' _ {}
echo "Script completed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment