importsocketimportargparsedefget_ips_by_dns_lookup(target,port=None):''' this function takes the passed target and optional port and does a dns lookup. it returns the ips that it finds to the caller. :param target: the URI that you'd like to get the ip address(es) for :type target: string :param port: which port do you want to do the lookup against? :type port: integer :returns ips: all of the discovered ips for the target :rtype ips: list of strings '''ifnotport:port=443returnlist(map(lambdax:x[4][0],socket.getaddrinfo('{}.'.format(target),port,type=socket.SOCK_STREAM)))if__name__=="__main__":parser=argparse.ArgumentParser(prog="Find all ips of a given domain")parser.add_argument('-d','--d',help='Domain',required=True)parser.add_argument('-p','--p',help='Port',required=False,default=80)args=parser.parse_args()ips=get_ips_by_dns_lookup(target=args.d,port=args.p)print(ips)
Comments (1)
Wangolo Joel
This snippet compliments the tools hosted online, we used it with the great tool theharvester which has this features
This snippet compliments the tools hosted online, we used it with the great tool theharvester which has this features