pulkin / esp8266-injection-example

Example project to demonstrate packet injection / sniffer capabilities of ESP8266 IC.
352 stars 92 forks source link

Reading RxControl in promiscuous mode(Mac-adress) #6

Closed alemlishar closed 8 years ago

alemlishar commented 8 years ago

Hello all, can anybody have any demo solution about getting mac address of station(clients) using esp8266 micro controller, I managed to get the data packet in sniffer (promiscuous)mode with the callback wifi_promiscuous_rx_cb, in my case what i impressed is to get the mac address of the client(smart-phones....) And when i used the struct sniffer-buf vector to extract the mac- address it raised an exception error, i appreciate any kind of help please. thank you

pulkin commented 8 years ago

Dear alemlishar,

This example does sniff both mac addresses. To check that you may try to print it into serial. If it does not work for you please let me know.

alemlishar commented 8 years ago

Thank you Pulkin for your reply,

the example is based on LUA and i am demonstrating on arduino 1.6.10 IDE , still now i only achieve to get the sniffed data with wifi_promiscuous_rx_cb, and i even tried to print out on the serial every sniffer-buf vector value(uint16_t len ) when len is different from 12 or 128 but still it bring exception error, what i need is if you exactly tell me on which index of buf[] will the mac addresses can be found, so my life will be easy to proceed with my project,,,

Best regards

pulkin commented 8 years ago

Sorry, I do not understand you at all. It seems like you ask something unrelated to this example project. What I can say is that if the length is different from 12 and 128 than you should look into ((struct sniffer_buf*)data)->buf[10] and 5 bytes after it. It is pretty much implemented in following piece of the code:

    if (len == 12){
        struct RxControl *sniffer = (struct RxControl*) buf;
    } else if (len == 128) {
        struct sniffer_buf2 *sniffer = (struct sniffer_buf2*) buf;
    } else {
        struct sniffer_buf *sniffer = (struct sniffer_buf*) buf;
        int i=0;
        // Check MACs
        for (i=0; i<6; i++) if (sniffer->buf[i+4] != client[i]) return;
        for (i=0; i<6; i++) if (sniffer->buf[i+10] != ap[i]) return;
        // Update sequence number
        seq_n = sniffer->buf[23] * 0xFF + sniffer->buf[22];
    }

If you want to get MAC address from buf directly ... well, add the size of struct RxControl to the index. Note that it was the case in some intermediate version of 1.3.0 SDK which is bundled in this project.

alemlishar commented 8 years ago

well i did like below

else {
        struct sniffer_buf *sniffer = (struct sniffer_buf*) buf;
        int i=0;
        // Check MACs
        for (i=0; i<6; i++) if (sniffer->buf[i+4] != client[i]) return;
        for (i=0; i<6; i++) if (sniffer->buf[i+10] != ap[i]) return;
        // Update sequence number
        seq_n = sniffer->buf[23] * 0xFF + sniffer->buf[22];

for (i=10; i<15; i++){
       Serial.print(sniffer->buf[i]);////////////to print the mac on the serial (it print always 15 and 8)
    }//for

}//else

i am new for this thing,,, how can i print it on serial,, their mac address,,, if i am not taking your time

pulkin commented 8 years ago

Are you using SDK from this repo?

alemlishar commented 8 years ago

Hello Pulkin, i am using the same SDK, and now i can managed to capture both side mac-addresses, thank you for your follow up responses,, if possible i would like to ask some capability of this micro controller since i am doing a project on it, can i post it here or elsewhere?

regards

pulkin commented 8 years ago

To the best of my knowledge there is no Arduino-level community support. You may try official forum, community forum or stackoverflow.

alemlishar commented 8 years ago

the Arduino doesn't matter, i can handle it by my own,

but how range(distance) does it cover esp8266 in promiscuous mode? and is it possible to limit the coverage distance? the project am doing is about behavioral analysis of human movement, so i want this kind of feature to know where the user is around in specific place how many time he stayed in that place ,,,,

On Mon, Aug 29, 2016 at 9:23 AM, pulkin notifications@github.com wrote:

To the best of my knowledge there is no Arduino-level community support. You may try official forum http://bbs.espressif.com/, community forum http://www.esp8266.com/ or stackoverflow http://stackoverflow.com/questions/tagged/nodemcu.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pulkin/esp8266-injection-example/issues/6#issuecomment-243122233, or mute the thread https://github.com/notifications/unsubscribe-auth/AUM-F3XNywF6kH2JEzs686On-Tpv3HX2ks5qkt1FgaJpZM4JqXnT .

pulkin commented 8 years ago

I believe the signal strength is accessible via sniffer->rssi. However I never used it and cannot comment on it.

I kindly ask to stop using this thread as a question-answer session. Please use aforementioned resources for questions unrelated to this repo. Thank you.