1.0.2 • Published 4 years ago

@zhiying8710/windivert v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

node-windivert: NodeJS bindings for WinDivert

  1. Introduction

This module provides NodeJS bindings for the WinDivert project. WinDivert provides packet sniffing, modification, injection and blocking for windows. WinDivert: https://reqrypt.org/windivert.html

See the windivert readme: https://github.com/basil00/Divert/blob/master/README

  1. Usage

npm install windivert

var wd = require("windivert");
wd.listen("tcp.DstPort==80 or tcp.SrcPort==80", function(data, inbound){
	console.log("HTTP packet with length", data.length);
});
  1. Other Examples

//Block Packet	
var wd = require("windivert");
wd.listen("tcp.DstPort==80 or tcp.SrcPort==80", function(data, inbound){
	console.log("BLOCKED HTTP packet with length", data.length);
	return false;
});

//Modify Packet
require("buffertools").extend();
var wd = require("windivert");
wd.listen("tcp.DstPort==80 or tcp.SrcPort==80", function(data, inbound){	//inbound is bool
	var d = new Buffer(data);
	console.log(data.length);
	var i = d.indexOf(new Buffer("BOB"));
	if(i>=0){
		d.writeUInt8("S".charCodeAt(0), i++);
		d.writeUInt8("A".charCodeAt(0), i++);
		d.writeUInt8("M".charCodeAt(0), i++);
	}
	return wd.HelperCalcChecksums(d, 0);
});
  1. Building

1) Make sure node-gyp is installed and working. Instructions are here: https://github.com/nodejs/node-gyp
2) Download WinDivert-1.1.8-MSVC.zip from https://reqrypt.org/windivert.html and extract its contents into the module directory. 
3) node-gyp clean configure build
4) Windivert will automatically use the custom built binary from build/Release if it exists, instead of the precompiled binaries in ./bin