mscdex / cap Goto Github PK
View Code? Open in Web Editor NEWA cross-platform binding for performing packet capturing with node.js
License: MIT License
A cross-platform binding for performing packet capturing with node.js
License: MIT License
I cannot bind to the loopback adaptor. Is there anything I need to do to be able to?
Saw on your examples that when you did
console.dir(Cap.deviceList());
It returned
// { name: 'lo',
// addresses:
// [ { addr: '127.0.0.1', netmask: '255.0.0.0' },
// { addr: '::1',
// netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff' } ],
// flags: 'PCAP_IF_LOOPBACK' } ]
I don't think mine does, its on windows XP. I installed the winpcap libs.
libpcap was easy to find and install but I can't libpcap-dev, this causes npm install cap to fail on node-gyp.
Can you please add some instructions or links to stable versions of libpcap-dev, I only found versions that failed installation.
Library worked great on Windows, can't wait to run a proper server with it!
Thanks,
Roee
When i executed your tests or your exampled i get this error. And the build in https://ci.appveyor.com/project/mscdex/cap fail too
TypeError: device must be a string
at TypeError (native)
at Object. (D:\Mis Cosas\Sistema\perfil\Escritorio\sniff\main.js:
11:18)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:430:10)
at startup (node.js:141:18)
at node.js:980:3
i use windows and the last winpcap installed today and use nodejs v5.3.0
thanks!! very usefull lib
Please delete problem solved :p
Capture and decode all outgoing TCP data packets destined for port 80 on the interface for 192.168.0.10: but i want to capture and decode all TCP packets from Port 80 to the interface 192.168.0.10 i.e it should capture and decode the packets in both ways...
I have some problem with it:
Uncaught node.js Error
Error: Module version mismatch. Expected 13, got 11.
at Module.load (module.js:352:32)
at Function.Module._load (module.js:308:12)
at Module.require (module.js:360:17)
at require (module.js:376:17)
at Object.eval (D:\node\cap\node_modules\cap\lib\Cap.js:3:13)
at Module._compile (module.js:452:26)
at Object.Module._extensions..js (module.js:470:10)
at Module.load (module.js:352:32)
at Function.Module._load (module.js:308:12)
at Module.require (module.js:360:17)
OS : win7 64bit
nodejs: v0.10.25 ia32
python: 2.7.5 32bit
Does this module can't use with node-webkit?
Thanks.
PS C:\xampp\htdocs\npcap> npm install cap
[email protected] install C:\xampp\htdocs\node_modules\cap
node-gyp rebuild
C:\xampp\htdocs\node_modules\cap>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin
node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
binding.cc
win_delay_load_hook.cc
c:\users\asus.node-gyp\9.2.0\include\node\v8.h(2455): error C2144: syntax error : 'int' should be preceded by ';' (..
src\binding.cc) [C:\xampp\htdocs\node_modules\cap\build\cap.vcxproj]
c:\users\asus.node-gyp\9.2.0\include\node\v8.h(2455): error C4430: missing type specifier - int assumed. Note: C++ doe
s not support default-int (..\src\binding.cc) [C:\xampp\htdocs\node_modules\cap\build\cap.vcxproj]
c:\users\asus.node-gyp\9.2.0\include\node\v8.h(4122): error C2610: 'v8::WasmCompiledModule::TransferrableModule::Trans
ferrableModule(v8::WasmCompiledModule::TransferrableModule &&)' : is not a special member function which can be default
ed (..\src\binding.cc) [C:\xampp\htdocs\node_modules\cap\build\cap.vcxproj]
c:\users\asus.node-gyp\9.2.0\include\node\v8.h(4125): error C2610: 'v8::WasmCompiledModule::TransferrableModule &v8::W
asmCompiledModule::TransferrableModule::operator =(v8::WasmCompiledModule::TransferrableModule &&)' : is not a special
member function which can be defaulted (..\src\binding.cc) [C:\xampp\htdocs\node_modules\cap\build\cap.vcxproj]
c:\users\asus.node-gyp\9.2.0\include\node\v8.h(4200): error C2610: 'v8::WasmModuleObjectBuilderStreaming::WasmModuleOb
jectBuilderStreaming(v8::WasmModuleObjectBuilderStreaming &&)' : is not a special member function which can be defaulte
d (..\src\binding.cc) [C:\xampp\htdocs\node_modules\cap\build\cap.vcxproj]
c:\users\asus.node-gyp\9.2.0\include\node\v8.h(4205): error C2610: 'v8::WasmModuleObjectBuilderStreaming &v8::WasmModu
leObjectBuilderStreaming::operator =(v8::WasmModuleObjectBuilderStreaming &&)' : is not a special member function which
can be defaulted (..\src\binding.cc) [C:\xampp\htdocs\node_modules\cap\build\cap.vcxproj]
c:\users\asus.node-gyp\9.2.0\include\node\v8.h(4238): error C2610: 'v8::WasmModuleObjectBuilder::WasmModuleObjectBuild
er(v8::WasmModuleObjectBuilder &&)' : is not a special member function which can be defaulted (..\src\binding.cc) [C:\x
ampp\htdocs\node_modules\cap\build\cap.vcxproj]
c:\users\asus.node-gyp\9.2.0\include\node\v8.h(4240): error C2610: 'v8::WasmModuleObjectBuilder &v8::WasmModuleObjectB
uilder::operator =(v8::WasmModuleObjectBuilder &&)' : is not a special member function which can be defaulted (..\src\b
inding.cc) [C:\xampp\htdocs\node_modules\cap\build\cap.vcxproj]
c:\users\asus.node-gyp\9.2.0\include\node\v8.h(4516): error C2146: syntax error : missing ';' before identifier 'size_
t' (..\src\binding.cc) [C:\xampp\htdocs\node_modules\cap\build\cap.vcxproj]
c:\users\asus.node-gyp\9.2.0\include\node\v8.h(4516): error C4430: missing type specifier - int assumed. Note: C++ doe
s not support default-int (..\src\binding.cc) [C:\xampp\htdocs\node_modules\cap\build\cap.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe
failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:2
58:23)
gyp ERR! stack at ChildProcess.emit (events.js:159:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node
-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\xampp\htdocs\node_modules\cap
gyp ERR! node -v v9.2.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open 'C:\xampp\htdocs\package.json'
npm WARN htdocs No description
npm WARN htdocs No repository field.
npm WARN htdocs No README data
npm WARN htdocs No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\asus\AppData\Roaming\npm-cache_logs\2018-02-26T07_12_01_572Z-debug.log
PS C:\xampp\htdocs\npcap>
In \Lib\Cap.js there is a line that throws an uncaught exception: Cannot find module '../build/Release/cap'
The line is --> var addon = require('../build/Release/cap');
There is no build\release\cap folder.
How can I solve this?
Thanks in advance
Hi mscdex,
When npm install cap, i've got
make: entrant dans le répertoire « /home/franck/cidr/node_modules/cap/build »
CXX(target) Release/obj.target/cap/src/binding.o
../src/binding.cc: In static member function ‘static void Pcap::EmitPacket(u_char*, const pcap_pkthdr*, const u_char*)’:
../src/binding.cc:120:50: error: ‘memcpy’ was not declared in this scope
../src/binding.cc: In function ‘v8::Handle<v8::Value> FindDevice(const v8::Arguments&)’:
../src/binding.cc:542:22: error: ‘strcpy’ was not declared in this scope
../src/binding.cc:558:35: error: ‘strcmp’ was not declared in this scope
../src/binding.cc:564:35: error: ‘strcmp’ was not declared in this scope
make: *** [Release/obj.target/cap/src/binding.o] Erreur 1
make: quittant le répertoire « /home/franck/cidr/node_modules/cap/build »
Linux debian 3.8-trunk-amd64 #1 SMP Debian 3.8.3-1~experimental.1 x86_64 GNU/Linux
node v0.10.0
gcc (Debian 4.7.2-5) 4.7.2
libpcap-dev 1.3.0-1 (package libpcap0.8-dev)
Thanks
Trying to npm install cap on windows 10, gets the following error:
c:\xampp\htdocs\node-project>npm install cap --save
> [email protected] install c:\xampp\htdocs\node-project\node_modules\cap
> node-gyp rebuild
c:\xampp\htdocs\node-project\node_modules\cap>if not defined npm_config_node_gyp (node "C:\Users\home\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" reb
uild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
binding.cc
win_delay_load_hook.cc
..\src\binding.cc(3): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [c:\xampp\htdocs\node-project\node_modules\cap\build\cap.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\home\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\home\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd c:\xampp\htdocs\node-project\node_modules\cap
gyp ERR! node -v v6.10.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\home\AppData\Roaming\npm-cache\_logs\2017-08-12T16_32_07_401Z-debug.log
Any idea what could have gone wrong?
D:\nodep\work>node server
module.js:356
Module._extensions[extension](this, filename);
^
Error: %1 is not a valid Win32 application.
D:\nodep\node_modules\cap\build\Release\cap.node
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (D:\nodep\node_modules\cap\lib\Cap.js:3:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
Hi! Are there any plans to add a typescript declaration file?
Finally had a chance to run this. The previous correction gets it to compile but the root cause is not addressed.
The callback signature has changed for windows and no longer includes an (int) status.
Once the callback signature is fixed the cast is not longer required and the code runs properly.
In its current condition it generates a failed assertion.
Since the chuck of data is reassembled into two packets. Cap module is not capturing the first reassembled TCP packet. It is capturing only the second packet. How to capture both the packets ?
I just copy-pasted code from the example and I get that error. Why though? I can ping it just fine.
var Cap = require('cap').Cap,
decoders = require('cap').decoders,
PROTOCOL = decoders.PROTOCOL;
var c = new Cap(),
device = Cap.findDevice('192.168.1.131'),
filter = 'tcp and dst port 80',
bufSize = 10 * 1024 * 1024,
buffer = new Buffer(65535);
var linkType = c.open(device, filter, bufSize, buffer);
c.setMinBytes && c.setMinBytes(0);
c.on('packet', function(nbytes, trunc) {
console.log('Potential Dash Button Press?!?!?!');
});
Checking your sourcecode, i did not find any DNS parsing, is this on roadmap or won't be implemented? Trying to put buffer from 53' packet into https://github.com/mdns-js/node-dns-js doesn't work :/
i want to send a udp packet in windows. the source port i needed is using by another program so i can't use normal dgram.
i'm using raw-socket (https://www.npmjs.com/package/raw-socket) to do it now, it works well but will trigger UAC each time. and i find wireshark can run as normal user after install winpcap as service. then i'm trying to use cap to send this packet.
the "Send an arbitrary packet" example writes MAC address and source IP address directly in program, which can't work in real world. and i can't find how it can be automatically detected.
could you add a example for sending a udp packet with detected addresses that will works in real-world?
hey is it possible to get the time when a "connection" is answered? as i see in your samples its just possible to get the time when a packet arrives... but can i also get the time or event when an connection is answered? is this possible somehow? so for example... i want the time between the request of a browser and the reponse from the server.
Hello dear admins ,
There are an issue with CPU . if you handle with the script a big amount of packets , the cpu of the node process start to be fucked . and stay fucked . It should be back to ~ 1 / 3 % of cpu usage , but when a lot of packet come it's come back to like 30% even if no more lot of paquet come. then if receive again a lot of packet = 100% cpu . and stay at 100% even if no more packet come . If you need a test , just handle a DDoS with the node running and look how the process is working ... . It's strange because it's a cpu leak .
I'm working on an Electron App that broadcasts UDP to find specific devices connected to the network and it is throwing an error on this line:
var linkType = c.open(device, filter, bufSize, buffer);
This is the error on the console: Uncaught Error: (cannot open BPF device) /dev/bpf0: Permission denied
It works fine on my local environment, but when running the App on another Mac it's failing as described. Do I have to grant permissions to the App in order to be able to open the Cap object (c)? I've tried using the sudo-prompt module but it is not working.
if i comment this line:
Address->Set(String::New(key), String::New(address));
then (after rebuilding) deviceList() retun something
problem here:
Address->Set(String::New(key), String::New(address));
right here:
String::New(address)
it fails when 'address' equal NULL
so, this code works fine:
if( address == NULL ) {
Address->Set(String::New(key), String::New("null"));
} else {
Address->Set(String::New(key), String::New(address));
}
I am using nwjs from the command line of a Mac.
For some time I have been using the command:
device = findDevice(selectedIP);
and then using the device string in an open command. It has worked fine.
Recently, the device value has been undefined.
When I use sudo to run nwjs, the device string en0 is returned and I can open and send packets.
Any idea why this might be happening?
Thanks!!
Is there any way to make the event on('packet')
buffered?
Some times a packet should be buffered before returning the full payload.
npm
npm ERR! cb() never called!
npm ERR! not ok code 0
npm log
[email protected] install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the cap package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
./node_modules/cap/lib/Decoders.js:305
IPhdr = exports.IPv4(b, offset);
TypeError: Object # has no method 'IPv4'
at Object.exports.ICMPV4 (./node_modules/cap/lib/Decoders.js:305:21)
module.js:339
Module._extensions[extension](this, filename);
^
Error: Module did not self-register.
at Error (native)
at Module.load (module.js:339:32)
at Function.Module._load (module.js:294:12)
at Module.require (module.js:349:17)
at require (module.js:368:17)
at Object.<anonymous> (C:\Users\Eric Range\Documents\GitHub\xyz\node_modules\cap\lib\Cap.
js:3:13)
at Module._compile (module.js:444:26)
at Object.Module._extensions..js (module.js:462:10)
at Module.load (module.js:339:32)
at Function.Module._load (module.js:294:12)
I'm trying to integrate this great library in one desktop application I'm working on. I'm using electron to build the desktop app.
Because electron uses a different version of node.js, Cap needs to be recompiled for it (instructions http://electron.atom.io/docs/v0.31.0/tutorial/using-native-node-modules/). When I try to do so I get this error:
> [email protected] install /Users/bkolobara/Development/starcraftbuildorder/node_modules/cap
> node-gyp rebuild
CXX(target) Release/obj.target/cap/src/binding.o
In file included from ../src/binding.cc:3:
../node_modules/nan/nan.h:324:27: error: redefinition of 'NanEnsureHandleOrPersistent'
NAN_INLINE v8::Local<T> NanEnsureHandleOrPersistent(const v8::Local<T> &val) {
^
../node_modules/nan/nan.h:319:17: note: previous definition is here
v8::Handle<T> NanEnsureHandleOrPersistent(const v8::Handle<T> &val) {
^
../node_modules/nan/nan.h:344:27: error: redefinition of 'NanEnsureLocal'
NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Handle<T> &val) {
^
../node_modules/nan/nan.h:334:27: note: previous definition is here
NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Local<T> &val) {
^
../node_modules/nan/nan.h:757:13: error: no member named 'smalloc' in namespace 'node'
, node::smalloc::FreeCallback callback
~~~~~~^
../node_modules/nan/nan.h:768:12: error: no matching function for call to 'New'
return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
^~~~~~~~~~~~~~~~~
.... removed ...
10 errors generated.
make: *** [Release/obj.target/cap/src/binding.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
... removed ...
I'm writing a little bit of code to monitor the amount of traffic going in/out of a computer.
Hey there. Is this still maintained somehow?
I tried to install the package with npm i cap.
I installed already wireshark and winpcap.
I'm getting following error
D:\Data\projects\ff14-trading-tracker>npm i cap
> [email protected] install D:\Data\projects\ff14-trading-tracker\node_modules\cap
> node-gyp rebuild
D:\Data\projects\ff14-trading-tracker\node_modules\cap>if not defined npm_config_node_gyp (node "D:\Programme\Entwicklung\NodeJS\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "D:\Programme\Entwicklung\NodeJS\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Die Projekte in dieser Projektmappe werden nacheinander erstellt. Um eine parallele Erstellung zu ermöglichen, müssen Sie den Schalter "/m" hinzufügen.
binding.cc
win_delay_load_hook.cc
..\src\binding.cc(52): error C2666: 'inet_ntop': 2 overloads have similar conversions [D:\Data\projects\ff14-trading-tracker\node_modules\cap\build\cap.vcxproj]
d:\data\projects\ff14-trading-tracker\node_modules\cap\src\windows_polyfills.h(116): note: could be 'char *inet_ntop(int,const void *,char *,socklen_t)' (compiling source file ..\src\binding.cc)
C:\Program Files (x86)\Windows Kits\8.1\Include\um\ws2tcpip.h(576): note: or 'PCSTR inet_ntop(INT,PVOID,PSTR,std::size_t)' (compiling source file ..\src\binding.cc)
..\src\binding.cc(52): note: while trying to match the argument list '(ADDRESS_FAMILY, char *, char [66], socklen_t)'
..\src\binding.cc(584): error C2666: 'inet_ntop': 2 overloads have similar conversions [D:\Data\projects\ff14-trading-tracker\node_modules\cap\build\cap.vcxproj]
d:\data\projects\ff14-trading-tracker\node_modules\cap\src\windows_polyfills.h(116): note: could be 'char *inet_ntop(int,const void *,char *,socklen_t)' (compiling source file ..\src\binding.cc)
C:\Program Files (x86)\Windows Kits\8.1\Include\um\ws2tcpip.h(576): note: or 'PCSTR inet_ntop(INT,PVOID,PSTR,std::size_t)' (compiling source file ..\src\binding.cc)
..\src\binding.cc(584): note: while trying to match the argument list '(int, char *, char [22], int)'
..\src\binding.cc(592): error C2666: 'inet_ntop': 2 overloads have similar conversions [D:\Data\projects\ff14-trading-tracker\node_modules\cap\build\cap.vcxproj]
d:\data\projects\ff14-trading-tracker\node_modules\cap\src\windows_polyfills.h(116): note: could be 'char *inet_ntop(int,const void *,char *,socklen_t)' (compiling source file ..\src\binding.cc)
C:\Program Files (x86)\Windows Kits\8.1\Include\um\ws2tcpip.h(576): note: or 'PCSTR inet_ntop(INT,PVOID,PSTR,std::size_t)' (compiling source file ..\src\binding.cc)
..\src\binding.cc(592): note: while trying to match the argument list '(int, char *, char [65], int)'
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (D:\Programme\Entwicklung\NodeJS\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack at ChildProcess.emit (events.js:160:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "D:\\Programme\\Entwicklung\\NodeJS\\node.exe" "D:\\Programme\\Entwicklung\\NodeJS\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\Data\projects\ff14-trading-tracker\node_modules\cap
gyp ERR! node -v v9.5.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Do you have a idea why this happens?
now when something wrong happeds, like
c = new Cap()
# no open
c.send(new Buffer(100))
node process will exit, without any chance to catch.
It's better to throw an Exception instead of do exit.
I only tested in windows.
On README we can see: For Windows: WinPcap
So, deps/winpcap
its just a "layer" to use a "winpcap dll" previously installed on host system?
On windows, do i must to have "winpcap" previously installed? Or "deps/winpcap" should manage it for me?
I am using node v4.2.4
npm v2.14.12
WinPcap 4.1.3
error is showing that in my system node-gyp rebuild has failed.
Build fails targeting node 0.11.13:
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info spawn python
gyp info spawn args [ '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/dominic/test/cap/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/dominic/.node-gyp/0.11.13/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/dominic/.node-gyp/0.11.13',
gyp info spawn args '-Dmodule_root_dir=/Users/dominic/test/cap',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/cap/src/binding.o
../src/binding.cc:65:28: error: no member named 'New' in 'v8::String'
Address->Set(String::New(key), Undefined());
~~~~~~~~^
../src/binding.cc:67:28: error: no member named 'New' in 'v8::String'
Address->Set(String::New(key), String::New(address));
~~~~~~~~^
../src/binding.cc:71:21: error: expected class name
class Pcap : public ObjectWrap {
^
../src/binding.cc:80:5: error: unknown type name 'uv_poll_t'
uv_poll_t poll_handle;
^
../src/binding.cc:180:28: error: unknown type name 'uv_poll_t'
static void cb_packets(uv_poll_t* handle, int status, int events) {
^
../src/binding.cc:194:36: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
static Handle<Value> New(const Arguments& args) {
^~~~~~~~~
v8::internal::Arguments
/Users/dominic/.node-gyp/0.11.13/deps/v8/include/v8.h:149:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
../src/binding.cc:213:37: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
static Handle<Value> Send(const Arguments& args) {
^~~~~~~~~
v8::internal::Arguments
/Users/dominic/.node-gyp/0.11.13/deps/v8/include/v8.h:149:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
../src/binding.cc:271:37: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
static Handle<Value> Open(const Arguments& args) {
^~~~~~~~~
v8::internal::Arguments
/Users/dominic/.node-gyp/0.11.13/deps/v8/include/v8.h:149:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
../src/binding.cc:508:38: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
static Handle<Value> Close(const Arguments& args) {
^~~~~~~~~
v8::internal::Arguments
/Users/dominic/.node-gyp/0.11.13/deps/v8/include/v8.h:149:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
../src/binding.cc:99:12: error: no member named 'Dispose' in 'v8::Persistent<v8::Function, v8::NonCopyablePersistentTraits<v8::Function> >'
Emit.Dispose();
~~~~ ^
../src/binding.cc:100:12: error: no member named 'Clear' in 'v8::Persistent<v8::Function, v8::NonCopyablePersistentTraits<v8::Function> >'
Emit.Clear();
~~~~ ^
../src/binding.cc:119:9: error: use of undeclared identifier 'Unref'
Unref();
^
../src/binding.cc:128:19: error: calling a protected constructor of class 'v8::HandleScope'
HandleScope scope;
^
/Users/dominic/.node-gyp/0.11.13/deps/v8/include/v8.h:845:13: note: declared protected here
V8_INLINE HandleScope() {}
^
../src/binding.cc:142:9: error: too few arguments to function call, expected 2, have 1; did you mean '::Pcap::New'?
Number::New(copy_len),
^~~~~~~~~~~
::Pcap::New
../src/binding.cc:194:26: note: '::Pcap::New' declared here
static Handle<Value> New(const Arguments& args) {
^
../src/binding.cc:143:9: error: too few arguments to function call, expected 2, have 1; did you mean '::Pcap::New'?
Boolean::New(truncated)
^~~~~~~~~~~~
::Pcap::New
../src/binding.cc:194:26: note: '::Pcap::New' declared here
static Handle<Value> New(const Arguments& args) {
^
../src/binding.cc:145:16: error: member reference type 'Persistent<v8::Function>' is not a pointer; maybe you meant to use '.'?
obj->Emit->Call(obj->handle_, 3, emit_argv);
~~~~~~~~~^~
.
../src/binding.cc:145:18: error: no member named 'Call' in 'v8::Persistent<v8::Function, v8::NonCopyablePersistentTraits<v8::Function> >'
obj->Emit->Call(obj->handle_, 3, emit_argv);
~~~~~~~~~ ^
../src/binding.cc:145:28: error: no member named 'handle_' in 'Pcap'
obj->Emit->Call(obj->handle_, 3, emit_argv);
~~~ ^
../src/binding.cc:184:20: error: use of undeclared identifier 'UV_READABLE'
if (events & UV_READABLE) {
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [Release/obj.target/cap/src/binding.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Darwin 13.3.0
gyp ERR! command "node" "/usr/local/bin/node-gyp" "rebuild" "--target=0.11.13"
gyp ERR! cwd /Users/dominic/test/cap
gyp ERR! node -v v0.10.31
gyp ERR! node-gyp -v v0.13.1
gyp ERR! not ok
Any chance of this module being updated?
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
binding.cc
..\src\binding.cc(249): warning C4267: '=' : conversion from 'size_t' to 'unsig
ned int', possible loss of data [c:\Users\Paul Dorn\Workspace\cap\build\cap.vcx
proj]
..\src\binding.cc(336): warning C4353: nonstandard extension used: constant 0 a
s function expression. Use '__noop' function intrinsic instead [c:\Users\Paul
Dorn\Workspace\cap\build\cap.vcxproj]
..\src\binding.cc(387): warning C4344: behavior change: use of explicit templat
e arguments results in call to 'v8::Local NanNewv8::String,char*(A0)' [c:
Users\Paul Dorn\Workspace\cap\build\cap.vcxproj]
with
[
T=v8::String,
A0=char *
]
but the regular function 'v8::Local NanNew(const char *)' is a bet
ter match
with
[
T=v8::String
]
if you expect 'v8::Local NanNew(const char *)' to be called then y
ou need to make it an explicit specialization
with
[
T=v8::String
]
..\src\binding.cc(393): error C2664: 'uv_async_init' : cannot convert parameter
3 from 'void (__cdecl *)(uv_async_t *,int)' to 'uv_async_cb' [c:\Users\Paul Do
rn\Workspace\cap\build\cap.vcxproj]
None of the functions with this name in scope match the target type
gyp ERR! build error
gyp ERR! stack Error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (c:\Users\Paul Dorn\AppData\Roaming\np
m\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1067
:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "c:\Program Files\nodejs\node.exe" "c:\Users\Paul Dorn\Ap
pData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd c:\Users\Paul Dorn\Workspace\cap
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v0.13.1
gyp ERR! not ok
I'm looking at what might have caused this but it will take some time since I need to wrap my head around NAN.
Firstly thanks for the great library, very helpful!
I'm feeding in data captured from Wireshark, and I've found that large packets (in this case over 60,000 bytes) aren't being decoded correctly. Small packets work as expected.
In the example below, the return value from decoders.IPV4()
gives info.totallen
as zero:
https://gist.github.com/karldd/7892a8dd08543e99e954
Ideally all TCP packets are below 1500 bytes, but apparently some configurations go well over this.
Hi,
I am using node v6.11.0 together with nw.js. I have installed cap successfully, and am now wanting to use it to send AVDECC ethernet packets. When I try to initialize with c = new Cap(); I get an error message indicating that a dll cannot be initialized in module.js.
I have used cap successfully on the Mac and am now porting the same code to Windows. I have Visual Studio 2015 enterprise edition installed.
Any idea what might be causing this run time message?
Thanks!
I don't quite understand the difference between the two. Isn't it the same if I set bufSize to 0 and no longer use setMinBytes ?
From the readme:
bufSize is the size of the internal buffer that libpcap uses to temporarily store packets until they are emitted
setMinBytes(< integer >nBytes) - (void) - (Windows ONLY) This sets the minimum number of packet bytes that must be captured before the full packet data is made available. If this value is set too high, you may not receive any packets until WinPCap's internal buffer fills up.
Can you explain a little bit better what they do ?
Thanks for your help
Hi,
I'm not able to install cap
on Windows. I receive the following error:
I have installed:
cap
)To install cap
I used npm install cap --save
I installed without any problems cap
on my OS X machine. Is there a problem if I copy it from my OS X machine into my Windows machine ? Or do I need to run npm install cap
on my Windows machine ?
What am I doing wrong ?
Thanks
Hello, i use your package but i need to read pcap trace file instead of real time capture. Is it possible?
Its not an issue . I know u didnt made a code to sniff ARP packets. But actually looking at your decoder file I just made some piece of code to sniff ARP packets but i didn't got output . I will attach code below. please help me if you found any errors.
// Internet Layer Protocols ====================================================
exports.ARP = function(b, offset) {
offset || (offset = 0);
var origoffset = offset, i;
var ret = {
info: {
hardwareAddr: undefined,
protocol: undefined,
hdrlen: undefined,
protlen: undefined,
opcode: undefined,
senderMac: undefined,
senderIp: undefined,
targetMac: undefined,
targetIp: undefined,
},
hdrlen: undefined,
offset: undefined
};
ret.info.hardwareAddr = b.readUInt16BE(offset, true);
offset += 2;
ret.info.protocol = b.readUInt16BE(offset, true);
offset += 2;
ret.info.hdrlen = b.readUInt16BE(offset, true);
offset += 1;
ret.info.protlen = b.readUInt16BE(offset, true);
offset += 1;
ret.info.opcode = b.readUInt16BE(offset, true);
offset += 2;
ret.info.senderMac = b.toString('hex', offset, offset + 6);
offset += 6;
ret.info.senderIp = b.toString('hex', offset, offset + 4);
offset += 4;
ret.info.targetMac = b.toString('hex', offset, offset + 6);
offset += 6;
ret.info.targetIp = b.toString('hex', offset, offset + 4);
offset += 4;
ret.offset = offset;
return ret;
};
Hi,
I'm trying to view packets through port 443 using the following filter:
filter = 'tcp and dst port 443',
I'm using the same code as in the example:
c.on('packet', function (nbytes, trunc) {
if (linkType === 'ETHERNET') {
var ret = decoders.Ethernet(buffer);
if (ret.info.type === PROTOCOL.ETHERNET.IPV4) {
ret = decoders.IPV4(buffer, ret.offset);
if (ret.info.protocol === PROTOCOL.IP.TCP) {
var datalen = ret.info.totallen - ret.hdrlen;
ret = decoders.TCP(buffer, ret.offset);
datalen -= ret.hdrlen;
const offset = buffer.toString('binary', ret.offset, ret.offset + datalen);
the problem is that offset
echos very strange output, see this:
Is there something I'm missing with the decoder?
Thanks
I can't get the module working with nodeJS v0.12 , only works on 0.10 ?
the static listDevices() method currently do not display any wi fi related networks, is it intended behavior or there is any way to show wi-fi connections as well?
In that example program is working for interface to port 80 but i want snif the packets from port to interface is it possible?
Any chance you can add an ARP decoder (or sample code on how to decode an ARP packet?)
Thanks!
Maybe a dump question here:
In the usage example in README:
var linkType = c.open(device, filter, bufSize, buffer);
open takes only one buffer. And when it emits the event, only nbytes and trunc are returned in the event. The data is in the buffer.
Question: when I read the buffer and do some processing, will the next incoming packet write the buffer so that maybe I will read the wrong data? And what's the best practice to read the buffer, shall I always slice the buffer with nbytes?
Thanks a lot!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.