lunedì 7 agosto 2023

TpLink WN722N v2v3 monitor ESP-NOW con Debian 11

 Volevo usare la scheda WN722N per monitorare il traffico Esp-Now usando WireShark...il fatto e' che la scheda e' riconosciuta da Debian 11 ma non entrava in monitor mode mentre usando ParrotOs funzionava perfettamente.




La soluzione e' ricompilare il modulo  usando questo link

git clone https://github.com/gglluukk/rtl8188eus

make &make install

e eliminando il modulo di defualt

sudo echo 'blacklist r8188eu'|sudo tee -a '/etc/modprobe.d/realtek.conf'

al riavvio si puo' monitorare il traffico mediante questi comandi


sudo ip link set wlx9c532268fdca down
sudo iw wlx9c532268fdca set monitor control
sudo ip link set wlx9c532268fdca up
sudo wireshark


per selezionare il traffico proveniente da un determinato MAC si puo'usare
wlan.sa==xx:xx:xx:xx:xx:xx



Il seguente codice invia un messaggio broadcast su ESP-NOW con abilitato il Long Range (evidenziato in giallo)
========================================================

/*
  ESP-NOW Demo - Transmit
  esp-now-demo-xmit.ino
  Sends data to Responder
  
  DroneBot Workshop 2022
  https://dronebotworkshop.com
  https://dronebotworkshop.com/esp-now/
*/

// Include Libraries
#include <esp_wifi.h>

#include <esp_now.h>
#include <WiFi.h>

// Variables for test data
int int_value;

// MAC Address of responder - edit as required
uint8_t broadcastAddress[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

esp_interface_t current_esp_interface;
wifi_interface_t current_wifi_interface;



// Define a data structure
typedef struct struct_message {
  char a[32];
  int b;
} struct_message;

// Create a structured object
struct_message myData;

// Peer info
esp_now_peer_info_t peerInfo;

// Callback function called when data is sent
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
  Serial.print("\r\nLast Packet Send Status:\t");
  Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail");
}

void setup() {
  int_value = 0;
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  esp_wifi_set_protocol(current_wifi_interface, WIFI_PROTOCOL_LR);
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }
  esp_now_register_send_cb(OnDataSent);
  memcpy(peerInfo.peer_addr, broadcastAddress, 6);
  peerInfo.channel = 0;  
  peerInfo.encrypt = false;
  if (esp_now_add_peer(&peerInfo) != ESP_OK){
    Serial.println("Failed to add peer");
    return;
  }
  
}

void loop() {
 strcpy(myData.a, "Luca");
  int_value++;
  myData.b = int_value;
  esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &myData, sizeof(myData));
  if (result == ESP_OK) {
    Serial.println("Sending confirmed");
  }
  else {
    Serial.println("Sending error");
  }
  delay(1000);
}
========================================================

Per leggere i pacchetti ESP-NOW a linea di comando si puo' usare tcpdump oppure un progetto Go che utilizza le libreria Pcap https://pkg.go.dev/github.com/google/gopacket/pcap

Nessun commento:

Posta un commento

ESP32-2432S028R e LVGL

La scheda ESP32-2432S028R monta un Esp Dev Module con uno schermo TFT a driver ILI9341 di 320x240 pixels 16 bit colore.Il sito di riferiment...