Created
October 2, 2018 18:02
-
-
Save WJDigby/dfd96844d1b36c4a98a2452f6560c772 to your computer and use it in GitHub Desktop.
Make reverse DNS output of host command more friendly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
'''Pipe output of host command into this script when performing reverse lookups to get a more friendly output: | |
while read i; do host $i | ./friendly-reverse.py; done < list.txt ''' | |
import sys | |
for lookup in sys.stdin: | |
ip = lookup.split('.', 4)[:4] | |
domain = lookup.rsplit(' ', 1)[1] | |
print(ip[3] + '.' + ip[2] + '.' + ip[1] + '.' + ip[0] + ', ' + domain).rstrip() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment