Skip to content

Commit

Permalink
speed improvement on automatic NC
Browse files Browse the repository at this point in the history
  • Loading branch information
ZerBea committed Apr 3, 2020
1 parent 8026f88 commit 12247ac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
20 changes: 15 additions & 5 deletions hcxpcapngtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -1501,8 +1501,9 @@ for(c = 0; c < 20; c ++)
if(zeiger->eapauthlen != handshakelistptr->eapauthlen) continue;
if(memcmp(zeiger->eapol, handshakelistptr->eapol, handshakelistptr->eapauthlen) != 0) continue;
if(zeiger->timestampgap > handshakelistptr->timestampgap) zeiger->timestampgap = handshakelistptr->timestampgap;
if(zeiger->rcgap > handshakelistptr->rcgap) zeiger->rcgap = handshakelistptr->rcgap;
if(zeiger->rcgap > handshakelistptr->rcgap) zeiger->rcgap = (zeiger->rcgap &0xe0) | handshakelistptr->rcgap;
if(zeiger->status < handshakelistptr->status) zeiger->status = handshakelistptr->status;

zeiger->messageap |= handshakelistptr->messageap;
zeiger->messageclient |= handshakelistptr->messageclient;
return true;
Expand All @@ -1518,7 +1519,10 @@ static messagelist_t *zeiger;
eapolmpcount++;
for(zeiger = messagelist; zeiger < messagelist +MESSAGELIST_MAX; zeiger++)
{
if(memcmp(msgap->ap, zeiger->ap, 6) == 0) mpfield |= zeiger->status;
if(((zeiger->status &ST_APLESS) != ST_APLESS) && ((mpfield &ST_APLESS) != ST_APLESS))
{
if(memcmp(msgap->ap, zeiger->ap, 6) == 0) mpfield |= zeiger->status;
}
}
if(msgap->timestamp == msgclient->timestamp) eapolmsgtimestamperrorcount++;
if(testeapolzeropmk(keyver, msgclient->client, msgap->ap, msgap->nonce, msgclient->eapauthlen, msgclient->eapol) == false)
Expand Down Expand Up @@ -2427,9 +2431,9 @@ for(zeiger = messagelist; zeiger < messagelist +MESSAGELIST_MAX; zeiger++)
if(eaptimegap > eaptimegapmax) eaptimegapmax = eaptimegap;
if(eaptimegap <= eapoltimeoutvalue) addhandshake(eaptimegap, rcgap, messagelist +MESSAGELIST_MAX, zeiger, keyver, mpfield);
}
if((zeiger->message &HS_M3) != HS_M3) continue;
if(memcmp(zeiger->client, macclient, 6) != 0) continue;
if(memcmp(zeiger->ap, macap, 6) != 0) continue;
if((zeiger->message &HS_M3) != HS_M3) continue;
if(zeiger->rc >= rc +1) rcgap = zeiger->rc -rc -1;
else rcgap = rc +1 -zeiger->rc;
if(rc != myaktreplaycount)
Expand Down Expand Up @@ -2513,6 +2517,14 @@ memcpy(zeiger->ap, macap, 6);
zeiger->message = HS_M1;
zeiger->rc = rc;
memcpy(zeiger->nonce, wpak->nonce, 32);

if((zeiger->rc == myaktreplaycount) && (memcmp(&myaktanonce, zeiger->nonce, 32) == 0))
{
zeiger->status |= ST_APLESS;
eapolm1ancount++;
qsort(messagelist, MESSAGELIST_MAX +1, MESSAGELIST_SIZE, sort_messagelist_by_epcount);
return;
}
if(authlen >= (int)(WPAKEY_SIZE +PMKID_SIZE))
{
pmkid = (pmkid_t*)(wpakptr +WPAKEY_SIZE);
Expand Down Expand Up @@ -2565,9 +2577,7 @@ return;
/*===========================================================================*/
static void process80211rc4key()
{

eapolrc4count++;

return;
}
/*===========================================================================*/
Expand Down
4 changes: 2 additions & 2 deletions include/hcxpcapngtool.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ struct messagelist_s
#define HS_M3 4
#define HS_M4 8
#define HS_PMKID 16
unsigned long long int rc;
uint64_t rc;
uint8_t nonce[32];
uint8_t pmkid[16];
uint16_t eapauthlen;
Expand All @@ -221,7 +221,7 @@ struct handshakelist_s
uint8_t status;
uint8_t messageap;
uint8_t messageclient;
unsigned long long int rcgap;
uint64_t rcgap;
uint8_t nc;
uint8_t ap[6];
uint8_t client[6];
Expand Down

0 comments on commit 12247ac

Please sign in to comment.