'Search all IP addresses in Bing and determine if they have more than
one domain hosted on it. Store findings in KB.'

def _analyze_ips(self, ip_address_list, fuzzable_request):

    bing_wrapper = bing(self._uri_opener)
    for ip_address in ip_address_list:
        results = bing_wrapper.get_n_results(('ip:' + ip_address), self._result_limit)
        results = [r.URL.base_url() for r in results]
        results = list(set(results))
        is_vulnerable = False
        if (len(results) > 1):
            is_vulnerable = True
            if (len(results) == 2):
                try:
                    res0 = socket.gethostbyname(results[0].get_domain())
                    res1 = socket.gethostbyname(results[1].get_domain())
                except:
                    pass
                else:
                    if (res0 == res1):
                        is_vulnerable = False
        if is_vulnerable:
            desc = ('The    web    application    under    test    seems    to    be    in    a    shared    hosting.    This    list    of    domains,    and    the    domain    of    the        web    application    under    test,    all    point    to    the    same    IP    address    (%s):\n' % ip_address)
            domain_list = kb.kb.raw_read(self, 'domains')
            for url in results:
                domain = url.get_domain()
                desc += ('-    %s\n' % domain)
                domain_list.append(domain)
            kb.kb.raw_write(self, 'domains', domain_list)
            v = Vuln.from_fr('Shared    hosting', desc, severity.MEDIUM, 1, self.get_name(), fuzzable_request)
            v['also_in_hosting'] = results
            om.out.vulnerability(desc, severity=severity.MEDIUM)
            kb.kb.append(self, 'shared_hosting', v)
