mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-09-11 08:55:32 +03:00
Fixed ScanAmt in agent and added AmtScan to MeshCmd
This commit is contained in:
parent
e3cad41330
commit
2750b6e39f
@ -137,6 +137,7 @@
|
||||
<Compile Include="webauthn.js" />
|
||||
<Compile Include="webserver.js" />
|
||||
<Compile Include="winservice.js" />
|
||||
<Content Include="agents\codesign.cer" />
|
||||
<Content Include="agents\compressModules.bat" />
|
||||
<Content Include="agents\MeshAgentOSXPackager.zip" />
|
||||
<Content Include="agents\meshagent_arm" />
|
||||
|
Binary file not shown.
Binary file not shown.
@ -114,7 +114,7 @@ function run(argv) {
|
||||
//console.log('addedModules = ' + JSON.stringify(addedModules));
|
||||
var actionpath = 'meshaction.txt';
|
||||
if (args.actionfile != null) { actionpath = args.actionfile; }
|
||||
var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTPOWER', 'AMTFEATURES', 'AMTNETWORK', 'AMTLOADWEBAPP', 'AMTLOADSMALLWEBAPP', 'AMTLOADLARGEWEBAPP', 'AMTCLEARWEBAPP', 'AMTSTORAGESTATE', 'AMTINFO', 'AMTINFODEBUG', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTSCRIPT', 'AMTUUID', 'AMTCCM', 'AMTACM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTEVENTLOG', 'AMTPRESENCE'];
|
||||
var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTSCAN', 'AMTPOWER', 'AMTFEATURES', 'AMTNETWORK', 'AMTLOADWEBAPP', 'AMTLOADSMALLWEBAPP', 'AMTLOADLARGEWEBAPP', 'AMTCLEARWEBAPP', 'AMTSTORAGESTATE', 'AMTINFO', 'AMTINFODEBUG', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTSCRIPT', 'AMTUUID', 'AMTCCM', 'AMTACM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTEVENTLOG', 'AMTPRESENCE'];
|
||||
|
||||
// Load the action file
|
||||
var actionfile = null;
|
||||
@ -151,6 +151,7 @@ function run(argv) {
|
||||
if ((typeof args.floppy) == 'string') { settings.floppy = args.floppy; }
|
||||
if ((typeof args.cdrom) == 'string') { settings.cdrom = args.cdrom; }
|
||||
if ((typeof args.tag) == 'string') { settings.tag = args.tag; }
|
||||
if ((typeof args.scan) == 'string') { settings.scan = args.scan; }
|
||||
if ((typeof args.timeout) == 'string') { settings.timeout = parseInt(args.timeout); }
|
||||
if (args.debug === true) { settings.debuglevel = 1; }
|
||||
if (args.debug) { try { waitForDebugger(); } catch (e) { } }
|
||||
@ -194,6 +195,7 @@ function run(argv) {
|
||||
console.log(' AmtIDER - Mount local disk image to remote computer.');
|
||||
console.log(' AmtFeatures - Intel AMT features & user consent.');
|
||||
console.log(' AmtNetwork - Intel AMT network interface settings.');
|
||||
console.log(' AmtScan - Search local network for Intel AMT devices.');
|
||||
console.log('\r\nHelp on a specific action using:\r\n');
|
||||
console.log(' meshcmd help [action]');
|
||||
exit(1); return;
|
||||
@ -373,6 +375,10 @@ function run(argv) {
|
||||
console.log(' --floppy [file] Specifies .img file to be mounted as a flppy disk.');
|
||||
console.log(' --cdrom [file] Specifies .img file to be mounted as a CDROM disk.');
|
||||
console.log(' --timeout [seconds] Optional, disconnect after number of seconds without disk read.');
|
||||
} else if (action == 'amtscan') {
|
||||
console.log('AmtSCAN will look for Intel AMT device on the network. Example usage:\r\n\r\n meshcmd amtscan --scan 192.168.1.0/24');
|
||||
console.log('\r\Required arguments:\r\n');
|
||||
console.log(' --scan [ip range] The IP address range to perform the scan on.');
|
||||
} else {
|
||||
actions.shift();
|
||||
console.log('Invalid action, usage:\r\n\r\n meshcmd help [action]\r\n\r\nValid actions are: ' + actions.join(', ') + '.');
|
||||
@ -629,6 +635,29 @@ function run(argv) {
|
||||
startMeshCommander();
|
||||
//} else if (settings.action == 'amtdisable') { // Disable AMT Network Interface
|
||||
// amtDisable();
|
||||
} else if (settings.action == 'amtscan') {
|
||||
// Scan the network for Intel AMT devices
|
||||
if ((settings.scan == null) || (typeof settings.scan != 'string') || (settings.scan == '')) { console.log('No or invalid \"scan\" specified, use --scan [ip range].'); exit(1); return; }
|
||||
console.log('Scanning: ' + settings.scan + '...');
|
||||
var AMTScannerModule = require('amt-scanner');
|
||||
var amtscanner = new AMTScannerModule(), r = '';
|
||||
amtscanner.scan(settings.scan, 2000, function (data) {
|
||||
if (data.length > 0) {
|
||||
r = '', pstates = ['NotActivated', 'InActivation', 'Activated'];
|
||||
for (var i in data) {
|
||||
var x = data[i];
|
||||
if (r != '') { r += '\r\n'; }
|
||||
r += x.address + ' - Intel AMT v' + x.majorVersion + '.' + x.minorVersion;
|
||||
if (x.provisioningState < 3) { r += (', ' + pstates[x.provisioningState]); }
|
||||
if (x.provisioningState == 2) { r += (', ' + x.openPorts.join(', ')); }
|
||||
r += '.';
|
||||
}
|
||||
} else {
|
||||
r = 'No Intel AMT found.';
|
||||
}
|
||||
console.log(r);
|
||||
exit(1);
|
||||
});
|
||||
} else if (settings.action == 'amtauditlog') { // Read the Intel AMT audit log
|
||||
if (settings.hostname != null) {
|
||||
if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
|
||||
@ -1146,7 +1175,7 @@ function activeToACMEx(fwNonce, dnsSuffix, digestRealm, uuid, allowedModes) {
|
||||
var connection = http.request(options);
|
||||
connection.on('upgrade', function (response, socket) {
|
||||
settings.xxsocket = socket;
|
||||
console.log('Connected, requesting activation...');
|
||||
if (settings.action == 'amtdiscover') { console.log('Connected, performing discovery...'); } else { console.log('Connected, requesting activation...'); }
|
||||
socket.on('end', function () { console.log('Connection closed'); exit(0); });
|
||||
socket.on('error', function () { console.log('Connection error'); exit(100); });
|
||||
socket.on('data', function (data) {
|
||||
|
33
agents/meshcmd.min.js
vendored
33
agents/meshcmd.min.js
vendored
@ -114,7 +114,7 @@ function run(argv) {
|
||||
//console.log('addedModules = ' + JSON.stringify(addedModules));
|
||||
var actionpath = 'meshaction.txt';
|
||||
if (args.actionfile != null) { actionpath = args.actionfile; }
|
||||
var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTPOWER', 'AMTFEATURES', 'AMTNETWORK', 'AMTLOADWEBAPP', 'AMTLOADSMALLWEBAPP', 'AMTLOADLARGEWEBAPP', 'AMTCLEARWEBAPP', 'AMTSTORAGESTATE', 'AMTINFO', 'AMTINFODEBUG', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTSCRIPT', 'AMTUUID', 'AMTCCM', 'AMTACM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTEVENTLOG', 'AMTPRESENCE'];
|
||||
var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTSCAN', 'AMTPOWER', 'AMTFEATURES', 'AMTNETWORK', 'AMTLOADWEBAPP', 'AMTLOADSMALLWEBAPP', 'AMTLOADLARGEWEBAPP', 'AMTCLEARWEBAPP', 'AMTSTORAGESTATE', 'AMTINFO', 'AMTINFODEBUG', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTSCRIPT', 'AMTUUID', 'AMTCCM', 'AMTACM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTEVENTLOG', 'AMTPRESENCE'];
|
||||
|
||||
// Load the action file
|
||||
var actionfile = null;
|
||||
@ -151,6 +151,7 @@ function run(argv) {
|
||||
if ((typeof args.floppy) == 'string') { settings.floppy = args.floppy; }
|
||||
if ((typeof args.cdrom) == 'string') { settings.cdrom = args.cdrom; }
|
||||
if ((typeof args.tag) == 'string') { settings.tag = args.tag; }
|
||||
if ((typeof args.scan) == 'string') { settings.scan = args.scan; }
|
||||
if ((typeof args.timeout) == 'string') { settings.timeout = parseInt(args.timeout); }
|
||||
if (args.debug === true) { settings.debuglevel = 1; }
|
||||
if (args.debug) { try { waitForDebugger(); } catch (e) { } }
|
||||
@ -194,6 +195,7 @@ function run(argv) {
|
||||
console.log(' AmtIDER - Mount local disk image to remote computer.');
|
||||
console.log(' AmtFeatures - Intel AMT features & user consent.');
|
||||
console.log(' AmtNetwork - Intel AMT network interface settings.');
|
||||
console.log(' AmtScan - Search local network for Intel AMT devices.');
|
||||
console.log('\r\nHelp on a specific action using:\r\n');
|
||||
console.log(' meshcmd help [action]');
|
||||
exit(1); return;
|
||||
@ -373,6 +375,10 @@ function run(argv) {
|
||||
console.log(' --floppy [file] Specifies .img file to be mounted as a flppy disk.');
|
||||
console.log(' --cdrom [file] Specifies .img file to be mounted as a CDROM disk.');
|
||||
console.log(' --timeout [seconds] Optional, disconnect after number of seconds without disk read.');
|
||||
} else if (action == 'amtscan') {
|
||||
console.log('AmtSCAN will look for Intel AMT device on the network. Example usage:\r\n\r\n meshcmd amtscan --scan 192.168.1.0/24');
|
||||
console.log('\r\Required arguments:\r\n');
|
||||
console.log(' --scan [ip range] The IP address range to perform the scan on.');
|
||||
} else {
|
||||
actions.shift();
|
||||
console.log('Invalid action, usage:\r\n\r\n meshcmd help [action]\r\n\r\nValid actions are: ' + actions.join(', ') + '.');
|
||||
@ -629,6 +635,29 @@ function run(argv) {
|
||||
startMeshCommander();
|
||||
//} else if (settings.action == 'amtdisable') { // Disable AMT Network Interface
|
||||
// amtDisable();
|
||||
} else if (settings.action == 'amtscan') {
|
||||
// Scan the network for Intel AMT devices
|
||||
if ((settings.scan == null) || (typeof settings.scan != 'string') || (settings.scan == '')) { console.log('No or invalid \"scan\" specified, use --scan [ip range].'); exit(1); return; }
|
||||
console.log('Scanning: ' + settings.scan + '...');
|
||||
var AMTScannerModule = require('amt-scanner');
|
||||
var amtscanner = new AMTScannerModule(), r = '';
|
||||
amtscanner.scan(settings.scan, 2000, function (data) {
|
||||
if (data.length > 0) {
|
||||
r = '', pstates = ['NotActivated', 'InActivation', 'Activated'];
|
||||
for (var i in data) {
|
||||
var x = data[i];
|
||||
if (r != '') { r += '\r\n'; }
|
||||
r += x.address + ' - Intel AMT v' + x.majorVersion + '.' + x.minorVersion;
|
||||
if (x.provisioningState < 3) { r += (', ' + pstates[x.provisioningState]); }
|
||||
if (x.provisioningState == 2) { r += (', ' + x.openPorts.join(', ')); }
|
||||
r += '.';
|
||||
}
|
||||
} else {
|
||||
r = 'No Intel AMT found.';
|
||||
}
|
||||
console.log(r);
|
||||
exit(1);
|
||||
});
|
||||
} else if (settings.action == 'amtauditlog') { // Read the Intel AMT audit log
|
||||
if (settings.hostname != null) {
|
||||
if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
|
||||
@ -1146,7 +1175,7 @@ function activeToACMEx(fwNonce, dnsSuffix, digestRealm, uuid, allowedModes) {
|
||||
var connection = http.request(options);
|
||||
connection.on('upgrade', function (response, socket) {
|
||||
settings.xxsocket = socket;
|
||||
console.log('Connected, requesting activation...');
|
||||
if (settings.action == 'amtdiscover') { console.log('Connected, performing discovery...'); } else { console.log('Connected, requesting activation...'); }
|
||||
socket.on('end', function () { console.log('Connection closed'); exit(0); });
|
||||
socket.on('error', function () { console.log('Connection error'); exit(100); });
|
||||
socket.on('data', function (data) {
|
||||
|
@ -64,7 +64,7 @@ function AMTScanner() {
|
||||
if (masknum <= 16 || masknum > 32) return null;
|
||||
masknum = 32 - masknum;
|
||||
for (var i = 0; i < masknum; i++) { mask = (mask << 1); mask++; }
|
||||
return { min: ip & (0xFFFFFFFF - mask), max: (ip & (0xFFFFFFFF - mask)) + mask };
|
||||
return { min: (ip & (0xFFFFFFFF - mask))+1, max: (ip & (0xFFFFFFFF - mask)) + mask -1 };//remove network and broadcast address to avoid irrecoverable socket error
|
||||
}
|
||||
x = this.parseIpv4Addr(range);
|
||||
if (x == null) return null;
|
||||
@ -83,7 +83,7 @@ function AMTScanner() {
|
||||
return ((num >> 24) & 0xFF) + '.' + ((num >> 16) & 0xFF) + '.' + ((num >> 8) & 0xFF) + '.' + (num & 0xFF);
|
||||
}
|
||||
|
||||
this.scan = function (rangestr, timeout) {
|
||||
this.scan = function (rangestr, timeout, callback) {
|
||||
var iprange = this.parseIPv4Range(rangestr);
|
||||
var rmcp = this.buildRmcpPing(0);
|
||||
var server = this.dgram.createSocket({ type: 'udp4' });
|
||||
@ -91,11 +91,15 @@ function AMTScanner() {
|
||||
server.scanResults = [];
|
||||
server.on('error', function (err) { console.log('Error:' + err); });
|
||||
server.on('message', function (msg, rinfo) { if (rinfo.size > 4) { this.parent.parseRmcpPacket(this, msg, rinfo, function (s, res) { s.scanResults.push(res); }) }; });
|
||||
server.on('listening', function () { for (var i = iprange.min; i <= iprange.max; i++) { server.send(rmcp, 623, server.parent.IPv4NumToStr(i)); } });
|
||||
server.on('listening', function () { for (var i = iprange.min; i <= iprange.max; i++) {
|
||||
server.send(rmcp, 623, server.parent.IPv4NumToStr(i)); } });
|
||||
server.bind({ address: '0.0.0.0', port: 0, exclusive: true });
|
||||
var tmout = setTimeout(function cb() {
|
||||
//console.log("Server closed");
|
||||
server.close();
|
||||
if (callback) {
|
||||
callback(server.scanResults);
|
||||
}
|
||||
server.parent.emit('found', server.scanResults);
|
||||
delete server;
|
||||
}, timeout);
|
||||
|
@ -1 +1 @@
|
||||
function AMTScanner(){var a=require("events").inherits(this);a.createEvent("found");this.dgram=require("dgram");this.buildRmcpPing=function(c){var b=Buffer.from("06000006000011BE80000000","hex");b[9]=c;return b};this.parseRmcpPacket=function(h,b,g,d){if(b==null||b.length<20){return}var f={};if(((b[12]==0)||(b[13]!=0)||(b[14]!=1)||(b[15]!=87))&&(b[21]&32)){f.servertag=b[9];f.minorVersion=b[18]&15;f.majorVersion=(b[18]>>4)&15;f.provisioningState=b[19]&3;var e=(b[16]*256)+b[17];var c=((b[19]&4)!=0)?true:false;f.openPorts=[e];f.address=g.address;if(c==true){f.openPorts=[16992,16993]}if(d!==undefined){d(h,f)}}};this.parseIPv4Range=function(f){if(f==undefined||f==null){return null}var g=f.split("-");if(g.length==2){return{min:this.parseIpv4Addr(g[0]),max:this.parseIpv4Addr(g[1])}}g=f.split("/");if(g.length==2){var c=this.parseIpv4Addr(g[0]),e=parseInt(g[1]),d=0;if(e<=16||e>32){return null}e=32-e;for(var b=0;b<e;b++){d=(d<<1);d++}return{min:c&(4294967295-d),max:(c&(4294967295-d))+d}}g=this.parseIpv4Addr(f);if(g==null){return null}return{min:g,max:g}};this.parseIpv4Addr=function(b){var c=b.split(".");if(c.length==4){return(parseInt(c[0])<<24)+(parseInt(c[1])<<16)+(parseInt(c[2])<<8)+(parseInt(c[3])<<0)}return null};this.IPv4NumToStr=function(b){return((b>>24)&255)+"."+((b>>16)&255)+"."+((b>>8)&255)+"."+(b&255)};this.scan=function(d,g){var c=this.parseIPv4Range(d);var e=this.buildRmcpPing(0);var f=this.dgram.createSocket({type:"udp4"});f.parent=this;f.scanResults=[];f.on("error",function(i){console.log("Error:"+i)});f.on("message",function(i,j){if(j.size>4){this.parent.parseRmcpPacket(this,i,j,function(l,k){l.scanResults.push(k)})}});f.on("listening",function(){for(var j=c.min;j<=c.max;j++){f.send(e,623,f.parent.IPv4NumToStr(j))}});f.bind({address:"0.0.0.0",port:0,exclusive:true});var h=setTimeout(function b(){f.close();f.parent.emit("found",f.scanResults);delete f},g)}}module.exports=AMTScanner;
|
||||
function AMTScanner(){var a=require("events").inherits(this);a.createEvent("found");this.dgram=require("dgram");this.buildRmcpPing=function(c){var b=Buffer.from("06000006000011BE80000000","hex");b[9]=c;return b};this.parseRmcpPacket=function(h,b,g,d){if(b==null||b.length<20){return}var f={};if(((b[12]==0)||(b[13]!=0)||(b[14]!=1)||(b[15]!=87))&&(b[21]&32)){f.servertag=b[9];f.minorVersion=b[18]&15;f.majorVersion=(b[18]>>4)&15;f.provisioningState=b[19]&3;var e=(b[16]*256)+b[17];var c=((b[19]&4)!=0)?true:false;f.openPorts=[e];f.address=g.address;if(c==true){f.openPorts=[16992,16993]}if(d!==undefined){d(h,f)}}};this.parseIPv4Range=function(f){if(f==undefined||f==null){return null}var g=f.split("-");if(g.length==2){return{min:this.parseIpv4Addr(g[0]),max:this.parseIpv4Addr(g[1])}}g=f.split("/");if(g.length==2){var c=this.parseIpv4Addr(g[0]),e=parseInt(g[1]),d=0;if(e<=16||e>32){return null}e=32-e;for(var b=0;b<e;b++){d=(d<<1);d++}return{min:(c&(4294967295-d))+1,max:(c&(4294967295-d))+d-1}}g=this.parseIpv4Addr(f);if(g==null){return null}return{min:g,max:g}};this.parseIpv4Addr=function(b){var c=b.split(".");if(c.length==4){return(parseInt(c[0])<<24)+(parseInt(c[1])<<16)+(parseInt(c[2])<<8)+(parseInt(c[3])<<0)}return null};this.IPv4NumToStr=function(b){return((b>>24)&255)+"."+((b>>16)&255)+"."+((b>>8)&255)+"."+(b&255)};this.scan=function(e,h,b){var d=this.parseIPv4Range(e);var f=this.buildRmcpPing(0);var g=this.dgram.createSocket({type:"udp4"});g.parent=this;g.scanResults=[];g.on("error",function(j){console.log("Error:"+j)});g.on("message",function(j,k){if(k.size>4){this.parent.parseRmcpPacket(this,j,k,function(m,l){m.scanResults.push(l)})}});g.on("listening",function(){for(var j=d.min;j<=d.max;j++){g.send(f,623,g.parent.IPv4NumToStr(j))}});g.bind({address:"0.0.0.0",port:0,exclusive:true});var i=setTimeout(function c(){g.close();if(b){b(g.scanResults)}g.parent.emit("found",g.scanResults);delete g},h)}}module.exports=AMTScanner;
|
@ -1 +1 @@
|
||||
function AMTScanner(){var a=require("events").inherits(this);a.createEvent("found");this.dgram=require("dgram");this.buildRmcpPing=function(c){var b=Buffer.from("06000006000011BE80000000","hex");b[9]=c;return b};this.parseRmcpPacket=function(h,b,g,d){if(b==null||b.length<20){return}var f={};if(((b[12]==0)||(b[13]!=0)||(b[14]!=1)||(b[15]!=87))&&(b[21]&32)){f.servertag=b[9];f.minorVersion=b[18]&15;f.majorVersion=(b[18]>>4)&15;f.provisioningState=b[19]&3;var e=(b[16]*256)+b[17];var c=((b[19]&4)!=0)?true:false;f.openPorts=[e];f.address=g.address;if(c==true){f.openPorts=[16992,16993]}if(d!==undefined){d(h,f)}}};this.parseIPv4Range=function(f){if(f==undefined||f==null){return null}var g=f.split("-");if(g.length==2){return{min:this.parseIpv4Addr(g[0]),max:this.parseIpv4Addr(g[1])}}g=f.split("/");if(g.length==2){var c=this.parseIpv4Addr(g[0]),e=parseInt(g[1]),d=0;if(e<=16||e>32){return null}e=32-e;for(var b=0;b<e;b++){d=(d<<1);d++}return{min:c&(4294967295-d),max:(c&(4294967295-d))+d}}g=this.parseIpv4Addr(f);if(g==null){return null}return{min:g,max:g}};this.parseIpv4Addr=function(b){var c=b.split(".");if(c.length==4){return(parseInt(c[0])<<24)+(parseInt(c[1])<<16)+(parseInt(c[2])<<8)+(parseInt(c[3])<<0)}return null};this.IPv4NumToStr=function(b){return((b>>24)&255)+"."+((b>>16)&255)+"."+((b>>8)&255)+"."+(b&255)};this.scan=function(d,g){var c=this.parseIPv4Range(d);var e=this.buildRmcpPing(0);var f=this.dgram.createSocket({type:"udp4"});f.parent=this;f.scanResults=[];f.on("error",function(i){console.log("Error:"+i)});f.on("message",function(i,j){if(j.size>4){this.parent.parseRmcpPacket(this,i,j,function(l,k){l.scanResults.push(k)})}});f.on("listening",function(){for(var j=c.min;j<=c.max;j++){f.send(e,623,f.parent.IPv4NumToStr(j))}});f.bind({address:"0.0.0.0",port:0,exclusive:true});var h=setTimeout(function b(){f.close();f.parent.emit("found",f.scanResults);delete f},g)}}module.exports=AMTScanner;
|
||||
function AMTScanner(){var a=require("events").inherits(this);a.createEvent("found");this.dgram=require("dgram");this.buildRmcpPing=function(c){var b=Buffer.from("06000006000011BE80000000","hex");b[9]=c;return b};this.parseRmcpPacket=function(h,b,g,d){if(b==null||b.length<20){return}var f={};if(((b[12]==0)||(b[13]!=0)||(b[14]!=1)||(b[15]!=87))&&(b[21]&32)){f.servertag=b[9];f.minorVersion=b[18]&15;f.majorVersion=(b[18]>>4)&15;f.provisioningState=b[19]&3;var e=(b[16]*256)+b[17];var c=((b[19]&4)!=0)?true:false;f.openPorts=[e];f.address=g.address;if(c==true){f.openPorts=[16992,16993]}if(d!==undefined){d(h,f)}}};this.parseIPv4Range=function(f){if(f==undefined||f==null){return null}var g=f.split("-");if(g.length==2){return{min:this.parseIpv4Addr(g[0]),max:this.parseIpv4Addr(g[1])}}g=f.split("/");if(g.length==2){var c=this.parseIpv4Addr(g[0]),e=parseInt(g[1]),d=0;if(e<=16||e>32){return null}e=32-e;for(var b=0;b<e;b++){d=(d<<1);d++}return{min:(c&(4294967295-d))+1,max:(c&(4294967295-d))+d-1}}g=this.parseIpv4Addr(f);if(g==null){return null}return{min:g,max:g}};this.parseIpv4Addr=function(b){var c=b.split(".");if(c.length==4){return(parseInt(c[0])<<24)+(parseInt(c[1])<<16)+(parseInt(c[2])<<8)+(parseInt(c[3])<<0)}return null};this.IPv4NumToStr=function(b){return((b>>24)&255)+"."+((b>>16)&255)+"."+((b>>8)&255)+"."+(b&255)};this.scan=function(e,h,b){var d=this.parseIPv4Range(e);var f=this.buildRmcpPing(0);var g=this.dgram.createSocket({type:"udp4"});g.parent=this;g.scanResults=[];g.on("error",function(j){console.log("Error:"+j)});g.on("message",function(j,k){if(k.size>4){this.parent.parseRmcpPacket(this,j,k,function(m,l){m.scanResults.push(l)})}});g.on("listening",function(){for(var j=d.min;j<=d.max;j++){g.send(f,623,g.parent.IPv4NumToStr(j))}});g.bind({address:"0.0.0.0",port:0,exclusive:true});var i=setTimeout(function c(){g.close();if(b){b(g.scanResults)}g.parent.emit("found",g.scanResults);delete g},h)}}module.exports=AMTScanner;
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "meshcentral",
|
||||
"version": "0.4.1-o",
|
||||
"version": "0.4.1-p",
|
||||
"keywords": [
|
||||
"Remote Management",
|
||||
"Intel AMT",
|
||||
|
Loading…
Reference in New Issue
Block a user