Snippets

Wangolo Joel Find all domain email addresses

Created by Wangolo Joel last modified
import socket 
import argparse

def get_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

    '''
    if not port:
        port = 443

    return list(map(lambda x: 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)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.