Created
September 9, 2020 18:29
-
-
Save renexu/63d370b45c35b840a0e068e6200f5fc3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from argparse import ArgumentParser | |
import socket | |
def dns_lookup(hostname: str) -> str: | |
return socket.gethostbyname(hostname) | |
if __name__ == '__main__': | |
parser = ArgumentParser() | |
parser.add_argument('input', type=str) | |
args = parser.parse_args() | |
with open(args.input, mode='r') as f: | |
hostname = f.readline() | |
while hostname: | |
hostname = hostname.replace('\n', '') | |
try: | |
ip = dns_lookup(hostname) | |
except: | |
ip = 'dne' | |
print(hostname, '\t', ip) | |
hostname = f.readline() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment