• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python whois.whois函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: whois_lookup

def whois_lookup(url):
    try:
        whois.whois(url)
        sys.stderr.write('unavailable domain: %s\n' % (url))
        sys.stderr.flush()
    except Exception:
        print('available domain: %s' % (url))
开发者ID:jlhg,项目名称:domaincheck,代码行数:7,代码来源:domaincheck.py


示例2: run

    def run(self, query, cmd, *args):

        # rip out newlines and gibberish
        query = query.strip()
        # replace the misp-style de-fanging
        query = query.replace("[", "")
        query = query.replace("]", "")

        parsed_uri = urlparse(query)
        # if it's an IP address
        try:
            if parsed_uri.netloc == '' and re.match('^\d{,3}\.\d{,3}\.\d{,3}\.\d{,3}$', query):
                self.logger.debug("whois on ip '{}'".format(query))
                w = whois.whois(query)
            elif parsed_uri.netloc == '' and parsed_uri.path != '':
                self.logger.debug("whois on domain '{}'".format(parsed_uri.path))    
                w = whois.whois(parsed_uri.path)
            else:
                self.logger.debug("whois on domain '{}'".format(parsed_uri.netloc))
                w = whois.whois(parsed_uri.netloc)
        except whois.parser.PywhoisError as e:
            return (False, {'error' : e})

        if w.get('status', False) == False:
            return (False, {'error' : "No result returned"})

        result = clean_dict(w)
        result['text'] = w.text.replace(">>> ", "--- ").replace(" <<<", " ---")
        return (True, result)
开发者ID:Cosive,项目名称:st2-whois,代码行数:29,代码来源:action_whois.py


示例3: is_available

 def is_available(self, domain):
     ''' Blindly grabbing PywhoisError isn't ideal but works '''
     try:
         whois(domain)
         return False
     except PywhoisError:
         return True
开发者ID:fun-alex-alex2006hw,项目名称:xcname,代码行数:7,代码来源:DomainValidators.py


示例4: whois_validate_domain

def whois_validate_domain(value):
    '''
    Check that this is a domain according to whois
    '''
    try:
        whois.whois(str(value))
    except PywhoisError:
        msg = _('%(domain)s does not seem to be a valid domain name')
        raise ValidationError(msg % {'domain': value})
开发者ID:Emergya,项目名称:peer,代码行数:9,代码来源:validation.py


示例5: whois_handler

    def whois_handler(bot, update, args):
        chat_id = update.message.chat_id
        domain = args[0] if len(args) > 0 else None

        whois_response = whois.whois(domain) if whois.whois(domain) else None
        if whois_response is None:
            bot.sendMessage(chat_id, text="Sorry, I can't retrieve whois information about: {}.".format(domain))
            return
        bot.sendMessage(chat_id, text='Whois: {}'.format(whois_response.text))
开发者ID:blackms,项目名称:myTelegramBot,代码行数:9,代码来源:whois_plugin.py


示例6: whois_validate_domain

def whois_validate_domain(value):
    """
    Check that this is a domain according to whois
    """
    try:
        whois.whois(value)
    except PywhoisError:
        msg = _("%(domain)s does not seem to be a valid domain name")
        raise ValidationError(msg % {"domain": value})
开发者ID:rhoerbe,项目名称:peer,代码行数:9,代码来源:validation.py


示例7: whois_lookup

def whois_lookup(url):
    url_parse = urlparse(url)
    new_url = str(url_parse.scheme) + "://" + str(url_parse.netloc)

    try:
        whois.whois(new_url)
        return 1
    except:
        return -1
开发者ID:ariepriyambadha,项目名称:ekstraksiFitur,代码行数:9,代码来源:ekstraksiFitur.py


示例8: getISP

def getISP(ip):
    tmp=gi.record_by_addr(ip)
    if ip in torexits:
        return tmp['city'], tmp['country_name'], "TOR"
    if tmp:
        return tmp['city'], tmp['country_name'], whois(ip)[-1]
    tmp=whois(ip)
    if tmp:
        return 'unknown', 'unknown', tmp[-1]
    return 'unknown', 'unknown', ip
