Skip to content

huge818/nodecap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

A cross-platform binding for performing packet capturing with node.js.

Requirements

  • node.js -- v0.12.18 or older (you can build it on latest nodejs)

  • For Windows: WinPcap

  • For *nix: libpcap and libpcap-dev/libpcap-devel packages

Install

npm install nodecap

Examples

  • Send an arbitrary packet: An arp request for example
var nodecap=require('nodecap');
var Cap =  new nodecap();
var buffer = new Buffer ([
    // ETHERNET
    //...
]);

try {
  // send will not work if pcap_sendpacket is not supported by underlying `device`
  c.sendBufer(buffer);
} catch (e) {
  console.log("Error sending packet:", e);
}
  • List all network devices:

API

Cap events

  • capture(< integer >nbytes, < boolean >truncated) - A packet nbytes in size was captured. truncated indicates if the entire packet did not fit inside the Buffer supplied to open().

nodecap methods

sendBufer
close

filter rules: http://www.tcpdump.org/manpages/pcap-filter.7.html

About

A cross-platform binding for performing packet capturing with [node.js]

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published