diff --git a/src/main.cpp b/src/main.cpp index 341307ac..5eab563d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -219,8 +219,7 @@ void wifi_sniffer_loop(void * pvParameters) { // clear counter if not in cumulative counter mode if (cfg.countermode != 1) { macs.clear(); // clear macs container - srand(temperatureRead()); // use chip temperature for pseudorandom generator init - 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 macnum = 0; u8x8.clearLine(0); u8x8.clearLine(1); // clear Display counter ESP_LOGI(TAG, "Scan cycle completed, new salt value: %i", salt); @@ -384,9 +383,8 @@ void setup() { antenna_init(); #endif - // initialize pseudorandom generator and salt value - srand(temperatureRead()); // use chip temperature for pseudorandom generator init - salt = rand() % 256; // get new random int between 0 and 255 for salting MAC hashes + // initialize salt value using esp_random() called by random in arduino-esp32 core + salt = random(65536); // get new 16bit random for salting hashes // initialize display init_display(PROGNAME, PROGVERSION); diff --git a/src/rcommand.cpp b/src/rcommand.cpp index 166e41ee..e1524e19 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -69,7 +69,7 @@ void set_reset(int val) { ESP_LOGI(TAG, "Remote command: reset MAC counter"); macs.clear(); // clear macs container 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(5); u8x8.setCursor(0, 5); diff --git a/src/wifisniffer.cpp b/src/wifisniffer.cpp index 301e9343..6b84f61c 100644 --- a/src/wifisniffer.cpp +++ b/src/wifisniffer.cpp @@ -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 // 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 += salt; // append salt value to MAC before hashing it + 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 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 newmac = macs.insert(hashedmac); // store hashed MAC if new unique