开发者ID:stef,项目名称:kopo,代码行数:10,代码来源:webapp.py


示例9: run_whois

    def run_whois(self,domain):
        """Perform a WHOIS lookup for the provided target domain. The WHOIS results are returned
        as a dictionary.

        This can fail, usually if the domain is protected by a WHOIS privacy service or the
        registrar has their own WHOIS service.

        Parameters:
        domain      The domain to use for the WHOIS query
        """
        try:
            who = whois.whois(domain)
            results = {}
            # Check if info was returned before proceeding because sometimes records are protected
            if who.registrar:
                results['domain_name'] = who.domain_name
                results['registrar'] = who.registrar
                results['expiration_date'] = who.expiration_date
                results['registrant'] = who.name
                results['org'] = who.org
                results['admin_email'] = who.emails[0]
                results['tech_email'] = who.emails[1]
                results['address'] = "{}, {}{}, {}, {}".format(who.address,who.city,who.zipcode,who.state,who.country)
                results['dnssec'] = who.dnssec
            else:
                click.secho("[*] WHOIS record for {} came back empty. You might try looking at dnsstuff.com.".format(domain),fg="yellow")
            return results
        except Exception as error:
            click.secho("[!] The WHOIS lookup for {} failed!".format(domain),fg="red")
            click.secho("L.. Details: {}".format(error),fg="red")
开发者ID:chrismaddalena,项目名称:viper,代码行数:30,代码来源:whois.py


示例10: domainify

def domainify():
    """Returns a random domain where the last characters form a TLD"""
    results = open('results','r')
    domains = []
    try:
        while True:
            domains.append(pickle.load(results))

    except EOFError:
        while True:
            pick = domains[random.randint(0, (len(domains))-1)]
            print(pick[0])
            definition =  find(pick[0][0])
            if definition:
                results = []
                for (word,tld) in pick:
                    try:
                        domain = word[:len(word)-len(tld)] + '.' + tld
                        if whois.whois(domain)["expiration_date"]:
                            results.append({'domain':domain, 'definition':definition})
                    except (UnboundLocalError, KeyError):
                        pass
                    except whois.parser.PywhoisError:           # this isn't 100% accurate
                        results.append({'domain':domain, 'definition':definition})
                if len(results)>0:
                    return results[random.randint(0, (len(results))-1)]
开发者ID:Kongaloosh,项目名称:word_search,代码行数:26,代码来源:domain_getter.py


示例11: checkargs

def checkargs():
  
  fqdn = sys.argv[1]
  image = sys.argv[2]
  flavor = sys.argv[3]

  try:
    img = cs.images.get(image)
    print "Good news, we found a valid image, continuing.."
  except:
    print "Sorry, your image was not found in the image list. Please try again."
    quit()

  try:
    int(flavor)
  except:
    print "Your flavor input was not numeric. Please try again."
    quit()

  try:
    cs.flavors.get(flavor)
    print "Valid flavor, still continuing"
  except:
    print "Your flavor is out of range. Please try again."
    quit()

  try:
    w = whois.whois(fqdn)
    print "Seems like a valid FQDN, let's keep rolling.."
  except:
    print
    print "This domain isn't a FQDN, please choose one that is. Quitting now."
    quit() 

  create(fqdn, image, img, flavor)
开发者ID:klausracker,项目名称:API-Challenge,代码行数:35,代码来源:challenge9.py


示例12: check_domain_available

    def check_domain_available(self,domain_name):
        

        # print( dir(whois))
        # domain = "esencia.in"
        w = whois(domain_name)
        t = w.query(False)
        p = parser.Parser(domain_name, t[1], t[0], True)

        try:

            # print( p.text)
            result=p.parse()

            print("######################")
            print(domain_name)

            if "NotFound" not in result:
            
                print ("Registrar:",list(result['Registrar']))
                print ("RegistrantID:",list(result['RegistrantID']))
                print ("CreationDate:",list(result['CreationDate']))
                print ("ExpirationDate",list(result['ExpirationDate']))
                print ("UpdateDate",list(result['UpdatedDate']))
                print ("RegistrantEmail:",list(result['RegistrantEmail']))

        except Exception as e:
            print(str(e))
