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


Python term.format函数代码示例

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


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

示例1: align_results

def align_results(line_type, line_content):
  """
  Strips the normal test results, and adds a right aligned variant instead with
  a bold attribute.
  """

  if line_type == LineType.CONTENT:
    return line_content

  # strip our current ending
  for ending in LINE_ENDINGS:
    if LINE_ENDINGS[ending] == line_type:
      line_content = line_content.replace(ending, "", 1)
      break

  # skipped tests have extra single quotes around the reason
  if line_type == LineType.SKIPPED:
    line_content = line_content.replace("'(", "(", 1).replace(")'", ")", 1)

  if line_type == LineType.OK:
    new_ending = "SUCCESS"
  elif line_type in (LineType.FAIL, LineType.ERROR):
    new_ending = "FAILURE"
  elif line_type == LineType.SKIPPED:
    new_ending = "SKIPPED"
  else:
    assert False, "Unexpected line type: %s" % line_type
    return line_content

  if CONFIG["argument.no_color"]:
    return "%-61s[%s]" % (line_content, term.format(new_ending))
  else:
    return "%-61s[%s]" % (line_content, term.format(new_ending, term.Attr.BOLD))
开发者ID:bwrichte,项目名称:TorFinalProject,代码行数:33,代码来源:output.py

示例2: __init__

    def __init__(self, cli, tortazoBots):
        self.filterBots = []
        self.excludedBots = []
        self.cli = cli
        if self.cli.zombieMode.lower() != "all":
            self.cli.logger.info(term.format("[+] Entering Zombie Mode... ", term.Color.YELLOW))
            botsExcluded = cli.zombieMode.split(",")
            for bot in tortazoBots:
                if bot.nickname.rstrip("\n") in botsExcluded:
                    self.cli.logger.info(
                        term.format("[+] Excluding Nickname: " + bot.nickname.rstrip("\n"), term.Color.YELLOW)
                    )
                    self.excludedBots.append(bot)
                else:
                    self.filterBots.append(bot)
        else:
            self.cli.logger.info(term.format("[+] Entering Zombie Mode... Including all bots ", term.Color.YELLOW))
            self.filterBots = tortazoBots

        for bot in self.filterBots:
            host = bot.user + "@" + bot.host + ":" + bot.port
            bot.host = host
            env.hosts.append(bot.host)
            env.passwords[bot.host] = bot.password
            self.cli.logger.debug(term.format("[+] Adding Bot: " + bot.host, term.Color.GREEN))
开发者ID:masterapocalyptic,项目名称:Tortazo-spanishtranslate,代码行数:25,代码来源:CommandAndControl.py

示例3: validate_anonymity

 def validate_anonymity(self):
     if get_IP_address(self.session) == _local_IP:
         err = "TOR connection leaked IP! Exiting"
         raise ValueError(err)
     else:
         line = "  Local and TOR IP address differ, continuing"
         print XTERM.format(line, XTERM.Color.WHITE)
开发者ID:thoppe,项目名称:tor_spiders,代码行数:7,代码来源:tor_spiders.py

示例4: run

 def run(self) :
     lock = threading.Lock()
     while True :
         lock.acquire()
         host = None
         try:
             self.torNode = self.queue.get()
             #values = self.queue.get()
             #self.ip, self.descriptor = values[0]
             #self.ports = values[1]
             if self.cli.brute is True:
                 #if self.cli.dictFile is not None:
                 for method in self.bruteForcePorts.keys():
                     for openPort in self.torNode.openPorts:
                         if self.bruteForcePorts[method] == openPort:
                             #Open port detected for a service supported in the "Brute-Forcer"
                             #Calling the method using reflection.
                             containedMethod = getattr(self, method)
                             if callable(containedMethod):
                                 containedMethod()
                 #else:
                 #    self.cli.logger.warn(term.format("[-] BruteForce mode specified but there's no files for users and passwords. Use -f option", term.Color.RED))
         except Queue.Empty :
             self.cli.logger.debug(term.format("[+] Worker %d exiting... "%self.tid, term.Color.GREEN))
         finally:
             self.cli.logger.debug(term.format("[+] Releasing the Lock in the Thread %d "%self.tid, term.Color.GREEN))
             lock.release()
             self.queue.task_done()
开发者ID:intfrr,项目名称:Tortazo,代码行数:28,代码来源:WorkerThread.py

