Skip to content

Instantly share code, notes, and snippets.

@ysangkok
Created December 4, 2015 14:52
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 ysangkok/95cb98089bfd93466f2e to your computer and use it in GitHub Desktop.
Save ysangkok/95cb98089bfd93466f2e to your computer and use it in GitHub Desktop.
#!/bin/bash
TMPNAM=$(mktemp)
rm $TMPNAM
mkfifo $TMPNAM
curl http://data.iana.org/TLD/tlds-alpha-by-domain.txt | sed -e 1d | parallel -j 24 host '{}' 8.8.8.8 | grep "has address" > $TMPNAM &
echo -en "
import requests
with open('$TMPNAM') as f:
for tld, has, address, addr in map(lambda x: x.strip().split(' '), f.readlines()):
if addr.startswith('127'): continue
try:
print(tld, addr, requests.get('http://{}'.format(addr), timeout=1))
except Exception as e:
if e.__class__.__name__ != 'ConnectionError': print(repr(e.__class__.__name__))
" | python3 -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment