new MACFILTER, replacing VENDORFILTER

This commit is contained in:
cyberman54 committed 2020-12-13 19:29:15 +01:00
1 parent b32e91317f
commit 14c8eeb471
11 files changed
+37 -288

No files matched your search

+5 -5
View File
@@ -151,7 +151,7 @@ IRAM_ATTR void gap_callback_handler(esp_gap_ble_cb_event_t event,
ESP_LOGV(TAG, "RSSI : %d", p->scan_rst.rssi);
#endif
#if (VENDORFILTER)
#if (MACFILTER)
if ((p->scan_rst.ble_addr_type == BLE_ADDR_TYPE_RANDOM) ||
(p->scan_rst.ble_addr_type == BLE_ADDR_TYPE_RPA_RANDOM)) {
#ifdef VERBOSE
@@ -176,7 +176,7 @@ IRAM_ATTR void gap_callback_handler(esp_gap_ble_cb_event_t event,
mac_add((uint8_t *)p->scan_rst.bda, p->scan_rst.rssi, MAC_SNIFF_BLE);
#endif
/* to be improved in vendorfilter if:
/* to be improved in macfilter:
// you can search for elements in the payload using the
// function esp_ble_resolve_adv_data()
//
@@ -187,7 +187,7 @@ IRAM_ATTR void gap_callback_handler(esp_gap_ble_cb_event_t event,
ESP_BLE_AD_TYPE_NAME_CMPL, &len);
filter BLE devices using their advertisements to get filter alternative
to vendor OUI if vendorfiltering is on, we ...
to vendor OUI if macfiltering is on, we ...
- want to count: mobile phones and tablets
- don't want to count: beacons, peripherals (earphones, headsets,
printers), cars and machines see
@@ -225,11 +225,11 @@ esp_err_t register_ble_callback(void) {
.scan_type = BLE_SCAN_TYPE_PASSIVE,
.own_addr_type = BLE_ADDR_TYPE_RANDOM,
#if (VENDORFILTER)
#if (MACFILTER)
.scan_filter_policy = BLE_SCAN_FILTER_ALLOW_WLIST_PRA_DIR,
// ADV_IND, ADV_NONCONN_IND, ADV_SCAN_IND packets are used for broadcasting
// data in broadcast applications (e.g., Beacons), so we don't want them in
// vendorfilter mode
// macfilter mode
#else
.scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL,
#endif
+8 -8
View File
@@ -48,14 +48,14 @@ static void defaultConfig(configData_t *myconfig) {
myconfig->blescantime =
BLESCANINTERVAL /
10; // BT channel scan cycle [seconds/100], default 1 (= 10ms)
myconfig->blescan = 1; // 0=disabled, 1=enabled
myconfig->wifiscan = 1; // 0=disabled, 1=enabled
myconfig->wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4)
myconfig->vendorfilter = VENDORFILTER; // 0=disabled, 1=enabled
myconfig->rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%)
myconfig->monitormode = 0; // 0=disabled, 1=enabled
myconfig->payloadmask = PAYLOADMASK; // payloads as defined in default
myconfig->enscount = COUNT_ENS; // 0=disabled, 1=enabled
myconfig->blescan = 1; // 0=disabled, 1=enabled
myconfig->wifiscan = 1; // 0=disabled, 1=enabled
myconfig->wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4)
myconfig->macfilter = MACFILTER; // 0=disabled, 1=enabled
myconfig->rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%)
myconfig->monitormode = 0; // 0=disabled, 1=enabled
myconfig->payloadmask = PAYLOADMASK; // payloads as defined in default
myconfig->enscount = COUNT_ENS; // 0=disabled, 1=enabled
#ifdef HAS_BME680
// initial BSEC state for BME680 sensor
-13
View File
@@ -3,10 +3,6 @@
#include "globals.h"
#include "macsniff.h"
#if (VENDORFILTER)
#include "vendor_array.h"
#endif
// Local logging tag
static const char TAG[] = __FILE__;
@@ -130,15 +126,6 @@ uint16_t mac_analyze(MacBuffer_t MacBuffer) {
}
};
#if (VENDORFILTER)
uint32_t *oui; // temporary buffer for vendor OUI
oui = (uint32_t *)MacBuffer.mac;
// if we find OUI on vendor filter list we don't analyze and return early
if (std::find(vendors.begin(), vendors.end(), __builtin_bswap32(*oui) >> 8) ==
vendors.end())
return 0;
#endif
char buff[10]; // temporary buffer for printf
uint32_t *mac; // temporary buffer for shortened MAC
+1 -1
View File
@@ -374,7 +374,7 @@ void setup() {
strcat_P(features, " SDS");
#endif
#if (VENDORFILTER)
#if (MACFILTER)
strcat_P(features, " FILTER");
#endif
+1 -1
View File
@@ -16,7 +16,7 @@
#define COUNTERMODE 0 // 0=cyclic, 1=cumulative, 2=cyclic confirmed
// MAC sniffing parameters
#define VENDORFILTER 0 // set to 0 if you want to scan all devices, not filtering smartphone OUIs
#define MACFILTER 1 // set to 0 if you want to scan all devices, 1 to scan only devices with random MACs (aka smartphones) [default = 1]
#define BLECOUNTER 1 // set to 0 if you do not want to install the BLE sniffer
#define WIFICOUNTER 1 // set to 0 if you do not want to install the WIFI sniffer
#define MAC_QUEUE_SIZE 50 // size of MAC processing buffer (number of MACs) [default = 50]
+2 -3
View File
@@ -49,7 +49,7 @@ void PayloadConvert::addConfig(configData_t value) {
buffer[cursor++] = value.blescantime;
buffer[cursor++] = value.blescan;
buffer[cursor++] = value.wifiant;
buffer[cursor++] = value.vendorfilter;
buffer[cursor++] = value.macfilter;
buffer[cursor++] = value.rgblum;
buffer[cursor++] = value.payloadmask;
buffer[cursor++] = value.monitormode;
@@ -179,8 +179,7 @@ void PayloadConvert::addConfig(configData_t value) {
writeBitmap(value.adrmode ? true : false, value.screensaver ? true : false,
value.screenon ? true : false, value.countermode ? true : false,
value.blescan ? true : false, value.wifiant ? true : false,
value.vendorfilter ? true : false,
value.monitormode ? true : false);
value.macfilter ? true : false, value.monitormode ? true : false);
writeUint8(value.payloadmask);
writeVersion(value.version);
}
+7 -7
View File
@@ -234,18 +234,18 @@ void set_loraadr(uint8_t val[]) {
void set_blescan(uint8_t val[]) {
ESP_LOGI(TAG, "Remote command: set BLE scanner to %s", val[0] ? "on" : "off");
macs_ble = 0; // clear BLE counter
cfg.blescan = val[0] ? 1 : 0;
if (cfg.blescan)
start_BLEscan();
else {
macs_ble = 0; // clear BLE counter
else
stop_BLEscan();
}
}
void set_wifiscan(uint8_t val[]) {
ESP_LOGI(TAG, "Remote command: set WIFI scanner to %s",
val[0] ? "on" : "off");
macs_wifi = 0; // clear WIFI counter
cfg.wifiscan = val[0] ? 1 : 0;
switch_wifi_sniffer(cfg.wifiscan);
}
@@ -259,10 +259,10 @@ void set_wifiant(uint8_t val[]) {
#endif
}
void set_vendorfilter(uint8_t val[]) {
ESP_LOGI(TAG, "Remote command: set vendorfilter mode to %s",
void set_macfilter(uint8_t val[]) {
ESP_LOGI(TAG, "Remote command: set macfilter mode to %s",
val[0] ? "on" : "off");
cfg.vendorfilter = val[0] ? 1 : 0;
cfg.macfilter = val[0] ? 1 : 0;
}
void set_rgblum(uint8_t val[]) {
@@ -378,7 +378,7 @@ static const cmd_t table[] = {
{0x07, set_loraadr, 1, true}, {0x08, set_screensaver, 1, true},
{0x09, set_reset, 1, false}, {0x0a, set_sendcycle, 1, true},
{0x0b, set_wifichancycle, 1, true}, {0x0c, set_blescantime, 1, true},
{0x0d, set_vendorfilter, 1, false}, {0x0e, set_blescan, 1, true},
{0x0d, set_macfilter, 1, false}, {0x0e, set_blescan, 1, true},
{0x0f, set_wifiant, 1, true}, {0x10, set_rgblum, 1, true},
{0x11, set_monitor, 1, true}, {0x12, set_beacon, 7, false},
{0x13, set_sensor, 2, true}, {0x14, set_payloadmask, 1, true},
+8 -2
View File
@@ -35,8 +35,14 @@ IRAM_ATTR void wifi_sniffer_packet_handler(void *buff,
(wifi_ieee80211_packet_t *)ppkt->payload;
const wifi_ieee80211_mac_hdr_t *hdr = &ipkt->hdr;
// process seen MAC
mac_add((uint8_t *)hdr->addr2, ppkt->rx_ctrl.rssi, MAC_SNIFF_WIFI);
// process seen MAC
#if MACFILTER
// we guess it's a smartphone, if randomization bit of MAC is set
if (!(hdr->addr2[0] & 0b10))
return;
else
#endif
mac_add((uint8_t *)hdr->addr2, ppkt->rx_ctrl.rssi, MAC_SNIFF_WIFI);
}
// Software-timer driven Wifi channel rotation callback function