示例#1
0
    def add_host(self, user_supplied):
        """
        Add string passed by user to self.targets as proper Host/Network objects
        For this, it attempts to create these objects and moves on if got a ValueError.
        """
        # Test if user_supplied is an IP?
        try:
            self.targets.add(Host(ips=[user_supplied]))
            return
        except ValueError:
            pass

        try:
            self.targets.add(Network(user_supplied))
            return
        except ValueError:
            pass

        # Test if user_supplied is a valid DNS? Needs strict flag, otherwise no ValueError will be raise by Host
        try:
            self.targets.add(Host(domain=user_supplied, strict=False))
            return
        except ValueError:
            logging.critical("Couldn't resolve or understand " + user_supplied)
            pass

        self.bad_targets.add(user_supplied)
def test_host():
    h1 = Host("192.168.0.1")
    h2 = Host("192.168.0.2")

    h1.link(h2)
    h2.link(h1)

    assert (h1 == "192.168.0.1")
    assert (h2 == "192.168.0.2")
    assert (h1.device_type() == Device_Type.HOST)
    assert (h2.device_type() == Device_Type.HOST)
    assert (h1.connected_router == h2)
    assert (h2.connected_router == h1)
示例#3
0
    def reverse_dns_on_cidr(target):
        """Does reverse dns lookups on a target, and saves results to target using target.add_related_host"""
        if not isinstance(target, Network):
            raise ValueError

        cidr = target.cidr

        for ip, reverse_domains in lookup.rev_dns_on_cidr(cidr):

            new_host = Host(ips=[ip], reverse_domains=reverse_domains)
            target.add_related_host(new_host)
            print(new_host.print_all_ips())

        if not target.related_hosts:
            print("# No results for this range")
示例#4
0
    def reverse_dns_on_cidr(target):
        """Does reverse dns lookups on a target, and saves results to target using target.add_related_host"""
        if not isinstance(target, Network):
            raise ValueError

        cidr = target.cidr

        for ip, reverse_domains in lookup.rev_dns_on_cidr(cidr):

            new_host = Host(ips=[ip], reverse_domains=reverse_domains)
            target.add_related_host(new_host)
            print(new_host.print_all_ips())

        if not target.related_hosts:
            print("# No results for this range")
示例#5
0
 def setUpClass(cls):
     possible_ips = ["8.8.8.8", "8.8.4.4", "4.2.2.2", "139.130.4.5"]
     cls.host = Host(ips=[(random.choice(possible_ips))])
     cls.host.ips[0].lookup_rev_dns()
     cls.host.ips[0].lookup_whois_ip()
     cls.host.ips[0].lookup_shodan()
     print("\n# Testing {} {}".format(cls.host.type, str(cls.host)))
def test_host():
    h1 = Host("192.168.0.1")
    h2 = Host("192.168.0.2")

    h1.link(h2)
    h2.link(h1)

    assert(h1 == "192.168.0.1")
    assert(h2 == "192.168.0.2")
    assert(h1.connected_router == h2)
    assert(h2.connected_router == h1)
示例#7
0
    def reverse_dns_on_cidr(target):
        """Does reverse dns lookups on a target, and saves results to target using target.add_related_host"""
        cidrs = set()
        if isinstance(target, Host):
            [cidrs.add(cidr) for cidr in target.cidrs]
        elif isinstance(target, Network):
            cidrs.add(target.cidr)
        else:
            raise ValueError

        for cidr in cidrs:

            for ip, reverse_domains in lookup.rev_dns_on_cidr(cidr):

                    new_host = Host(ips=[ip], reverse_domains=reverse_domains)
                    target.add_related_host(new_host)
                    print new_host.print_all_ips()

        if not target.related_hosts:
            print '# No results for this range'
