Skip to content

Instantly share code, notes, and snippets.

@josy1024
Last active January 25, 2016 10:59
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 josy1024/d39b428f3103b965fc38 to your computer and use it in GitHub Desktop.
Save josy1024/d39b428f3103b965fc38 to your computer and use it in GitHub Desktop.
arp find who-has requests with DNS
#!/bin/bash
#
# inspired from: Zeitmanagement für Systemadministratoren Thomas A. Limoncelli
#take a sample of 100 requests...
# -i any (most systems have more than one interface)
tcpdump -i any -l -n arp | grep 'who-has' |head -100 > /tmp/arprequests.txt
# wich sources?
cat /tmp/arprequests.txt | awk '{ print $NF }' | sort | uniq -c | sort -nr
#magic with DNS!:
for ip in `cat /tmp/arprequests.txt | awk '{ print $NF }'`; do dig +noall +answer -x $ip; done | awk '{ print $NF }' | sort | uniq -c | sort -nr
# soumetimes $(NF-1)
for ip in `cat /tmp/arprequests.txt | awk '{ print $(NF-2) }'`; do dig +noall +answer -x $ip; done | awk '{ print $NF }' | sort | uniq -c | sort -nr
# wich targets?
# (usually monitoring system...)
cat /tmp/arprequests.txt | awk '{ print $4 }' | sort | uniq -c | sort -nr
#DNS
for ip in `cat /tmp/arprequests.txt | awk '{ print $4 }'`; do dig +noall +answer -x $ip; done | awk '{ print $NF }' | sort | uniq -c | sort -nr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment