mirror of
https://github.com/wiire-a/pixiewps.git
synced 2025-07-28 16:24:55 +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
|
||||
|
||||
PKG_NAME:=pixiewps
|
||||
PKG_RELEASE:=1.1
|
||||
include version.mk
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
@ -11,13 +10,13 @@ define Package/pixiewps
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=wireless
|
||||
TITLE:=An offline WPS Bruteforce utility
|
||||
TITLE:=An offline WPS bruteforce utility
|
||||
DEPENDS:=+libopenssl
|
||||
URL:=https://github.com/wiire/pixiewps
|
||||
endef
|
||||
|
||||
define Package/pixiewps/description
|
||||
An offline WPS Bruteforce utility
|
||||
An offline WPS bruteforce utility
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
|
@ -48,8 +48,10 @@
|
||||
#include <sys/time.h>
|
||||
#ifdef __MACH__
|
||||
# include <libkern/OSByteOrder.h>
|
||||
# define be32(x) OSSwapBigToHostInt32(x)
|
||||
#else
|
||||
# include <asm/byteorder.h>
|
||||
# define be32(x) __be32_to_cpu(x)
|
||||
#endif /* __MACH__ */
|
||||
|
||||
#include "pixiewps.h"
|
||||
@ -316,12 +318,12 @@ int main(int argc, char **argv) {
|
||||
|
||||
uint32_t seed;
|
||||
uint32_t print_seed; /* Seed to display at the end */
|
||||
unsigned int first_half;
|
||||
unsigned int second_half;
|
||||
unsigned int first_half = 0;
|
||||
unsigned int second_half = 0;
|
||||
unsigned char s_pin[4] = {0};
|
||||
bool valid = false;
|
||||
|
||||
int mode = 1; bool found = false;
|
||||
uint_fast8_t mode = 1; bool found = false;
|
||||
clock_t c_start, c_end;
|
||||
c_start = clock();
|
||||
|
||||
@ -345,7 +347,7 @@ int main(int argc, char **argv) {
|
||||
while (1) {
|
||||
seed = index;
|
||||
|
||||
int i;
|
||||
uint_fast8_t i;
|
||||
for (i = 1; i < WPS_NONCE_LEN; i++) {
|
||||
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 */
|
||||
uint32_t randr_enonce[4] = {0};
|
||||
int j = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
uint_fast8_t j = 0;
|
||||
for (uint_fast8_t i = 0; i < 4; i++) {
|
||||
randr_enonce[i] |= wps->e_nonce[j++];
|
||||
randr_enonce[i] <<= 8;
|
||||
randr_enonce[i] |= wps->e_nonce[j++];
|
||||
@ -412,7 +414,7 @@ int main(int argc, char **argv) {
|
||||
while (1) {
|
||||
srandom_r(seed, buf);
|
||||
|
||||
int i;
|
||||
uint_fast8_t i;
|
||||
for (i = 0; i < 4; i++) {
|
||||
random_r(buf, &res);
|
||||
if ((uint32_t) res != randr_enonce[i]) break;
|
||||
@ -421,14 +423,10 @@ int main(int argc, char **argv) {
|
||||
if (i == 4) {
|
||||
print_seed = seed;
|
||||
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);
|
||||
#ifdef __MACH__
|
||||
uint32_t be = OSSwapBigToHostInt32(res);
|
||||
#else
|
||||
uint32_t be = __be32_to_cpu(res);
|
||||
#endif
|
||||
memcpy(&(wps->e_s1[4 * i]), &be, 4);
|
||||
uint32_t be = be32(res);
|
||||
memcpy(&(wps->e_s1[4 * j]), &be, 4);
|
||||
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 */
|
||||
unsigned char checksum_digit;
|
||||
uint_fast8_t checksum_digit;
|
||||
unsigned int c_second_half;
|
||||
|
||||
/* Testing with checksum digit */
|
||||
|
@ -125,7 +125,7 @@ char usage[] =
|
||||
"%s";
|
||||
|
||||
/* 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_Init(&ctx);
|
||||
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 */
|
||||
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;
|
||||
HMAC_CTX 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 */
|
||||
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 kdk_len = key_len * 8;
|
||||
int j = 0;
|
||||
uint_fast8_t j = 0;
|
||||
|
||||
/* 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";
|
||||
@ -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);
|
||||
|
||||
for (i = 1; i < 4; i++) {
|
||||
#ifdef __MACH__
|
||||
uint32_t be = OSSwapBigToHostInt32(i);
|
||||
#else
|
||||
uint32_t be = __be32_to_cpu(i);
|
||||
#endif
|
||||
uint32_t be = be32(i);
|
||||
memcpy(buffer, &be, 4);
|
||||
memcpy(buffer + 4, salt, WPS_KDF_SALT_LEN);
|
||||
#ifdef __MACH__
|
||||
be = OSSwapBigToHostInt32(kdk_len);
|
||||
#else
|
||||
be = __be32_to_cpu(kdk_len);
|
||||
#endif
|
||||
be = be32(kdk_len);
|
||||
memcpy(buffer + 4 + 36, &be, 4);
|
||||
hmac_sha256(key, WPS_HASH_LEN, buffer, WPS_KDF_SALT_LEN + 4 * 2, res + j);
|
||||
j += WPS_HASH_LEN;
|
||||
@ -175,7 +167,7 @@ void kdf(unsigned char *key, size_t key_len, unsigned char *res) {
|
||||
}
|
||||
|
||||
/* Pin checksum computing */
|
||||
unsigned int wps_pin_checksum(unsigned int pin) {
|
||||
inline unsigned int wps_pin_checksum(unsigned int pin) {
|
||||
unsigned int acc = 0;
|
||||
while (pin) {
|
||||
acc += 3 * (pin % 10);
|
||||
@ -187,7 +179,7 @@ unsigned int wps_pin_checksum(unsigned int pin) {
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
|
16
src/utils.h
16
src/utils.h
@ -41,16 +41,16 @@
|
||||
#define UTILS_H
|
||||
|
||||
/* Converts an hex string to a byte array */
|
||||
int hex_string_to_byte_array(char *in, unsigned char *out, int n_len) {
|
||||
int i, j, o;
|
||||
int len = strlen(in);
|
||||
int b_len = n_len * 2 + n_len - 1;
|
||||
unsigned int hex_string_to_byte_array(char *in, unsigned char *out, const unsigned int n_len) {
|
||||
uint_fast8_t o;
|
||||
unsigned int len = strlen(in);
|
||||
unsigned int b_len = n_len * 2 + n_len - 1;
|
||||
|
||||
if (len != n_len * 2 && len != b_len)
|
||||
return 1;
|
||||
for (i = 0; i < n_len; i++) {
|
||||
for (unsigned int i = 0; i < n_len; i++) {
|
||||
o = 0;
|
||||
for (j = 0; j < 2; j++) {
|
||||
for (uint_fast8_t j = 0; j < 2; j++) {
|
||||
o <<= 4;
|
||||
if (*in >= 'A' && *in <= 'F')
|
||||
*in += 'a'-'A';
|
||||
@ -89,7 +89,7 @@ int get_int(char *in, int *out) {
|
||||
};
|
||||
|
||||
/* 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;
|
||||
while (len--) {
|
||||
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 */
|
||||
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;
|
||||
for (i = 0; i < length; 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