示例#8
0
    def reverse_dns_on_cidr(target):
        """Does reverse dns lookups on a target, and saves results to target using target.add_related_host"""
        cidrs = set()
        if isinstance(target, Host):
            [cidrs.add(cidr) for cidr in target.cidrs]
        elif isinstance(target, Network):
            cidrs.add(target.cidr)
        else:
            raise ValueError

        for cidr in cidrs:

            for ip, reverse_domains in lookup.rev_dns_on_cidr(cidr):

                new_host = Host(ips=[ip], reverse_domains=reverse_domains)
                target.add_related_host(new_host)
                print new_host.print_all_ips()

        if not target.related_hosts:
            print '# No results for this range'
示例#9
0
 def setUpClass(cls):
     possible_ips = [
         '8.8.8.8',
         '8.8.4.4',
         '4.2.2.2',
         '139.130.4.5',
     ]
     cls.host = Host(ips=[(random.choice(possible_ips))])
     cls.host.ips[0].lookup_rev_dns()
     cls.host.ips[0].lookup_whois_ip()
     cls.host.ips[0].lookup_shodan()
     print '\n# Testing {} {}'.format(cls.host.type, str(cls.host))
示例#10
0
    def setUpClass(cls):

        possible_hosts = [
            'google.com',
            'amazon.com',
            'reddit.com',
            'seek.com.au',
            'google.cn',
            'sucuri.net',
            'twitter.com',
        ]

        cls.host = Host(random.choice(possible_hosts))
        print '\n# Testing {} {}'.format(cls.host.type, str(cls.host))
        cls.host.lookup_dns()
        cls.host.lookup_whois_domain()
        cls.host.lookup_whois_ip_all()
        cls.host.lookup_shodan_all()
示例#11
0
    def setUpClass(cls):

        possible_hosts = [
            "google.com",
            "amazon.com",
            "reddit.com",
            "seek.com.au",
            "google.cn",
            "sucuri.net",
            "twitter.com",
        ]

        cls.host = Host(random.choice(possible_hosts))
        print("\n# Testing {} {}".format(cls.host.type, str(cls.host)))
        cls.host.lookup_dns()
        cls.host.lookup_whois_domain()
        cls.host.lookup_whois_ip_all()
        cls.host.lookup_shodan_all()
示例#12
0
 def test_google_lookups(self):
     new_host = Host('google.co')
     new_host.google_lookups()
     self.assertTrue(new_host.linkedin_page)
     self.assertTrue(new_host.subdomains)
     self.assertTrue(Host('www.google.co') in new_host.subdomains)
示例#13
0
 def add_host(self, ip: str):
     self.hosts[ip] = Host(ip)
     self.devices[ip] = self.hosts[ip]
示例#14
0
    line = line.strip()

    # Skip blank lines and comments
    if not line or line[0] == '#':
        continue
    line_parts = shlex.split(line)

    # Check validity of ip address, otherwise, skip it
    try:
        addr = ipaddress.ip_address(line_parts[0])
    except ValueError:
        logging.error("IP address on line " + str(line_num + 1) + " is not valid, skipping it.")
        continue

    # Subsequent additions of optional fields will require a "None" value to be supported
    # If a label exists, use it
    label = None
    if len(line_parts) > 1:
        label = line_parts[1]

    # Add the host to the list
    hosts.append(Host(addr, label=label))

file.close()

# Start pinger thread
threading.Thread(target=pinger.ping_all, name="Pinger", daemon=True).start()

# Start GUI
ui.start_gui()
示例#15
0
 def test_google_lookups(self):
     new_host = Host("google.com")
     new_host.google_lookups()
     self.assertTrue(new_host.linkedin_page)
     self.assertTrue(new_host.subdomains)
     self.assertTrue(Host("www.google.com") in new_host.subdomains)
示例#16
0
 def __init__(self, xml):
     self.hosts = []
     for host in xml.find_all("host"):
         self.hosts.append(Host(host))
示例#17
0
 def add_host(self, ip: str, buffer_cap=5):
     self.hosts[ip] = Host(ip, buffer_cap)
     self.devices[ip] = self.hosts[ip]