mirror of
https://github.com/wiire-a/pixiewps.git
synced 2025-07-29 00:34:47 +02:00
Minor changes
This commit is contained in:
parent
6471952b3f
commit
617193e404
9
Makefile
9
Makefile
@ -1,9 +1,8 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=pixiewps
|
include version.mk
|
||||||
PKG_RELEASE:=1.1
|
|
||||||
|
|
||||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
@ -11,13 +10,13 @@ define Package/pixiewps
|
|||||||
SECTION:=net
|
SECTION:=net
|
||||||
CATEGORY:=Network
|
CATEGORY:=Network
|
||||||
SUBMENU:=wireless
|
SUBMENU:=wireless
|
||||||
TITLE:=An offline WPS Bruteforce utility
|
TITLE:=An offline WPS bruteforce utility
|
||||||
DEPENDS:=+libopenssl
|
DEPENDS:=+libopenssl
|
||||||
URL:=https://github.com/wiire/pixiewps
|
URL:=https://github.com/wiire/pixiewps
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/pixiewps/description
|
define Package/pixiewps/description
|
||||||
An offline WPS Bruteforce utility
|
An offline WPS bruteforce utility
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Build/Prepare
|
define Build/Prepare
|
||||||
|
@ -48,8 +48,10 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#ifdef __MACH__
|
#ifdef __MACH__
|
||||||
# include <libkern/OSByteOrder.h>
|
# include <libkern/OSByteOrder.h>
|
||||||
|
# define be32(x) OSSwapBigToHostInt32(x)
|
||||||
#else
|
#else
|
||||||
# include <asm/byteorder.h>
|
# include <asm/byteorder.h>
|
||||||
|
# define be32(x) __be32_to_cpu(x)
|
||||||
#endif /* __MACH__ */
|
#endif /* __MACH__ */
|
||||||
|
|
||||||
#include "pixiewps.h"
|
#include "pixiewps.h"
|
||||||
@ -316,12 +318,12 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
uint32_t seed;
|
uint32_t seed;
|
||||||
uint32_t print_seed; /* Seed to display at the end */
|
uint32_t print_seed; /* Seed to display at the end */
|
||||||
unsigned int first_half;
|
unsigned int first_half = 0;
|
||||||
unsigned int second_half;
|
unsigned int second_half = 0;
|
||||||
unsigned char s_pin[4] = {0};
|
unsigned char s_pin[4] = {0};
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
|
|
||||||
int mode = 1; bool found = false;
|
uint_fast8_t mode = 1; bool found = false;
|
||||||
clock_t c_start, c_end;
|
clock_t c_start, c_end;
|
||||||
c_start = clock();
|
c_start = clock();
|
||||||
|
|
||||||
@ -345,7 +347,7 @@ int main(int argc, char **argv) {
|
|||||||
while (1) {
|
while (1) {
|
||||||
seed = index;
|
seed = index;
|
||||||
|
|
||||||
int i;
|
uint_fast8_t i;
|
||||||
for (i = 1; i < WPS_NONCE_LEN; i++) {
|
for (i = 1; i < WPS_NONCE_LEN; i++) {
|
||||||
if (wps->e_nonce[i] != (unsigned char) rand_r(&seed)) break;
|
if (wps->e_nonce[i] != (unsigned char) rand_r(&seed)) break;
|
||||||
}
|
}
|
||||||
@ -380,8 +382,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
/* Converting enrollee nonce to the sequence may be generated by current random function */
|
/* Converting enrollee nonce to the sequence may be generated by current random function */
|
||||||
uint32_t randr_enonce[4] = {0};
|
uint32_t randr_enonce[4] = {0};
|
||||||
int j = 0;
|
uint_fast8_t j = 0;
|
||||||
for (int i = 0; i < 4; i++) {
|
for (uint_fast8_t i = 0; i < 4; i++) {
|
||||||
randr_enonce[i] |= wps->e_nonce[j++];
|
randr_enonce[i] |= wps->e_nonce[j++];
|
||||||
randr_enonce[i] <<= 8;
|
randr_enonce[i] <<= 8;
|
||||||
randr_enonce[i] |= wps->e_nonce[j++];
|
randr_enonce[i] |= wps->e_nonce[j++];
|
||||||
@ -412,7 +414,7 @@ int main(int argc, char **argv) {
|
|||||||
while (1) {
|
while (1) {
|
||||||
srandom_r(seed, buf);
|
srandom_r(seed, buf);
|
||||||
|
|
||||||
int i;
|
uint_fast8_t i;
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
random_r(buf, &res);
|
random_r(buf, &res);
|
||||||
if ((uint32_t) res != randr_enonce[i]) break;
|
if ((uint32_t) res != randr_enonce[i]) break;
|
||||||
@ -421,14 +423,10 @@ int main(int argc, char **argv) {
|
|||||||
if (i == 4) {
|
if (i == 4) {
|
||||||
print_seed = seed;
|
print_seed = seed;
|
||||||
srandom_r(print_seed + 1, buf);
|
srandom_r(print_seed + 1, buf);
|
||||||
for (int i = 0; i < 4; i++) {
|
for (uint_fast8_t j = 0; j < 4; j++) {
|
||||||
random_r(buf, &res);
|
random_r(buf, &res);
|
||||||
#ifdef __MACH__
|
uint32_t be = be32(res);
|
||||||
uint32_t be = OSSwapBigToHostInt32(res);
|
memcpy(&(wps->e_s1[4 * j]), &be, 4);
|
||||||
#else
|
|
||||||
uint32_t be = __be32_to_cpu(res);
|
|
||||||
#endif
|
|
||||||
memcpy(&(wps->e_s1[4 * i]), &be, 4);
|
|
||||||
memcpy(wps->e_s2, wps->e_s1, WPS_SECRET_NONCE_LEN); /* E-S1 = E-S2 != E-Nonce */
|
memcpy(wps->e_s2, wps->e_s1, WPS_SECRET_NONCE_LEN); /* E-S1 = E-S2 != E-Nonce */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -467,7 +465,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (first_half < 10000) { /* First half found */
|
if (first_half < 10000) { /* First half found */
|
||||||
unsigned char checksum_digit;
|
uint_fast8_t checksum_digit;
|
||||||
unsigned int c_second_half;
|
unsigned int c_second_half;
|
||||||
|
|
||||||
/* Testing with checksum digit */
|
/* Testing with checksum digit */
|
||||||
|
@ -125,7 +125,7 @@ char usage[] =
|
|||||||
"%s";
|
"%s";
|
||||||
|
|
||||||
/* SHA-256 */
|
/* SHA-256 */
|
||||||
void sha256(const unsigned char *data, size_t data_len, unsigned char *digest) {
|
void sha256(const unsigned char *data, const size_t data_len, unsigned char *digest) {
|
||||||
SHA256_CTX ctx;
|
SHA256_CTX ctx;
|
||||||
SHA256_Init(&ctx);
|
SHA256_Init(&ctx);
|
||||||
SHA256_Update(&ctx, data, data_len);
|
SHA256_Update(&ctx, data, data_len);
|
||||||
@ -133,7 +133,7 @@ void sha256(const unsigned char *data, size_t data_len, unsigned char *digest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* HMAC-SHA-256 */
|
/* HMAC-SHA-256 */
|
||||||
void hmac_sha256(const void *key, int key_len, const unsigned char *data, size_t data_len, unsigned char *digest) {
|
void hmac_sha256(const void *key, int key_len, const unsigned char *data, const size_t data_len, unsigned char *digest) {
|
||||||
unsigned int h_len = WPS_HASH_LEN;
|
unsigned int h_len = WPS_HASH_LEN;
|
||||||
HMAC_CTX ctx;
|
HMAC_CTX ctx;
|
||||||
HMAC_CTX_init(&ctx);
|
HMAC_CTX_init(&ctx);
|
||||||
@ -144,10 +144,10 @@ void hmac_sha256(const void *key, int key_len, const unsigned char *data, size_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Key Derivation Function */
|
/* Key Derivation Function */
|
||||||
void kdf(unsigned char *key, size_t key_len, unsigned char *res) {
|
void kdf(const void *key, const size_t key_len, unsigned char *res) {
|
||||||
uint32_t i = 1;
|
uint32_t i = 1;
|
||||||
uint32_t kdk_len = key_len * 8;
|
uint32_t kdk_len = key_len * 8;
|
||||||
int j = 0;
|
uint_fast8_t j = 0;
|
||||||
|
|
||||||
/* Wi-Fi Easy and Secure Key Derivation */
|
/* Wi-Fi Easy and Secure Key Derivation */
|
||||||
char *salt = "\x57\x69\x2d\x46\x69\x20\x45\x61\x73\x79\x20\x61\x6e\x64\x20\x53\x65\x63\x75\x72\x65\x20\x4b\x65\x79\x20\x44\x65\x72\x69\x76\x61\x74\x69\x6f\x6e";
|
char *salt = "\x57\x69\x2d\x46\x69\x20\x45\x61\x73\x79\x20\x61\x6e\x64\x20\x53\x65\x63\x75\x72\x65\x20\x4b\x65\x79\x20\x44\x65\x72\x69\x76\x61\x74\x69\x6f\x6e";
|
||||||
@ -155,18 +155,10 @@ void kdf(unsigned char *key, size_t key_len, unsigned char *res) {
|
|||||||
unsigned char *buffer = malloc(WPS_KDF_SALT_LEN + 4 * 2);
|
unsigned char *buffer = malloc(WPS_KDF_SALT_LEN + 4 * 2);
|
||||||
|
|
||||||
for (i = 1; i < 4; i++) {
|
for (i = 1; i < 4; i++) {
|
||||||
#ifdef __MACH__
|
uint32_t be = be32(i);
|
||||||
uint32_t be = OSSwapBigToHostInt32(i);
|
|
||||||
#else
|
|
||||||
uint32_t be = __be32_to_cpu(i);
|
|
||||||
#endif
|
|
||||||
memcpy(buffer, &be, 4);
|
memcpy(buffer, &be, 4);
|
||||||
memcpy(buffer + 4, salt, WPS_KDF_SALT_LEN);
|
memcpy(buffer + 4, salt, WPS_KDF_SALT_LEN);
|
||||||
#ifdef __MACH__
|
be = be32(kdk_len);
|
||||||
be = OSSwapBigToHostInt32(kdk_len);
|
|
||||||
#else
|
|
||||||
be = __be32_to_cpu(kdk_len);
|
|
||||||
#endif
|
|
||||||
memcpy(buffer + 4 + 36, &be, 4);
|
memcpy(buffer + 4 + 36, &be, 4);
|
||||||
hmac_sha256(key, WPS_HASH_LEN, buffer, WPS_KDF_SALT_LEN + 4 * 2, res + j);
|
hmac_sha256(key, WPS_HASH_LEN, buffer, WPS_KDF_SALT_LEN + 4 * 2, res + j);
|
||||||
j += WPS_HASH_LEN;
|
j += WPS_HASH_LEN;
|
||||||
@ -175,7 +167,7 @@ void kdf(unsigned char *key, size_t key_len, unsigned char *res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Pin checksum computing */
|
/* Pin checksum computing */
|
||||||
unsigned int wps_pin_checksum(unsigned int pin) {
|
inline unsigned int wps_pin_checksum(unsigned int pin) {
|
||||||
unsigned int acc = 0;
|
unsigned int acc = 0;
|
||||||
while (pin) {
|
while (pin) {
|
||||||
acc += 3 * (pin % 10);
|
acc += 3 * (pin % 10);
|
||||||
@ -187,7 +179,7 @@ unsigned int wps_pin_checksum(unsigned int pin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Validity PIN control based on checksum */
|
/* Validity PIN control based on checksum */
|
||||||
unsigned int wps_pin_valid(unsigned int pin) {
|
inline unsigned int wps_pin_valid(unsigned int pin) {
|
||||||
return wps_pin_checksum(pin / 10) == (pin % 10);
|
return wps_pin_checksum(pin / 10) == (pin % 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
src/utils.h
16
src/utils.h
@ -41,16 +41,16 @@
|
|||||||
#define UTILS_H
|
#define UTILS_H
|
||||||
|
|
||||||
/* Converts an hex string to a byte array */
|
/* Converts an hex string to a byte array */
|
||||||
int hex_string_to_byte_array(char *in, unsigned char *out, int n_len) {
|
unsigned int hex_string_to_byte_array(char *in, unsigned char *out, const unsigned int n_len) {
|
||||||
int i, j, o;
|
uint_fast8_t o;
|
||||||
int len = strlen(in);
|
unsigned int len = strlen(in);
|
||||||
int b_len = n_len * 2 + n_len - 1;
|
unsigned int b_len = n_len * 2 + n_len - 1;
|
||||||
|
|
||||||
if (len != n_len * 2 && len != b_len)
|
if (len != n_len * 2 && len != b_len)
|
||||||
return 1;
|
return 1;
|
||||||
for (i = 0; i < n_len; i++) {
|
for (unsigned int i = 0; i < n_len; i++) {
|
||||||
o = 0;
|
o = 0;
|
||||||
for (j = 0; j < 2; j++) {
|
for (uint_fast8_t j = 0; j < 2; j++) {
|
||||||
o <<= 4;
|
o <<= 4;
|
||||||
if (*in >= 'A' && *in <= 'F')
|
if (*in >= 'A' && *in <= 'F')
|
||||||
*in += 'a'-'A';
|
*in += 'a'-'A';
|
||||||
@ -89,7 +89,7 @@ int get_int(char *in, int *out) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Converts an unsigned integer to a char array without termination */
|
/* Converts an unsigned integer to a char array without termination */
|
||||||
void uint_to_char_array(unsigned int num, int len, unsigned char *dst) {
|
void uint_to_char_array(unsigned int num, unsigned int len, unsigned char *dst) {
|
||||||
unsigned int mul = 1;
|
unsigned int mul = 1;
|
||||||
while (len--) {
|
while (len--) {
|
||||||
dst[len] = (num % (mul * 10) / mul) + '0';
|
dst[len] = (num % (mul * 10) / mul) + '0';
|
||||||
@ -98,7 +98,7 @@ void uint_to_char_array(unsigned int num, int len, unsigned char *dst) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Prints a byte array in hexadecimal */
|
/* Prints a byte array in hexadecimal */
|
||||||
void byte_array_print(unsigned char *buffer, unsigned int length) {
|
void byte_array_print(const unsigned char *buffer, const unsigned int length) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
printf("%02x", buffer[i]);
|
printf("%02x", buffer[i]);
|
||||||
|
4
version.mk
Normal file
4
version.mk
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
PKG_NAME:=pixiewps
|
||||||
|
PKG_VERSION:=1.1
|
||||||
|
PKG_RELEASE:=2
|
||||||
|
PKG_LICENSE:=GPLv3
|
Loading…
x
Reference in New Issue
Block a user