示例5: sshBrute

    def sshBrute(self):
        '''
        Perform the SSH Bruteforce attack.
        '''
        self.cli.logger.debug(term.format("[+] Starting SSH BruteForce mode on Thread: %d " %self.tid, term.Color.GREEN))

        if(self.cli.dictFile is not None and os.path.exists(self.cli.dictFile)):
            self.cli.logger.debug(term.format("[+] Reading the Passwords file %s " %(self.cli.dictFile), term.Color.GREEN))
            for line in open(self.cli.dictFile, "r").readlines():
                [user, passwd] = line.strip().split(self.cli.SEPARATOR)
                if self.performSSHConnection(user, passwd):
                    break

        else:
            self.cli.logger.warn(term.format("[-] Dictionary file not found on the path %s" %(self.cli.dictFile), term.Color.RED))
            usersList = self.getUserlistFromFuzzDB()
            passList = self.getPasslistFromFuzzDB()

            stop_attack = False
            for user in usersList:
                if stop_attack:
                    break
                for passwd in passList:
                    if self.performSSHConnection(user, passwd):
                        stop_attack = True
                        break
开发者ID:intfrr,项目名称:Tortazo,代码行数:26,代码来源:WorkerThread.py

示例6: souk_ma_crawler

def souk_ma_crawler(begin=1, n=10):
    """
        Souk.ma Crawler : Permet de récupérer les numéros de téléphone disponible sur Souk.ma.

    :param begin: Par où commencer la récupération (numéro de page).
    :param n: Nombre de numéros souhaités
    :return: Liste contenant les numéros.
    """

    nums = []
    iterations = {'success': 0, 'failure': 0}
    page = begin

    new_identity()

    while len(nums) < n:

        soup = BeautifulSoup(get_html("http://www.souk.ma/fr/Maroc/&p="+str(page)), "html.parser")

        if "Sorry, there are no Web results for this search!" in soup:
            print(term.format("Vous atteint la limite des résultats de recherche .\n", term.Color.RED))
            break

        if len(soup.find_all('div', class_="desc")):
            iterations["success"] += 1
        else:
            iterations["failure"] += 1
            new_identity()
            continue

        for div in soup.find_all('div', class_="desc"):
            if div.h2:
                annonce = BeautifulSoup(get_html(div.h2.a['href']), "html.parser")

                try:
                    if annonce.find_all('div', class_="userinfo-pro"):
                        if annonce.find_all('div', class_="inner")[0].contents[7].text[0] == '0':
                            nums.append(annonce.find_all('div', class_="inner")[0].contents[7].text)

                    elif annonce.find_all('div', class_="userinfo"):
                        if annonce.find_all('i', class_="icon-envelope")[1].parent.parent.text[0] == '0':
                            nums.append(annonce.find_all('i', class_="icon-envelope")[1].parent.parent.text)
                except:
                    continue

            sys.stdout.write("\r" + OKGREEN + "Avancement : " + str(len(nums)) + " / " + str(n) + ENDC)
            sys.stdout.flush()

            if len(nums) >= n:
                break

        print()
        page += 1

    if use_tor:
        print(term.format("Arret de Tor.\n", term.Attr.BOLD))
        kill_tor()

    return nums[:n]
开发者ID:ukarroum,项目名称:nums-crawler,代码行数:59,代码来源:nums_crawler.py

示例7: new_identity

def new_identity():
    if use_tor:
        print(term.format("Nouvelle identite : "+get_ip()+"\n", term.Color.BLUE))
        kill_tor()
        init_tor()
    else:
        print(term.format("Lancement de Tor.\n", term.Attr.BOLD))
        init_tor()
开发者ID:ukarroum,项目名称:tor-python-interface,代码行数:8,代码来源:__init__.py

示例8: __init__

	def __init__(self, debugu):
		self.debugu = debugu
		if debugu == "y" or debugu == "f":
			debug = 1
		elif debugu == "n":
			debug = 0
		self.debug = debug
		import StringIO
		import socket
		import urllib

		import socks  # SocksiPy module
		import stem.process

		from stem.util import term

		SOCKS_PORT = 7000

		# Set socks proxy and wrap the urllib module

		socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', SOCKS_PORT)
		socket.socket = socks.socksocket

		# Perform DNS resolution through the socket

		def getaddrinfo(*args):
			return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]

		socket.getaddrinfo = getaddrinfo





		# Start an instance of Tor configured to only exit through Russia. This prints
		# Tor's bootstrap information as it starts. Note that this likely will not
		# work if you have another Tor instance running.

		def print_bootstrap_lines(line):
			if "Bootstrapped " in line and self.debug == 1 :
				print term.format(line, term.Color.BLUE)


		if self.debug == 1:
				print term.format("Starting Tor:\n", term.Attr.BOLD)

		self.tor_process = stem.process.launch_tor_with_config(
														config = {
															   'SocksPort': str(SOCKS_PORT),
															   'ExitNodes': '{pl}',
															   'EntryNodes': '{pl}',
														},
														init_msg_handler = print_bootstrap_lines,
		)
