当前位置: 首页>>代码示例>>Python>>正文


Python ipwhois.IPWhois类代码示例

本文整理汇总了Python中ipwhois.IPWhois的典型用法代码示例。如果您正苦于以下问题:Python IPWhois类的具体用法?Python IPWhois怎么用?Python IPWhois使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IPWhois类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main(ip):
    obj = IPWhois(ip)
    try:
        results = obj.lookup_rdap(depth=1)
    except:
        results = None
    return results
开发者ID:KunalAggarwal,项目名称:datasploit,代码行数:7,代码来源:ip_whois.py

示例2: _whois

def _whois(ip_pk):
    ip = IPv4Whois.objects.get(pk=ip_pk)
    ip.status = IPv4Whois.STATUS_LOOKING_UP_WHOIS
    ip.save()

    obj = IPWhois(ip.address, timeout=9)

    try:
        results = obj.lookup_rdap()
    except Exception as exc:
        ip.status = IPv4Whois.STATUS_LOOKUP_WHOIS_FAILED
        ip.save()
        raise exc

    ip.whois = json.dumps(results)
    ip.status = IPv4Whois.STATUS_LOOKUP_WHOIS_SUCCESS
    ip.save()

    kafka_msg = {
        'IP': ip.address,
        'Whois': results,
        'Host': settings.EXTERNAL_IP,
        'Timestamp': datetime.utcnow().isoformat(),
    }
    send_to_kafka('results', kafka_msg)
开发者ID:marklit,项目名称:mass-ipv4-whois,代码行数:25,代码来源:tasks.py

示例3: get_remote_whos

 def get_remote_whos(url):
     try:
         obj = IPWhois(DomainCheck.get_remote_IP(url))
         results = obj.lookup_rdap(depth=1)
         pprint(results)
     except socket.error:
         print("Error no connection .. WHOS")
开发者ID:Delfyn,项目名称:Python_webscanner,代码行数:7,代码来源:Scanner.py

示例4: test_lookup_rws

    def test_lookup_rws(self):
        try:
            from urllib.request import ProxyHandler, build_opener
        except ImportError:
            from urllib2 import ProxyHandler, build_opener

        ips = [
            '74.125.225.229',  # ARIN
            '2001:4860:4860::8888',
            '62.239.237.1',  # RIPE
            '2a00:2381:ffff::1',
            '210.107.73.73',  # APNIC
            '2001:240:10c:1::ca20:9d1d',
            '200.57.141.161',  # LACNIC
            '2801:10:c000::',
            '196.11.240.215',  # AFRINIC
            '2001:43f8:7b0::'
        ]

        for ip in ips:

            result = IPWhois(ip)
            try:
                self.assertIsInstance(result.lookup_rws(), dict)
            except (ASNLookupError, ASNRegistryError, WhoisLookupError):
                pass
            except AssertionError as e:
                raise e
            except Exception as e:
                self.fail('Unexpected exception raised: %r' % e)

        handler = ProxyHandler({'http': 'http://0.0.0.0:80/'})
        opener = build_opener(handler)
        result = IPWhois('74.125.225.229', 0, opener)
        self.assertRaises(WhoisLookupError, result.lookup_rws)
开发者ID:max0d41,项目名称:ipwhois,代码行数:35,代码来源:test_ipwhois.py

示例5: test_lookup

    def test_lookup(self):

        ips = [
            '74.125.225.229',  # ARIN
            '2001:4860:4860::8888',
            '62.239.237.1',  # RIPE
            '2a00:2381:ffff::1',
            '210.107.73.73',  # APNIC
            '2001:240:10c:1::ca20:9d1d',
            '200.57.141.161',  # LACNIC
            '2801:10:c000::',
            '196.11.240.215',  # AFRINIC
            '2001:43f8:7b0::'
        ]

        for ip in ips:

            result = IPWhois(ip)
            try:
                self.assertIsInstance(result.lookup(), dict)
            except (ASNLookupError, ASNRegistryError, WhoisLookupError):
                pass
            except AssertionError as e:
                raise e
            except Exception as e:
                self.fail('Unexpected exception raised: %r' % e)
开发者ID:merisbahti,项目名称:ipwhois,代码行数:26,代码来源:test_ipwhois.py

示例6: check_addr_type

def check_addr_type(addr, addr_dict):
    if addr != local and not any([pattern.match(addr) for pattern in pattern_list]):
        obj = IPWhois(addr)
        results = obj.lookup()
        domain = results['nets'][0]['name']
        if domain is not None:
            addr_dict[addr] = domain
开发者ID:robertjuric,项目名称:flow-whois,代码行数:7,代码来源:flow-whois.py

示例7: orgGroups

    def orgGroups(self, sender, mID):
        # import pdb; pdb.set_trace()
        try:
            newmID = "www." + mID
            afterAT = "www." + sender[sender.index("@")+1:]

            if newmID in self.domainCompanyPairing.keys():
                res1 = self.domainCompanyPairing[newmID]
            else:
                ip1 = socket.gethostbyname(newmID)
                obj1 = IPWhois(ip1)
                res1 = obj1.lookup(get_referral=True)['nets'][0]['name']
                self.domainCompanyPairing[newmID] = res1

            if afterAT in self.domainCompanyPairing.keys():
                res2 = self.domainCompanyPairing[afterAT]
            else:
                ip2 = socket.gethostbyname(afterAT)
                obj2 = IPWhois(ip2)
                res2 = obj2.lookup(get_referral=True)['nets'][0]['name']
                self.domainCompanyPairing[afterAT] = res2
            
            if res1 == res2:
                return True
            return False
        except:
            return False
