mirror of
https://github.com/wiire-a/pixiewps.git
synced 2025-07-30 17:25:27 +02:00
parent
150f8d9db2
commit
03da4adea5
@ -24,9 +24,9 @@
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "pixiewps.h"
|
||||
@ -80,7 +80,7 @@ memory_err:
|
||||
}
|
||||
|
||||
time_t start_p = (time_t) -1, end_p = (time_t) -1;
|
||||
clock_t c_start = 0, c_end;
|
||||
struct timeval t_start, t_end;
|
||||
|
||||
int opt = 0;
|
||||
int long_index = 0;
|
||||
@ -328,12 +328,12 @@ usage_err:
|
||||
p_mode[4], p_mode_name[p_mode[4]]
|
||||
);
|
||||
|
||||
gettimeofday(&t_start, 0);
|
||||
|
||||
if (is_mode_selected(RTL819x)) { /* Ignore --start and --end otherwise */
|
||||
|
||||
struct timeval t_now;
|
||||
gettimeofday(&t_now, 0);
|
||||
wps->start = t_now.tv_sec;
|
||||
wps->end = t_now.tv_sec - MODE3_DAYS * SEC_PER_DAY;
|
||||
wps->start = t_start.tv_sec;
|
||||
wps->end = t_start.tv_sec - MODE3_DAYS * SEC_PER_DAY;
|
||||
|
||||
/* Attributes --start and --end can be switched start > end or end > start */
|
||||
if (start_p != (time_t) -1) {
|
||||
@ -398,8 +398,6 @@ usage_err:
|
||||
if (!buffer)
|
||||
goto memory_err;
|
||||
|
||||
c_start = clock();
|
||||
|
||||
/* DHKey = SHA-256(g^(AB) mod p) = SHA-256(PKe^A mod p) = SHA-256(PKe) (g = 2, A = 1, p > 2) */
|
||||
sha256(wps->pke, WPS_PKEY_LEN, wps->dhkey);
|
||||
|
||||
@ -468,9 +466,6 @@ usage_err:
|
||||
uint32_t seed;
|
||||
uint32_t print_seed = 0;
|
||||
|
||||
if (!c_start)
|
||||
c_start = clock();
|
||||
|
||||
/* Main loop */
|
||||
while (!found_p_mode && p_mode[k] != NONE && k < MODE_LEN) {
|
||||
|
||||
@ -786,8 +781,8 @@ usage_err:
|
||||
k++;
|
||||
}
|
||||
|
||||
c_end = clock();
|
||||
unsigned long long ms_elapsed = (c_end - c_start) / (CLOCKS_PER_SEC / 1000);
|
||||
gettimeofday(&t_end, 0);
|
||||
unsigned long ms_elapsed = get_elapsed_ms(&t_start, &t_end);
|
||||
|
||||
k--;
|
||||
|
||||
@ -839,7 +834,7 @@ usage_err:
|
||||
} else {
|
||||
printf("\n [-] WPS pin not found!");
|
||||
}
|
||||
printf("\n\n [*] Time taken: %llu s %llu ms\n\n", ms_elapsed / 1000, ms_elapsed % 1000);
|
||||
printf("\n\n [*] Time taken: %lu s %lu ms\n\n", ms_elapsed / 1000, ms_elapsed % 1000);
|
||||
|
||||
if (wps->warning) {
|
||||
printf("%s", wps->warning);
|
||||
|
@ -24,7 +24,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/* Converts an hex string to a byte array */
|
||||
unsigned int hex_string_to_byte_array(char *in, uint8_t *out, const unsigned int n_len) {
|
||||
@ -159,6 +160,11 @@ unsigned int get_unix_datetime(char *s, time_t *datetime) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Returns the difference of time between the two in milliseconds */
|
||||
unsigned long get_elapsed_ms(struct timeval *start, struct timeval *end) {
|
||||
return (((end->tv_sec - start->tv_sec) * 1000000 + (end->tv_usec - start->tv_usec)) / 1000);
|
||||
}
|
||||
|
||||
/* Converts an unsigned integer to a char array without termination */
|
||||
inline void uint_to_char_array(unsigned int num, unsigned int len, uint8_t *dst) {
|
||||
unsigned int mul = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user