Socket
Socket
Sign inDemoInstall

pcap

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pcap - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

17

decode/ieee802.11/radio_packet.js

@@ -33,2 +33,4 @@ /* jshint evil: true */

RadioPacket.globalCache = {};
RadioPacket.prototype.decode = function (raw_packet, offset, options) {

@@ -53,7 +55,8 @@ var original_offset = offset;

}
const cache = (options && options.radiotapCache) || RadioPacket.globalCache;
if (!Object.hasOwnProperty.call(cache, this.presentFields))
cache[this.presentFields] = buildDecoder(this.presentFields);
this.fields = cache[this.presentFields](raw_packet, offset, original_offset + this.headerLength);
if (!Object.hasOwnProperty.call(this._decoderCache, this.presentFields))
this._decoderCache[this.presentFields] = this.buildDecoder(this.presentFields);
this.fields = this._decoderCache[this.presentFields](raw_packet, offset, original_offset + this.headerLength);
offset = original_offset + this.headerLength;

@@ -75,3 +78,3 @@

// Important: Bits 31, 63, etc. must NOT be set
RadioPacket.prototype.buildDecoder = function (fields) {
function buildDecoder(fields) {
var code = 'var result = {};\n';

@@ -136,5 +139,5 @@

return new Function('readBigUInt64LE', 'data', 'offset', 'end_offset', code)
.bind(this, readBigUInt64LE);
};
.bind(null, readBigUInt64LE);
}
module.exports = RadioPacket;
var pcap = require("../pcap"),
pcap_session = pcap.createSession("", "tcp"),
pcap_session = pcap.createSession("", { filter: "tcp" }),
matcher = /safari/i;

@@ -9,8 +9,8 @@

var packet = pcap.decode.packet(raw_packet),
data = packet.link.ip.tcp.data;
data = packet.payload.payload.payload.data;
if (data && matcher.test(data.toString())) {
console.log(pcap.print.packet(packet));
console.log(packet);
console.log(data.toString());
}
});
{
"name": "pcap",
"version": "3.0.0",
"version": "3.1.0",
"description": "raw packet capture, decoding, and analysis",

@@ -14,3 +14,3 @@ "author": "Matt Ranney <mjr@ranney.com>",

"type": "git",
"url": "git://github.com/mranney/node_pcap.git"
"url": "git://github.com/node-pcap/node_pcap.git"
},

