Skip to content

Instantly share code, notes, and snippets.

@WJDigby
Created October 2, 2018 18:02
Show Gist options
  • Save WJDigby/dfd96844d1b36c4a98a2452f6560c772 to your computer and use it in GitHub Desktop.
Save WJDigby/dfd96844d1b36c4a98a2452f6560c772 to your computer and use it in GitHub Desktop.
Make reverse DNS output of host command more friendly.
#!/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