Professional Documents
Culture Documents
Hcxhashtool
Hcxhashtool
#include <ctype.h>
#include <errno.h>
#include <getopt.h>
#include <inttypes.h>
#include <libgen.h>
#include <limits.h>
#include <pwd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#ifdef _WIN32
#include <winsock2.h>
#else
#include <arpa/inet.h>
#endif
#include <curl/curl.h>
#include <openssl/core.h>
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/params.h>
#include <openssl/types.h>
#include "include/hcxhashtool.h"
#include "include/strings.c"
#include "include/fileops.c"
#include "include/ieee80211.h"
#include "include/byteops.c"
/*===========================================================================*/
/* global var */
static const char *usedoui;
static int ouicount;
static int ouilistcount;
static ouilist_t *ouilist;
static hashlist_t *hashlist;
static long int pbkdf2count;
static long int pbkdf2readerrorcount;
static long int hashlistcount;
static long int readcount;
static long int readerrorcount;
static long int pmkideapolcount;
static long int pmkidcount;
static long int eapolcount;
static long int pmkidwrittencount;
static long int eapolwrittencount;
static long int essidwrittencount;
static long int essidrawwrittencount;
static long int hccapxwrittencount;
static long int hccapwrittencount;
static long int johnpmkidwrittencount;
static long int johneapolwrittencount;
ERR_load_crypto_strings();
OpenSSL_add_all_algorithms();
hmac = NULL;
ctxhmac = NULL;
cmac = NULL;
ctxcmac = NULL;
ctxhmac = EVP_MAC_CTX_new(hmac);
if(ctxhmac == NULL) return false;
ctxcmac = EVP_MAC_CTX_new(cmac);
if(ctxcmac == NULL) return false;
return true;
}
/*===========================================================================*/
static char *getvendor(uint8_t *mac)
{
static ouilist_t * zeiger;
static char unknown[] = "Unknown";
if(flagfilterouiap == true)
{
vendor = getvendor(filterouiap);
fprintf(stdout, "filter AP by OUI..............: %02x%02x%02x (%s)\n",
filterouiap[0], filterouiap[1], filterouiap[2], vendor);
}
if(filtervendorptr != NULL) fprintf(stdout, "filter AP and CLIENT by
VENDOR: %s\n", filtervendorptr);
if(filtervendorapptr != NULL) fprintf(stdout, "filter AP by
VENDOR...........: %s\n", filtervendorapptr);
if(filtervendorclientptr != NULL) fprintf(stdout, "filter CLIENT by
VENDOR.......: %s\n", filtervendorclientptr);
if(flagfilterouiclient == true)
{
vendor = getvendor(filterouiclient);
fprintf(stdout, "filter CLIENT by OUI..........: %02x%02x%02x (%s)\n",
filterouiclient[0], filterouiclient[1], filterouiclient[2], vendor);
}
if(flagfilterapless == true) fprintf(stdout, "filter by
M2..................: requested from client (AP-LESS)\n");
if(flagfilterrcchecked == true) fprintf(stdout, "filter by
replaycount.........: checked\n");
if(flagfilterrcnotchecked == true) fprintf(stdout, "filter by
replaycount.........: not checked\n");
if(flagfilterauthorized == true) fprintf(stdout, "filter by
status..............: authorized (M1M4, M2M3 or M3M4)\n");
if(flagfilterchallenge == true) fprintf(stdout, "filter by
status..............: challenge (M1M2)\n");
if(pmkidwrittencount > 0) fprintf(stdout, "PMKID
written.................: %ld\n", pmkidwrittencount);
if(eapolwrittencount > 0) fprintf(stdout, "EAPOL
written.................: %ld\n", eapolwrittencount);
if(johnpmkidwrittencount > 0) fprintf(stdout, "PMKID written to
john.........: %ld\n", johnpmkidwrittencount);
if(johneapolwrittencount > 0) fprintf(stdout, "EAPOL written to
john.........: %ld\n", johneapolwrittencount);
if(hccapxwrittencount > 0) fprintf(stdout, "EAPOL written to
hccapx.......: %ld\n", hccapxwrittencount);
if(hccapwrittencount > 0) fprintf(stdout, "EAPOL written to
hccap........: %ld\n", hccapwrittencount);
if(essidwrittencount > 0) fprintf(stdout, "ESSID (unique)
written........: %ld\n", essidwrittencount);
if(essidrawwrittencount > 0) fprintf(stdout, "ESSID
written.................: %ld\n", essidrawwrittencount);
fprintf(stdout, "\n");
return;
}
/*===========================================================================*/
static void testeapolpmk(hashlist_t *zeiger)
{
static int keyver;
static int p;
static wpakey_t *wpak;
static uint8_t *pkeptr;
wpak = (wpakey_t*)&zeiger->eapol[EAPAUTH_SIZE];
keyver = ntohs(wpak->keyinfo) & WPA_KEY_INFO_TYPE_MASK;
zeigerold = hashlist;
if(dopbkdf2(pskptrlen, pskptr, zeigerold->essidlen, zeigerold->essid) == true)
{
if(zeigerold->type == HCX_TYPE_PMKID) testpmkidpmk(zeigerold);
if(zeigerold->type == HCX_TYPE_EAPOL) testeapolpmk(zeigerold);
}
for(zeiger = hashlist +1; zeiger < hashlist +pmkideapolcount; zeiger++)
{
if((zeigerold->essidlen == zeiger->essidlen) && (memcmp(zeigerold->essid,
zeiger->essid, zeigerold->essidlen) == 0))
{
if(zeiger->type == HCX_TYPE_PMKID) testpmkidpmk(zeiger);
if(zeiger->type == HCX_TYPE_EAPOL) testeapolpmk(zeiger);
}
else
{
if(dopbkdf2(pskptrlen, pskptr, zeiger->essidlen, zeiger->essid) ==
true)
{
if(zeiger->type == HCX_TYPE_PMKID) testpmkidpmk(zeiger);
if(zeiger->type == HCX_TYPE_EAPOL) testeapolpmk(zeiger);
}
}
zeigerold = zeiger;
}
return;
}
/*===========================================================================*/
static bool isoui(uint8_t *macap, uint8_t *macclient)
{
static ouilist_t *zeiger;
if(zeiger->type == HCX_TYPE_PMKID)
{
fprintf(fh_john, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x
%02x%02x*%02x%02x%02x%02x%02x%02x*%02x%02x%02x%02x%02x%02x*",
zeiger->hash[0], zeiger->hash[1], zeiger->hash[2], zeiger->hash[3],
zeiger->hash[4], zeiger->hash[5], zeiger->hash[6], zeiger->hash[7],
zeiger->hash[8], zeiger->hash[9], zeiger->hash[10], zeiger->hash[11],
zeiger->hash[12], zeiger->hash[13], zeiger->hash[14], zeiger->hash[15],
zeiger->ap[0], zeiger->ap[1], zeiger->ap[2], zeiger->ap[3], zeiger-
>ap[4], zeiger->ap[5],
zeiger->client[0], zeiger->client[1], zeiger->client[2], zeiger-
>client[3], zeiger->client[4], zeiger->client[5]);
for(i = 0; i < zeiger->essidlen; i++) fprintf(fh_john, "%02x", zeiger-
>essid[i]);
fprintf(fh_john, "\n");
johnpmkidwrittencount++;
return;
}
wpak = (wpakey_t*)(zeiger->eapol +EAPAUTH_SIZE);
memset(&hccap, 0, sizeof(hccap_t));
memcpy(&hccap.essid, zeiger->essid, zeiger->essidlen);
memcpy(&hccap.ap, zeiger->ap, 6);
memcpy(&hccap.client, zeiger->client, 6);
memcpy(&hccap.anonce, zeiger->nonce, 32);
memcpy(&hccap.snonce, wpak->nonce, 32);
memcpy(&hccap.keymic, zeiger->hash, 16);
hccap.keyver = ntohs(wpak->keyinfo) & WPA_KEY_INFO_TYPE_MASK;
hccap.eapol_size = zeiger->eapauthlen;
memcpy(&hccap.eapol, zeiger->eapol, zeiger->eapauthlen);
#ifdef BIG_ENDIAN_HOST
hccap.eapol_size = byte_swap_16(hccap.eapol_size);
#endif
if(johnoutname != NULL)
{
if((fh_john = fopen(johnoutname, "a")) == NULL)
{
fprintf(stdout, "error opening file %s: %s\n", johnoutname,
strerror(errno));
return;
}
}
for(zeiger = hashlist; zeiger < hashlist +pmkideapolcount; zeiger++)
writejohnrecord(fh_john, zeiger);
if(fh_john != NULL) fclose(fh_john);
if(johnoutname != NULL)
{
if(stat(johnoutname, &statinfo) == 0)
{
if(statinfo.st_size == 0) remove(johnoutname);
}
}
return;
}
/*===========================================================================*/
static void writehccaprecord(FILE *fh_hccap, hashlist_t *zeiger)
{
struct hccap_s
{
char essid[36];
unsigned char ap[6];
unsigned char client[6];
unsigned char snonce[32];
unsigned char anonce[32];
unsigned char eapol[256];
int eapol_size;
int keyver;
unsigned char keymic[16];
};
typedef struct hccap_s hccap_t;
#define HCCAP_SIZE (sizeof(hccap_t))
if(hccapoutname != NULL)
{
if((fh_hccap = fopen(hccapoutname, "a")) == NULL)
{
fprintf(stdout, "error opening file %s: %s\n", hccapoutname,
strerror(errno));
return;
}
}
for(zeiger = hashlist; zeiger < hashlist +pmkideapolcount; zeiger++)
writehccaprecord(fh_hccap, zeiger);
if(fh_hccap != NULL) fclose(fh_hccap);
if(hccapoutname != NULL)
{
if(stat(hccapoutname, &statinfo) == 0)
{
if(statinfo.st_size == 0) remove(hccapoutname);
}
}
return;
}
/*===========================================================================*/
static void writehccapxrecord(FILE *fh_hccapx, hashlist_t *zeiger)
{
struct hccapx_s
{
uint32_t signature;
#define HCCAPX_SIGNATURE 0x58504348
uint32_t version;
#define HCCAPX_VERSION 4
uint8_t message_pair;
uint8_t essid_len;
uint8_t essid[32];
uint8_t keyver;
uint8_t keymic[16];
uint8_t ap[6];
uint8_t anonce[32];
uint8_t client[6];
uint8_t snonce[32];
uint16_t eapol_len;
uint8_t eapol[256];
} __attribute__((packed));
typedef struct hccapx_s hccapx_t;
#define HCCAPX_SIZE (sizeof(hccapx_t))
if(hccapxoutname != NULL)
{
if((fh_hccapx = fopen(hccapxoutname, "a")) == NULL)
{
fprintf(stdout, "error opening file %s: %s\n", hccapxoutname,
strerror(errno));
return;
}
}
for(zeiger = hashlist; zeiger < hashlist +pmkideapolcount; zeiger++)
writehccapxrecord(fh_hccapx, zeiger);
if(fh_hccapx != NULL) fclose(fh_hccapx);
if(hccapxoutname != NULL)
{
if(stat(hccapxoutname, &statinfo) == 0)
{
if(statinfo.st_size == 0) remove(hccapxoutname);
}
}
return;
}
/*===========================================================================*/
static void processessidraw(char *essidrawoutname)
{
static long int pc;
static hashlist_t *zeiger;
static FILE *fh_essid;
static struct stat statinfo;
if(strcmp(essidoutname, "stdout") != 0)
{
if((fh_essid = fopen(essidoutname, "a")) == NULL)
{
fprintf(stdout, "error opening file %s: %s\n", essidoutname,
strerror(errno));
return;
}
zeigerold = NULL;
qsort(hashlist, pmkideapolcount, HASHLIST_SIZE, sort_hashlist_by_essid);
for(pc = 0; pc < pmkideapolcount; pc++)
{
zeiger = hashlist +pc;
if(zeigerold != NULL)
{
if(memcmp(zeiger->essid, zeigerold->essid, ESSID_LEN_MAX) == 0)
continue;
}
fwriteessidstr(zeiger->essidlen, zeiger->essid, fh_essid);
essidwrittencount++;
zeigerold = zeiger;
}
fclose(fh_essid);
if(stat(essidoutname, &statinfo) == 0)
{
if(statinfo.st_size == 0) remove(essidoutname);
}
}
else
{
statusflag = false;
zeigerold = NULL;
qsort(hashlist, pmkideapolcount, HASHLIST_SIZE, sort_hashlist_by_essid);
for(pc = 0; pc < pmkideapolcount; pc++)
{
zeiger = hashlist +pc;
if(zeigerold != NULL)
{
if(memcmp(zeiger->essid, zeigerold->essid, ESSID_LEN_MAX) == 0)
continue;
}
fwriteessidstr(zeiger->essidlen, zeiger->essid, stdout);
essidwrittencount++;
zeigerold = zeiger;
}
}
return;
}
/*===========================================================================*/
static void writepmkideapolhashline(FILE *fh_pmkideapol, hashlist_t *zeiger)
{
static int p;
if(pmkideapoloutname != NULL)
{
if((fh_pmkideapol = fopen(pmkideapoloutname, "a")) == NULL)
{
fprintf(stdout, "error opening file %s: %s\n", pmkideapoloutname,
strerror(errno));
return;
}
}
for(zeiger = hashlist; zeiger < hashlist +pmkideapolcount; zeiger++)
writepmkideapolhashline(fh_pmkideapol, zeiger);
if(fh_pmkideapol != NULL) fclose(fh_pmkideapol);
if(pmkideapoloutname != NULL)
{
if(stat(pmkideapoloutname, &statinfo) == 0)
{
if(statinfo.st_size == 0) remove(pmkideapoloutname);
}
}
return;
}
/*===========================================================================*/
static void writepmkideapolhashlineinfo(FILE *fh_pmkideapol, hashlist_t *zeiger)
{
static eapauth_t *eapa;
static wpakey_t *wpak;
static uint8_t keyver;
static uint64_t rc;
static char *vendor;
if(strcmp(infooutname, "stdout") != 0)
{
if((fh_info = fopen(infooutname, "a")) == NULL)
{
fprintf(stdout, "error opening file %s: %s\n", infooutname,
strerror(errno));
return;
}
for(zeiger = hashlist; zeiger < hashlist +pmkideapolcount; zeiger++)
writepmkideapolhashlineinfo(fh_info, zeiger);
fclose(fh_info);
}
else
{
for(zeiger = hashlist; zeiger < hashlist +pmkideapolcount; zeiger++)
writepmkideapolhashlineinfo(stdout, zeiger);
}
return;
}
/*===========================================================================*/
static uint16_t getfield(char *lineptr, size_t bufflen, uint8_t *buff)
{
static size_t p;
static uint8_t idx0;
static uint8_t idx1;
static const uint8_t hashmap[] =
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // 01234567
0x08, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 89:;<=>?
0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, // @ABCDEFG
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // HIJKLMNO
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // PQRSTUVW
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // XYZ[\]^_
0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, // `abcdefg
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // hijklmno
};
memset(buff, 0, bufflen);
p = 0;
while((lineptr[p] != '*') && (lineptr[p] != 0) && (p /2 <= bufflen))
{
if(!isxdigit((unsigned char)lineptr[p +0])) return 0;
if(!isxdigit((unsigned char)lineptr[p +1])) return 0;
if((lineptr[p +1] == '*') || (lineptr[p +1] == 0)) return 0;
idx0 = ((uint8_t)lineptr[p +0] &0x1F) ^0x10;
idx1 = ((uint8_t)lineptr[p +1] &0x1F) ^0x10;
buff[p /2] = (uint8_t)(hashmap[idx0] <<4) | hashmap[idx1];
p += 2;
}
return p /2;
}
/*===========================================================================*/
static size_t chop(char *buffer, size_t len)
{
static char *ptr;
maclistskipmax = 1000;
if((maclistskip = (maclist_t*)calloc(maclistskipmax, MACLIST_SIZE)) == NULL)
return;
if((fh_maclistin = fopen(macskipname, "r")) == NULL)
{
fprintf(stdout, "error opening file %s: %s\n", macskipname, strerror(errno));
return;
}
zeiger = maclistskip;
maclistskipcount = 0;
while(1)
{
if((len = fgetline(fh_maclistin, PMKIDEAPOL_BUFFER_LEN, linein)) == -1)
break;
if(len < 12) continue;
if(len > 17)
{
p2 = 0;
for(p1 = 0; p1 < 17; p1++)
{
if(isxdigit((unsigned char)linein[p1]))
{
linein[p2] = linein[p1];
p2++;
}
}
linein[p2] = 0;
len = p2;
}
linein[12] = 0;
if(getfield(linein, 6, zeiger->mac) != 6) continue;
maclistskipcount++;
if(maclistskipcount >= maclistskipmax)
{
maclistskipmax += 1000;
maclistskipnew = (maclist_t*)realloc(maclistskip, maclistskipmax
*MACLIST_SIZE);
if(maclistskipnew == NULL)
{
fprintf(stderr, "failed to allocate memory for internal list\n");
exit(EXIT_FAILURE);
}
maclistskip = maclistskipnew;
}
zeiger = maclistskip +maclistskipcount;
}
if(fh_maclistin != NULL) fclose(fh_maclistin);
qsort(maclistskip, maclistskipcount, MACLIST_SIZE, sort_maclistin);
qsort(hashlist, pmkideapolcount, HASHLIST_SIZE, sort_hashlist_by_macap);
zeigerhash = hashlist;
zeiger = maclistskip;
f = 0;
r = 0;
for(i = 0; i < pmkideapolcount; i++)
{
if(memcmp((zeigerhash +i)->ap, (zeiger +f)->mac, 6) > 0)
while(f < maclistskipcount)
{
if(memcmp((zeiger +f)->mac, (zeigerhash +i)->ap, 6) >= 0) break;
f++;
}
if(memcmp((zeigerhash +i)->ap, (zeiger +f)->mac, 6) == 0)
{
(zeigerhash +i)->type = HS_REMOVED;
r++;
}
}
qsort(hashlist, pmkideapolcount, HASHLIST_SIZE, sort_hashlist_by_type);
pmkidcount -= r;
qsort(hashlist, pmkideapolcount, HASHLIST_SIZE, sort_hashlist_by_macclient);
zeigerhash = hashlist;
zeiger = maclistskip;
f = 0;
r = 0;
for(i = 0; i < pmkideapolcount; i++)
{
if(memcmp((zeigerhash +i)->client, (zeiger +f)->mac, 6) > 0)
while(f < maclistskipcount)
{
if(memcmp((zeiger +f)->mac, (zeigerhash +i)->client, 6) >= 0) break;
f++;
}
if(memcmp((zeigerhash +i)->client, (zeiger +f)->mac, 6) == 0)
{
(zeigerhash +i)->type = HS_REMOVED;
r++;
}
}
qsort(hashlist, pmkideapolcount, HASHLIST_SIZE, sort_hashlist_by_type);
pmkidcount -= r;
if(maclistskip != NULL) free(maclistskip);
return;
}
/*===========================================================================*/
static void processmacfile(char *maclistinname, char *pmkideapoloutname)
{
static int len;
static int p1, p2;
static FILE *fh_maclistin;
static FILE *fh_pmkideapol;
static struct stat statinfo;
static int maclistincount, maclistinmax;
static maclist_t *maclistin, *zeiger, *maclistinnew;
static hashlist_t *zeigerhash;
static int i, o;
maclistinmax = 1000;
if((maclistin = (maclist_t*)calloc(maclistinmax, MACLIST_SIZE)) == NULL) return;
if((fh_maclistin = fopen(maclistinname, "r")) == NULL)
{
fprintf(stdout, "error opening file %s: %s\n", maclistinname,
strerror(errno));
return;
}
zeiger = maclistin;
maclistincount = 0;
while(1)
{
if((len = fgetline(fh_maclistin, PMKIDEAPOL_BUFFER_LEN, linein)) == -1)
break;
if(len == 17)
{
p2 = 0;
for(p1 = 0; p1 < 17; p1++)
{
if(isxdigit((unsigned char)linein[p1]))
{
linein[p2] = linein[p1];
p2++;
}
}
linein[p2] = 0;
len = p2;
}
if(len != 12) continue;
if(getfield(linein, 6, zeiger->mac) != 6) continue;
maclistincount++;
if(maclistincount >= maclistinmax)
{
maclistinmax += 1000;
maclistinnew = (maclist_t*)realloc(maclistin, maclistinmax
*MACLIST_SIZE);
if(maclistinnew == NULL)
{
fprintf(stdout, "failed to allocate memory for internal list\n");
exit(EXIT_FAILURE);
}
maclistin = maclistinnew;
}
zeiger = maclistin +maclistincount;
}
if(fh_maclistin != NULL) fclose(fh_maclistin);
qsort(maclistin, maclistincount, MACLIST_SIZE, sort_maclistin);
if(pmkideapoloutname != NULL)
{
if((fh_pmkideapol = fopen(pmkideapoloutname, "a")) == NULL)
{
fprintf(stdout, "error opening file %s: %s\n", pmkideapoloutname,
strerror(errno));
free(maclistin);
return;
}
}
qsort(hashlist, pmkideapolcount, HASHLIST_SIZE, sort_hashlist_by_macap);
zeiger = maclistin;
zeigerhash = hashlist;
o = 0;
for(i = 0; i < maclistincount; i++)
{
while(o < pmkideapolcount)
{
if(memcmp((zeigerhash +o)->ap, (zeiger +i)->mac, 6) > 0) break;
if(memcmp((zeigerhash +o)->ap, (zeiger +i)->mac, 6) == 0)
writepmkideapolhashline(fh_pmkideapol, zeigerhash +o);
o++;
}
}
qsort(hashlist, pmkideapolcount, HASHLIST_SIZE, sort_hashlist_by_macclient);
zeiger = maclistin;
zeigerhash = hashlist;
o = 0;
for(i = 0; i < maclistincount; i++)
{
while(o < pmkideapolcount)
{
if(memcmp((zeigerhash +o)->client, (zeiger +i)->mac, 6) > 0) break;
if(memcmp((zeigerhash +o)->client, (zeiger +i)->mac, 6) == 0)
writepmkideapolhashline(fh_pmkideapol, zeigerhash +o);
o++;
}
}
if(fh_pmkideapol != NULL) fclose(fh_pmkideapol);
if(pmkideapoloutname != NULL)
{
if(stat(pmkideapoloutname, &statinfo) == 0)
{
if(statinfo.st_size == 0) remove(pmkideapoloutname);
}
}
if(maclistin != NULL) free(maclistin);
return;
}
/*===========================================================================*/
static void processessidfile(char *essidlistinname, char *pmkideapoloutname)
{
static int len;
static int i, o;
static FILE *fh_essidlistin;
static FILE *fh_pmkideapol;
static struct stat statinfo;
static int essidlistincount, essidlistinmax;
static essidlist_t *essidlistin, *zeiger, *essidlistinnew;
static hashlist_t *zeigerhash;
static char hexpfx[] = { "$HEX[" };
static char linein[PMKIDEAPOL_BUFFER_LEN];
essidlistinmax = 1000;
if((essidlistin = (essidlist_t*)calloc(essidlistinmax, ESSIDLIST_SIZE)) == NULL)
return;
if((fh_essidlistin = fopen(essidlistinname, "r")) == NULL)
{
fprintf(stdout, "error opening file %s: %s\n", essidlistinname,
strerror(errno));
return;
}
zeiger = essidlistin;
essidlistincount = 0;
while(1)
{
if((len = fgetline(fh_essidlistin, PMKIDEAPOL_BUFFER_LEN, linein)) == -1)
break;
if((len < 1) || (len > 70)) continue;
memset(zeiger->essid, 0, 33);
if((len >= 8) && ((len %2) == 0) && (linein[len -1] == ']') &&
(memcmp(linein, hexpfx, 5) == 0))
{
linein[len -1] = 0;
zeiger->essidlen = getfield(&linein[5], 32, zeiger->essid);
}
else if(len <= 32)
{
zeiger->essidlen = len;
memcpy(zeiger->essid, linein, len);
}
else continue;
essidlistincount++;
if(essidlistincount >= essidlistinmax)
{
essidlistinmax += 1000;
essidlistinnew = (essidlist_t*)realloc(essidlistin, essidlistinmax
*ESSIDLIST_SIZE);
if(essidlistinnew == NULL)
{
fprintf(stderr, "failed to allocate memory for internal list\n");
exit(EXIT_FAILURE);
}
essidlistin = essidlistinnew;
}
zeiger = essidlistin +essidlistincount;
}
if(fh_essidlistin != NULL) fclose(fh_essidlistin);
qsort(essidlistin, essidlistincount, ESSIDLIST_SIZE, sort_essidlistin);
qsort(hashlist, pmkideapolcount, HASHLIST_SIZE, sort_hashlist_by_essidlen);
if(pmkideapoloutname == NULL)
{
if(essidlistin != NULL) free(essidlistin);
return;
}
if((fh_pmkideapol = fopen(pmkideapoloutname, "a")) == NULL)
{
fprintf(stdout, "error opening file %s: %s\n", pmkideapoloutname,
strerror(errno));
free(essidlistin);
return;
}
zeiger = essidlistin;
zeigerhash = hashlist;
o = 0;
for(i = 0; i < essidlistincount; i++)
{
while(o < pmkideapolcount)
{
if((zeigerhash +o)->essidlen < (zeiger +i)->essidlen)
{
o++;
continue;
}
if((zeigerhash +o)->essidlen > (zeiger +i)->essidlen) break;
if((memcmp((zeigerhash +o)->essid, (zeiger +i)->essid, (zeigerhash +o)-
>essidlen)) > 0) break;
if((memcmp((zeigerhash +o)->essid, (zeiger +i)->essid, (zeigerhash +o)-
>essidlen)) == 0) writepmkideapolhashline(fh_pmkideapol, zeigerhash +o);
o++;
}
}
if(fh_pmkideapol != NULL) fclose(fh_pmkideapol);
if(pmkideapoloutname != NULL)
{
if(stat(pmkideapoloutname, &statinfo) == 0)
{
if(statinfo.st_size == 0) remove(pmkideapoloutname);
}
}
if(essidlistin != NULL) free(essidlistin);
return;
}
/*===========================================================================*/
static bool readpmkideapolfile(FILE *fh_pmkideapol)
{
static int len;
static int oflen;
static uint16_t essidlen;
static uint16_t noncelen;
static uint16_t eapauthlen;
static uint16_t mplen;
static hashlist_t *zeiger, *hashlistnew;
static const char wpa01[] = { "WPA*01*" };
static const char wpa02[] = { "WPA*02*" };
zeiger = hashlist;
while(1)
{
if((len = fgetline(fh_pmkideapol, PMKIDEAPOL_LINE_LEN, linein)) == -1) break;
readcount++;
if(len < 68)
{
readerrorcount++;
continue;
}
if((memcmp(&linein, &wpa01, 7) != 0) && (memcmp(&linein, &wpa02, 7) != 0))
{
readerrorcount++;
continue;
}
if((linein[39] != '*') && (linein[52] != '*') && (linein[65] != '*'))
{
readerrorcount++;
continue;
}
if(getfield(&linein[7], PMKIDEAPOL_LINE_LEN, buffer) != 16)
{
readerrorcount++;
continue;
}
memcpy(zeiger->hash, &buffer, 16);
pbkdf2count = 0;
pbkdf2readerrorcount = 0;
while(1)
{
if((len = fgetline(fh_pbkdf2, PBKDF2_LINE_LEN, linein)) == -1) break;
if(len < 76)
{
pbkdf2readerrorcount++;
continue;
}
if(linein[64] != '*')
{
pbkdf2readerrorcount++;
continue;
}
pskpos = strchr(&linein[65], ':');
if(pskpos == NULL)
{
pbkdf2readerrorcount++;
continue;
}
pskpos[0] = 0;
fprintf(stdout, "%s %s\n", &linein[65], pskpos +1);
pbkdf2count++;
}
fclose(fh_pbkdf2);
return true;
}
/*===========================================================================*/
static void showvendorlist(void)
{
static ouilist_t *zeiger;
fprintf(stdout, "\n");
for(zeiger = ouilist; zeiger < ouilist +ouicount; zeiger++) fprintf(stdout, "%02x
%02x%02x %s\n", zeiger->oui[0], zeiger->oui[1], zeiger->oui[2], zeiger->vendor);
return;
}
/*===========================================================================*/
static int isvendor(int len, char *linein)
{
static int c;
static int ret;
for(c = 7; c < len; c++)
{
if(islower((unsigned char)linein[c])) linein[c] = toupper((unsigned
char)linein[c]);
}
ret = 0;
if(filtervendorptr != NULL)
{
if(strstr(&linein[7], filtervendorptr) != NULL) ret |= TYPE_AP + TYPE_CLIENT;
}
if(filtervendorapptr != NULL)
{
if(strstr(&linein[7], filtervendorapptr) != NULL) ret |= TYPE_AP;
}
if(filtervendorclientptr != NULL)
{
if(strstr(&linein[7], filtervendorclientptr) != NULL) ret |= TYPE_CLIENT;
}
return ret;
}
/*===========================================================================*/
static void readoui(void)
{
static int len;
static uid_t uid;
static struct passwd *pwd;
static struct stat statinfo;
static ouilist_t *zeiger, *ouilistnew;
static FILE *fh_oui;
static char *vendorptr;
static const char *ouinameuser = "/.hcxtools/oui.txt";
static const char *ouinamesystemwide = "/usr/share/ieee-data/oui.txt";
static const char *ouina = "N/A";
static char ouinameuserpath[PATH_MAX +1];
static char linein[OUI_LINE_LEN +1];
usedoui = ouina;
uid = getuid();
pwd = getpwuid(uid);
if(pwd == NULL) return;
strncpy(ouinameuserpath, pwd->pw_dir, PATH_MAX -1);
strncat(ouinameuserpath, ouinameuser, PATH_MAX -1);
if(stat(ouinameuserpath, &statinfo) == 0) usedoui = ouinameuserpath;
else if(stat(ouinameuser, &statinfo) == 0) usedoui = ouinamesystemwide;
else return;
if((fh_oui = fopen(usedoui, "r")) == NULL) return;
zeiger = ouilist;
while(1)
{
if((len = fgetline(fh_oui, OUI_LINE_LEN, linein)) == -1) break;
if(len < 20) continue;
linein[6] = 0;
if(getfield(linein, OUI_LINE_LEN, zeiger->oui) != 3) continue;
if(strstr(&linein[7], "(base 16)") == NULL) continue;
zeiger->type = 0;
if((filtervendorptr != NULL) || (filtervendorapptr != NULL) ||
(filtervendorclientptr != NULL))
{
zeiger->type = isvendor(len, linein);
if(zeiger->type == 0) continue;
}
vendorptr = strrchr(&linein[7], '\t');
if(vendorptr == NULL) continue;
if(vendorptr++ == 0) continue;
strncpy(zeiger->vendor, vendorptr, VENDOR_LEN_MAX -1);
ouicount++;
if(ouicount >= ouilistcount)
{
ouilistcount += OUILIST_MAX;
ouilistnew = (ouilist_t*)realloc(ouilist, ouilistcount *OUILIST_SIZE);
if(ouilistnew == NULL)
{
fprintf(stderr, "failed to allocate memory for internal list\n");
exit(EXIT_FAILURE);
}
ouilist = ouilistnew;
}
zeiger = ouilist +ouicount;
}
fclose(fh_oui);
qsort(ouilist, ouicount, OUILIST_SIZE, sort_ouilist_by_oui);
return;
}
/*===========================================================================*/
static void downloadoui(void)
{
static uid_t uid;
static size_t bread;
static struct passwd *pwd;
static CURLcode ret;
static CURL *hnd;
static FILE *fhoui;
static FILE *fhouitmp;
static struct stat statinfo;
static const char *ouipath = "/.hcxtools";
static const char *ouiname = "/oui.txt";
static char ouinameuserpath[PATH_MAX];
static char ouibuff[OUIBUFFER_MAX];
uid = getuid();
pwd = getpwuid(uid);
if(pwd == NULL) return;
strncpy(ouinameuserpath, pwd->pw_dir, PATH_MAX -1);
strncat(ouinameuserpath, ouipath, PATH_MAX -1);
if(stat(ouinameuserpath, &statinfo) == -1)
{
if(mkdir(ouinameuserpath, 0755) == -1)
{
fprintf(stderr, "failed to create conf dir\n");
return;
}
}
strncat(ouinameuserpath, ouiname, PATH_MAX -1);
fprintf(stdout, "start downloading oui from https://standards-oui.ieee.org to: %s\
n", ouinameuserpath);
if((fhouitmp = tmpfile()) == NULL)
{
fprintf(stderr, "\nfailed to create temporary download file\n");
return;
}
hnd = curl_easy_init ();
curl_easy_setopt(hnd, CURLOPT_URL, "https://standards-oui.ieee.org/oui/oui.txt");
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 5L);
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, fhouitmp) ;
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 0L);
ret = curl_easy_perform(hnd);
curl_easy_cleanup(hnd);
if(ret != 0)
{
fprintf(stderr, "\ndownload not successful\n");
return;
}
rewind(fhouitmp);
if((fhoui = fopen(ouinameuserpath, "w")) == NULL)
{
fprintf(stderr, "\nfailed to create %s\n", ouiname);
return;
}
while (!feof(fhouitmp))
{
bread = fread(ouibuff, 1, sizeof(ouibuff), fhouitmp);
if(bread > 0) fwrite(ouibuff, 1, bread, fhoui);
}
fclose(fhoui);
fprintf(stdout, "\ndownload finished\n");
return;
}
/*===========================================================================*/
__attribute__ ((noreturn))
static void version(char *eigenname)
{
fprintf(stdout, "%s %s (C) %s ZeroBeat\n", eigenname, VERSION_TAG, VERSION_YEAR);
exit(EXIT_SUCCESS);
}
/*---------------------------------------------------------------------------*/
__attribute__ ((noreturn))
static void usage(char *eigenname)
{
fprintf(stdout, "%s %s (C) %s ZeroBeat\n"
"usage:\n"
"%s <options>\n"
"\n"
"options:\n"
"-i <file> : input PMKID/EAPOL hash file\n"
"-o <file> : output PMKID/EAPOL hash file\n"
"-E <file> : output ESSID list (autohex enabled)\n"
"-E stdout : output ESSID list to stdout (autohex enabled)\n"
"-L <file> : output ESSID list (unfiltered and unsorted)\n"
" useful in combination with hashcat -a9 option\n"
"-d : download https://standards-oui.ieee.org/oui.txt\n"
" and save to ~/.hcxtools/oui.txt\n"
" internet connection required\n"
// "-p : input PBKDF2 file (hashcat potfile 22000 format)\n"
"-h : show this help\n"
"-v : show version\n"
"\n"
"--essid-group : convert to ESSID groups in working directory\
n"
" full advantage of reuse of PBKDF2\n"
" not on old hash formats\n"
"--oui-group : convert to OUI groups in working directory\n"
" not on old hash formats\n"
"--mac-group-ap : convert APs to MAC groups in working
directory\n"
" not on old hash formats\n"
"--mac-group-client : convert CLIENTs to MAC groups in working
directory\n"
" not on old hash formats\n"
"--type=<digit> : filter by hash type\n"
" bitmask:\n"
" 1 = PMKID\n"
" 2 = EAPOL\n"
" default PMKID and EAPOL (1+2=3)\n"
"--hcx-min=<digit> : disregard hashes with occurrence lower than
hcx-min/ESSID\n"
"--hcx-max=<digit> : disregard hashes with occurrence higher than
hcx-max/ESSID\n"
"--essid-len : filter by ESSID length\n"
" default ESSID length: %d...%d\n"
"--essid-min : filter by ESSID minimum length\n"
" default ESSID minimum length: %d\n"
"--essid-max : filter by ESSID maximum length\n"
" default ESSID maximum length: %d\n"
"--essid=<ESSID> : filter by ESSID\n"
"--essid-part=<part of ESSID> : filter by part of ESSID (case sensitive)\n"
"--essid-partx=<part of ESSID>: filter by part of ESSID (case insensitive)\n"
" locale and wide characters are ignored\n"
"--essid-list=<file> : filter by ESSID file\n"
"--mac-ap=<MAC> : filter AP by MAC\n"
" format: 001122334455, 00:11:22:33:44:55, 00-
11-22-33-44-55 (hex)\n"
"--mac-client=<MAC> : filter CLIENT by MAC\n"
" format: 001122334455, 00:11:22:33:44:55, 00-
11-22-33-44-55 (hex)\n"
"--mac-list=<file> : filter by MAC file\n"
" format: 001122334455, 00:11:22:33:44:55, 00-
11-22-33-44-55 (hex)\n"
"--mac-skiplist=<file> : exclude MAC from file\n"
" format: 001122334455, 00:11:22:33:44:55, 00-
11-22-33-44-55 (hex)\n"
"--oui-ap=<OUI> : filter AP by OUI\n"
" format: 001122, 00:11:22, 00-11-22 (hex)\n"
"--oui-client=<OUI> : filter CLIENT by OUI\n"
" format: 001122, 00:11:22, 00-11-22 (hex)\n"
"--vendor=<VENDOR> : filter AP or CLIENT by (part of) VENDOR name\
n"
"--vendor-ap=<VENDOR> : filter AP by (part of) VENDOR name\n"
"--vendor-client=<VENDOR> : filter CLIENT by (part of) VENDOR name\n",
eigenname, VERSION_TAG, VERSION_YEAR, eigenname, ESSID_LEN_MIN,
ESSID_LEN_MAX, ESSID_LEN_MIN, ESSID_LEN_MAX);
auswahl = -1;
index = 0;
optind = 1;
optopt = 0;
pbkdf2inname = NULL;
fh_pmkideapol = NULL;
pmkideapolinname = NULL;
pmkideapoloutname = NULL;
essidoutname = NULL;
essidrawoutname = NULL;
essidinname = NULL;
macinname = NULL;
macskipname = NULL;
infooutname = NULL;
infovendoroutname = NULL;
infovendorapoutname = NULL;
infovendorclientoutname = NULL;
hccapxoutname = NULL;
hccapoutname = NULL;
johnoutname = NULL;
ouiinstring = NULL;
macinstring = NULL;
pmkinstring = NULL;
filteressidptr = NULL;
filteressidpartptr = NULL;
filtervendorptr = NULL;
filtervendorapptr = NULL;
filtervendorclientptr = NULL;
flagfiltermacap = false;
flagfiltermacclient = false;
flagfilterouiap = false;
flagfilterouiclient = false;
flagfilterauthorized = false;
flagfilterchallenge = false;
flagfilterrcchecked = false;
flagfilterrcnotchecked = false;
flagfilterapless = false;
flagpsk = false;
flagpmk = false;
flagessidgroup = false;
flagmacapgroup = false;
flagmacclientgroup = false;
flagouigroup = false;
flagvendorout = false;
flaghccapsingleout = false;
caseflag = false;
hashtypein = 0;
hashtype = HCX_TYPE_PMKID | HCX_TYPE_EAPOL;
essidlenin = ESSID_LEN_MAX;
essidlen = ESSID_LEN_MAX;
essidlenmin = ESSID_LEN_MIN;
essidlenmax = ESSID_LEN_MAX;
lcmin = 0;
lcmax = 0;
statusflag = true;
case HCX_PMKIDEAPOL_OUT:
pmkideapoloutname = optarg;
break;
case HCX_ESSID_OUT:
essidoutname = optarg;
break;
case HCX_ESSID_RAW_OUT:
essidrawoutname = optarg;
break;
case HCX_VENDOR_OUT:
flagvendorout = true;
break;
case HCX_INFO_OUT:
infooutname = optarg;
break;
case HCX_INFO_VENDOR_OUT:
infovendoroutname = optarg;
break;
case HCX_INFO_VENDOR_AP_OUT:
infovendorapoutname = optarg;
break;
case HCX_INFO_VENDOR_CLIENT_OUT:
infovendorclientoutname = optarg;
break;
case HCX_ESSID_GROUP:
flagessidgroup = true;
break;
case HCX_HASH_TYPE:
hashtypein |= strtol(optarg, NULL, 10);
if((hashtypein < HCX_TYPE_PMKID) || (hashtypein > (HCX_TYPE_PMKID +
HCX_TYPE_EAPOL)))
{
fprintf(stderr, "only hash types 1 and 2 allowed (values 1, 2 or
3)\n");
exit(EXIT_FAILURE);
}
break;
case HCX_ESSID_LEN:
essidlenin = strtol(optarg, NULL, 10);
if((essidlenin < 0) || (essidlenin > ESSID_LEN_MAX))
{
fprintf(stderr, "only values 0...32 allowed\n");
exit(EXIT_FAILURE);
}
essidlenmin = essidlenin;
essidlenmax = essidlenin;
break;
case HCX_ESSID_MIN:
essidlenin = strtol(optarg, NULL, 10);
if((essidlenin < 0) || (essidlenin > ESSID_LEN_MAX))
{
fprintf(stderr, "only values 0...32 allowed\n");
exit(EXIT_FAILURE);
}
essidlenmin = essidlenin;
break;
case HCX_ESSID_MAX:
essidlenin = strtol(optarg, NULL, 10);
if((essidlenin < 0) || (essidlenin > ESSID_LEN_MAX))
{
fprintf(stderr, "only values 0...32 allowed\n");
exit(EXIT_FAILURE);
}
essidlenmax = essidlenin;
break;
case HCX_FILTER_ESSID:
filteressidptr = optarg;
filteressidlen = strlen(filteressidptr);
if((filteressidlen < 1) || (filteressidlen > ESSID_LEN_MAX))
{
fprintf(stderr, "only values 0...32 allowed\n");
exit(EXIT_FAILURE);
}
break;
case HCX_FILTER_ESSID_PART:
filteressidpartptr = optarg;
filteressidpartlen = strlen(filteressidpartptr);
if((filteressidpartlen < 1) || (filteressidpartlen > ESSID_LEN_MAX))
{
fprintf(stderr, "only values 0...32 allowed\n");
exit(EXIT_FAILURE);
}
caseflag = false;
break;
case HCX_FILTER_ESSID_PARTX:
filteressidpartptr = optarg;
filteressidpartlen = strlen(filteressidpartptr);
if((filteressidpartlen < 1) || (filteressidpartlen > ESSID_LEN_MAX))
{
fprintf(stderr, "only values 0...32 allowed\n");
exit(EXIT_FAILURE);
}
caseflag = true;
break;
case HCX_FILTER_ESSID_LIST_IN:
essidinname = optarg;
break;
case HCX_HASH_MIN:
lcmin = strtol(optarg, NULL, 10);
break;
case HCX_HASH_MAX:
lcmax = strtol(optarg, NULL, 10);
break;
case HCX_MAC_GROUP_AP:
flagmacapgroup = true;
break;
case HCX_MAC_GROUP_CLIENT:
flagmacclientgroup = true;
break;
case HCX_OUI_GROUP:
flagouigroup = true;
break;
case HCX_FILTER_OUI_AP:
l= strlen(optarg);
p2 = 0;
for(p1 = 0; p1 < l; p1++)
{
if(isxdigit((unsigned char)optarg[p1]))
{
optarg[p2] = optarg[p1];
p2++;
}
}
optarg[6] = 0;
ouiinstring = optarg;
if(getfield(ouiinstring, 3, filterouiap) != 3)
{
fprintf(stderr, "wrong OUI format\n");
exit(EXIT_FAILURE);
}
flagfilterouiap = true;
break;
case HCX_FILTER_MAC_AP:
l= strlen(optarg);
p2 = 0;
for(p1 = 0; p1 < l; p1++)
{
if(isxdigit((unsigned char)optarg[p1]))
{
optarg[p2] = optarg[p1];
p2++;
}
}
optarg[12] = 0;
macinstring = optarg;
if(getfield(macinstring, 6, filtermacap) != 6)
{
fprintf(stderr, "wrong MAC format $\n");
exit(EXIT_FAILURE);
}
flagfiltermacap = true;
break;
case HCX_FILTER_MAC_CLIENT:
l= strlen(optarg);
p2 = 0;
for(p1 = 0; p1 < l; p1++)
{
if(isxdigit((unsigned char)optarg[p1]))
{
optarg[p2] = optarg[p1];
p2++;
}
}
optarg[12] = 0;
macinstring = optarg;
if(getfield(macinstring, 6, filtermacclient) != 6)
{
fprintf(stderr, "wrong MAC format\n");
exit(EXIT_FAILURE);
}
flagfiltermacclient = true;
break;
case HCX_FILTER_MAC_LIST_IN:
macinname = optarg;
break;
case HCX_FILTER_MAC_LIST_SKIP:
macskipname = optarg;
break;
case HCX_FILTER_OUI_CLIENT:
l= strlen(optarg);
p2 = 0;
for(p1 = 0; p1 < l; p1++)
{
if(isxdigit((unsigned char)optarg[p1]))
{
optarg[p2] = optarg[p1];
p2++;
}
}
optarg[6] = 0;
ouiinstring = optarg;
if(getfield(ouiinstring, 3, filterouiclient) != 3)
{
fprintf(stderr, "wrong OUI format\n");
exit(EXIT_FAILURE);
}
flagfilterouiclient = true;
break;
case HCX_FILTER_VENDOR:
filtervendorptr = optarg;
l = strlen(filtervendorptr);
if(l < 3)
{
fprintf(stderr, "at least three characters of the VENDOR name are
mandatory\n");
exit(EXIT_FAILURE);
}
for(p1 = 0; p1 < l; p1++)
{
if(islower((unsigned char)filtervendorptr[p1]))
filtervendorptr[p1] = toupper((unsigned char)filtervendorptr[p1]);
}
break;
case HCX_FILTER_VENDOR_AP:
filtervendorapptr = optarg;
l = strlen(filtervendorapptr);
if(l < 3)
{
fprintf(stderr, "at least three characters of the VENDOR name are
mandatory\n");
exit(EXIT_FAILURE);
}
for(p1 = 0; p1 < l; p1++)
{
if(islower((unsigned char)filtervendorapptr[p1]))
filtervendorapptr[p1] = toupper((unsigned char)filtervendorapptr[p1]);
}
break;
case HCX_FILTER_VENDOR_CLIENT:
filtervendorclientptr = optarg;
l = strlen(filtervendorclientptr);
if(l < 3)
{
fprintf(stderr, "at least three characters of the VENDOR name are
mandatory\n");
exit(EXIT_FAILURE);
}
for(p1 = 0; p1 < l; p1++)
{
if(islower((unsigned char)filtervendorclientptr[p1]))
filtervendorclientptr[p1] = toupper((unsigned char)filtervendorclientptr[p1]);
}
break;
case HCX_FILTER_RC:
flagfilterrcchecked = true;
break;
case HCX_FILTER_RC_NOT:
flagfilterrcnotchecked = true;
break;
case HCX_FILTER_M12:
flagfilterauthorized = true;
break;
case HCX_FILTER_M1234:
flagfilterchallenge = true;
break;
case HCX_FILTER_M1M2ROGUE:
flagfilterapless = true;
break;
case HCX_PSK:
pskptr = optarg;
pskptrlen = strlen(pskptr);
if((pskptrlen < 0) || (pskptrlen > 63))
{
fprintf(stderr, "only 0...63 characters allowed\n");
exit(EXIT_FAILURE);
}
flagpsk = true;
break;
case HCX_PMK:
pmkinstring = optarg;
if(getfield(pmkinstring, 32, pmk) != 32)
{
fprintf(stderr, "wrong PMK length \n");
exit(EXIT_FAILURE);
}
flagpmk = true;
break;
case HCX_DOWNLOAD_OUI:
downloadoui();
break;
case HCX_PBKDF2_IN:
// pbkdf2inname = optarg;
break;
case HCX_HCCAPX_OUT:
hccapxoutname = optarg;
break;
case HCX_HCCAP_OUT:
hccapoutname = optarg;
break;
case HCX_HCCAP_SINGLE_OUT:
flaghccapsingleout = true;
break;
case HCX_JOHN_OUT:
johnoutname = optarg;
break;
case HCX_HELP:
usage(basename(argv[0]));
break;
case HCX_VERSION:
version(basename(argv[0]));
break;
case '?':
usageerror(basename(argv[0]));
break;
}
}
if(argc < 2)
{
fprintf(stderr, "no option selected\n");
return EXIT_SUCCESS;
}
if(pmkideapolcount == 0)
{
fprintf(stdout, "no hashes loaded\n");
if(fh_pmkideapol != NULL) fclose(fh_pmkideapol);
closelists();
return EXIT_SUCCESS;
}
if(essidrawoutname != 0) processessidraw(essidrawoutname);
if(infooutname != NULL)
{
writeinfofile(infooutname);
if(fh_pmkideapol != NULL) fclose(fh_pmkideapol);
closelists();
return EXIT_SUCCESS;
}
if(infovendoroutname != NULL)
{
writevendorapinfofile(infovendoroutname);
writevendorclientinfofile(infovendoroutname);
if(fh_pmkideapol != NULL) fclose(fh_pmkideapol);
closelists();
return EXIT_SUCCESS;
}
else if(infovendorapoutname != NULL)
{
writevendorapinfofile(infovendorapoutname);
if(fh_pmkideapol != NULL) fclose(fh_pmkideapol);
closelists();
return EXIT_SUCCESS;
}
else if(infovendorclientoutname != NULL)
{
writevendorclientinfofile(infovendorclientoutname);
if(fh_pmkideapol != NULL) fclose(fh_pmkideapol);
closelists();
return EXIT_SUCCESS;
}