开发者ID:shellleyma,项目名称:python-whois,代码行数:28,代码来源:test.py


示例13: main

def main():
    opts, args = options.parse_args()
    if len(args) < 1:
        options.print_help()
        return
  
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    site=args[0]
    s.connect((args[0], opts.port))
    
    s.send(hello)
    
    while True:
        typ, ver, pay = recvmsg(s)
        if typ == None:
            
            return
        # Look for server hello done message.
        if typ == 22 and ord(pay[0]) == 0x0E:
            break
  
    
    s.send(hb)
    b = hit_hb(s)
    if b == False:
	print site+" is not vulnerable"
    else:
	print site+" is VULNERABLE!"
	w = whois.whois(site)
	for x in range(0, len(w.emails)):
	  sendmail(w.emails[x])  
开发者ID:MrNasro,项目名称:heartbleed,代码行数:31,代码来源:exploit.py


示例14: get_whois

def get_whois(domain):
    global COUNT
    host = random.choice([USE_WHOIS_CMD, random.choice(HOST)])
    logging.info("Retrieving whois of domain '%s' by using '%s'." % (domain, host))
    if COUNT == 10:
        logging.warn("Whoiser thread is sleeping for 2 seconds.")
        time.sleep(2)
        host = USE_WHOIS_CMD
        COUNT = 0
    w = None
    try:
        w = whois.whois(domain, host)
    except Exception as e:
        logging.error("PyWhois Exception: %s" % e)

    if w is None:
        COUNT += 1
        logging.error("FAIL Retrieve whois of domain '%s' fail." % domain)
        return None
    #: 没有邮箱直接判定为查询失败
    elif w.emails is not None:
        logging.debug("SUCCESS Retrieve whois of domain '%s'." % domain)
        return w
    else:
        COUNT += 1
        logging.error("FAIL Retrieve whois of domain '%s' fail." % domain)
        return None
开发者ID:h404bi,项目名称:whoiser,代码行数:27,代码来源:jobs.py


示例15: __get_whois_record

 def __get_whois_record(self, domain):
     try:
         record = whois.whois(domain)
     except Exception, e:
         sys.stderr.write('The whois lookup for the domain: ' + domain + ' failed for the following reason:\n\n')
         sys.stderr.write(e + "\n")
         return None
开发者ID:AAG-SATIEDN,项目名称:Tools,代码行数:7,代码来源:email_to_cybox.py


示例16: FWhoisInfo

def FWhoisInfo(domaine):
	print("Information whois")
	#création de l'objet whois
	obj_whois = whois.whois(domaine)
	#Ouverture du fichier de sortie
	Fichier_result_auto = open("result_whois.txt","a")

	Fichier_result_auto.write("--- Nom domaine ---\n")
	Fichier_result_auto.write(obj_whois.domaine_name)

	Fichier_result_auto.write("--- Date création ---\n")
	Fichier_result_auto.write(obj_whois.creation_date)

	Fichier_result_auto.write("--- Register ---\n")
	Fichier_result_auto.write(obj_whois.registrar)

	Fichier_result_auto.write("--- Serveurs ---\n")
	Fichier_result_auto.write(obj_whois.name_servers)

	Fichier_result_auto.write("--- Emails ---\n")
	Fichier_result_auto.write(obj_whois.emails)

	Fichier_result_auto.write("--- Texte---\n")
	Fichier_result_auto.write(obj_whois.text)

	#Fermeture du fichier de sortie
	Fichier_result_auto.close()
开发者ID:Eatherzhuu,项目名称:Taaut,代码行数:27,代码来源:nmapAttaque.py


