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


Python Process.stdout方法代码示例

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


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

示例1: cowpatty_handshakes

# 需要导入模块: from Process import Process [as 别名]
# 或者: from Process.Process import stdout [as 别名]
    def cowpatty_handshakes(self):
        ''' Returns True if cowpatty identifies a handshake, False otherwise '''
        if not Process.exists('cowpatty'):
            return []
        if not self.essid:
            return [] # We need a essid for cowpatty :(

        proc = Process(self.cowpatty_command(), devnull=False)
        for line in proc.stdout().split('\n'):
            if 'Collected all necessary data to mount crack against WPA' in line:
                return [(None, self.essid)]
        return []
开发者ID:j1m1h3ndr1x,项目名称:wifite2,代码行数:14,代码来源:Handshake.py

示例2: pyrit_handshakes

# 需要导入模块: from Process import Process [as 别名]
# 或者: from Process.Process import stdout [as 别名]
    def pyrit_handshakes(self):
        ''' Returns True if pyrit identifies a handshake, False otherwise '''
        if not Process.exists('pyrit'):
            return []

        bssid_essid_pairs = set()
        hit_target = False
        current_bssid = self.bssid
        current_essid = self.essid
        proc = Process(self.pyrit_command(), devnull=False)
        for line in proc.stdout().split('\n'):
            mac_regex = ('[a-zA-Z0-9]{2}:' * 6)[:-1]
            match = re.search("^#\d+: AccessPoint (%s) \('(.*)'\):$"
                % (mac_regex), line)
            if match:
                # We found a BSSID and ESSID
                (bssid, essid) = match.groups()

                # Compare to what we're searching for
                if self.bssid and self.bssid.lower() == bssid.lower():
                    current_essid = essid
                    hit_target = True
                    continue

                elif self.essid and self.essid == essid:
                    current_bssid = bssid
                    hit_target = True
                    continue

                elif not self.bssid and not self.essid:
                    # We don't know either
                    current_bssid = bssid
                    current_essid = essid
                    hit_target = True
                else:
                    # This AccessPoint is not what we're looking for
                    hit_Target = False
            else:
                # Line does not contain AccessPoint
                if hit_target and ', good,' in line:
                    bssid_essid_pairs.add( (current_bssid, current_essid) )
        return [x for x in bssid_essid_pairs]
开发者ID:j1m1h3ndr1x,项目名称:wifite2,代码行数:44,代码来源:Handshake.py

示例3: get_interfaces

# 需要导入模块: from Process import Process [as 别名]
# 或者: from Process.Process import stdout [as 别名]
    def get_interfaces():
        '''
            Returns:
                List of Interface objects known by airmon-ng
        '''
        interfaces = []
        p = Process('airmon-ng')
        for line in p.stdout().split('\n'):
            # Ignore blank/header lines
            if len(line) == 0: continue
            if line.startswith('Interface'): continue
            if line.startswith('PHY'): continue

            # Strip out interface information
            fields = line.split("\t")
            while '' in fields:
                fields.remove('')
            # Add Interface object to list
            interfaces.append(Interface(fields))
        return interfaces
开发者ID:HoMeCracKeR,项目名称:wifite2,代码行数:22,代码来源:Airmon.py

示例4: check_for_wps_and_update_targets

# 需要导入模块: from Process import Process [as 别名]
# 或者: from Process.Process import stdout [as 别名]
    def check_for_wps_and_update_targets(capfile, targets):
        '''
            Given a cap file and list of targets, use Wash to
            find which BSSIDs in the cap file use WPS.
            Then update the 'wps' flag for those BSSIDs in the targets.

            Args:
                capfile - .cap file from airodump containing packets
                targets - list of Targets from scan, to be updated
        '''
        # Wash/Walsh is required to detect WPS
        wash_name = 'wash'
        if not Process.exists(wash_name):
            wash_name = 'walsh'
            if not Proces.exists(wash_name):
                # Wash isn't found, drop out
                return

        command = [
            'wash',
            '-f', capfile, # Path to cap file
            '-C'            # Ignore Frame Check Sum errors
        ]
        p = Process(command)
        for line in p.stdout().split('\n'):
            # Ignore irrelevant lines
            if line.strip() == '' or line.startswith('Scanning for'):
                continue
            bssid = line.split(' ')[0]
            for t in targets:
                if t.bssid.lower() == bssid.lower():
                    # Update the WPS flag
                    t.wps = True

        # Mark other targets as "no" wps support
        for t in targets:
            if t.wps: continue
            t.wps = False
开发者ID:j1m1h3ndr1x,项目名称:wifite2,代码行数:40,代码来源:Wash.py

示例5: tshark_bssid_essid_pairs

# 需要导入模块: from Process import Process [as 别名]
# 或者: from Process.Process import stdout [as 别名]
    def tshark_bssid_essid_pairs(self):
        '''
            Scrapes capfile for beacon frames indicating the ESSID.
            Returns list of tuples: (bssid,essid)
        '''
        if not Process.exists('tshark'):
            raise Exception('tshark is required to find ESSID')

        essids = set()

        # Extract beacon frames from cap file
        cmd = [
            'tshark',
            '-r', self.capfile,
            '-R', 'wlan.fc.type_subtype == 0x08 || wlan.fc.type_subtype == 0x05',
            '-2', # tshark: -R without -2 is deprecated.
            '-n'
        ]
        proc = Process(cmd, devnull=False)
        for line in proc.stdout().split('\n'):
            # Extract src, dst, and essid
            mac_regex = ('[a-zA-Z0-9]{2}:' * 6)[:-1]
            match = re.search('(%s) [^ ]* (%s).*.*SSID=(.*)$'
                % (mac_regex, mac_regex), line)
            if match == None:
                # Line doesn't contain src, dst, ssid
                continue
            (src, dst, essid) = match.groups()
            if dst.lower() == "ff:ff:ff:ff:ff:ff": continue
            if self.bssid:
                # We know the BSSID, only return the ESSID for this BSSID.
                if self.bssid.lower() == src.lower() or self.bssid.lower() == dst.lower():
                    essids.add((src, essid))
            else:
                # We do not know BSSID, add it.
                essids.add((src, essid))
        # Return list of tuples
        return [x for x in essids]
开发者ID:schoonc,项目名称:wifite2,代码行数:40,代码来源:Handshake.py

示例6: tshark_handshakes

# 需要导入模块: from Process import Process [as 别名]
# 或者: from Process.Process import stdout [as 别名]
    def tshark_handshakes(self):
        ''' Returns True if tshark identifies a handshake, False otherwise '''
        if not Process.exists('tshark'):
            return []

        target_client_msg_nums = {}

        # Dump EAPOL packets
        proc = Process(self.tshark_command(), devnull=False)
        for line in proc.stdout().split('\n'):
            # Extract source mac, destination mac, and message numbers
            mac_regex = ('[a-zA-Z0-9]{2}:' * 6)[:-1]
            match = re.search('(%s) -> (%s).*Message.*(\d).*(\d)'
                % (mac_regex, mac_regex), line)
            if match == None:
                # Line doesn't contain src, dst, Message numbers
                continue
            (src, dst, index, ttl) = match.groups()
            # "Message (index) of (ttl)"
            index = int(index)
            ttl = int(ttl)

            if ttl != 4:
                # Must be a 4-way handshake
                continue

            # Identify the client and target MAC addresses
            if index % 2 == 1:
                # First and Third messages
                target = src
                client = dst
            else:
                # Second and Fourth messages
                client = src
                target = dst

            if self.bssid and self.bssid.lower() != target.lower():
                # We know the BSSID and this msg was not for the target
                continue

            target_client_key = '%s,%s' % (target, client)

            # Ensure all 4 messages are:
            # Between the same client and target
            # In numeric & chronological order (1,2,3,4)
            if index == 1:
                # First message, add to dict
                target_client_msg_nums[target_client_key] = 1

            elif target_client_key not in target_client_msg_nums:
                # Not first message, we haven't gotten the first message yet
                continue

            elif index - 1 != target_client_msg_nums[target_client_key]:
                # Message is not in sequence
                continue

            else:
                # Message is > 1 and is received in-order
                target_client_msg_nums[target_client_key] = index

        bssids = set()
        # Check if we have all 4 messages for the handshake between the same MACs
        for (client_target, num) in target_client_msg_nums.iteritems():
            if num == 4:
                # We got a handshake!
                bssid = client_target.split(',')[0]
                bssids.add(bssid)

        return [(bssid, None) for bssid in bssids]
开发者ID:j1m1h3ndr1x,项目名称:wifite2,代码行数:72,代码来源:Handshake.py

示例7: Aireplay

# 需要导入模块: from Process import Process [as 别名]
# 或者: from Process.Process import stdout [as 别名]
class Aireplay(object):
    def __init__(self, target, attack_type, client_mac=None, replay_file=None):
        '''
            Starts aireplay process.
            Args:
                target - Instance of Target object, AP to attack.
                attack_type - int, str, or WEPAttackType instance.
                client_mac - MAC address of an associated client.
        '''
        cmd = Aireplay.get_aireplay_command(target,
                                            attack_type,
                                            client_mac=client_mac,
                                            replay_file=replay_file)

        # TODO: set 'stdout' when creating process to store output to file.
        # AttackWEP will read file to get status of attack.
        # E.g., chopchop will regex "(\d+)% done" to get percent complete.
        '''
        from subprocess import PIPE
        sout = PIPE
        if '--chopchop' in cmd:
            sout = open(Configuration.temp('chopchop'), 'w')
        '''

        self.pid = Process(cmd,
                           devnull=False,
                           cwd=Configuration.temp())

    def is_running(self):
        return self.pid.poll() == None

    def stop(self):
        ''' Stops aireplay process '''
        if self.pid and self.pid.poll() != None:
            self.pid.interrupt()

    def get_output(self):
        ''' Returns stdout from aireplay process '''
        return self.pid.stdout()

    @staticmethod
    def get_aireplay_command(target, attack_type,
                             client_mac=None, replay_file=None):
        '''
            Generates aireplay command based on target and attack type
            Args:
                target      - Instance of Target object, AP to attack.
                attack_type - int, str, or WEPAttackType instance.
                client_mac  - MAC address of an associated client.
                replay_file - .Cap file to replay via --arpreplay
        '''

        # Interface is required at this point
        Configuration.initialize()
        if Configuration.interface == None:
            raise Exception("Wireless interface must be defined (-i)")
            
        cmd = ['aireplay-ng']
        cmd.append('--ignore-negative-one')

        if not client_mac and len(target.clients) > 0:
            # Client MAC wasn't specified, but there's an associated client. Use that.
            client_mac = target.clients[0].station

        # type(attack_type) might be str, int, or WEPAttackType.
        # Find the appropriate attack enum.
        attack_type = WEPAttackType(attack_type).value

        if attack_type == WEPAttackType.fakeauth:
            cmd.extend(['-1', '0']) # Fake auth, no delay
            cmd.extend(['-a', target.bssid])
            cmd.extend(['-T', '3']) # Make 3 attempts
            if target.essid_known:
                cmd.extend(['-e', target.essid])
            # Do not specify client MAC address,
            # we're trying to fake-authenticate using *our* MAC

        elif attack_type == WEPAttackType.replay:
            cmd.append('--arpreplay')
            cmd.extend(['-b', target.bssid])
            cmd.extend(['-x', str(Configuration.wep_pps)])
            if client_mac:
                cmd.extend(['-h', client_mac])

        elif attack_type == WEPAttackType.chopchop:
            cmd.append('--chopchop')
            cmd.extend(['-b', target.bssid])
            cmd.extend(['-x', str(Configuration.wep_pps)])
            cmd.extend(['-m', '60']) # Minimum packet length (bytes)
            cmd.extend(['-n', '82']) # Maximum packet length
            cmd.extend(['-F'])       # Automatically choose first packet
            if client_mac:
                cmd.extend(['-h', client_mac])

        elif attack_type == WEPAttackType.fragment:
            cmd.append('--fragment')
            cmd.extend(['-b', target.bssid])
            cmd.extend(['-x', str(Configuration.wep_pps)])
            cmd.extend(['-m', '100']) # Minimum packet length (bytes)
            cmd.extend(['-F'])       # Automatically choose first packet
#.........这里部分代码省略.........
开发者ID:Andrey-Omelyanuk,项目名称:wifite2,代码行数:103,代码来源:Aireplay.py


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