'Uses cowpatty to check for a handshake.
Returns "True" if handshake is found, false otherwise.'

def has_handshake_cowpatty(self, target, capfile, nonstrict=True):

    if (not program_exists('cowpatty')):
        return False
    cmd = ['cowpatty', '-r', capfile, '-s', target.ssid, '-c']
    if nonstrict:
        cmd.append('-2')
    proc = Popen(cmd, stdout=PIPE, stderr=DN)
    proc.wait()
    response = proc.communicate()[0]
    if (response.find('incomplete    four-way    handshake    exchange') != (-1)):
        return False
    elif (response.find('Unsupported    or    unrecognized    pcap    file.') != (-1)):
        return False
    elif (response.find('Unable    to    open    capture    file:    Success') != (-1)):
        return False
    return True