示例17: retrieveWHOIShostInfo

 def retrieveWHOIShostInfo(self):
     try:
         self.whoisData = whois.whois(self._uri)
     except Exception, error:
         logger = logging.getLogger(self.__class__.__name__)
         logger.error(error)
         pass
开发者ID:Hokan-Ashir,项目名称:Diploma,代码行数:7,代码来源:whoisFunctions.py


示例18: retWhois

def retWhois(data):
    try:
        w = whois.whois(data)
        return w.text
    except:
        w = ''
        return w
开发者ID:Beercow,项目名称:malicious-domain-profiling,代码行数:7,代码来源:MalProfile.py


示例19: process

 def process(load,h):
     if load:
         if load.count('4vPI')>0 or load.count('IPv4')>0:
             ls=load.split('\r\n')
             ffrom=''
             ip=''
             for l in ls:
                 if l.startswith('From: '):
                     ffrom=l.split(':')[2].split(';')[0].rstrip('>').lstrip(' ')
                 else:
                     ips=''
                     if l.count('4vPI')>0 and l.count('Addrs'[::-1])>0:
                         ips=l.split(':',1)[1][::-1].split(':')[0].split(' ')
                     if l.count('IPv4')>0 and l.count('Addrs')>0:
                         ips=l.split(':',1)[1].split(':')[0].split(' ')
                     if ffrom and ips:
                         for ip in ips:
                             ip=ip.strip(' ')
                             if ip and not (ip.startswith('192.168.') or
                                            ip.startswith('127.') or
                                            ip.startswith('10.') ):
                                 k=ip+'\t'+ffrom.strip(' ')
                                 t=time.localtime(h.ts[0]+h.ts[1]*0.000001)
                                 ts=time.strftime('%Y-%m-%d %X %Z',t)
                                 owner=''
                                 try:
                                     owner=whois.whois(ip)
                                 except:
                                     pass
                                 result.append(k+'\t'+ts+'\t'+owner)
开发者ID:atilaromero,项目名称:msn,代码行数:30,代码来源:ipsmsn.py


示例20: get_whois

    def get_whois(self, request, *args, **kwargs):
        self.method_check(request, ['post'])

        data = json.loads(request.body)
        host = data.get('host')
        try:
            domain = whois.whois(host)

            uuid_hex = uuid.uuid3(uuid.NAMESPACE_URL, str(host))
            domain_uuid = base64.b64encode(uuid_hex.get_hex())
            cname_domain = base64.urlsafe_b64encode(host.lower())

            domain.update(uuid=domain_uuid,
                          cname=cname_domain.lower().replace('=', ''),
                          host=host,
                          base=data.get('base'))

            print(domain)
            domain_obj = Domain.objects.filter(domain_name=host).last()

            if domain_obj:
                resp = {
                    "success": False,
                    "status": 418,
                    "message": "We have already generated an SSL certificate for your domain. Login to manage your account.",
                    "data": domain
                }
            else:
                if not data.get('forced'):
                    expiration_date = (lambda d: d.expiration_date if isinstance(
                        d.expiration_date, str) else min(d.expiration_date))(domain)

                    if datetime.now() > expiration_date:
                        resp = {
                            "success": False,
                            "status": 418,
                            "message": "Your Domain name has expired.",
                            "data": domain
                        }
                    else:
                        resp = {
                            "success": True,
                            "message": "Whois record exist.",
                            "data": domain
                        }
                else:
                    resp = {
                        "success": True,
                        "message": "Whois record exist.",
                        "data": domain
                    }
                    
            print(resp, 'here')
            return self.create_response(request, resp, HttpAccepted)

        except Exception, e:
            print(e)
            raise CustomBadRequest(code='whois_error',
                                    message='Whois record verification error. Our developers have been notified.')
开发者ID:apipanda,项目名称:openssl,代码行数:59,代码来源:resource.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python analysis.unstopped函数代码示例发布时间:2022-05-26
下一篇:
Python whois.query函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap