@@ -52,7 +52,6 @@ static unsigned long long int johnskipped;
5252/*===========================================================================*/
5353static void globalinit (void )
5454{
55-
5655srand (time (NULL ));
5756gettimeofday (& tv , NULL );
5857timestamp = ((uint64_t )tv .tv_sec * 1000000 ) + tv .tv_usec ;
@@ -92,13 +91,13 @@ static const uint8_t m1wpa1data[] =
92910x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
93920x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
94930x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
95- 0x00 , 0x00 ,
94+ 0x00 , 0x00
9695};
9796#define M1WPA1DATA_SIZE sizeof(m1wpa1data)
9897
99- static uint8_t packetout [0xff ];
98+ static uint8_t packetout [PACKETOUTBUFFSMAX ];
10099
101- memset (& packetout , 0 , 0xff );
100+ memset (& packetout , 0 , PACKETOUTBUFFSMAX );
102101pcaph = (pcaprec_hdr_t * )packetout ;
103102pcaph -> ts_sec = timestamp /1000000 ;
104103pcaph -> ts_usec = timestamp %1000000 ;
@@ -117,14 +116,8 @@ rc = byte_swap_64(rc);
117116#endif
118117wpak -> keylen = keylen ;
119118wpak -> replaycount = rc ;
120- for (c = 0 ; c < 32 ; c ++ )
121- {
122- packetout [PCAPREC_SIZE + 0x33 + c ] = anonce [c ];
123- }
124- if (write (fd_cap , packetout , PCAPREC_SIZE + M1WPA1DATA_SIZE ) < 0 )
125- {
126- perror ("\nfailed to write EAPOL packet" );
127- }
119+ for (c = 0 ; c < 32 ; c ++ ) packetout [PCAPREC_SIZE + 0x33 + c ] = anonce [c ];
120+ if (write (fd_cap , packetout , PCAPREC_SIZE + M1WPA1DATA_SIZE ) < 0 ) perror ("\nfailed to write EAPOL packet" );
128121return ;
129122}
130123/*===========================================================================*/
@@ -151,13 +144,13 @@ static const uint8_t m1wpa2data[] =
1511440x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
1521450x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
1531460x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
154- 0x00 , 0x00 ,
147+ 0x00 , 0x00
155148};
156149#define M1WPA2DATA_SIZE sizeof(m1wpa2data)
157150
158- static uint8_t packetout [0xff ];
151+ static uint8_t packetout [PACKETOUTBUFFSMAX ];
159152
160- memset (& packetout , 0 , 0xff );
153+ memset (& packetout , 0 , PACKETOUTBUFFSMAX );
161154pcaph = (pcaprec_hdr_t * )packetout ;
162155pcaph -> ts_sec = timestamp /1000000 ;
163156pcaph -> ts_usec = timestamp %1000000 ;
@@ -177,14 +170,8 @@ rc = byte_swap_64(rc);
177170#endif
178171wpak -> keylen = keylen ;
179172wpak -> replaycount = rc ;
180- for (c = 0 ; c < 32 ; c ++ )
181- {
182- packetout [PCAPREC_SIZE + 0x33 + c ] = anonce [c ];
183- }
184- if (write (fd_cap , packetout , PCAPREC_SIZE + M1WPA2DATA_SIZE ) < 0 )
185- {
186- perror ("\nfailed to write EAPOL packet" );
187- }
173+ for (c = 0 ; c < 32 ; c ++ ) packetout [PCAPREC_SIZE + 0x33 + c ] = anonce [c ];
174+ if (write (fd_cap , packetout , PCAPREC_SIZE + M1WPA2DATA_SIZE ) < 0 ) perror ("\nfailed to write EAPOL packet" );
188175return ;
189176}
190177/*===========================================================================*/
@@ -215,9 +202,9 @@ static const uint8_t m1wpa2keyver3data[] =
215202};
216203#define M1WPA2KEYVER3DATA_SIZE sizeof(m1wpa2keyver3data)
217204
218- static uint8_t packetout [0xff ];
205+ static uint8_t packetout [PACKETOUTBUFFSMAX ];
219206
220- memset (& packetout , 0 , 0xff );
207+ memset (& packetout , 0 , PACKETOUTBUFFSMAX );
221208pcaph = (pcaprec_hdr_t * )packetout ;
222209pcaph -> ts_sec = timestamp /1000000 ;
223210pcaph -> ts_usec = timestamp %1000000 ;
@@ -236,14 +223,8 @@ rc = byte_swap_64(rc);
236223#endif
237224wpak -> keylen = keylen ;
238225wpak -> replaycount = rc ;
239- for (c = 0 ; c < 32 ; c ++ )
240- {
241- packetout [PCAPREC_SIZE + 0x33 + c ] = anonce [c ];
242- }
243- if (write (fd_cap , packetout , PCAPREC_SIZE + M1WPA2KEYVER3DATA_SIZE ) < 0 )
244- {
245- perror ("\nfailed to write EAPOL packet" );
246- }
226+ for (c = 0 ; c < 32 ; c ++ ) packetout [PCAPREC_SIZE + 0x33 + c ] = anonce [c ];
227+ if (write (fd_cap , packetout , PCAPREC_SIZE + M1WPA2KEYVER3DATA_SIZE ) < 0 ) perror ("\nfailed to write EAPOL packet" );
247228return ;
248229}
249230/*===========================================================================*/
@@ -273,9 +254,9 @@ static const uint8_t pmkiddata[] =
273254};
274255#define PMKIDDATA_SIZE sizeof(pmkiddata)
275256
276- static uint8_t packetout [0xff ];
257+ static uint8_t packetout [PACKETOUTBUFFSMAX ];
277258
278- memset (& packetout , 0 , 0xff );
259+ memset (& packetout , 0 , PACKETOUTBUFFSMAX );
279260pcaph = (pcaprec_hdr_t * )packetout ;
280261pcaph -> ts_sec = timestamp /1000000 ;
281262pcaph -> ts_usec = timestamp %1000000 ;
@@ -288,10 +269,7 @@ memcpy(mach->addr1, macsta, 6);
288269memcpy (mach -> addr2 , macap , 6 );
289270memcpy (mach -> addr3 , macap , 6 );
290271memcpy (& packetout [PCAPREC_SIZE + 0x8b ], pmkid , 16 );
291- if (write (fd_cap , packetout , PCAPREC_SIZE + PMKIDDATA_SIZE ) < 0 )
292- {
293- perror ("\nfailed to write EAPOL packet" );
294- }
272+ if (write (fd_cap , packetout , PCAPREC_SIZE + PMKIDDATA_SIZE ) < 0 ) perror ("\nfailed to write EAPOL packet" );
295273return ;
296274}
297275/*===========================================================================*/
@@ -311,9 +289,9 @@ static const uint8_t m2data[] =
311289};
312290#define M2DATA_SIZE sizeof(m2data)
313291
314- static uint8_t packetout [0xff ];
292+ static uint8_t packetout [PACKETOUTBUFFSMAX ];
315293
316- memset (& packetout , 0 , 0xff );
294+ memset (& packetout , 0 , PACKETOUTBUFFSMAX );
317295pcaph = (pcaprec_hdr_t * )packetout ;
318296pcaph -> ts_sec = timestamp /1000000 ;
319297pcaph -> ts_usec = timestamp %1000000 ;
@@ -327,10 +305,7 @@ memcpy(mach->addr2, macsta, 6);
327305memcpy (mach -> addr3 , macap , 6 );
328306memcpy (& packetout [PCAPREC_SIZE + M2DATA_SIZE ], eapol , eapollen );
329307memcpy (& packetout [PCAPREC_SIZE + M2DATA_SIZE + 0x51 ], mic , 16 );
330- if (write (fd_cap , packetout , PCAPREC_SIZE + M2DATA_SIZE + eapollen ) < 0 )
331- {
332- perror ("\nfailed to write EAPOL packet" );
333- }
308+ if (write (fd_cap , packetout , PCAPREC_SIZE + M2DATA_SIZE + eapollen ) < 0 ) perror ("\nfailed to write EAPOL packet" );
334309return ;
335310}
336311/*===========================================================================*/
@@ -351,9 +326,9 @@ static const uint8_t beacondata[] =
351326};
352327#define BEACONDATA_SIZE sizeof(beacondata)
353328
354- static uint8_t packetout [0xff ];
329+ static uint8_t packetout [PACKETOUTBUFFSMAX ];
355330
356- memset (& packetout , 0 , 0xff );
331+ memset (& packetout , 0 , PACKETOUTBUFFSMAX );
357332pcaph = (pcaprec_hdr_t * )packetout ;
358333pcaph -> ts_sec = timestamp /1000000 ;
359334pcaph -> ts_usec = timestamp %1000000 ;
@@ -367,10 +342,7 @@ memcpy(mach->addr1, &mac_broadcast, 6);
367342memcpy (mach -> addr2 , macap , 6 );
368343memcpy (mach -> addr3 , macap , 6 );
369344mach -> sequence = mybeaconsequence ++ << 4 ;
370- if (mybeaconsequence >= 4096 )
371- {
372- mybeaconsequence = 0 ;
373- }
345+ if (mybeaconsequence >= 4096 ) mybeaconsequence = 0 ;
374346capap = (capap_t * )(packetout + PCAPREC_SIZE + MAC_SIZE_NORM );
375347capap -> timestamp = myaponlinetime ++ ;
376348capap -> beaconintervall = 0x64 ;
@@ -379,10 +351,7 @@ packetout[PCAPREC_SIZE +MAC_SIZE_NORM +CAPABILITIESAP_SIZE +1] = essidlen;
379351memcpy (& packetout [PCAPREC_SIZE + MAC_SIZE_NORM + CAPABILITIESAP_SIZE + 2 ], essid , essidlen );
380352memcpy (& packetout [PCAPREC_SIZE + MAC_SIZE_NORM + CAPABILITIESAP_SIZE + 2 + essidlen ], & beacondata , BEACONDATA_SIZE );
381353packetout [PCAPREC_SIZE + MAC_SIZE_NORM + CAPABILITIESAP_SIZE + 2 + essidlen + 0x0c ] = myapchannel ;
382- if (write (fd_cap , packetout , PCAPREC_SIZE + MAC_SIZE_NORM + CAPABILITIESAP_SIZE + 2 + essidlen + BEACONDATA_SIZE ) < 0 )
383- {
384- perror ("\nfailed to write beacon packet" );
385- }
354+ if (write (fd_cap , packetout , PCAPREC_SIZE + MAC_SIZE_NORM + CAPABILITIESAP_SIZE + 2 + essidlen + BEACONDATA_SIZE ) < 0 ) perror ("\nfailed to write beacon packet" );
386355return ;
387356}
388357/*===========================================================================*/
@@ -403,9 +372,9 @@ static const uint8_t beacondata[] =
403372};
404373#define BEACONDATA_SIZE sizeof(beacondata)
405374
406- static uint8_t packetout [0xff ];
375+ static uint8_t packetout [PACKETOUTBUFFSMAX ];
407376
408- memset (& packetout , 0 , 0xff );
377+ memset (& packetout , 0 , PACKETOUTBUFFSMAX );
409378pcaph = (pcaprec_hdr_t * )packetout ;
410379pcaph -> ts_sec = timestamp /1000000 ;
411380pcaph -> ts_usec = timestamp %1000000 ;
@@ -419,10 +388,7 @@ memcpy(mach->addr1, &mac_broadcast, 6);
419388memcpy (mach -> addr2 , macap , 6 );
420389memcpy (mach -> addr3 , macap , 6 );
421390mach -> sequence = mybeaconsequence ++ << 4 ;
422- if (mybeaconsequence >= 4096 )
423- {
424- mybeaconsequence = 0 ;
425- }
391+ if (mybeaconsequence >= 4096 ) mybeaconsequence = 0 ;
426392capap = (capap_t * )(packetout + PCAPREC_SIZE + MAC_SIZE_NORM );
427393capap -> timestamp = myaponlinetime ++ ;
428394capap -> beaconintervall = 0x64 ;
@@ -431,10 +397,7 @@ packetout[PCAPREC_SIZE +MAC_SIZE_NORM +CAPABILITIESAP_SIZE +1] = essidlen;
431397memcpy (& packetout [PCAPREC_SIZE + MAC_SIZE_NORM + CAPABILITIESAP_SIZE + 2 ], essid , essidlen );
432398memcpy (& packetout [PCAPREC_SIZE + MAC_SIZE_NORM + CAPABILITIESAP_SIZE + 2 + essidlen ], & beacondata , BEACONDATA_SIZE );
433399packetout [PCAPREC_SIZE + MAC_SIZE_NORM + CAPABILITIESAP_SIZE + 2 + essidlen + 0x0c ] = myapchannel ;
434- if (write (fd_cap , packetout , PCAPREC_SIZE + MAC_SIZE_NORM + CAPABILITIESAP_SIZE + 2 + essidlen + BEACONDATA_SIZE ) < 0 )
435- {
436- perror ("\nfailed to write beacon packet" );
437- }
400+ if (write (fd_cap , packetout , PCAPREC_SIZE + MAC_SIZE_NORM + CAPABILITIESAP_SIZE + 2 + essidlen + BEACONDATA_SIZE ) < 0 ) perror ("\nfailed to write beacon packet" );
438401return ;
439402}
440403/*===========================================================================*/
@@ -455,9 +418,9 @@ static const uint8_t beacondata[] =
455418};
456419#define BEACONDATA_SIZE sizeof(beacondata)
457420
458- static uint8_t packetout [0xff ];
421+ static uint8_t packetout [PACKETOUTBUFFSMAX ];
459422
460- memset (& packetout , 0 , 0xff );
423+ memset (& packetout , 0 , PACKETOUTBUFFSMAX );
461424pcaph = (pcaprec_hdr_t * )packetout ;
462425pcaph -> ts_sec = timestamp /1000000 ;
463426pcaph -> ts_usec = timestamp %1000000 ;
@@ -471,10 +434,7 @@ memcpy(mach->addr1, &mac_broadcast, 6);
471434memcpy (mach -> addr2 , macap , 6 );
472435memcpy (mach -> addr3 , macap , 6 );
473436mach -> sequence = mybeaconsequence ++ << 4 ;
474- if (mybeaconsequence >= 4096 )
475- {
476- mybeaconsequence = 0 ;
477- }
437+ if (mybeaconsequence >= 4096 ) mybeaconsequence = 0 ;
478438capap = (capap_t * )(packetout + PCAPREC_SIZE + MAC_SIZE_NORM );
479439capap -> timestamp = myaponlinetime ++ ;
480440capap -> beaconintervall = 0x64 ;
@@ -483,10 +443,7 @@ packetout[PCAPREC_SIZE +MAC_SIZE_NORM +CAPABILITIESAP_SIZE +1] = essidlen;
483443memcpy (& packetout [PCAPREC_SIZE + MAC_SIZE_NORM + CAPABILITIESAP_SIZE + 2 ], essid , essidlen );
484444memcpy (& packetout [PCAPREC_SIZE + MAC_SIZE_NORM + CAPABILITIESAP_SIZE + 2 + essidlen ], & beacondata , BEACONDATA_SIZE );
485445packetout [PCAPREC_SIZE + MAC_SIZE_NORM + CAPABILITIESAP_SIZE + 2 + essidlen + 0x0c ] = myapchannel ;
486- if (write (fd_cap , packetout , PCAPREC_SIZE + MAC_SIZE_NORM + CAPABILITIESAP_SIZE + 2 + essidlen + BEACONDATA_SIZE ) < 0 )
487- {
488- perror ("\nfailed to write beacon packet" );
489- }
446+ if (write (fd_cap , packetout , PCAPREC_SIZE + MAC_SIZE_NORM + CAPABILITIESAP_SIZE + 2 + essidlen + BEACONDATA_SIZE ) < 0 ) perror ("\nfailed to write beacon packet" );
490447return ;
491448}
492449/*===========================================================================*/
@@ -771,10 +728,7 @@ if((fhpmkid = fopen(pmkidname, "r")) == NULL)
771728 }
772729while (1 )
773730 {
774- if ((len = fgetline (fhpmkid , PMKID_LINE_LEN , linein )) == -1 )
775- {
776- break ;
777- }
731+ if ((len = fgetline (fhpmkid , PMKID_LINE_LEN , linein )) == -1 ) break ;
778732 if ((len < 61 ) || ((len > 59 + (ESSID_LEN_MAX * 2 ))))
779733 {
780734 fprintf (stderr , "reading hash line %d failed: %s\n" , aktread , linein );
@@ -935,10 +889,7 @@ while(fread(&hcxdata, HCCAPX_SIZE, 1, fhhcx) == 1)
935889 #ifdef BIG_ENDIAN_HOST
936890 rc = byte_swap_64 (rc );
937891 #endif
938- if (keyinfo == 4 )
939- {
940- rc -- ;
941- }
892+ if (keyinfo == 4 ) rc -- ;
942893 if (fd_cap == 0 )
943894 {
944895 snprintf (singlecapname , 18 , "%02x%02x%02x%02x%02x%02x.cap" , hcxptr -> mac_sta [0 ], hcxptr -> mac_sta [1 ], hcxptr -> mac_sta [2 ], hcxptr -> mac_sta [3 ], hcxptr -> mac_sta [4 ], hcxptr -> mac_sta [5 ]);
0 commit comments