Skip to content

Instantly share code, notes, and snippets.

@antonydevanchi
Created July 26, 2020 04:46
Show Gist options
  • Select an option

  • Save antonydevanchi/becc3a31c4239e91dbcdf6008332a095 to your computer and use it in GitHub Desktop.

Select an option

Save antonydevanchi/becc3a31c4239e91dbcdf6008332a095 to your computer and use it in GitHub Desktop.
Parse dnstap.log and get list with only unique subdomains
# Okay.
# It's just a few lines in «shitbash» language.
# Shitbash is awesome! It's great tool for scripts which you run once.
# So... Oh, yeah! You can go fuck yourself if you want say something about quality of this line.
dnstap -r /var/log/knot.tap > /opt/dnstap.log
07:35:58.000000 AQ 0.0.0.0 UDP 42b "domain.tld." IN A
07:35:59.000000 AQ 0.0.0.0 UDP 42b "domain.tld." IN A
07:35:59.000000 AQ 0.0.0.0 UDP 42b "domain.tld." IN AAAA
cat /opt/dnstap.log | grep -iEo '[a-zA-Z0-9-]*\.domain.tld' > /opt/subdomains.txt
accounting.domain.tld
accounting.domain.tld
account.domain.tld
account.domain.tld
accounts.domain.tld
cat /opt/subdomains.txt | sort --unique
accounting.domain.tld
account.domain.tld
accounts.domain.tld
cat /opt/subdomains.txt | sort --unique | grep -iEo '[a-zA-Z0-9-]*\.' | grep -iEo '[a-zA-Z0-9-]*' | grep -v domain
accounting
account
accounts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment