Giter Club home page Giter Club logo

Comments (7)

mfontanini avatar mfontanini commented on June 13, 2024

Can you provide an example on how you are instantiating a RadioTap object? In case you are seeing this on a pcap file, can you attach it?

It's not possible to add a pointer to the raw buffer in the PDU class because the buffer is constructed when sending the packet. There's no buffer that contains the whole packet attached to the PDU. You could call PDU::serialize which generates that buffer for you (see the docs).

from libtins.

notsyncing avatar notsyncing commented on June 13, 2024

I use find_pdu in a sniffer loop.

bool SSISampler::OnPacketRecv(const PDU& pdu)
{
    if (stop_sampling) {
        return false;
    }

    const RadioTap* tap = pdu.find_pdu<RadioTap>();

    if (tap) {
        const Dot11* dot11 = tap->find_pdu<Dot11>();

        cout << "From: " << dot11->addr1() << ", SSI: " << (int)tap->dbm_signal() << " dBm" << endl;

        if (callback) {
            callback(dot11->addr1(), tap->dbm_signal());
        }
    }

    return true;
}

The tap->dbm_signal() always returns 0.

I hacked RadioTap::RadioTap() directly to see if the packet has a SSI value.

RadioTap::RadioTap(const uint8_t *buffer, uint32_t total_sz) 
{
    check_size(total_sz, sizeof(_radio));
    const uint8_t *buffer_start = buffer;
    std::memcpy(&_radio, buffer, sizeof(_radio));
    uint32_t radiotap_hdr_size = length();
    check_size(total_sz, radiotap_hdr_size);
    buffer += sizeof(_radio);
    radiotap_hdr_size -= sizeof(_radio);

    for (int i = 0; i < 0x20; i++) {
      std::cout << std::hex << (int)buffer[i] << " ";
    }
    std::cout << std::endl;
    std::cout << "SSI: " << std::dec << (int)buffer[0x16] - 256 << std::endl;    // SSI is here!

    if(_radio.flags.tsft) 
        read_field(buffer, radiotap_hdr_size, _tsft);

    if(_radio.flags.flags) 
        read_field(buffer, radiotap_hdr_size, _flags);
....

from libtins.

mfontanini avatar mfontanini commented on June 13, 2024

If you could use tcpdump to capture at least one packet that includes a RadioTap header and attaching it here, I could fix the bug easily. Also, which platform are you running this on?

from libtins.

notsyncing avatar notsyncing commented on June 13, 2024

Test pcap file attached:
https://www.dropbox.com/s/vtlj3n80p4dtpca/cap.pcap?dl=0

I'm running it on a x86_64 intel machine.

from libtins.

mfontanini avatar mfontanini commented on June 13, 2024

Thanks for the pcap. I've found the problem. Apparently it's a completely undocumented field, the last one on the headers flags, which (and this is just based on what I see on your packets) allows the RadioTap header to be extended with another set of flag fields right after the previous one.

I don't know what's the rationale on that flag, but it completely breaks parsing because optional fields start 32 bits after they normally do. I'm working on fixing it, will let you know when it's done.

from libtins.

mfontanini avatar mfontanini commented on June 13, 2024

I've just pushed a fix. It's working on your pcap file. Could you check if it works for you please? Thanks!

from libtins.

notsyncing avatar notsyncing commented on June 13, 2024

Now it works like a charm.
Thank you very much!

from libtins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.