@@ -17,0 +17,0 @@ "engines": {

@@ -97,2 +97,15 @@ /// <reference types="node" />

/**
* specifies if the interface is opened in promiscuous mode (default: true)
*
* > On broadcast LANs such as Ethernet, if the network isn't switched, or if the adapter is connected to a "mirror port" on a switch to which all packets passing through the switch are sent, a network adapter receives all packets on the LAN, including unicast or multicast packets not sent to a network address that the network adapter isn't configured to recognize.
* >
* > Normally, the adapter will discard those packets; however, many network adapters support "promiscuous mode", which is a mode in which all packets, even if they are not sent to an address that the adapter recognizes, are provided to the host. This is useful for passively capturing traffic between two or more other hosts for analysis.
* >
* > Note that even if an application does not set promiscuous mode, the adapter could well be in promiscuous mode for some other reason.
* >
* > For now, this doesn't work on the "any" device; if an argument of "any" or NULL is supplied, the setting of promiscuous mode is ignored.
*/
promiscuous?: boolean;
/**
* packet buffer timeout in milliseconds (default: 1000)

@@ -99,0 +112,0 @@ *

@@ -19,3 +19,3 @@ var util = require("util");

function PcapSession(is_live, device_name, filter, buffer_size, snap_length, outfile, is_monitor, buffer_timeout) {
function PcapSession(is_live, device_name, filter, buffer_size, snap_length, outfile, is_monitor, buffer_timeout, promiscuous) {
this.is_live = is_live;

@@ -29,2 +29,3 @@ this.device_name = device_name;

this.buffer_timeout = buffer_timeout;
this.promiscuous = typeof promiscuous === 'undefined' ? true : promiscuous;

@@ -61,5 +62,5 @@ this.link_type = null;

this.device_name = this.device_name || binding.default_device();
this.link_type = this.session.open_live(this.device_name, this.filter, this.buffer_size, this.snap_length, this.outfile, packet_ready, this.is_monitor, this.buffer_timeout, exports.warningHandler);
this.link_type = this.session.open_live(this.device_name, this.filter, this.buffer_size, this.snap_length, this.outfile, packet_ready, this.is_monitor, this.buffer_timeout, exports.warningHandler, this.promiscuous);
} else {
this.link_type = this.session.open_offline(this.device_name, this.filter, this.buffer_size, this.snap_length, this.outfile, packet_ready, this.is_monitor, this.buffer_timeout, exports.warningHandler);
this.link_type = this.session.open_offline(this.device_name, this.filter, this.buffer_size, this.snap_length, this.outfile, packet_ready, this.is_monitor, this.buffer_timeout, exports.warningHandler, this.promiscuous);
}

@@ -133,3 +134,3 @@

options = options || {};
return new PcapSession(true, device, options.filter, options.buffer_size, options.snap_length, null, options.monitor, options.buffer_timeout);
return new PcapSession(true, device, options.filter, options.buffer_size, options.snap_length, null, options.monitor, options.buffer_timeout, options.promiscuous);
};

@@ -136,0 +137,0 @@

@@ -12,3 +12,3 @@ **Disclaimer:**

[![Join the chat at https://gitter.im/mranney/node_pcap](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mranney/node_pcap?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/mranney/node_pcap.svg?branch=master)](https://travis-ci.org/mranney/node_pcap)[![Coverage Status](https://coveralls.io/repos/mranney/node_pcap/badge.svg)](https://coveralls.io/r/mranney/node_pcap)
[![Build Status](https://travis-ci.org/node-pcap/node_pcap.svg?branch=master)](https://travis-ci.org/node-pcap/node_pcap)[![Coverage Status](https://coveralls.io/repos/mranney/node_pcap/badge.svg)](https://coveralls.io/r/mranney/node_pcap)

@@ -53,3 +53,3 @@ This is a set of bindings from `libpcap` to node as well as some useful libraries to decode, print, and

git clone git://github.com/mranney/node_pcap.git
git clone git://github.com/node-pcap/node_pcap.git

@@ -76,6 +76,6 @@ To compile the native code bindings, do this:

var pcap = require('pcap'),
pcap_session = pcap.createSession(interface, options);
pcap_session = pcap.createSession(device_name, options);
```
`interface` is the name of the interface on which to capture packets. If passed an empty string, `libpcap`
`device_name` is the name of the network interface on which to capture packets. If passed an empty string, `libpcap`
will try to pick a "default" interface, which is often just the first one in some list and not what you want.

@@ -88,2 +88,12 @@

- `promiscuous` (boolean) specifies if the interface is opened in promiscuous mode (default: true)
> On broadcast LANs such as Ethernet, if the network isn't switched, or if the adapter is connected to a "mirror port" on a switch to which all packets passing through the switch are sent, a network adapter receives all packets on the LAN, including unicast or multicast packets not sent to a network address that the network adapter isn't configured to recognize.
>
> Normally, the adapter will discard those packets; however, many network adapters support "promiscuous mode", which is a mode in which all packets, even if they are not sent to an address that the adapter recognizes, are provided to the host. This is useful for passively capturing traffic between two or more other hosts for analysis.
>
> Note that even if an application does not set promiscuous mode, the adapter could well be in promiscuous mode for some other reason.
>
> For now, this doesn't work on the "any" device; if an argument of "any" or NULL is supplied, the setting of promiscuous mode is ignored.
- `buffer_size` (number) specifies size of the ringbuffer where packets are stored until delivered to your code, in bytes (default: 10MB)

@@ -124,3 +134,3 @@

Note that `node_pcap` always opens the interface in promiscuous mode, which generally requires running as root.
Note that by default `node_pcap` opens the interface in promiscuous mode, which generally requires running as root.
Unless you are recklessly roaming about as root already, you'll probably want to start your node program like this:

@@ -150,6 +160,7 @@

The protocol stack is exposed as a nested set of objects. For example, the TCP destination port is part of TCP
which is encapsulated within IP, which is encapsulated within a link layer. Access it like this:
which is encapsulated within IP, which is encapsulated within a link layer. Each layer is contained within the
`payload` attribute of the upper layer (or the packet itself):
```javascript
packet.link.ip.tcp.dport
packet.payload.payload.payload.dport
```

@@ -168,3 +179,3 @@

tcp_tracker = new pcap.TCPTracker(),
pcap_session = pcap.createSession('en0', "ip proto \\tcp");
pcap_session = pcap.createSession('en0', { filter: "ip proto \\tcp" });

@@ -171,0 +182,0 @@ tcp_tracker.on('session', function (session) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc