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


Python Color.s方法代码示例

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


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

示例1: __str__

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import s [as 别名]
    def __str__(self):
        ''' Colored string representation of interface '''
        s = Color.s("{W}%s" % self.phy)
        s += ' ' * max(Interface.PHY_LEN - len(self.phy), 0)

        s += Color.s("{G}%s" % self.name)
        s += ' ' * max(Interface.NAME_LEN - len(self.name), 0)

        s += Color.s("{C}%s" % self.driver)
        s += ' ' * max(Interface.DRIVER_LEN - len(self.driver), 0)

        s += Color.s("{W}%s" % self.chipset)
        s += ' ' * max(Interface.CHIPSET_LEN - len(self.chipset), 0)
        return s
开发者ID:schoonc,项目名称:wifite2,代码行数:16,代码来源:Interface.py

示例2: select_targets

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import s [as 别名]
    def select_targets(self):
        ''' Asks user to select target(s) '''

        if len(self.targets) == 0:
            # TODO Print a more-helpful reason for failure.
            # 1. Link to wireless drivers wiki,
            # 2. How to check if your device supporst monitor mode,
            # 3. Provide airodump-ng command being executed.
            raise Exception("No targets found."
                + " You may need to wait longer,"
                + " or you may have issues with your wifi card")

        self.print_targets()
        input_str  = '{+} select target(s)'
        input_str += ' ({G}1-%d{W})' % len(self.targets)
        input_str += ' separated by commas, dashes'
        input_str += ' or {G}all{W}: '

        chosen_targets = []
        for choice in raw_input(Color.s(input_str)).split(','):
            if choice == 'all':
                chosen_targets = self.targets
                break
            if '-' in choice:
                # User selected a range
                (lower,upper) = [int(x) - 1 for x in choice.split('-')]
                for i in xrange(lower, upper):
                    chosen_targets.append(self.targets[i])
            else:
                choice = int(choice) - 1
                chosen_targets.append(self.targets[choice])
        return chosen_targets
开发者ID:wflk,项目名称:wifite2,代码行数:34,代码来源:Scanner.py

示例3: choose_handshake

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import s [as 别名]
    def choose_handshake(self):
        Color.pl("\n{+} Listing captured handshakes...\n")
        handshakes = CrackResult.load_all()
        handshakes = [hs for hs in handshakes if "handshake_file" in hs and os.path.exists(hs["handshake_file"])]
        if len(handshakes) == 0:
            raise Exception("No handshakes found in %s" % os.path.realpath(CrackResult.cracked_file))

        # Handshakes Header
        max_essid_len = max([len(hs["essid"]) for hs in handshakes])
        Color.p("  NUM")
        Color.p("  " + "ESSID".ljust(max_essid_len))
        Color.p("  " + "BSSID".ljust(17))
        Color.p("  DATE CAPTURED\n")
        Color.p("  ---")
        Color.p("  " + ("-" * max_essid_len))
        Color.p("  " + ("-" * 17))
        Color.p("  " + ("-" * 19) + "\n")
        # Print all handshakes
        for index, hs in enumerate(handshakes):
            bssid = hs["bssid"]
            essid = hs["essid"]
            date = datetime.strftime(datetime.fromtimestamp(hs["date"]), "%Y-%m-%dT%H:%M:%S")
            Color.p("  {G}%s{W}" % str(index + 1).rjust(3))
            Color.p("  {C}%s{W}" % essid.ljust(max_essid_len))
            Color.p("  {C}%s{W}" % bssid)
            Color.p("  {C}%s{W}\n" % date)
        # Get number from user
        hs_index = raw_input(Color.s("\n{+} Select handshake num to crack ({G}1-%d{W}): " % len(handshakes)))
        if not hs_index.isdigit():
            raise Exception("Invalid input: %s" % hs_index)
        hs_index = int(hs_index)
        if hs_index < 1 or hs_index > len(handshakes):
            raise Exception("Handshake num must be between 1 and %d" % len(handshakes))

        return handshakes[hs_index - 1]
开发者ID:schoonc,项目名称:wifite2,代码行数:37,代码来源:CrackHandshake.py

示例4: dump

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import s [as 别名]
    def dump():
        ''' (Colorful) string representation of the configuration '''
        from Color import Color

        max_len = 20
        for key in Configuration.__dict__.keys():
            max_len = max(max_len, len(key))

        result  = Color.s('{W}%s  Value{W}\n' % 'Configuration Key'.ljust(max_len))
        result += Color.s('{W}%s------------------{W}\n' % ('-' * max_len))

        for (key,val) in sorted(Configuration.__dict__.iteritems()):
            if key.startswith('__'): continue
            if type(val) == staticmethod: continue
            if val == None: continue
            result += Color.s("{G}%s {W} {C}%s{W}\n" % (key.ljust(max_len),val))
        return result
开发者ID:j1m1h3ndr1x,项目名称:wifite2,代码行数:19,代码来源:Configuration.py

示例5: user_wants_to_stop

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import s [as 别名]
    def user_wants_to_stop(self, current_attack, attacks_remaining, target):
        '''
            Ask user what attack to perform next (re-orders attacks_remaining, returns False),
            or if we should stop attacking this target (returns True).
        '''
        target_name = target.essid if target.essid_known else target.bssid

        Color.pl("\n\n{!} {O}Interrupted")
        Color.pl("{+} {W}Next steps:")

        # Deauth clients & retry
        attack_index = 1
        Color.pl("     {G}1{W}: {O}Deauth clients{W} and {G}retry{W} {C}%s attack{W} against {G}%s{W}" % (current_attack, target_name))

        # Move onto a different WEP attack
        for attack_name in attacks_remaining:
            attack_index += 1
            Color.pl("     {G}%d{W}: Start new {C}%s attack{W} against {G}%s{W}" % (attack_index, attack_name, target_name))

        # Stop attacking entirely
        attack_index += 1
        Color.pl("     {G}%d{W}: {R}Stop attacking, {O}Move onto next target{W}" % attack_index)
        while True:
            answer = raw_input(Color.s("{?} Select an option ({G}1-%d{W}): " % attack_index))
            if not answer.isdigit() or int(answer) < 1 or int(answer) > attack_index:
                Color.pl("{!} {R}Invalid input: {O}Must enter a number between {G}1-%d{W}" % attack_index)
                continue
            answer = int(answer)
            break

        if answer == 1:
            # Deauth clients & retry
            deauth_count = 1
            Color.clear_entire_line()
            Color.p("\r{+} {O}Deauthenticating *broadcast*{W} (all clients)...")
            Aireplay.deauth(target.bssid, essid=target.essid)
            for client in target.clients:
                Color.clear_entire_line()
                Color.p("\r{+} {O}Deauthenticating client {C}%s{W}..." % client.station)
                Aireplay.deauth(target.bssid, client_mac=client.station, essid=target.essid)
                deauth_count += 1
            Color.clear_entire_line()
            Color.pl("\r{+} Sent {C}%d {O}deauths{W}" % deauth_count)
            # Re-insert current attack to top of list of attacks remaining
            attacks_remaining.insert(0, current_attack)
            return False # Don't stop
        elif answer == attack_index:
            return True # Stop attacking
        elif answer > 1:
            # User selected specific attack: Re-order attacks based on desired next-step
            attacks_remaining.insert(0, attacks_remaining.pop(answer-2))
            return False # Don't stop
开发者ID:schoonc,项目名称:wifite2,代码行数:54,代码来源:AttackWEP.py

示例6: ask

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import s [as 别名]
    def ask():
        '''
            Asks user to define which wireless interface to use.
            Does not ask if:
                1. There is already an interface in monitor mode, or
                2. There is only one wireles interface (automatically selected).
            Puts selected device into Monitor Mode.
        '''

        Airmon.terminate_conflicting_processes()

        Color.pl('\n{+} looking for {C}wireless interfaces{W}')
        mon_ifaces = Airmon.get_interfaces_in_monitor_mode()
        mon_count = len(mon_ifaces)
        if mon_count == 1:
            # Assume we're using the device already in montior mode
            iface = mon_ifaces[0]
            Color.pl('{+} using interface {G}%s{W} which is already in monitor mode'
                % iface);
            Airmon.base_interface = None
            return iface

        a = Airmon()
        count = len(a.interfaces)
        if count == 0:
            # No interfaces found
            Color.pl('\n{!} {O}airmon-ng did not find {R}any{O} wireless interfaces')
            Color.pl('{!} {O}make sure your wireless device is connected')
            Color.pl('{!} {O}see {C}http://www.aircrack-ng.org/doku.php?id=airmon-ng{O} for more info{W}')
            raise Exception('airmon-ng did not find any wireless interfaces')

        Color.pl('')

        a.print_menu()

        Color.pl('')

        if count == 1:
            # Only one interface, assume this is the one to use
            choice = 1
        else:
            # Multiple interfaces found
            question = Color.s("{+} select interface ({G}1-%d{W}): " % (count))
            choice = raw_input(question)

        iface = a.get(choice)

        if a.get(choice).name in mon_ifaces:
            Color.pl('{+} {G}%s{W} is already in monitor mode' % iface.name)
        else:
            iface.name = Airmon.start(iface)
        return iface.name
开发者ID:schoonc,项目名称:wifite2,代码行数:54,代码来源:Airmon.py

示例7: user_wants_to_continue

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import s [as 别名]
    def user_wants_to_continue(self, attack_index):
        ''' Asks user if attacks should continue using remaining methods '''
        Color.pl('\n{!} {O}interrupted{W}\n')

        if attack_index + 1 >= len(Configuration.wep_attacks):
            # No more WEP attacks to perform.
            return False

        attacks_remaining = Configuration.wep_attacks[attack_index + 1:]
        Color.pl("{+} {G}%d{W} attacks remain ({C}%s{W})" % (len(attacks_remaining), ', '.join(attacks_remaining)))
        prompt = Color.s('{+} type {G}c{W} to {G}continue{W}' +
                         ' or {R}s{W} to {R}stop{W}: ')
        if raw_input(prompt).lower().startswith('s'):
            return False
        else:
            return True
开发者ID:Andrey-Omelyanuk,项目名称:wifite2,代码行数:18,代码来源:AttackWEP.py

示例8: get_arguments

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import s [as 别名]
    def get_arguments(self, Configuration):
        """ Returns parser.args() containing all program arguments """

        parser = argparse.ArgumentParser(
            usage=argparse.SUPPRESS,
            formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=80, width=130),
        )

        # Global variables
        glob = parser.add_argument_group("SETTINGS")
        glob.add_argument(
            "-i",
            action="store",
            dest="interface",
            metavar="[interface]",
            type=str,
            help=Color.s("Wireless interface to use (default: {G}ask{W})"),
        )
        glob.add_argument(
            "-c",
            action="store",
            dest="channel",
            metavar="[channel]",
            type=int,
            help=Color.s("Wireless channel to scan (default: {G}all channels{W})"),
        )
        glob.add_argument(
            "-b",
            action="store",
            dest="target_bssid",
            metavar="[bssid]",
            type=str,
            help=Color.s("BSSID (e.g. {GR}AA:BB:CC:DD:EE:FF{W}) of access point to attack"),
        )
        glob.add_argument(
            "-e",
            action="store",
            dest="target_essid",
            metavar="[essid]",
            type=str,
            help=Color.s("ESSID (name) of access point to attack"),
        )
        glob.add_argument(
            "-v",
            "--verbose",
            action="count",
            default=0,
            dest="verbose",
            help=Color.s("Verbose mode, prints more lines (default: {G}quiet{W})"),
        )

        # WEP
        wep = parser.add_argument_group("WEP-RELATED")
        wep.add_argument(
            "--wep",
            action="store_true",
            dest="wep_filter",
            help=Color.s("Filter to display WEP-encrypted networks (default: {G}off{W})"),
        )
        wep.add_argument(
            "--require-fakeauth",
            action="store_true",
            dest="require_fakeauth",
            help=Color.s("Fails attacks if fake-auth fails (default: {G}off{W})"),
        )
        wep.add_argument(
            "-pps",
            action="store",
            dest="wep_pps",
            metavar="[pps]",
            type=int,
            help=Color.s("Packets Per Second to replay (default: {G}%d pps{W})") % Configuration.wep_pps,
        )
        wep.add_argument(
            "-wept",
            action="store",
            dest="wep_timeout",
            metavar="[seconds]",
            type=int,
            help=Color.s("Seconds to wait before failing (default: {G}%d ivs{W})") % Configuration.wep_timeout,
        )
        wep.add_argument(
            "-wepc",
            action="store",
            dest="wep_crack_at_ivs",
            metavar="[ivs]",
            type=int,
            help=Color.s("Start cracking at this many IVs (default: {G}%d ivs{W})") % Configuration.wep_crack_at_ivs,
        )
        wep.add_argument(
            "-weprs",
            action="store",
            dest="wep_restart_stale_ivs",
            metavar="[seconds]",
            type=int,
            help=Color.s("Restart aireplay if no new IVs appear (default: {G}%d sec{W})")
            % Configuration.wep_restart_stale_ivs,
        )
        wep.add_argument(
            "-weprc",
#.........这里部分代码省略.........
开发者ID:wflk,项目名称:wifite2,代码行数:103,代码来源:Arguments.py

示例9: __str__

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import s [as 别名]
    def __str__(self):
        '''
            *Colored* string representation of this Target.
            Specifically formatted for the "scanning" table view.
        '''

        max_essid_len = 25
        essid = self.essid if self.essid_known else "(%s)" % self.bssid
        # Trim ESSID (router name) if needed
        if len(essid) > max_essid_len:
            essid = essid[0:max_essid_len-3] + '...'
        else:
            essid = essid.rjust(max_essid_len)

        if self.essid_known:
            # Known ESSID
            essid = Color.s("{C}%s" % essid)
        else:
            # Unknown ESSID
            essid = Color.s("{O}%s" % essid)

        channel_color = "{G}"
        if int(self.channel) > 14:
            channel_color = "{C}"
        channel = Color.s("%s%s" % (channel_color, str(self.channel).rjust(3)))

        encryption = self.encryption.rjust(4)
        if 'WEP' in encryption:
            encryption = Color.s("{G}%s" % encryption)
        elif 'WPA' in encryption:
            encryption = Color.s("{O}%s" % encryption)

        power = '%sdb' % str(self.power).rjust(3)
        if self.power > 50:
            color ='G'
        elif self.power > 35:
            color = 'O'
        else:
            color = 'R'
        power = Color.s('{%s}%s' % (color, power))

        wps = Color.s('{O} n/a')
        if self.wps == True:
            wps = Color.s('{G} yes')
        elif self.wps == False:
            wps = Color.s('{R}  no')
        else:
            wps = Color.s('{O} n/a')

        clients = '       '
        if len(self.clients) == 1:
            clients = Color.s('{G}client ')
        elif len(self.clients) > 1:
            clients = Color.s('{G}clients')

        result = '%s  %s  %s  %s  %s  %s' % (essid, channel,
                                        encryption, power,
                                        wps, clients)
        result += Color.s("{W}")
        return result
开发者ID:schoonc,项目名称:wifite2,代码行数:62,代码来源:Target.py

示例10: __str__

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import s [as 别名]
    def __str__(self):
        """
            *Colored* string representation of this Target.
            Specifically formatted for the "scanning" table view.
        """

        max_essid_len = 25
        essid = self.essid
        # Trim ESSID (router name) if needed
        if len(essid) > max_essid_len:
            essid = essid[0 : max_essid_len - 3] + "..."
        else:
            essid = essid.rjust(max_essid_len)

        if self.essid_known:
            # Known ESSID
            essid = Color.s("{C}%s" % essid)
        else:
            # Unknown ESSID
            essid = Color.s("{O}%s" % essid)

        channel = str(self.channel)
        if len(channel) == 1:
            channel = Color.s("{G} %s" % channel)

        encryption = self.encryption.rjust(4)
        if "WEP" in encryption:
            encryption = Color.s("{G}%s" % encryption)
        elif "WPA" in encryption:
            encryption = Color.s("{O}%s" % encryption)

        power = "%sdb" % str(self.power).rjust(3)
        if self.power > 50:
            color = "G"
        elif self.power > 35:
            color = "O"
        else:
            color = "R"
        power = Color.s("{%s}%s" % (color, power))

        wps = Color.s("{O} n/a")
        if self.wps:
            wps = Color.s("{G} yes")
        else:
            wps = Color.s("{R}  no")

        clients = "       "
        if len(self.clients) == 1:
            clients = Color.s("{G}client ")
        elif len(self.clients) > 1:
            clients = Color.s("{G}clients")

        result = "%s  %s  %s  %s  %s  %s" % (essid, channel, encryption, power, wps, clients)
        result += Color.s("{W}")
        return result
开发者ID:wflk,项目名称:wifite2,代码行数:57,代码来源:Target.py

示例11: get_arguments

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import s [as 别名]
    def get_arguments(self, Configuration):
        ''' Returns parser.args() containing all program arguments '''

        parser = argparse.ArgumentParser(usage=argparse.SUPPRESS,
                formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=80, width=130))

        # Global variables
        glob = parser.add_argument_group('SETTINGS')
        glob.add_argument('-i',
            action='store',
            dest='interface',
            metavar='[interface]',
            type=str,
            help=Color.s('Wireless interface to use (default: {G}ask{W})'))
        glob.add_argument('-c',
            action='store',
            dest='channel',
            metavar='[channel]',
            type=int,
            help=Color.s('Wireless channel to scan (default: {G}all channels{W})'))
        glob.add_argument('--channel', help=argparse.SUPPRESS, action='store', dest='channel', type=int)
        glob.add_argument('-5',
            '--5ghz',
            action='store_true',
            dest='five_ghz',
            help=Color.s('Include 5Ghz channels (default: {G}off{W})'))
        glob.add_argument('-b',
            action='store',
            dest='target_bssid',
            metavar='[bssid]',
            type=str,
            help=Color.s('BSSID (e.g. {GR}AA:BB:CC:DD:EE:FF{W}) of access point to attack'))
        glob.add_argument('--bssid', help=argparse.SUPPRESS, action='store', dest='target_bssid', type=str)
        glob.add_argument('-e',
            action='store',
            dest='target_essid',
            metavar='[essid]',
            type=str,
            help=Color.s('ESSID (name) of access point to attack'))
        glob.add_argument('--essid', help=argparse.SUPPRESS, action='store', dest='target_essid', type=str)
        glob.add_argument('-v',
            '--verbose',
            action='count',
            default=0,
            dest='verbose',
            help=Color.s('Verbose mode, prints more lines (default: {G}quiet{W})'))

        # WEP
        wep = parser.add_argument_group('WEP-RELATED')
        wep.add_argument('--wep',
            action='store_true',
            dest='wep_filter',
            help=Color.s('Filter to display WEP-encrypted networks (default: {G}off{W})'))
        wep.add_argument('-wep', help=argparse.SUPPRESS, action='store_true', dest='wep_filter')
        wep.add_argument('--require-fakeauth',
            action='store_true',
            dest='require_fakeauth',
            help=Color.s('Fails attacks if fake-auth fails (default: {G}off{W})'))
        wep.add_argument('--nofakeauth', help=argparse.SUPPRESS, action='store_true', dest='require_fakeauth')
        wep.add_argument('-nofakeauth', help=argparse.SUPPRESS, action='store_true', dest='require_fakeauth')
        wep.add_argument('--pps',
            action='store',
            dest='wep_pps',
            metavar='[pps]',
            type=int,
            help=Color.s('Packets Per Second to replay (default: {G}%d pps{W})')
                % Configuration.wep_pps)
        wep.add_argument('-pps', help=argparse.SUPPRESS, action='store', dest='wep_pps', type=int)
        wep.add_argument('--wept',
            action='store',
            dest='wep_timeout',
            metavar='[seconds]',
            type=int,
            help=Color.s('Seconds to wait before failing (default: {G}%d sec{W})')
                % Configuration.wep_timeout)
        wep.add_argument('-wept', help=argparse.SUPPRESS, action='store', dest='wep_timeout', type=int)
        wep.add_argument('--wepca',
            action='store',
            dest='wep_crack_at_ivs',
            metavar='[ivs]',
            type=int,
            help=Color.s('Start cracking at this many IVs (default: {G}%d ivs{W})')
                % Configuration.wep_crack_at_ivs)
        wep.add_argument('-wepca', help=argparse.SUPPRESS, action='store', dest='wep_crack_at_ivs', type=int)
        wep.add_argument('--weprs',
            action='store',
            dest='wep_restart_stale_ivs',
            metavar='[seconds]',
            type=int,
            help=Color.s('Restart aireplay if no new IVs appear (default: {G}%d sec{W})')
                % Configuration.wep_restart_stale_ivs)
        wep.add_argument('-weprs', help=argparse.SUPPRESS, action='store', dest='wep_restart_stale_ivs', type=int)
        wep.add_argument('--weprc',
            action='store',
            dest='wep_restart_aircrack',
            metavar='[seconds]',
            type=int,
            help=Color.s('Restart aircrack after this delay (default: {G}%d sec{W})')
                % Configuration.wep_restart_aircrack)
        wep.add_argument('-weprc', help=argparse.SUPPRESS, action='store', dest='wep_restart_aircrack', type=int)
#.........这里部分代码省略.........
开发者ID:j1m1h3ndr1x,项目名称:wifite2,代码行数:103,代码来源:Arguments.py


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