开发者ID:mikeaboody,项目名称:phishing-research,代码行数:27,代码来源:messageIDDomainBest.py

示例8: cmd_whois_ip

def cmd_whois_ip(ip):
    """Simple whois client to check IP addresses (IPv4 and IPv6).

    Example:

    \b
    $ habu.whois.ip 8.8.8.8
    {
        "nir": null,
        "asn_registry": "arin",
        "asn": "15169",
        "asn_cidr": "8.8.8.0/24",
        "asn_country_code": "US",
        "asn_date": "1992-12-01",
        "asn_description": "GOOGLE - Google LLC, US",
        "query": "8.8.8.8",
        ...
    """

    warnings.filterwarnings("ignore")

    obj = IPWhois(ip)
    data = obj.lookup_rdap()

    print(json.dumps(data, indent=4))
开发者ID:coolsnake,项目名称:habu,代码行数:25,代码来源:cmd_whois_ip.py

示例9: set

    def set(self,pagenum,kw):
        try:
            url = 'http://www.ebay.com/sch/i.html?_from=R40&_sacat=0&LH_Complete=1&LH_Sold=1&LH_ItemCondition=3&_nkw=' + kw + '&_pgn=' + str(pagenum) + '&_ipg=200&rt=nc&_dmd=1'
            if len(self.proxies) > 0:
                countries = get_countries()
                obj = IPWhois(self.proxies[0].split(':')[0])
                results = obj.lookup(False)

                if countries[results['nets'][0]['country']] == "United States":

                    if self.getfile(url,self.proxies[0],".ht") == "error":
                        print("Switching Proxy")
                        self.proxies.pop(0)
                        self.set(pagenum,kw)
                    else:
                        print(self.proxies[0])

                else:
                    print(countries[results['nets'][0]['country']])
                    print("Non-US IP " + self.proxies[0].split(':')[0]  + ": Switching Proxy")
                    self.proxies.pop(0)
                    self.set(pagenum,kw)

            else:
                print("No Proxies in Queue")


        except Exception as e:
            print(str(e))
开发者ID:chibrander,项目名称:python-play,代码行数:29,代码来源:bayclass.py

示例10: getCIDR

 def getCIDR(cls, ip):
     if Lookup.offline:
         Lookup.cidr_tot += 1
         for cidr in Lookup.seen_pairings_keys:
             ip_bin = getBinaryRep(ip, cidr)
             if ip_bin in Lookup.seen_pairings[cidr]:
                 Lookup.cidr_hit += 1
                 return ip_bin
         return getBinaryRep(ip, 32)
     else:
         Lookup.cidr_tot += 1
         try:
             if ip in Lookup.seen_pairings:
                 Lookup.cidr_hit += 1
                 return Lookup.seen_pairings[ip]
             else:
                 obj = IPWhois(ip)
                 results = obj.lookup()
                 if "nets" not in results.keys() or "cidr" not in results["nets"][0].keys():
                     cidr = ip + "/32"
                 else:
                     cidr = results["nets"][0]["cidr"]
                 Lookup.seen_pairings[ip] = cidr
                 if cidr:
                     Lookup.cidr_hit += 1
                 return cidr
         except:
             Lookup.seen_pairings[ip] = "Invalid"
             return "Invalid"
开发者ID:mikeaboody,项目名称:phishing-research,代码行数:29,代码来源:lookup.py

示例11: performWhoIs

def performWhoIs(IP):
    print()
    print(timeStamp() + "* Performing WHOIS on " + IP)
    obj = IPWhois(IP)
    res = obj.lookup_whois()
    print(timeStamp() + "- WHOIS name: " + res["nets"][0]['name'])
    print(timeStamp() + "- WHOIS CIDR: " + res['asn_cidr'])
    print(timeStamp() + "- More info at http://who.is/whois-ip/ip-address/" + IP)
开发者ID:rascal999,项目名称:qad,代码行数:8,代码来源:__init__.py

示例12: whois

def whois(ip):
    try:
        obj = IPWhois(ip)
        response = obj.lookup()
    except ipwhois.exceptions.WhoisLookupError:
        return None

    return response
开发者ID:eacha,项目名称:Data-Collector,代码行数:8,代码来源:whois.py

示例13: geoinfo

 def geoinfo(self):
     
     try:
         data = IPWhois(self.ip)
         return data.lookup(False)['nets'][0]   
     except:
         #raise
         return None
开发者ID:nullbytes0x00,项目名称:srvfilter,代码行数:8,代码来源:proxy.py

示例14: getIPandWhoIsData

 def getIPandWhoIsData(self,url):
     try:
         ip=socket.gethostbyname(url);
         obj=IPWhois(ip);
         whoIsDict=obj.lookup();
         whoIsDict['resolved_IP']=ip;
         return {url : whoIsDict};
     except Exception:
         return dict();
开发者ID:relyt0925,项目名称:InternetContentAnalysisSystem,代码行数:9,代码来源:webCrawlerBetter.py

示例15: queryIP

 def queryIP(self,ip):
     try:
         self.result['type'] = 'ip'
         self.result['keyword'] = ip
         self.ip = ip
         ipwhois = IPWhois(self.ip)
         self.result['whois'] = ipwhois.lookup()
     except Exception as e:
         self.result['exceptions'].append(e)
     return self
开发者ID:fjly,项目名称:scanner,代码行数:10,代码来源:Inetnum.py


注:本文中的ipwhois.IPWhois类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。