changed random number generator
This commit is contained in:
parent
c1c6dda221
commit
78ead0f0ce
@ -219,8 +219,7 @@ void wifi_sniffer_loop(void * pvParameters) {
|
|||||||
// clear counter if not in cumulative counter mode
|
// clear counter if not in cumulative counter mode
|
||||||
if (cfg.countermode != 1) {
|
if (cfg.countermode != 1) {
|
||||||
macs.clear(); // clear macs container
|
macs.clear(); // clear macs container
|
||||||
srand(temperatureRead()); // use chip temperature for pseudorandom generator init
|
salt = random(65536); // get new 16bit random for salting hashes
|
||||||
salt = rand() % 256; // get new random int between 0 and 255 for salting MAC hashes
|
|
||||||
macnum = 0;
|
macnum = 0;
|
||||||
u8x8.clearLine(0); u8x8.clearLine(1); // clear Display counter
|
u8x8.clearLine(0); u8x8.clearLine(1); // clear Display counter
|
||||||
ESP_LOGI(TAG, "Scan cycle completed, new salt value: %i", salt);
|
ESP_LOGI(TAG, "Scan cycle completed, new salt value: %i", salt);
|
||||||
@ -384,9 +383,8 @@ void setup() {
|
|||||||
antenna_init();
|
antenna_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// initialize pseudorandom generator and salt value
|
// initialize salt value using esp_random() called by random in arduino-esp32 core
|
||||||
srand(temperatureRead()); // use chip temperature for pseudorandom generator init
|
salt = random(65536); // get new 16bit random for salting hashes
|
||||||
salt = rand() % 256; // get new random int between 0 and 255 for salting MAC hashes
|
|
||||||
|
|
||||||
// initialize display
|
// initialize display
|
||||||
init_display(PROGNAME, PROGVERSION);
|
init_display(PROGNAME, PROGVERSION);
|
||||||
|
@ -69,7 +69,7 @@ void set_reset(int val) {
|
|||||||
ESP_LOGI(TAG, "Remote command: reset MAC counter");
|
ESP_LOGI(TAG, "Remote command: reset MAC counter");
|
||||||
macs.clear(); // clear macs container
|
macs.clear(); // clear macs container
|
||||||
macnum = 0;
|
macnum = 0;
|
||||||
salt = rand() % 256; // get new random int between 0 and 255 for salting MAC hashes
|
salt = random(65536); // get new 16bit random for salting hashes
|
||||||
u8x8.clearLine(0); u8x8.clearLine(1); // clear Display counter
|
u8x8.clearLine(0); u8x8.clearLine(1); // clear Display counter
|
||||||
u8x8.clearLine(5);
|
u8x8.clearLine(5);
|
||||||
u8x8.setCursor(0, 5);
|
u8x8.setCursor(0, 5);
|
||||||
|
@ -79,8 +79,8 @@ void wifi_sniffer_packet_handler(void* buff, wifi_promiscuous_pkt_type_t type) {
|
|||||||
//if (!(addr2int & WIFI_MAC_FILTER_MASK)) { // filter local and group MACs
|
//if (!(addr2int & WIFI_MAC_FILTER_MASK)) { // filter local and group MACs
|
||||||
|
|
||||||
// salt and hash MAC, and if new unique one, store hash in container and increment counter on display
|
// salt and hash MAC, and if new unique one, store hash in container and increment counter on display
|
||||||
addr2int <<= 8; // left shift out msb of vendor oui
|
addr2int <<= 16; // left shift out 2 bytes of vendor oui to give space for salt
|
||||||
addr2int += salt; // append salt value to MAC before hashing it
|
addr2int |= salt; // append salt value to MAC before hashing it
|
||||||
itoa(addr2int, macbuf, 10); // convert 64 bit MAC to base 10 decimal string
|
itoa(addr2int, macbuf, 10); // convert 64 bit MAC to base 10 decimal string
|
||||||
hashedmac = rokkit(macbuf, 5); // hash MAC for privacy, use 5 chars to fit in uint16_t container
|
hashedmac = rokkit(macbuf, 5); // hash MAC for privacy, use 5 chars to fit in uint16_t container
|
||||||
newmac = macs.insert(hashedmac); // store hashed MAC if new unique
|
newmac = macs.insert(hashedmac); // store hashed MAC if new unique
|
||||||
|
Loading…
Reference in New Issue
Block a user