开发者ID:jasi306,项目名称:stacjetrm,代码行数:54,代码来源:tordown.py

示例9: runOnBotnet

 def runOnBotnet(self, command):
     try:
         with hide("running", "stdout", "stderr"):
             if command.strip()[0:5] == "sudo":
                 results = sudo(command)
             else:
                 results = run(command)
     except:
         results = "Unexpected error:", sys.exc_info()[0]
         self.cli.logger.error(term.format("[-] Exception executing command:  " + command, term.Color.RED))
         self.cli.logger.error(term.format("[-] Trace of the exception: " + str(results), term.Color.RED))
     return results
开发者ID:masterapocalyptic,项目名称:Tortazo-spanishtranslate,代码行数:12,代码来源:CommandAndControl.py

示例10: pobierz

	def pobierz(self, url):
		if self.debugu == 'f':
			print "pobieram"
			def query(self, url):
				"Uses urllib to fetch a site using SocksiPy for Tor over the SOCKS_PORT."
				try:
					return urllib.urlopen(url).read()
				except:
					return "Unable to reach %s" % url
			print term.format("\nChecking our endpoint:\n", term.Attr.BOLD)
			print term.format(query("https://www.atagar.com/echo.php"), term.Color.BLUE)
		return urllib.urlopen(url)
开发者ID:jasi306,项目名称:stacjetrm,代码行数:12,代码来源:tordown.py

示例11: _general_help

def _general_help():
  lines = []

  for line in msg('help.general').splitlines():
    div = line.find(' - ')

    if div != -1:
      cmd, description = line[:div], line[div:]
      lines.append(format(cmd, *BOLD_OUTPUT) + format(description, *STANDARD_OUTPUT))
    else:
      lines.append(format(line, *BOLD_OUTPUT))

  return '\n'.join(lines)
开发者ID:sammyshj,项目名称:stem,代码行数:13,代码来源:help.py

示例12: start

    def start(self):
        def print_bootstrap_lines(line):
          if "Bootstrapped " in line:
            print term.format(line, term.Color.BLUE)


        print term.format("Starting Tor:\n", term.Attr.BOLD)

        self.tor_process = stem.process.launch_tor_with_config(
          config = {
            'SocksPort': str(self.sock_port),
            'ExitNodes': '{'+self.country+'}',
          },
          init_msg_handler = print_bootstrap_lines,
        )
开发者ID:ggarri,项目名称:lowCostTravel,代码行数:15,代码来源:tor.py

示例13: kill_tor

	def kill_tor(self):
		try:	
			self.tor_process.kill()
			print(term.format("\nTor Instance Killed.", term.Attr.BOLD))
			return True
		except NameError as e:
			return False
开发者ID:benjkelley,项目名称:torscraper,代码行数:7,代码来源:TorHandler.py

示例14: launch_tor

def launch_tor(country):
    print(term.format("Starting Tor with exit node in %s:" % (country), term.Attr.BOLD))
    try:
        tor_process = stem.process.launch_tor_with_config(
            config = {
                'SocksPort': str(SOCKS_PORT),
                'ControlPort': str(CONTROL_PORT),
                'ExitNodes': "{"+country+"}",
            },
            timeout = 30,
            # init_msg_handler = print_bootstrap_lines,
        )
    # finally:
    #     print("test")
    except OSError: 
        print("Timeout when trying to find relay....")
        return 0

            # Add listener
    with Controller.from_port(port = CONTROL_PORT) as controller:
        controller.authenticate()
        stream_listener = functools.partial(stream_event, controller)
        controller.add_event_listener(stream_listener, EventType.STREAM)

    return tor_process
开发者ID:Sushisugre,项目名称:infosec,代码行数:25,代码来源:exit_node.py

示例15: print_noline

def print_noline(msg, *attr):
  if CONFIG["argument.no_color"]:
    sys.stdout.write(msg)
    sys.stdout.flush()
  else:
    sys.stdout.write(term.format(msg, *attr))
    sys.stdout.flush()
开发者ID:ankitmodi,项目名称:Projects,代码行数:7,代码来源:output.py


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