node-pcap / node_pcap

libpcap bindings for node
MIT License
930 stars 256 forks source link

Unknow LLC types issue #85

Closed diegobernardes closed 10 years ago

diegobernardes commented 10 years ago

Hi,

Im running wlan0 into monitor mode and tried to inspect all packets in mon0. I get lots of packets, but, i get too many errors like this:

[Error: Unknown LLC types: DSAP: 221, SSAP: 153]

What this can be?

var pcap = require('pcap');
var pcap_session = pcap.createSession("mon0", "");

pcap_session.on('packet', function (raw_packet) {
    try {
        var packet = pcap.decode.packet(raw_packet);
        console.log(packet);
    } catch(err)  {
        console.log(err);
    }
});
diegobernardes commented 10 years ago

It seems that the error is because the mon0 interface, the mon0 is a monitor mode interface that is generated after run the command:

sudo airmon-ng start wlan0

Does node-pcap work with interfaces in monitor mode??

ujjwalt commented 10 years ago

You have to enable monitor mode when you initiaize the session. https://github.com/mranney/node_pcap/blob/master/pcap.js#L25 You can do something like `var pcap_session = pcap.createSession("mon0", "", true);

On 12 January 2014 00:14, Diego Bernardes de Sousa Pinto < notifications@github.com> wrote:

It seems that the error is because the mon0 interface, the mon0 is a monitor mode interface that is generated after run the command:

sudo airmon-ng start wlan0

Does node-pcap work with interfaces in monitor mode??

— Reply to this email directly or view it on GitHubhttps://github.com/mranney/node_pcap/issues/85#issuecomment-32103570 .

Thanks Ujjwal

diegobernardes commented 10 years ago

I notice something strange, i had installed the node_pcap from npm using this command:

sudo npm install -g pcap

The installed version is 1.0.1, same as the repository here in github according to file package.json. But, i was missing the RSSI info inside the wifi packet. In the pcap.js file from github it has the RSSI info:

decode.ieee802_11_frame = function (raw_packet, offset) {
    var ret = {};

    ret.frameControl = unpack.uint16_be(raw_packet, offset); offset += 2;
    ret.type = (ret.frameControl >> 2) & 0x0003;
    ret.subType = (ret.frameControl >> 4) & 0x000f;
    ret.flags = (ret.frameControl >> 8) & 0xff;
    ret.duration = unpack.uint16_be(raw_packet, offset); offset += 2;
    ret.bssid = unpack.ethernet_addr(raw_packet, offset); offset += 6;
    ret.shost = unpack.ethernet_addr(raw_packet, offset); offset += 6;
    ret.dhost = unpack.ethernet_addr(raw_packet, offset); offset += 6;
    ret.fragSeq = unpack.uint16_be(raw_packet, offset); offset += 2;

    var strength = raw_packet[22];
    ret.strength = -Math.abs(265 - strength);

    switch(ret.subType) {
        case 8: // QoS Data
            ret.qosPriority = raw_packet[offset++];
            ret.txop = raw_packet[offset++];
            break;
    }

In the installed version in my machine, don't have this info. Don't know how to fix thix.

The second issue is the error with Unknow LLC types, maybe is because of this issue with version, in my machine the createSession is like this:

exports.createSession = function (device, filter, buffer_size) {

in github:

exports.createSession = function (device, filter, buffer_size, monitor) {

Thanks.

ujjwalt commented 10 years ago

I guess I hadn't published it. Sorry. Done. Can you try again and confirm.