mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Make MeshAgent and MeshCore update.
This commit is contained in:
parent
5a4223e5a6
commit
8f568380d5
61 changed files with 2446 additions and 3093 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -155,7 +155,7 @@ function run(argv) {
|
|||
console.log(' AmtVersions - Show all Intel ME version information.');
|
||||
console.log(' AmtHashes - Show all Intel AMT trusted activation hashes.');
|
||||
console.log(' AmtCCM - Activate Intel AMT into Client Control Mode.');
|
||||
//console.log(' AmtACM - Activate Intel AMT into Admin Control Mode.'); // Not correcly implemented so not making this visible yet.
|
||||
console.log(' AmtACM - Activate Intel AMT into Admin Control Mode.');
|
||||
console.log(' AmtDeactivate - Deactivate Intel AMT if activated in Client Control mode.');
|
||||
console.log(' AmtAcmDeactivate - Deactivate Intel AMT if activated in Admin Control mode.');
|
||||
console.log('\r\nValid local or remote actions:');
|
||||
|
@ -449,7 +449,7 @@ function run(argv) {
|
|||
amtMei.getLanInterfaceSettings(0, function (result) { console.log('getLanInterfaceSettings0: ' + JSON.stringify(result)); });
|
||||
amtMei.getLanInterfaceSettings(1, function (result) { console.log('getLanInterfaceSettings1: ' + JSON.stringify(result)); });
|
||||
amtMei.getUuid(function (result) { console.log('getUuid: ' + JSON.stringify(result)); });
|
||||
amtMei.getDnsSuffix(function (result) { console.log('getDnsSuffix: ' + JSON.stringify(result)); exit(1);});
|
||||
amtMei.getDnsSuffix(function (result) { console.log('getDnsSuffix: ' + JSON.stringify(result)); exit(1); });
|
||||
} else if (settings.action == 'amtsavestate') {
|
||||
// Save the entire state of Intel AMT info a JSON file
|
||||
if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
|
||||
|
@ -519,6 +519,8 @@ function run(argv) {
|
|||
deactivateACM();
|
||||
} else if (settings.action == 'meshcommander') { // Start MeshCommander
|
||||
startMeshCommander();
|
||||
//} else if (settings.action == 'amtdisable') { // Disable AMT Network Interface
|
||||
// amtDisable();
|
||||
} 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; }
|
||||
|
@ -657,6 +659,21 @@ function readAmtAuditLogEx2(stack, response, status) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
//
|
||||
// Disable AMT Network
|
||||
//
|
||||
|
||||
//function amtDisable() {
|
||||
// settings.noconsole = true;
|
||||
// startLms(amtDisableEx);
|
||||
//}
|
||||
|
||||
//function amtDisableEx(stack, response, status) {
|
||||
// //console.log(osamtstack);
|
||||
// osamtstack.Get('AMT_EthernetPortSettings', function (stack, name, response, status) {
|
||||
// console.log(response.Body);
|
||||
// });
|
||||
//}
|
||||
|
||||
//
|
||||
// MeshCommander local web server
|
||||
|
@ -831,11 +848,11 @@ function deactivateACMEx() {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Activate Intel AMT to ACM
|
||||
//
|
||||
|
||||
|
||||
function activeToACM() {
|
||||
// See if MicroLMS needs to be started and setup the $$OsAdmin wsman stack
|
||||
console.log('Starting AMT Provisioning to Admin Control Mode.');
|
||||
|
@ -855,12 +872,30 @@ function activeToACM() {
|
|||
|
||||
// Gets the FWNonce from AMT and saves it to a file.
|
||||
function getFwNonce() {
|
||||
osamtstack.Get("IPS_HostBasedSetupService", function (obj, name, responses, status) {
|
||||
var fwNonce = Buffer.from(responses["Body"]['ConfigurationNonce'], 'base64');
|
||||
var amtMeiModule, amtMei;
|
||||
osamtstack.BatchEnum(null, ['*AMT_GeneralSettings', '*IPS_HostBasedSetupService'], function (stack, name, responses, status) {
|
||||
var fwNonce = responses['IPS_HostBasedSetupService'].response['ConfigurationNonce'];
|
||||
var digestRealm = responses['AMT_GeneralSettings'].response['DigestRealm'];
|
||||
var amtMeiModule, amtMei, str;
|
||||
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
|
||||
amtMei.getLanInterfaceSettings(0, function (result) { if (result) { mestate.net0 = result; } });
|
||||
amtMei.getDnsSuffix(function (result) {
|
||||
activeToACMEx(fwNonce, result);
|
||||
var fqdn = null;
|
||||
if ((mestate.net0 == null) && (meinfo.net0.enabled != 0)) { console.log("No Intel AMT wired interface, can't perform ACM activation."); exit(100); return; }
|
||||
if (result) { fqdn = result; } // If Intel AMT has a trusted DNS suffix set, use that one.
|
||||
else {
|
||||
// Look for the DNS suffix for the Intel AMT Ethernet interface
|
||||
var interfaces = require('os').networkInterfaces();
|
||||
for (var i in interfaces) {
|
||||
for (var j in interfaces[i]) {
|
||||
if ((interfaces[i][j].mac == mestate.net0.mac) && (interfaces[i][j].fqdn != null) && (interfaces[i][j].fqdn != '')) { fqdn = interfaces[i][j].fqdn; }
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fqdn != null) {
|
||||
activeToACMEx(fwNonce, fqdn, digestRealm);
|
||||
} else {
|
||||
console.log("Trusted DNS suffix not set, can't perform ACM activation."); exit(100); return;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -868,10 +903,10 @@ function getFwNonce() {
|
|||
// Sends a message to RCS server using RCS Message Protocol
|
||||
function sendRCSMessage(socket, status, event, message) {
|
||||
//console.log('Status: ' + status + '. Event: ' + event + '. Message: ' + message);
|
||||
if (socket !== null) { socket.write({"status": status, "event": event, "data": message}); }
|
||||
if (socket !== null) { socket.write({ "status": status, "event": event, "data": message }); }
|
||||
}
|
||||
|
||||
function activeToACMEx(fwNonce, dnsSuffix) {
|
||||
function activeToACMEx(fwNonce, dnsSuffix, digestRealm) {
|
||||
// open connection to RCS
|
||||
console.log('Initializing WebSocket...');
|
||||
// Establish WebSocket connection to RCS server
|
||||
|
@ -890,8 +925,7 @@ function activeToACMEx(fwNonce, dnsSuffix) {
|
|||
if (status == 2) {
|
||||
console.log('AMT already provisioned.Exiting ' + status);
|
||||
sendRCSMessage(socket, "error", "finish", "failed with status: " + status);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
console.log('Failed to fetch activation status, status ' + status);
|
||||
sendRCSMessage(socket, "error", "finish", "failed with status: " + status);
|
||||
}
|
||||
|
@ -903,7 +937,7 @@ function activeToACMEx(fwNonce, dnsSuffix) {
|
|||
socket.end();
|
||||
exit(status);
|
||||
} else {
|
||||
activeToACMEx2(message, responses, function (stack, name, responses, status, message) {
|
||||
activeToACMEx2(message, function (stack, name, responses, status, message) {
|
||||
if (status != 200) {
|
||||
console.log('Failed to activate, status ' + status);
|
||||
sendRCSMessage(socket, "error", "finish", "failed to activate. Status: " + status);
|
||||
|
@ -911,7 +945,7 @@ function activeToACMEx(fwNonce, dnsSuffix) {
|
|||
console.log('Admin control mode activation failed: ' + responses.Body.ReturnValueStr);
|
||||
sendRCSMessage(socket, "error", "finish", "failed to activate: " + responses.Body.ReturnValueStr);
|
||||
} else {
|
||||
if (message.profileScript !== '') {
|
||||
if (message.profileScript !== null) {
|
||||
console.log("Running MEScript...");
|
||||
settings.scriptjson = message.profileScript;
|
||||
settings.password = message.amtPassword
|
||||
|
@ -928,7 +962,6 @@ function activeToACMEx(fwNonce, dnsSuffix) {
|
|||
exit(0);
|
||||
}
|
||||
console.log('AMT Provisioning Success');
|
||||
|
||||
}
|
||||
//socket.end();
|
||||
//exit(status);
|
||||
|
@ -940,10 +973,8 @@ function activeToACMEx(fwNonce, dnsSuffix) {
|
|||
sendRCSMessage(socket, "ok", "message", JSON.stringify(fwNonce));
|
||||
}
|
||||
});
|
||||
socket.on('end', function () {
|
||||
console.log('WebSocket closed');
|
||||
});
|
||||
sendRCSMessage(socket, "ok", "cmd", { "cmd": "acm", "dnssuffix": dnsSuffix, "profile": settings.profile });
|
||||
socket.on('end', function () { console.log('WebSocket closed'); });
|
||||
sendRCSMessage(socket, "ok", "cmd", { "cmd": "acm", "dnssuffix": dnsSuffix, "profile": settings.profile, 'digestrealm': digestRealm, 'fwnonce': fwNonce });
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -980,8 +1011,8 @@ function injectCert(index, cert, callback, stack, name, responses, status) {
|
|||
var root = false;
|
||||
if (index == 0) { leaf = true; }
|
||||
if (index == cert.provCertObj.certChain.length - 1) { root = true; }
|
||||
if (index < cert.provCertObj.certChain.length){
|
||||
if (cert.provCertObj.certChain[index] !== undefined){
|
||||
if (index < cert.provCertObj.certChain.length) {
|
||||
if (cert.provCertObj.certChain[index] !== undefined) {
|
||||
osamtstack.IPS_HostBasedSetupService_AddNextCertInChain(cert.provCertObj.certChain[index], leaf, root, function (stack, name, responses, status) {
|
||||
if (status !== 200) { exit(status); return; }
|
||||
else if (responses['Body']['ReturnValue'] !== 0) { exit(responses['Body']['ReturnValueStr']); return; }
|
||||
|
@ -995,11 +1026,11 @@ function injectCert(index, cert, callback, stack, name, responses, status) {
|
|||
}
|
||||
|
||||
// Sends the password hash, mcnonce, and digital signature to complete the admin control mode provisioning
|
||||
function activeToACMEx2(data, responses, callback) {
|
||||
var passwordhash = md5hex('admin:' + responses['AMT_GeneralSettings'].response['DigestRealm'] + ':' + data.amtPassword).substring(0, 32);
|
||||
function activeToACMEx2(data, callback) {
|
||||
//var passwordhash = md5hex('admin:' + responses['AMT_GeneralSettings'].response['DigestRealm'] + ':' + data.passwordHash).substring(0, 32);
|
||||
//var debugreturn = {"Body": {"ReturnValue": 0}};
|
||||
//console.log("DEBUG: Everything up to activation works"); callback(null, null, debugreturn, 200, data);
|
||||
osamtstack.IPS_HostBasedSetupService_AdminSetup(2, passwordhash, data.mcNonce, 2, data.digitalSignature, function (stack, name, responses, status) { callback(stack, name, responses, status, data); });
|
||||
osamtstack.IPS_HostBasedSetupService_AdminSetup(2, data.passwordHash, data.mcNonce, 2, data.digitalSignature, function (stack, name, responses, status) { callback(stack, name, responses, status, data); });
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -1075,8 +1106,7 @@ function startMeScriptEx(callback, amtstack) {
|
|||
//
|
||||
|
||||
|
||||
function saveEntireAmtState2()
|
||||
{
|
||||
function saveEntireAmtState2() {
|
||||
console.log('Fetching all Intel AMT state, this may take a few minutes...');
|
||||
var transport = require('amt-wsman-duk');
|
||||
var wsman = require('amt-wsman');
|
||||
|
@ -1096,16 +1126,13 @@ function saveEntireAmtState2()
|
|||
}
|
||||
|
||||
// Save the entire Intel AMT state
|
||||
function saveEntireAmtState()
|
||||
{
|
||||
function saveEntireAmtState() {
|
||||
// See if MicroLMS needs to be started
|
||||
if ((settings.hostname == '127.0.0.1') || (settings.hostname.toLowerCase() == 'localhost'))
|
||||
{
|
||||
if ((settings.hostname == '127.0.0.1') || (settings.hostname.toLowerCase() == 'localhost')) {
|
||||
settings.noconsole = true;
|
||||
startLms().then(saveEntireAmtState2);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
saveEntireAmtState2();
|
||||
}
|
||||
}
|
||||
|
@ -1196,8 +1223,7 @@ var lmsNotifications = [];
|
|||
var amtLms = null;
|
||||
var promise = require('promise');
|
||||
|
||||
function startLms(func, lmscommander)
|
||||
{
|
||||
function startLms(func, lmscommander) {
|
||||
var ret = new promise(function (res, rej) { this._res = res; this._rej = rej; });
|
||||
var lme_heci = null
|
||||
try { lme_heci = require('amt-lme'); } catch (ex) { }
|
||||
|
@ -1893,7 +1919,7 @@ function performIder() {
|
|||
var sfloppy = null, scdrom = null;
|
||||
if (settings.floppy) { try { if (sfloppy = fs.statSync(settings.floppy)) { sfloppy.file = fs.openSync(settings.floppy, 'rbN'); } } catch (ex) { console.log(ex); process.exit(1); return; } }
|
||||
if (settings.cdrom) { try { scdrom = fs.statSync(settings.cdrom); if (scdrom) { scdrom.file = fs.openSync(settings.cdrom, 'rbN'); } } catch (ex) { console.log(ex); process.exit(1); return; } }
|
||||
|
||||
|
||||
ider = require('amt-redir-duk')(require('amt-ider')());
|
||||
ider.onStateChanged = onIderStateChange;
|
||||
ider.m.floppy = sfloppy;
|
||||
|
@ -1903,11 +1929,11 @@ function performIder() {
|
|||
if (settings.timeout > 0) { ider.m.sectorStats = iderSectorStats; }
|
||||
//ider.digestRealmMatch = wsstack.comm.digestRealm;
|
||||
//ider.tlsv1only = amtstack.wsman.comm.tlsv1only;
|
||||
ider.Start(settings.hostname, (settings.tls == true)?16995:16994, settings.username ? 'admin' : settings.username, settings.password, settings.tls);
|
||||
ider.Start(settings.hostname, (settings.tls == true) ? 16995 : 16994, settings.username ? 'admin' : settings.username, settings.password, settings.tls);
|
||||
} catch (ex) { console.log(ex); }
|
||||
}
|
||||
|
||||
function onIderStateChange(stack, state) { console.log(['Disconnected', 'Connecting...', 'Connected...', 'Started IDER...'][state]);}
|
||||
function onIderStateChange(stack, state) { console.log(['Disconnected', 'Connecting...', 'Connected...', 'Started IDER...'][state]); }
|
||||
|
||||
function iderSectorStats(mode, dev, mediaBlocks, lba, len) {
|
||||
if (iderIdleTimer != null) { clearTimeout(iderIdleTimer); }
|
||||
|
|
1979
agents/meshcmd.min.js
vendored
1979
agents/meshcmd.min.js
vendored
File diff suppressed because one or more lines are too long
1950
agents/meshcore-old.js
Normal file
1950
agents/meshcore-old.js
Normal file
File diff suppressed because it is too large
Load diff
|
@ -22,6 +22,7 @@ process.on('uncaughtException', function (ex) {
|
|||
//attachDebugger({ webport: 9999, wait: 1 }).then(function (prt) { console.log('Point Browser for Debug to port: ' + prt); });
|
||||
|
||||
// Mesh Rights
|
||||
var MNG_ERROR = 65;
|
||||
var MESHRIGHT_EDITMESH = 1;
|
||||
var MESHRIGHT_MANAGEUSERS = 2;
|
||||
var MESHRIGHT_MANAGECOMPUTERS = 4;
|
||||
|
@ -36,10 +37,12 @@ var MESHRIGHT_NOFILES = 1024;
|
|||
var MESHRIGHT_NOAMT = 2048;
|
||||
var MESHRIGHT_LIMITEDINPUT = 4096;
|
||||
|
||||
function createMeshCore(agent) {
|
||||
function createMeshCore(agent)
|
||||
{
|
||||
var obj = {};
|
||||
|
||||
if (process.platform == 'darwin' && !process.versions) {
|
||||
if (process.platform == 'darwin' && !process.versions)
|
||||
{
|
||||
// This is an older MacOS Agent, so we'll need to check the service definition so that Auto-Update will function correctly
|
||||
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
child.stdout.str = '';
|
||||
|
@ -48,18 +51,21 @@ function createMeshCore(agent) {
|
|||
child.stdin.write(" if(c[1]==\"dict\"){ split(a[2], d, \"</dict>\"); if(split(d[1], truval, \"<true/>\")>1) { split(truval[1], kn1, \"<key>\"); split(kn1[2], kn2, \"</key>\"); print kn2[1]; } }");
|
||||
child.stdin.write(" else { split(c[1], ka, \"/\"); if(ka[1]==\"true\") {print \"ALWAYS\";} } }'\nexit\n");
|
||||
child.waitExit();
|
||||
if (child.stdout.str.trim() == 'Crashed') {
|
||||
if (child.stdout.str.trim() == 'Crashed')
|
||||
{
|
||||
child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
child.stdout.str = '';
|
||||
child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
|
||||
child.stdin.write("launchctl list | grep 'meshagent' | awk '{ if($3==\"meshagent\"){print $1;}}'\nexit\n");
|
||||
child.waitExit();
|
||||
|
||||
if (parseInt(child.stdout.str.trim()) == process.pid) {
|
||||
if (parseInt(child.stdout.str.trim()) == process.pid)
|
||||
{
|
||||
// The currently running MeshAgent is us, so we can continue with the update
|
||||
var plist = require('fs').readFileSync('/Library/LaunchDaemons/meshagent_osx64_LaunchDaemon.plist').toString();
|
||||
var tokens = plist.split('<key>KeepAlive</key>');
|
||||
if (tokens[1].split('>')[0].split('<')[1] == 'dict') {
|
||||
if (tokens[1].split('>')[0].split('<')[1] == 'dict')
|
||||
{
|
||||
var tmp = tokens[1].split('</dict>');
|
||||
tmp.shift();
|
||||
tokens[1] = '\n <true/>' + tmp.join('</dict>');
|
||||
|
@ -114,6 +120,133 @@ function createMeshCore(agent) {
|
|||
}
|
||||
}
|
||||
|
||||
// Create Secure IPC for Diagnostic Agent Communications
|
||||
obj.DAIPC = require('net').createServer();
|
||||
if (process.platform != 'win32') { try { require('fs').unlinkSync(process.cwd() + '/DAIPC'); } catch (ee) { } }
|
||||
obj.DAIPC.IPCPATH = process.platform == 'win32' ? ('\\\\.\\pipe\\' + require('_agentNodeId')() + '-DAIPC') : (process.cwd() + '/DAIPC');
|
||||
try { obj.DAIPC.listen({ path: obj.DAIPC.IPCPATH }); } catch (e) { }
|
||||
obj.DAIPC.on('connection', function (c)
|
||||
{
|
||||
c._send = function (j)
|
||||
{
|
||||
var data = JSON.stringify(j);
|
||||
var packet = Buffer.alloc(data.length + 4);
|
||||
packet.writeUInt32LE(data.length + 4, 0);
|
||||
Buffer.from(data).copy(packet, 4);
|
||||
this.end(packet);
|
||||
};
|
||||
this._daipc = c;
|
||||
c.parent = this;
|
||||
c.on('end', function () { console.log('Connection Closed'); this.parent._daipc = null; });
|
||||
c.on('data', function (chunk)
|
||||
{
|
||||
if (chunk.length < 4) { this.unshift(chunk); return; }
|
||||
var len = chunk.readUInt32LE(0);
|
||||
if (len > 8192) { this.parent._daipc = null; this.end(); return; }
|
||||
if (chunk.length < len) { this.unshift(chunk); return; }
|
||||
|
||||
var data = chunk.slice(4, len);
|
||||
try
|
||||
{
|
||||
data = JSON.parse(data.toString());
|
||||
}
|
||||
catch(de)
|
||||
{
|
||||
this.parent._daipc = null; this.end(); return;
|
||||
}
|
||||
|
||||
if (!data.cmd) { this.parent._daipc = null; this.end(); return; }
|
||||
|
||||
try
|
||||
{
|
||||
switch(data.cmd)
|
||||
{
|
||||
case 'query':
|
||||
switch(data.value)
|
||||
{
|
||||
case 'connection':
|
||||
data.result = require('MeshAgent').ConnectedServer;
|
||||
this._send(data);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
this.parent._daipc = null; this.end(); return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(xe)
|
||||
{
|
||||
this.parent._daipc = null; this.end(); return;
|
||||
}
|
||||
});
|
||||
});
|
||||
function diagnosticAgent_uninstall()
|
||||
{
|
||||
require('service-manager').manager.uninstallService('meshagentDiagnostic');
|
||||
require('task-scheduler').delete('meshagentDiagnostic/periodicStart');
|
||||
};
|
||||
function diagnosticAgent_installCheck(install)
|
||||
{
|
||||
try
|
||||
{
|
||||
var diag = require('service-manager').manager.getService('meshagentDiagnostic');
|
||||
return (diag);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
}
|
||||
if (!install) { return (null); }
|
||||
|
||||
var svc = null;
|
||||
try
|
||||
{
|
||||
require('service-manager').manager.installService(
|
||||
{
|
||||
name: 'meshagentDiagnostic',
|
||||
displayName: 'Mesh Agent Diagnostic Service',
|
||||
description: 'Mesh Agent Diagnostic Service',
|
||||
servicePath: process.execPath,
|
||||
parameters: ['-recovery']
|
||||
//files: [{ newName: 'diagnostic.js', _buffer: Buffer.from('LyoNCkNvcHlyaWdodCAyMDE5IEludGVsIENvcnBvcmF0aW9uDQoNCkxpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSAiTGljZW5zZSIpOw0KeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLg0KWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0DQoNCiAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjANCg0KVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQ0KZGlzdHJpYnV0ZWQgdW5kZXIgdGhlIExpY2Vuc2UgaXMgZGlzdHJpYnV0ZWQgb24gYW4gIkFTIElTIiBCQVNJUywNCldJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GIEFOWSBLSU5ELCBlaXRoZXIgZXhwcmVzcyBvciBpbXBsaWVkLg0KU2VlIHRoZSBMaWNlbnNlIGZvciB0aGUgc3BlY2lmaWMgbGFuZ3VhZ2UgZ292ZXJuaW5nIHBlcm1pc3Npb25zIGFuZA0KbGltaXRhdGlvbnMgdW5kZXIgdGhlIExpY2Vuc2UuDQoqLw0KDQp2YXIgaG9zdCA9IHJlcXVpcmUoJ3NlcnZpY2UtaG9zdCcpLmNyZWF0ZSgnbWVzaGFnZW50RGlhZ25vc3RpYycpOw0KdmFyIFJlY292ZXJ5QWdlbnQgPSByZXF1aXJlKCdNZXNoQWdlbnQnKTsNCg0KaG9zdC5vbignc2VydmljZVN0YXJ0JywgZnVuY3Rpb24gKCkNCnsNCiAgICBjb25zb2xlLnNldERlc3RpbmF0aW9uKGNvbnNvbGUuRGVzdGluYXRpb25zLkxPR0ZJTEUpOw0KICAgIGhvc3Quc3RvcCA9IGZ1bmN0aW9uKCkNCiAgICB7DQogICAgICAgIHJlcXVpcmUoJ3NlcnZpY2UtbWFuYWdlcicpLm1hbmFnZXIuZ2V0U2VydmljZSgnbWVzaGFnZW50RGlhZ25vc3RpYycpLnN0b3AoKTsNCiAgICB9DQogICAgUmVjb3ZlcnlBZ2VudC5vbignQ29ubmVjdGVkJywgZnVuY3Rpb24gKHN0YXR1cykNCiAgICB7DQogICAgICAgIGlmIChzdGF0dXMgPT0gMCkNCiAgICAgICAgew0KICAgICAgICAgICAgY29uc29sZS5sb2coJ0RpYWdub3N0aWMgQWdlbnQ6IFNlcnZlciBjb25uZWN0aW9uIGxvc3QuLi4nKTsNCiAgICAgICAgICAgIHJldHVybjsNCiAgICAgICAgfQ0KICAgICAgICBjb25zb2xlLmxvZygnRGlhZ25vc3RpYyBBZ2VudDogQ29ubmVjdGlvbiBFc3RhYmxpc2hlZCB3aXRoIFNlcnZlcicpOw0KICAgICAgICBzdGFydCgpOw0KICAgIH0pOw0KfSk7DQpob3N0Lm9uKCdub3JtYWxTdGFydCcsIGZ1bmN0aW9uICgpDQp7DQogICAgaG9zdC5zdG9wID0gZnVuY3Rpb24gKCkNCiAgICB7DQogICAgICAgIHByb2Nlc3MuZXhpdCgpOw0KICAgIH0NCiAgICBjb25zb2xlLmxvZygnTm9uIFNlcnZpY2UgTW9kZScpOw0KICAgIFJlY292ZXJ5QWdlbnQub24oJ0Nvbm5lY3RlZCcsIGZ1bmN0aW9uIChzdGF0dXMpDQogICAgew0KICAgICAgICBpZiAoc3RhdHVzID09IDApDQogICAgICAgIHsNCiAgICAgICAgICAgIGNvbnNvbGUubG9nKCdEaWFnbm9zdGljIEFnZW50OiBTZXJ2ZXIgY29ubmVjdGlvbiBsb3N0Li4uJyk7DQogICAgICAgICAgICByZXR1cm47DQogICAgICAgIH0NCiAgICAgICAgY29uc29sZS5sb2coJ0RpYWdub3N0aWMgQWdlbnQ6IENvbm5lY3Rpb24gRXN0YWJsaXNoZWQgd2l0aCBTZXJ2ZXInKTsNCiAgICAgICAgc3RhcnQoKTsNCiAgICB9KTsNCn0pOw0KaG9zdC5vbignc2VydmljZVN0b3AnLCBmdW5jdGlvbiAoKSB7IHByb2Nlc3MuZXhpdCgpOyB9KTsNCmhvc3QucnVuKCk7DQoNCg0KZnVuY3Rpb24gc3RhcnQoKQ0Kew0KDQp9Ow0K', 'base64') }]
|
||||
});
|
||||
svc = require('service-manager').manager.getService('meshagentDiagnostic');
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
return (null);
|
||||
}
|
||||
var proxyConfig = require('global-tunnel').proxyConfig;
|
||||
var cert = require('MeshAgent').GenerateAgentCertificate('CN=MeshNodeDiagnosticCertificate');
|
||||
var nodeid = require('tls').loadCertificate(cert.root).getKeyHash().toString('base64');
|
||||
ddb = require('SimpleDataStore').Create(svc.appWorkingDirectory().replace('\\', '/') + '/meshagentDiagnostic.db');
|
||||
ddb.Put('disableUpdate', '1');
|
||||
ddb.Put('MeshID', Buffer.from(require('MeshAgent').ServerInfo.MeshID, 'hex'));
|
||||
ddb.Put('ServerID', require('MeshAgent').ServerInfo.ServerID);
|
||||
ddb.Put('MeshServer', require('MeshAgent').ServerInfo.ServerUri);
|
||||
if (cert.root.pfx) { ddb.Put('SelfNodeCert', cert.root.pfx); }
|
||||
if (cert.tls) { ddb.Put('SelfNodeTlsCert', cert.tls.pfx); }
|
||||
if (proxyConfig)
|
||||
{
|
||||
ddb.Put('WebProxy', proxyConfig.host + ':' + proxyConfig.port);
|
||||
}
|
||||
else
|
||||
{
|
||||
ddb.Put('ignoreProxyFile', '1');
|
||||
}
|
||||
|
||||
require('MeshAgent').SendCommand({ action: 'diagnostic', value: { command: 'register', value: nodeid } });
|
||||
require('MeshAgent').SendCommand({ action: 'msg', type: 'console', value: 'Diagnostic Agent Registered [' + nodeid.length + '/' + nodeid + ']' });
|
||||
|
||||
delete ddb;
|
||||
|
||||
// Set a recurrent task, to run the Diagnostic Agent every 2 days
|
||||
require('task-scheduler').create({name: 'meshagentDiagnostic/periodicStart', daily: 2, time: require('tls').generateRandomInteger('0', '23') + ':' + require('tls').generateRandomInteger('0', '59').padStart(2, '0'), service: 'meshagentDiagnostic'});
|
||||
//require('task-scheduler').create({ name: 'meshagentDiagnostic/periodicStart', daily: '1', time: '17:16', service: 'meshagentDiagnostic' });
|
||||
|
||||
return (svc);
|
||||
}
|
||||
|
||||
/*
|
||||
function borderController() {
|
||||
this.container = null;
|
||||
|
@ -191,6 +324,8 @@ function createMeshCore(agent) {
|
|||
mesh = agent.getMeshApi();
|
||||
}
|
||||
|
||||
mesh.DAIPC = obj.DAIPC;
|
||||
|
||||
/*
|
||||
var AMTScanner = require("AMTScanner");
|
||||
var scan = new AMTScanner();
|
||||
|
@ -815,39 +950,7 @@ function createMeshCore(agent) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Test the console messaging system
|
||||
//this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: 'This is a sample test for remote terminal...' })); // Send a console message back using the console channel, "\n" is supported.
|
||||
|
||||
// Perform notification if needed. Toast messages may not be supported on all platforms.
|
||||
if (this.httprequest.consent && (this.httprequest.consent & 2)) {
|
||||
try { require('toaster').Toast('MeshCentral', this.httprequest.username + ' started a remote terminal session.'); } catch (ex) { }
|
||||
}
|
||||
|
||||
// Remote terminal using native pipes
|
||||
if (process.platform == "win32")
|
||||
{
|
||||
this.httprequest._term = require('win-terminal').Start(80, 25);
|
||||
this.httprequest._term.pipe(this, { dataTypeSkip: 1 });
|
||||
this.pipe(this.httprequest._term, { dataTypeSkip: 1, end: false });
|
||||
this.prependListener('end', function () { this.httprequest._term.end(function () { console.log('Terminal was closed'); }); });
|
||||
//this.httprequest.process = childProcess.execFile("%windir%\\system32\\cmd.exe");
|
||||
} else {
|
||||
if (fs.existsSync("/bin/bash")) {
|
||||
this.httprequest.process = childProcess.execFile("/bin/bash", ["bash", "-i"], { type: childProcess.SpawnTypes.TERM });
|
||||
if (process.platform == 'linux') { this.httprequest.process.stdin.write("alias ls='ls --color=auto'\nclear\n"); }
|
||||
} else {
|
||||
this.httprequest.process = childProcess.execFile("/bin/sh", ["sh"], { type: childProcess.SpawnTypes.TERM });
|
||||
if (process.platform == 'linux') { this.httprequest.process.stdin.write("stty erase ^H\nalias ls='ls --color=auto'\nPS1='\\u@\\h:\\w\\$ '\nclear\n"); }
|
||||
}
|
||||
//if (this.httprequest.process == null) { }
|
||||
this.httprequest.process.tunnel = this;
|
||||
this.httprequest.process.on('exit', function (ecode, sig) { this.tunnel.end(); });
|
||||
this.httprequest.process.stderr.on('data', function (chunk) { this.parent.tunnel.write(chunk); });
|
||||
this.httprequest.process.stdout.pipe(this, { dataTypeSkip: 1 }); // 0 = Binary, 1 = Text.
|
||||
this.pipe(this.httprequest.process.stdin, { dataTypeSkip: 1, end: false }); // 0 = Binary, 1 = Text.
|
||||
this.prependListener('end', function () { this.httprequest.process.kill(); });
|
||||
}
|
||||
|
||||
|
||||
this.end = function () {
|
||||
if (process.platform == "win32") {
|
||||
// Unpipe the web socket
|
||||
|
@ -868,11 +971,75 @@ function createMeshCore(agent) {
|
|||
}
|
||||
};
|
||||
|
||||
// Remote terminal using native pipes
|
||||
if (process.platform == "win32") {
|
||||
this.httprequest._term = require('win-terminal').Start(80, 25);
|
||||
this.httprequest._term.pipe(this, { dataTypeSkip: 1 });
|
||||
this.pipe(this.httprequest._term, { dataTypeSkip: 1, end: false });
|
||||
this.prependListener('end', function () { this.httprequest._term.end(function () { console.log('Terminal was closed'); }); });
|
||||
} else {
|
||||
if (fs.existsSync("/bin/bash")) {
|
||||
this.httprequest.process = childProcess.execFile("/bin/bash", ["bash", "-i"], { type: childProcess.SpawnTypes.TERM });
|
||||
if (process.platform == 'linux') { this.httprequest.process.stdin.write("alias ls='ls --color=auto'\nclear\n"); }
|
||||
} else {
|
||||
this.httprequest.process = childProcess.execFile("/bin/sh", ["sh"], { type: childProcess.SpawnTypes.TERM });
|
||||
if (process.platform == 'linux') { this.httprequest.process.stdin.write("stty erase ^H\nalias ls='ls --color=auto'\nPS1='\\u@\\h:\\w\\$ '\nclear\n"); }
|
||||
}
|
||||
this.httprequest.process.tunnel = this;
|
||||
this.httprequest.process.on('exit', function (ecode, sig) { this.tunnel.end(); });
|
||||
this.httprequest.process.stderr.on('data', function (chunk) { this.parent.tunnel.write(chunk); });
|
||||
this.httprequest.process.stdout.pipe(this, { dataTypeSkip: 1 }); // 0 = Binary, 1 = Text.
|
||||
this.pipe(this.httprequest.process.stdin, { dataTypeSkip: 1, end: false }); // 0 = Binary, 1 = Text.
|
||||
this.prependListener('end', function () { this.httprequest.process.kill(); });
|
||||
this.httprequest.process.stdin.write("stty erase ^H\nalias ls='ls --color=auto'\nclear\n");
|
||||
}
|
||||
|
||||
// Perform notification if needed. Toast messages may not be supported on all platforms.
|
||||
if (this.httprequest.consent && (this.httprequest.consent & 16)) {
|
||||
// User Consent Prompt is required
|
||||
|
||||
// Send a console message back using the console channel, "\n" is supported.
|
||||
this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: 'Waiting for user to grant access...' }));
|
||||
|
||||
var pr = require('message-box').create('MeshCentral', this.httprequest.username + ' requesting Terminal Access. Grant access?', 10);
|
||||
pr.ws = this;
|
||||
this.pause();
|
||||
|
||||
pr.then(
|
||||
function () {
|
||||
// Success!
|
||||
this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null }));
|
||||
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 2)) {
|
||||
// User Notifications is required
|
||||
try { require('toaster').Toast('MeshCentral', this.ws.httprequest.username + ' started a remote terminal session.'); } catch (ex) { }
|
||||
}
|
||||
|
||||
this.ws.resume();
|
||||
},
|
||||
function (e) {
|
||||
// User Consent Denied/Failed!
|
||||
this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString() }));
|
||||
this.ws.end();
|
||||
});
|
||||
}
|
||||
else {
|
||||
// User Consent Prompt is not required
|
||||
if (this.httprequest.consent && (this.httprequest.consent & 2)) {
|
||||
// User Notifications is required
|
||||
try { require('toaster').Toast('MeshCentral', this.httprequest.username + ' started a remote terminal session.'); } catch (ex) { }
|
||||
}
|
||||
this.resume();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
this.removeAllListeners('data');
|
||||
this.on('data', onTunnelControlData);
|
||||
//this.write('MeshCore Terminal Hello');
|
||||
} else if (this.httprequest.protocol == 2) {
|
||||
|
||||
} else if (this.httprequest.protocol == 2)
|
||||
{
|
||||
// Check user access rights for desktop
|
||||
if (((this.httprequest.rights & MESHRIGHT_REMOTECONTROL) == 0) && ((this.httprequest.rights & MESHRIGHT_REMOTEVIEW) == 0)) {
|
||||
// Disengage this tunnel, user does not have the rights to do this!!
|
||||
|
@ -882,13 +1049,6 @@ function createMeshCore(agent) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Test the console messaging system
|
||||
//this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: 'This is a sample test for remote desktop...' })); // Send a console message back using the console channel, "\n" is supported.
|
||||
|
||||
// Perform notification if needed. Toast messages may not be supported on all platforms.
|
||||
if (this.httprequest.consent && (this.httprequest.consent & 1)) {
|
||||
try { require('toaster').Toast('MeshCentral', this.httprequest.username + ' started a remote desktop session.'); } catch (ex) { }
|
||||
}
|
||||
|
||||
// Remote desktop using native pipes
|
||||
this.httprequest.desktop = { state: 0, kvm: mesh.getRemoteDesktopStream(), tunnel: this };
|
||||
|
@ -926,7 +1086,56 @@ function createMeshCore(agent) {
|
|||
// TODO!!!
|
||||
}
|
||||
|
||||
this.httprequest.desktop.kvm.pipe(this, { dataTypeSkip: 1 }); // 0 = Binary, 1 = Text. Pipe the KVM --> Browser images.
|
||||
// Perform notification if needed. Toast messages may not be supported on all platforms.
|
||||
if (this.httprequest.consent && (this.httprequest.consent & 8))
|
||||
{
|
||||
// User Consent Prompt is required
|
||||
|
||||
// Send a console message back using the console channel, "\n" is supported.
|
||||
this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: 'Waiting for user to grant access...' }));
|
||||
|
||||
var pr = require('message-box').create('MeshCentral', this.httprequest.username + ' requesting KVM Access. Grant access?', 10);
|
||||
pr.ws = this;
|
||||
this.pause();
|
||||
|
||||
pr.then(
|
||||
function ()
|
||||
{
|
||||
// Success!
|
||||
this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null }));
|
||||
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 1))
|
||||
{
|
||||
// User Notifications is required
|
||||
try { require('toaster').Toast('MeshCentral', this.ws.httprequest.username + ' started a remote desktop session.'); } catch (ex) { }
|
||||
}
|
||||
|
||||
this.ws.httprequest.desktop.kvm.pipe(this.ws, { dataTypeSkip: 1 });
|
||||
this.ws.resume();
|
||||
},
|
||||
function (e)
|
||||
{
|
||||
// User Consent Denied/Failed!
|
||||
this.ws.end(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString() }));
|
||||
|
||||
//var err = 'User consent: ' + e.toString();
|
||||
//var b = Buffer.alloc(5 + err.length);
|
||||
//b.writeUInt16BE(MNG_ERROR, 0);
|
||||
//b.writeUInt16BE(err.length + 4, 2);
|
||||
//Buffer.from(err).copy(b, 4);
|
||||
//this.ws.end(b);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// User Consent Prompt is not required
|
||||
if (this.httprequest.consent && (this.httprequest.consent & 1))
|
||||
{
|
||||
// User Notifications is required
|
||||
try { require('toaster').Toast('MeshCentral', this.httprequest.username + ' started a remote desktop session.'); } catch (ex) { }
|
||||
}
|
||||
this.httprequest.desktop.kvm.pipe(this, { dataTypeSkip: 1 });
|
||||
}
|
||||
|
||||
this.removeAllListeners('data');
|
||||
this.on('data', onTunnelControlData);
|
||||
//this.write('MeshCore KVM Hello!1');
|
||||
|
@ -938,16 +1147,45 @@ function createMeshCore(agent) {
|
|||
// Disengage this tunnel, user does not have the rights to do this!!
|
||||
this.httprequest.protocol = 999999;
|
||||
this.httprequest.s.end();
|
||||
sendConsoleText('Error: No Files Control Rights.');
|
||||
sendConsoleText('Error: No files control rights.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Test the console messaging system
|
||||
//this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: 'This is a sample test for remote files...' })); // Send a console message back using the console channel, "\n" is supported.
|
||||
// Perform notification if needed. Toast messages may not be supported on all platforms.
|
||||
if (this.httprequest.consent && (this.httprequest.consent & 32))
|
||||
{
|
||||
// User Consent Prompt is required
|
||||
|
||||
// Perform notification if needed
|
||||
if (this.httprequest.consent && (this.httprequest.consent & 4)) {
|
||||
try { require('toaster').Toast('MeshCentral', this.httprequest.username + ' started a remote file access.'); } catch (ex) { }
|
||||
// Send a console message back using the console channel, "\n" is supported.
|
||||
this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: 'Waiting for user to grant access...' }));
|
||||
|
||||
var pr = require('message-box').create('MeshCentral', this.httprequest.username + ' requesting remote file access. Grant access?', 10);
|
||||
pr.ws = this;
|
||||
this.pause();
|
||||
|
||||
pr.then(
|
||||
function () {
|
||||
// Success!
|
||||
this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null }));
|
||||
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 4))
|
||||
{
|
||||
// User Notifications is required
|
||||
try { require('toaster').Toast('MeshCentral', this.ws.httprequest.username + ' started a remote file session.'); } catch (ex) { }
|
||||
}
|
||||
this.ws.resume();
|
||||
},
|
||||
function (e) {
|
||||
// User Consent Denied/Failed!
|
||||
this.ws.end(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString() }));
|
||||
});
|
||||
}
|
||||
else {
|
||||
// User Consent Prompt is not required
|
||||
if (this.httprequest.consent && (this.httprequest.consent & 4)) {
|
||||
// User Notifications is required
|
||||
try { require('toaster').Toast('MeshCentral', this.httprequest.username + ' started a remote file session.'); } catch (ex) { }
|
||||
}
|
||||
this.resume();
|
||||
}
|
||||
|
||||
// Setup files
|
||||
|
@ -1291,7 +1529,7 @@ function createMeshCore(agent) {
|
|||
var response = null;
|
||||
switch (cmd) {
|
||||
case 'help': { // Displays available commands
|
||||
response = 'Available commands: help, info, osinfo,args, print, type, dbget, dbset, dbcompact, eval, parseuri, httpget,\r\nwslist, wsconnect, wssend, wsclose, notify, ls, ps, kill, amt, netinfo, location, power, wakeonlan, scanwifi,\r\nscanamt, setdebug, smbios, rawsmbios, toast, lock, users, sendcaps, openurl, amtreset, amtccm, amtdeactivate,\r\namtpolicy, getscript, getclip, setclip.';
|
||||
response = 'Available commands: help, info, osinfo,args, print, type, dbget, dbset, dbcompact, eval, parseuri, httpget,\r\nwslist, wsconnect, wssend, wsclose, notify, ls, ps, kill, amt, netinfo, location, power, wakeonlan, scanwifi,\r\nscanamt, setdebug, smbios, rawsmbios, toast, lock, users, sendcaps, openurl, amtreset, amtccm, amtacm, amtdeactivate,\r\namtpolicy, getscript, getclip, setclip.';
|
||||
break;
|
||||
}
|
||||
/*
|
||||
|
@ -1349,6 +1587,13 @@ function createMeshCore(agent) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 'amtacm': {
|
||||
if (amt == null) { response = 'Intel AMT not supported.'; } else {
|
||||
amt.setPolicy({ type: 0 });
|
||||
amt.getAmtInfo(function (meinfo) { amt.activeToACM(meinfo); });
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'amtdeactivate': {
|
||||
if (amt == null) { response = 'Intel AMT not supported.'; } else { amt.setPolicy({ type: 0 }); amt.deactivateCCM(); }
|
||||
break;
|
||||
|
@ -1372,12 +1617,9 @@ function createMeshCore(agent) {
|
|||
break;
|
||||
}
|
||||
case 'toast': {
|
||||
if (process.platform == 'win32') {
|
||||
if (args['_'].length < 1) { response = 'Proper usage: toast "message"'; } else {
|
||||
try { require('toaster').Toast('MeshCentral', args['_'][0]); response = 'ok'; } catch (ex) { response = ex; }
|
||||
}
|
||||
} else {
|
||||
response = 'Only supported on Windows.';
|
||||
if (args['_'].length < 1) { response = 'Proper usage: toast "message"'; } else
|
||||
{
|
||||
require('toaster').Toast('MeshCentral', args['_'][0]).then(sendConsoleText, sendConsoleText);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1669,6 +1911,8 @@ function createMeshCore(agent) {
|
|||
if (state != null) { resp = objToString(state, 0, ' ', true); }
|
||||
sendConsoleText(resp, sessionid);
|
||||
});
|
||||
} else {
|
||||
response = 'Intel AMT not detected.';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1763,6 +2007,48 @@ function createMeshCore(agent) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 'diagnostic':
|
||||
{
|
||||
if (!mesh.DAIPC.listening)
|
||||
{
|
||||
response = 'Unable to bind to Diagnostic IPC, most likely because the path (' + process.cwd() + ') is not on a local file system';
|
||||
break;
|
||||
}
|
||||
var diag = diagnosticAgent_installCheck();
|
||||
if (diag)
|
||||
{
|
||||
if (args['_'].length == 1 && args['_'][0] == 'uninstall')
|
||||
{
|
||||
diagnosticAgent_uninstall();
|
||||
response = 'Diagnostic Agent uninstalled';
|
||||
}
|
||||
else
|
||||
{
|
||||
response = 'Diagnostic Agent installed at: ' + diag.appLocation();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (args['_'].length == 1 && args['_'][0] == 'install')
|
||||
{
|
||||
diag = diagnosticAgent_installCheck(true);
|
||||
if (diag)
|
||||
{
|
||||
response = 'Diagnostic agent was installed at: ' + diag.appLocation();
|
||||
}
|
||||
else
|
||||
{
|
||||
response = 'Diagnostic agent installation failed';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response = 'Diagnostic Agent Not installed. To install: diagnostic install';
|
||||
}
|
||||
}
|
||||
if (diag) { diag.close(); diag = null; }
|
||||
break;
|
||||
}
|
||||
default: { // This is an unknown command, return an error message
|
||||
response = 'Unknown command \"' + cmd + '\", type \"help\" for list of avaialble commands.';
|
||||
break;
|
||||
|
@ -1839,7 +2125,7 @@ function createMeshCore(agent) {
|
|||
if (meinfo.UUID != null) { intelamt.uuid = meinfo.UUID; p = true; }
|
||||
if ((meinfo.ProvisioningState == 0) && (meinfo.net0 != null) && (meinfo.net0.enabled == 1)) { // If not activated, look to see if we have wired net working.
|
||||
// Not activated and we have wired ethernet, look for the trusted DNS
|
||||
var dns = meinfo.dns;
|
||||
var dns = meinfo.DNS;
|
||||
if (dns == null) {
|
||||
// Trusted DNS not set, let's look for the OS network DNS suffix
|
||||
var interfaces = require('os').networkInterfaces();
|
||||
|
|
1
agents/meshcore.min.js
vendored
1
agents/meshcore.min.js
vendored
File diff suppressed because one or more lines are too long
1
agents/modules_meshcmd_min/amt-ider.min.js
vendored
1
agents/modules_meshcmd_min/amt-ider.min.js
vendored
File diff suppressed because one or more lines are too long
1
agents/modules_meshcmd_min/amt-lme.min.js
vendored
1
agents/modules_meshcmd_min/amt-lme.min.js
vendored
File diff suppressed because one or more lines are too long
1
agents/modules_meshcmd_min/amt-mei.min.js
vendored
1
agents/modules_meshcmd_min/amt-mei.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
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;
|
1
agents/modules_meshcmd_min/amt-script.min.js
vendored
1
agents/modules_meshcmd_min/amt-script.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
function CreateWsmanComm(){var a={};a.PendingAjax=[];a.ActiveAjaxCount=0;a.MaxActiveAjaxCount=1;a.FailAllError=0;a.digest=null;a.RequestCount=0;if(arguments.length==1&&typeof(arguments[0]=="object")){a.host=arguments[0].host;a.port=arguments[0].port;a.authToken=arguments[0].authToken;a.tls=arguments[0].tls}else{a.host=arguments[0];a.port=arguments[1];a.user=arguments[2];a.pass=arguments[3];a.tls=arguments[4]}a.PerformAjax=function(d,c,f,e,g,b){if((a.ActiveAjaxCount==0||((a.ActiveAjaxCount<a.MaxActiveAjaxCount)&&(a.challengeParams!=null)))&&a.PendingAjax.length==0){a.PerformAjaxEx(d,c,f,g,b)}else{if(e==1){a.PendingAjax.unshift([d,c,f,g,b])}else{a.PendingAjax.push([d,c,f,g,b])}}};a.PerformNextAjax=function(){if(a.ActiveAjaxCount>=a.MaxActiveAjaxCount||a.PendingAjax.length==0){return}var b=a.PendingAjax.shift();a.PerformAjaxEx(b[0],b[1],b[2],b[3],b[4]);a.PerformNextAjax()};a.PerformAjaxEx=function(d,c,g,h,b){if(a.FailAllError!=0){if(a.FailAllError!=999){a.gotNextMessagesError({status:a.FailAllError},"error",null,[d,c,g])}return}if(!d){d=""}if(globalDebugFlags&1){console.log("SEND: "+d+"\r\n\r\n")}if(a.digest==null){if(a.authToken){a.digest=require("http-digest").create({authToken:a.authToken})}else{a.digest=require("http-digest").create(a.user,a.pass)}a.digest.http=require("http")}var f={protocol:(a.tls==1?"https:":"http:"),method:"POST",host:a.host,path:"/wsman",port:a.port,rejectUnauthorized:false,checkServerIdentity:function(i){console.log("checkServerIdentity",JSON.stringify(i))}};var e=a.digest.request(f);e.on("error",function(i){a.gotNextMessagesError({status:600},"error",null,[d,c,g])});e.on("response",function(i){if(globalDebugFlags&1){console.log("Response: "+i.statusCode)}if(i.statusCode!=200){if(globalDebugFlags&1){console.log("ERR:"+JSON.stringify(i))}a.gotNextMessagesError({status:i.statusCode},"error",null,[d,c,g])}else{i.acc="";i.on("data",function(j){this.acc+=j});i.on("end",function(){a.gotNextMessages(i.acc,"success",{status:i.statusCode},[d,c,g])})}});e.end(d);a.ActiveAjaxCount++;return e};a.pendingAjaxCall=[];a.gotNextMessages=function(c,e,d,b){a.ActiveAjaxCount--;if(a.FailAllError==999){return}if(globalDebugFlags&1){console.log("RECV: "+c+"\r\n\r\n")}if(a.FailAllError!=0){b[1](null,a.FailAllError,b[2]);return}if(d.status!=200){b[1](null,d.status,b[2]);return}b[1](c,200,b[2]);a.PerformNextAjax()};a.gotNextMessagesError=function(d,e,c,b){a.ActiveAjaxCount--;if(a.FailAllError==999){return}if(a.FailAllError!=0){b[1](null,a.FailAllError,b[2]);return}if(a.FailAllError!=999){b[1]({Header:{HttpError:d.status}},d.status,b[2])}a.PerformNextAjax()};a.CancelAllQueries=function(b){while(a.PendingAjax.length>0){var c=a.PendingAjax.shift();c[1](null,b,c[2])}};return a}module.exports=CreateWsmanComm;
|
1
agents/modules_meshcmd_min/amt-wsman.min.js
vendored
1
agents/modules_meshcmd_min/amt-wsman.min.js
vendored
File diff suppressed because one or more lines are too long
1
agents/modules_meshcmd_min/amt-xml.min.js
vendored
1
agents/modules_meshcmd_min/amt-xml.min.js
vendored
File diff suppressed because one or more lines are too long
1
agents/modules_meshcmd_min/amt.min.js
vendored
1
agents/modules_meshcmd_min/amt.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
agents/modules_meshcmd_min/smbios.min.js
vendored
1
agents/modules_meshcmd_min/smbios.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -34,6 +34,7 @@ function AmtManager(agent, db, isdebug) {
|
|||
var osamtstack = null;
|
||||
var amtpolicy = null;
|
||||
var obj = this;
|
||||
var mestate;
|
||||
obj.state = 0;
|
||||
obj.lmsstate = 0;
|
||||
obj.onStateChange = null;
|
||||
|
@ -92,7 +93,7 @@ function AmtManager(agent, db, isdebug) {
|
|||
amtMei.getLanInterfaceSettings(0, function (result) { if (result) { amtMeiTmpState.net0 = result; } });
|
||||
amtMei.getLanInterfaceSettings(1, function (result) { if (result) { amtMeiTmpState.net1 = result; } });
|
||||
amtMei.getUuid(function (result) { if ((result != null) && (result.uuid != null)) { amtMeiTmpState.UUID = result.uuid; } });
|
||||
amtMei.getDnsSuffix(function (result) { if (result != null) { amtMeiTmpState.dns = result; } if (func != null) { func(amtMeiTmpState); } });
|
||||
amtMei.getDnsSuffix(function (result) { if (result != null) { amtMeiTmpState.DNS = result; } if (func != null) { func(amtMeiTmpState); } });
|
||||
} catch (e) { if (func != null) { func(null); } return; }
|
||||
}
|
||||
|
||||
|
@ -167,7 +168,7 @@ function AmtManager(agent, db, isdebug) {
|
|||
var amtver = null;
|
||||
try { for (var i in amtGetVersionResult.Versions) { if (amtGetVersionResult.Versions[i].Description == 'AMT') amtver = parseInt(amtGetVersionResult.Versions[i].Version.split('.')[0]); } } catch (e) { }
|
||||
if ((amtver != null) && (amtver >= 12)) {
|
||||
debug('KVM data channel setup');
|
||||
//debug('KVM data channel setup');
|
||||
kvmGetData('skip'); // Clear any previous data, this is a dummy read to about handling old data.
|
||||
obj.kvmTempTimer = setInterval(function () { kvmGetData(); }, 2000); // Start polling for KVM data.
|
||||
kvmSetData(JSON.stringify({ action: 'restart', ver: 1 })); // Send a restart command to advise the console if present that MicroLMS just started.
|
||||
|
@ -431,6 +432,60 @@ function AmtManager(agent, db, isdebug) {
|
|||
});
|
||||
}
|
||||
|
||||
//
|
||||
// Activate Intel AMT to ACM
|
||||
//
|
||||
|
||||
obj.activeToACM = function (mestate) {
|
||||
//debug('ProvisioningState: ' + JSON.stringify(mestate.ProvisioningState));
|
||||
if (mestate.ProvisioningState != 0) return; // Can't activate unless in "PRE" activation mode.
|
||||
var trustedFqdn = null;
|
||||
//debug('Wired Interface: ' + JSON.stringify(mestate.net0));
|
||||
if ((mestate.net0 == null) && (mestate.net0.enabled != 0)) return; // Can't activate unless wired interface is active
|
||||
if (mestate.DNS) { trustedFqdn = mestate.DNS; } // If Intel AMT has a trusted DNS suffix set, use that one.
|
||||
else {
|
||||
// Look for the DNS suffix for the Intel AMT Ethernet interface
|
||||
var interfaces = require('os').networkInterfaces();
|
||||
for (var i in interfaces) {
|
||||
for (var j in interfaces[i]) {
|
||||
if ((interfaces[i][j].mac == mestate.net0.mac) && (interfaces[i][j].fqdn != null) && (interfaces[i][j].fqdn != '')) { trustedFqdn = interfaces[i][j].fqdn; }
|
||||
}
|
||||
}
|
||||
}
|
||||
if (trustedFqdn == null) return; // No trusted DNS suffix.
|
||||
//debug('TrustedFqdn: ' + trustedFqdn);
|
||||
|
||||
// Fetch Intel AMT realm and activation nonce and get ready to ACM activation...
|
||||
if (osamtstack != null) {
|
||||
//debug('Trying to get Intel AMT activation information...');
|
||||
osamtstack.BatchEnum(null, ['*AMT_GeneralSettings', '*IPS_HostBasedSetupService'], activeToACM2, trustedFqdn);
|
||||
} else {
|
||||
//debug('ACM Activation: Trying to get local account info...');
|
||||
amtMei.getLocalSystemAccount(function (x) {
|
||||
if ((x != null) && x.user && x.pass) {
|
||||
//debug('Intel AMT local account info: User=' + x.user + ', Pass=' + x.pass + '.');
|
||||
var transport = require('amt-wsman-duk');
|
||||
var wsman = require('amt-wsman');
|
||||
var amt = require('amt');
|
||||
oswsstack = new wsman(transport, '127.0.0.1', 16992, x.user, x.pass, false);
|
||||
osamtstack = new amt(oswsstack);
|
||||
//debug('Trying to get Intel AMT activation information...');
|
||||
osamtstack.BatchEnum(null, ['*AMT_GeneralSettings', '*IPS_HostBasedSetupService'], activeToACM2, trustedFqdn);
|
||||
} else {
|
||||
//debug('Unable to get $$OsAdmin password.');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function activeToACM2(stack, name, responses, status, trustedFqdn) {
|
||||
debug('activeToACM2: ' + trustedFqdn);
|
||||
if (status != 200) return;
|
||||
var fwNonce = responses['IPS_HostBasedSetupService'].response['ConfigurationNonce'];
|
||||
var digestRealm = responses['AMT_GeneralSettings'].response['DigestRealm'];
|
||||
agent.SendCommand({ "action": "acmactivate", "nonce": fwNonce, "realm": digestRealm, "fqdn": trustedFqdn });
|
||||
}
|
||||
|
||||
//
|
||||
// Activate Intel AMT to CCM
|
||||
//
|
||||
|
@ -444,21 +499,25 @@ function AmtManager(agent, db, isdebug) {
|
|||
obj.activeToCCM = function (adminpass) {
|
||||
if ((adminpass == null) || (adminpass == '')) { adminpass = 'P@0s' + makePass(23); }
|
||||
intelAmtAdminPass = adminpass;
|
||||
//debug('Trying to get local account info...');
|
||||
amtMei.getLocalSystemAccount(function (x) {
|
||||
if ((x != null) && x.user && x.pass) {
|
||||
//debug('Intel AMT local account info: User=' + x.user + ', Pass=' + x.pass + '.');
|
||||
var transport = require('amt-wsman-duk');
|
||||
var wsman = require('amt-wsman');
|
||||
var amt = require('amt');
|
||||
oswsstack = new wsman(transport, '127.0.0.1', 16992, x.user, x.pass, false);
|
||||
osamtstack = new amt(oswsstack);
|
||||
//debug('Trying to get Intel AMT activation information...');
|
||||
osamtstack.BatchEnum(null, ['*AMT_GeneralSettings', '*IPS_HostBasedSetupService'], activeToCCMEx2, adminpass);
|
||||
} else {
|
||||
debug('Unable to get $$OsAdmin password.');
|
||||
}
|
||||
});
|
||||
if (osamtstack != null) {
|
||||
osamtstack.BatchEnum(null, ['*AMT_GeneralSettings', '*IPS_HostBasedSetupService'], activeToCCMEx2, adminpass);
|
||||
} else {
|
||||
//debug('Trying to get local account info...');
|
||||
amtMei.getLocalSystemAccount(function (x) {
|
||||
if ((x != null) && x.user && x.pass) {
|
||||
//debug('Intel AMT local account info: User=' + x.user + ', Pass=' + x.pass + '.');
|
||||
var transport = require('amt-wsman-duk');
|
||||
var wsman = require('amt-wsman');
|
||||
var amt = require('amt');
|
||||
oswsstack = new wsman(transport, '127.0.0.1', 16992, x.user, x.pass, false);
|
||||
osamtstack = new amt(oswsstack);
|
||||
//debug('Trying to get Intel AMT activation information...');
|
||||
osamtstack.BatchEnum(null, ['*AMT_GeneralSettings', '*IPS_HostBasedSetupService'], activeToCCMEx2, adminpass);
|
||||
} else {
|
||||
//debug('Unable to get $$OsAdmin password.');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var activeToCCMEx2 = function(stack, name, responses, status, adminpass) {
|
||||
|
@ -518,13 +577,7 @@ function AmtManager(agent, db, isdebug) {
|
|||
try { amtstack.BatchEnum(null, wsmanQuery, wsmanPassTestResponse); } catch (ex) { debug(ex); }
|
||||
} else if ((amtpolicy.type == 3) && (meinfo.ProvisioningState == 0)) {
|
||||
// ACM Activation Policy
|
||||
// TODO: Check that we have wired ethernet enabled and that the DNS domain suffix matches a server certificate...
|
||||
|
||||
// TODO: Check that a trusted hash matches the server cert root hash...
|
||||
|
||||
// TODO: Fetch Intel AMT Realm and Nonce and get ready to ACM activation...
|
||||
|
||||
//console.log(meinfo);
|
||||
obj.activeToACM(meinfo);
|
||||
} else {
|
||||
// Other possible cases...
|
||||
}
|
||||
|
|
|
@ -1,125 +0,0 @@
|
|||
/*
|
||||
Copyright 2018-2019 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
var toasters = {};
|
||||
|
||||
function Toaster()
|
||||
{
|
||||
this._ObjectID = 'toaster';
|
||||
this.Toast = function Toast(title, caption)
|
||||
{
|
||||
var retVal = {};
|
||||
var emitter = require('events').inherits(retVal);
|
||||
emitter.createEvent('Dismissed');
|
||||
|
||||
retVal.title = title;
|
||||
retVal.caption = caption;
|
||||
|
||||
if (process.platform == 'win32')
|
||||
{
|
||||
emitter.createEvent('Clicked');
|
||||
|
||||
var session = require('user-sessions').Current();
|
||||
for (var i in session) {
|
||||
console.log(session[i]);
|
||||
}
|
||||
try {
|
||||
console.log('Attempting Toast Mechanism 1');
|
||||
retVal._child = require('ScriptContainer').Create({ processIsolation: true, sessionId: session.Active[0].SessionId });
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e);
|
||||
console.log('Attempting Toast Mechanism 2');
|
||||
retVal._child = require('ScriptContainer').Create({ processIsolation: true });
|
||||
}
|
||||
retVal._child.parent = retVal;
|
||||
|
||||
retVal._child.on('exit', function (code) { this.parent.emit('Dismissed'); delete this.parent._child; });
|
||||
retVal._child.addModule('win-console', getJSModule('win-console'));
|
||||
retVal._child.addModule('win-message-pump', getJSModule('win-message-pump'));
|
||||
|
||||
var str = "\
|
||||
try{\
|
||||
var toast = require('win-console');\
|
||||
var balloon = toast.SetTrayIcon({ szInfo: '" + caption + "', szInfoTitle: '" + title + "', balloonOnly: true });\
|
||||
balloon.on('ToastDismissed', function(){process.exit();});\
|
||||
}\
|
||||
catch(e)\
|
||||
{\
|
||||
require('ScriptContainer').send(e);\
|
||||
}\
|
||||
require('ScriptContainer').send('done');\
|
||||
";
|
||||
retVal._child.ExecuteString(str);
|
||||
toasters[retVal._hashCode()] = retVal;
|
||||
retVal.on('Dismissed', function () { delete toasters[this._hashCode()]; });
|
||||
console.log('Returning');
|
||||
return (retVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!require('fs').existsSync('/usr/bin/notify-send'))
|
||||
{
|
||||
throw ('Toast not supported on this platform');
|
||||
}
|
||||
Object.defineProperty(retVal, '_sessions', {
|
||||
value: require('user-sessions').Current(function onCurrentSession(sessions)
|
||||
{
|
||||
this._cchild = require('child_process').execFile('/usr/bin/whoami', ['whoami'], { type: require('child_process').SpawnTypes.TERM });
|
||||
this._cchild.stdout.on('data', function (chunk)
|
||||
{
|
||||
if (chunk.toString().split('\r\n')[0] == 'root')
|
||||
{
|
||||
if (sessions[':0'].State != 'Connected' && sessions[':0'].State != 'Active')
|
||||
{
|
||||
// No logged in user owns the display
|
||||
this.parent.parent.Parent.emit('Dismissed');
|
||||
return;
|
||||
}
|
||||
|
||||
// We root, so we need to direct to DISPLAY=:0
|
||||
this.parent.parent._notify = require('child_process').execFile('/bin/sh', ['sh'], { type: require('child_process').SpawnTypes.TERM });
|
||||
this.parent.parent._notify.stdin.write('su - ' + sessions[':0'].Username + ' -c "DISPLAY=:0 notify-send \'' + this.parent.parent.Parent.title + '\' \'' + this.parent.parent.Parent.caption + '\'"\n');
|
||||
this.parent.parent._notify.stdin.write('exit\n');
|
||||
this.parent.parent._notify.stdout.on('data', function (chunk) { });
|
||||
}
|
||||
else
|
||||
{
|
||||
// We ain't root, so that means we can just call send-notify directly
|
||||
this.parent.parent._notify = require('child_process').execFile('/usr/bin/notify-send', ['notify-send', this.parent.parent.Parent.title, this.parent.parent.Parent.caption], { type: require('child_process').SpawnTypes.TERM });
|
||||
this.parent.parent._notify.stdout.on('data', function (chunk) { });
|
||||
}
|
||||
|
||||
// NOTIFY-SEND has a bug where timeouts don't work, so the default is 10 seconds
|
||||
this.parent.parent.Parent._timeout = setTimeout(function onFakeDismissed(obj)
|
||||
{
|
||||
obj.emit('Dismissed');
|
||||
}, 10000, this.parent.parent.Parent);
|
||||
});
|
||||
this._cchild.parent = this;
|
||||
})
|
||||
});
|
||||
retVal._sessions.Parent = retVal;
|
||||
|
||||
toasters[retVal._hashCode()] = retVal;
|
||||
retVal.on('Dismissed', function () { delete toasters[this._hashCode()]; });
|
||||
|
||||
return (retVal);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = new Toaster();
|
1
agents/modules_meshcore_min/amt-lme.min.js
vendored
1
agents/modules_meshcore_min/amt-lme.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
agents/modules_meshcore_min/amt-mei.min.js
vendored
1
agents/modules_meshcore_min/amt-mei.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
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;
|
|
@ -1 +0,0 @@
|
|||
function CreateWsmanComm(){var a={};a.PendingAjax=[];a.ActiveAjaxCount=0;a.MaxActiveAjaxCount=1;a.FailAllError=0;a.digest=null;a.RequestCount=0;if(arguments.length==1&&typeof(arguments[0]=="object")){a.host=arguments[0].host;a.port=arguments[0].port;a.authToken=arguments[0].authToken;a.tls=arguments[0].tls}else{a.host=arguments[0];a.port=arguments[1];a.user=arguments[2];a.pass=arguments[3];a.tls=arguments[4]}a.PerformAjax=function(d,c,f,e,g,b){if((a.ActiveAjaxCount==0||((a.ActiveAjaxCount<a.MaxActiveAjaxCount)&&(a.challengeParams!=null)))&&a.PendingAjax.length==0){a.PerformAjaxEx(d,c,f,g,b)}else{if(e==1){a.PendingAjax.unshift([d,c,f,g,b])}else{a.PendingAjax.push([d,c,f,g,b])}}};a.PerformNextAjax=function(){if(a.ActiveAjaxCount>=a.MaxActiveAjaxCount||a.PendingAjax.length==0){return}var b=a.PendingAjax.shift();a.PerformAjaxEx(b[0],b[1],b[2],b[3],b[4]);a.PerformNextAjax()};a.PerformAjaxEx=function(d,c,g,h,b){if(a.FailAllError!=0){if(a.FailAllError!=999){a.gotNextMessagesError({status:a.FailAllError},"error",null,[d,c,g])}return}if(!d){d=""}if(a.digest==null){if(a.authToken){a.digest=require("http-digest").create({authToken:a.authToken})}else{a.digest=require("http-digest").create(a.user,a.pass)}a.digest.http=require("http")}var f={protocol:(a.tls==1?"https:":"http:"),method:"POST",host:a.host,path:"/wsman",port:a.port,rejectUnauthorized:false,checkServerIdentity:function(i){console.log("checkServerIdentity",JSON.stringify(i))}};var e=a.digest.request(f);e.on("error",function(i){a.gotNextMessagesError({status:600},"error",null,[d,c,g])});e.on("response",function(i){if(i.statusCode!=200){a.gotNextMessagesError({status:i.statusCode},"error",null,[d,c,g])}else{i.acc="";i.on("data",function(j){this.acc+=j});i.on("end",function(){a.gotNextMessages(i.acc,"success",{status:i.statusCode},[d,c,g])})}});e.end(d);a.ActiveAjaxCount++;return e};a.pendingAjaxCall=[];a.gotNextMessages=function(c,e,d,b){a.ActiveAjaxCount--;if(a.FailAllError==999){return}if(a.FailAllError!=0){b[1](null,a.FailAllError,b[2]);return}if(d.status!=200){b[1](null,d.status,b[2]);return}b[1](c,200,b[2]);a.PerformNextAjax()};a.gotNextMessagesError=function(d,e,c,b){a.ActiveAjaxCount--;if(a.FailAllError==999){return}if(a.FailAllError!=0){b[1](null,a.FailAllError,b[2]);return}if(a.FailAllError!=999){b[1]({Header:{HttpError:d.status}},d.status,b[2])}a.PerformNextAjax()};a.CancelAllQueries=function(b){while(a.PendingAjax.length>0){var c=a.PendingAjax.shift();c[1](null,b,c[2])}};return a}module.exports=CreateWsmanComm;
|
1
agents/modules_meshcore_min/amt-wsman.min.js
vendored
1
agents/modules_meshcore_min/amt-wsman.min.js
vendored
File diff suppressed because one or more lines are too long
1
agents/modules_meshcore_min/amt-xml.min.js
vendored
1
agents/modules_meshcore_min/amt-xml.min.js
vendored
File diff suppressed because one or more lines are too long
1
agents/modules_meshcore_min/amt.min.js
vendored
1
agents/modules_meshcore_min/amt.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
try{Object.defineProperty(Array.prototype,"peek",{value:function(){return(this.length>0?this[this.length-1]:undefined)}})}catch(e){}function dbus(a,b){this._ObjectID="linux-dbus";require("events").EventEmitter.call(this,true).createEvent("signal");Object.defineProperty(this,"uid",{value:b});this._child=require("child_process").execFile("/bin/sh",["sh"],{type:require("child_process").SpawnTypes.TERM,uid:b==null?-1:b});this._child.stdin.write("dbus-monitor --session \"type='signal', interface='"+a+'\'" | ( while read X; do echo "$X"; done )\n');this._child.stdout.dbus=this;this._child.stdout.on("data",function(c){if(!this.ready){this.ready=true;return}var f=[];var g=c.toString().split("\r\n");for(var d in g){if(g[d]==""){this.dbus.preParseRecords(f);f=[]}else{f.push(g[d])}}});this.preParseRecords=function(d){var f=[];for(var c in d){if(d[c].startsWith("signal ")){if(f.length>0){this.parseRecords(f)}f=[]}f.push(d[c])}if(f.length>0){this.parseRecords(f)}};this.parseRecords=function(d){if(d[0].startsWith("signal ")){var g={};var h=d[0].split(" ");h.shift();for(var c in h){var f=h[c].split("=");if(f.length==2){g[f[0]]=f[1]}}d.shift();g.data=d;this.parseSignal(g)}};this.parseSignal=function(f){var c=f.data;f.data=[];for(var d=0;d<c.length;++d){if(c[d].startsWith("array ")){f.data.push([]);for(d=d+1;d<c.length;++d){this.parseSignal2(c[d],f.data.peek())}}else{this.parseSignal2(c[d],f.data)}}this.emit("signal",f)};this.parseSignal2=function(c,d){if(c.startsWith("string ")){d.push(JSON.parse(c.slice(7)))}else{if(c.startsWith("boolean ")){d.push(JSON.parse(c.slice(8)))}}}}module.exports=dbus;
|
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
function powerMonitor(){this._ObjectID="power-monitor";require("events").EventEmitter.call(this,true).createEvent("changed").createEvent("sx").createEvent("batteryLevel").createEvent("acdc").createEvent("display");this._i=setImmediate(function(a){require("user-sessions");delete a._i},this)}module.exports=new powerMonitor();
|
1
agents/modules_meshcore_min/smbios.min.js
vendored
1
agents/modules_meshcore_min/smbios.min.js
vendored
File diff suppressed because one or more lines are too long
1
agents/modules_meshcore_min/toaster.min.js
vendored
1
agents/modules_meshcore_min/toaster.min.js
vendored
|
@ -1 +0,0 @@
|
|||
var toasters={};function Toaster(){this._ObjectID="toaster";this.Toast=function a(l,b){var h={};var d=require("events").inherits(h);d.createEvent("Dismissed");h.title=l;h.caption=b;if(process.platform=="win32"){d.createEvent("Clicked");var j=require("user-sessions").Current();for(var f in j){console.log(j[f])}try{console.log("Attempting Toast Mechanism 1");h._child=require("ScriptContainer").Create({processIsolation:true,sessionId:j.Active[0].SessionId})}catch(c){console.log(c);console.log("Attempting Toast Mechanism 2");h._child=require("ScriptContainer").Create({processIsolation:true})}h._child.parent=h;h._child.on("exit",function(e){this.parent.emit("Dismissed");delete this.parent._child});h._child.addModule("win-console",getJSModule("win-console"));h._child.addModule("win-message-pump",getJSModule("win-message-pump"));var k=" try{ var toast = require('win-console'); var balloon = toast.SetTrayIcon({ szInfo: '"+b+"', szInfoTitle: '"+l+"', balloonOnly: true }); balloon.on('ToastDismissed', function(){process.exit();}); } catch(e) { require('ScriptContainer').send(e); } require('ScriptContainer').send('done'); ";h._child.ExecuteString(k);toasters[h._hashCode()]=h;h.on("Dismissed",function(){delete toasters[this._hashCode()]});console.log("Returning");return(h)}else{if(!require("fs").existsSync("/usr/bin/notify-send")){throw ("Toast not supported on this platform")}Object.defineProperty(h,"_sessions",{value:require("user-sessions").Current(function g(e){this._cchild=require("child_process").execFile("/usr/bin/whoami",["whoami"],{type:require("child_process").SpawnTypes.TERM});this._cchild.stdout.on("data",function(i){if(i.toString().split("\r\n")[0]=="root"){if(e[":0"].State!="Connected"&&e[":0"].State!="Active"){this.parent.parent.Parent.emit("Dismissed");return}this.parent.parent._notify=require("child_process").execFile("/bin/sh",["sh"],{type:require("child_process").SpawnTypes.TERM});this.parent.parent._notify.stdin.write("su - "+e[":0"].Username+" -c \"DISPLAY=:0 notify-send '"+this.parent.parent.Parent.title+"' '"+this.parent.parent.Parent.caption+"'\"\n");this.parent.parent._notify.stdin.write("exit\n");this.parent.parent._notify.stdout.on("data",function(n){})}else{this.parent.parent._notify=require("child_process").execFile("/usr/bin/notify-send",["notify-send",this.parent.parent.Parent.title,this.parent.parent.Parent.caption],{type:require("child_process").SpawnTypes.TERM});this.parent.parent._notify.stdout.on("data",function(n){})}this.parent.parent.Parent._timeout=setTimeout(function m(n){n.emit("Dismissed")},10000,this.parent.parent.Parent)});this._cchild.parent=this})});h._sessions.Parent=h;toasters[h._hashCode()]=h;h.on("Dismissed",function(){delete toasters[this._hashCode()]});return(h)}}}module.exports=new Toaster();
|
|
@ -1 +0,0 @@
|
|||
function _Scan(){var f=this.Marshal.CreatePointer();this.Native.WlanEnumInterfaces(this.Handle,0,f);var a=f.Deref().Deref(0,4).toBuffer().readUInt32LE(0);var d=f.Deref().Deref(8,532);var c=d.Deref(16,512).AnsiString;var e;switch(d.Deref(528,4).toBuffer().readUInt32LE(0)){case 0:e="NOT READY";break;case 1:e="CONNECTED";break;case 2:e="AD-HOC";break;case 3:e="DISCONNECTING";break;case 4:e="DISCONNECTED";break;case 5:e="ASSOCIATING";break;case 6:e="DISCOVERING";break;case 7:e="AUTHENTICATING";break;default:e="UNKNOWN";break}var b=d.Deref(0,16);if(this.Native.WlanScan(this.Handle,b,0,0,0).Val==0){return(true)}else{return(false)}}function AccessPoint(d,a,c,b){this.ssid=d;this.bssid=a;this.rssi=c;this.lq=b}AccessPoint.prototype.toString=function(){return(this.ssid+" ["+this.bssid+"]: "+this.lq)};function OnNotify(g){var h=g.Deref(0,4).toBuffer().readUInt32LE(0);var f=g.Deref(4,4).toBuffer().readUInt32LE(0);var c=g.Deref(8,16);if((h&8)&&(f==7)){var a=this.Parent.Marshal.CreatePointer();var k=this.Parent.Native.GetBSSList(this.Parent.Handle,c,0,3,0,0,a).Val;if(k==0){var n=a.Deref().Deref(0,4).toBuffer().readUInt32LE(0);var j=a.Deref().Deref(4,4).toBuffer().readUInt32LE(0);for(i=0;i<j;++i){var d=a.Deref().Deref(8+(360*i),360);var m=d.Deref(4,32).String.trim();var b=d.Deref(40,6).HexString2;var l=d.Deref(56,4).toBuffer().readUInt32LE(0);var e=d.Deref(60,4).toBuffer().readUInt32LE(0);this.Parent.emit("Scan",new AccessPoint(m,b,l,e))}}}}function Wireless(){var a=require("events").inherits(this);this.Marshal=require("_GenericMarshal");this.Native=this.Marshal.CreateNativeProxy("wlanapi.dll");this.Native.CreateMethod("WlanOpenHandle");this.Native.CreateMethod("WlanGetNetworkBssList","GetBSSList");this.Native.CreateMethod("WlanRegisterNotification");this.Native.CreateMethod("WlanEnumInterfaces");this.Native.CreateMethod("WlanScan");this.Native.CreateMethod("WlanQueryInterface");var c=this.Marshal.CreatePointer();var b=this.Marshal.CreatePointer();this.Native.WlanOpenHandle(2,0,c,b);this.Handle=b.Deref();this._NOTIFY_PROXY_OBJECT=this.Marshal.CreateCallbackProxy(OnNotify,2);this._NOTIFY_PROXY_OBJECT.Parent=this;var d=this.Marshal.CreatePointer();var e=this.Native.WlanRegisterNotification(this.Handle,65535,0,this._NOTIFY_PROXY_OBJECT.Callback,this._NOTIFY_PROXY_OBJECT.State,0,d);a.createEvent("Scan");a.addMethod("Scan",_Scan);this.GetConnectedNetwork=function(){var n=this.Marshal.CreatePointer();console.log("Success = "+this.Native.WlanEnumInterfaces(this.Handle,0,n).Val);var h=n.Deref().Deref(0,4).toBuffer().readUInt32LE(0);var m=n.Deref().Deref(8,532);var l=m.Deref(16,512).AnsiString;var o=m.Deref(528,4).toBuffer().readUInt32LE(0);if(m.Deref(528,4).toBuffer().readUInt32LE(0)==1){var j=this.Marshal.CreatePointer();var q=this.Marshal.CreatePointer();var s=this.Marshal.CreatePointer();var k=m.Deref(0,16);var r=this.Native.WlanQueryInterface(this.Handle,k,7,0,j,q,s).Val;if(r==0){var f=q.Deref().Deref(524,32).String;var g=q.Deref().Deref(560,6).HexString;var p=q.Deref().Deref(576,4).toBuffer().readUInt32LE(0);return(new AccessPoint(f,g,0,p))}}throw ("GetConnectedNetworks: FAILED (not associated to a network)")};return(this)}module.exports=new Wireless();
|
|
@ -1 +0,0 @@
|
|||
var MemoryStream=require("MemoryStream");var WindowsChildScript='var parent = require("ScriptContainer");var Wireless = require("wifi-scanner-windows");Wireless.on("Scan", function (ap) { parent.send(ap); });Wireless.Scan();';function AccessPoint(c,a,b){this.ssid=c;this.bssid=a;this.lq=b}AccessPoint.prototype.toString=function(){return("["+this.bssid+"]: "+this.ssid+" ("+this.lq+")")};function WiFiScanner(){var a=require("events").inherits(this);a.createEvent("accessPoint");this.hasWireless=function(){var d=false;var b=require("os").networkInterfaces();for(var c in b){if(b[c][0].type=="wireless"){d=true;break}}return(d)};this.Scan=function(){if(process.platform=="win32"){this.master=require("ScriptContainer").Create(15,ContainerPermissions.DEFAULT);this.master.parent=this;this.master.on("data",function(e){this.parent.emit("accessPoint",new AccessPoint(e.ssid,e.bssid,e.lq))});this.master.addModule("wifi-scanner-windows",getJSModule("wifi-scanner-windows"));this.master.ExecuteString(WindowsChildScript)}else{if(process.platform=="linux"){var c=require("os").networkInterfaces();var d=null;for(var b in c){if(c[b][0].type=="wireless"){d=b;break}}if(d!=null){this.child=require("child_process").execFile("/sbin/iwlist",["iwlist",d,"scan"]);this.child.parent=this;this.child.ms=new MemoryStream();this.child.ms.parent=this.child;this.child.stdout.on("data",function(e){this.parent.ms.write(e)});this.child.on("exit",function(){this.ms.end()});this.child.ms.on("end",function(){var l=this.buffer.toString();tokens=l.split(" - Address: ");for(var h in tokens){if(h==0){continue}var i=tokens[h].split("\n");var e=i[0];var f;var g;for(var j in i){j=i[j].trim();j=j.trim();if(j.startsWith("ESSID:")){g=j.slice(7,j.length-1);if(g=="<hidden>"){g=""}}if(j.startsWith("Signal level=")){f=j.slice(13,j.length-4)}else{if(j.startsWith("Quality=")){f=j.slice(8,10);var k=j.slice(11,13)}}}this.parent.parent.emit("accessPoint",new AccessPoint(g,e,f))}})}}}}}module.exports=WiFiScanner;
|
|
@ -1 +0,0 @@
|
|||
var TrayIconFlags={NIF_MESSAGE:1,NIF_ICON:2,NIF_TIP:4,NIF_STATE:8,NIF_INFO:16,NIF_GUID:32,NIF_REALTIME:64,NIF_SHOWTIP:128,NIM_ADD:0,NIM_MODIFY:1,NIM_DELETE:2,NIM_SETFOCUS:3,NIM_SETVERSION:4};var NOTIFYICON_VERSION_4=4;var MessageTypes={WM_APP:32768,WM_USER:1024};function WindowsConsole(){if(process.platform=="win32"){this._ObjectID="win-console";this._Marshal=require("_GenericMarshal");this._kernel32=this._Marshal.CreateNativeProxy("kernel32.dll");this._user32=this._Marshal.CreateNativeProxy("user32.dll");this._kernel32.CreateMethod("GetConsoleWindow");this._kernel32.CreateMethod("GetCurrentThread");this._user32.CreateMethod("ShowWindow");this._user32.CreateMethod("LoadImageA");this._user32.CreateMethod({method:"GetMessageA",threadDispatch:1});this._shell32=this._Marshal.CreateNativeProxy("Shell32.dll");this._shell32.CreateMethod("Shell_NotifyIconA");this._handle=this._kernel32.GetConsoleWindow();this.minimize=function(){this._user32.ShowWindow(this._handle,6)};this.restore=function(){this._user32.ShowWindow(this._handle,9)};this.hide=function(){this._user32.ShowWindow(this._handle,0)};this.show=function(){this._user32.ShowWindow(this._handle,5)};this._loadicon=function(c){var b=this._user32.LoadImageA(0,this._Marshal.CreateVariable(c),1,0,0,16|32768|64);return(b)};this.SetTrayIcon=function a(h){var b=this._Marshal.CreateVariable(this._Marshal.PointerSize==4?508:528);b.toBuffer().writeUInt32LE(b._size,0);var n=TrayIconFlags.NIF_TIP|TrayIconFlags.NIF_MESSAGE;h.filter=MessageTypes.WM_APP+1;b.Deref(this._Marshal.PointerSize==4?16:24,4).toBuffer().writeUInt32LE(h.filter);if(!h.noBalloon){n|=TrayIconFlags.NIF_INFO}if(h.icon){n|=TrayIconFlags.NIF_ICON;var c=b.Deref(this._Marshal.PointerSize==4?20:32,this._Marshal.PointerSize);h.icon.pointerBuffer().copy(c.toBuffer())}b.Deref(this._Marshal.PointerSize*2,4).toBuffer().writeUInt32LE(1);b.Deref(this._Marshal.PointerSize==4?12:20,4).toBuffer().writeUInt32LE(n);b.Deref(this._Marshal.PointerSize==4?416:432,4).toBuffer().writeUInt32LE(NOTIFYICON_VERSION_4);var m=b.Deref(this._Marshal.PointerSize==4?24:40,128);var k=b.Deref(this._Marshal.PointerSize==4?160:176,256);var l=b.Deref(this._Marshal.PointerSize==4?420:436,64);if(h.szTip){Buffer.from(h.szTip).copy(m.toBuffer())}if(h.szInfo){Buffer.from(h.szInfo).copy(k.toBuffer())}if(h.szInfoTitle){Buffer.from(h.szInfoTitle).copy(l.toBuffer())}var d=require("win-message-pump");retVal={_ObjectID:"WindowsConsole.TrayIcon",MessagePump:new d(h)};var j=require("events").inherits(retVal);j.createEvent("ToastClicked");j.createEvent("IconHover");j.createEvent("ToastDismissed");retVal.Options=h;retVal.MessagePump.TrayIcon=retVal;retVal.MessagePump.NotifyData=b;retVal.MessagePump.WindowsConsole=this;retVal.MessagePump.on("exit",function e(o){console.log("Pump Exited");if(this.TrayIcon){this.TrayIcon.remove()}});retVal.MessagePump.on("hwnd",function f(o){h.hwnd=o;o.pointerBuffer().copy(this.NotifyData.Deref(this.WindowsConsole._Marshal.PointerSize,this.WindowsConsole._Marshal.PointerSize).toBuffer());if(this.WindowsConsole._shell32.Shell_NotifyIconA(TrayIconFlags.NIM_ADD,this.NotifyData).Val==0){}});retVal.MessagePump.on("message",function g(p){if(p.message==this.TrayIcon.Options.filter){var o=false;if(p.wparam==1&&p.lparam==1029){this.TrayIcon.emit("ToastClicked");o=true}if(p.wparam==1&&p.lparam==512){this.TrayIcon.emit("IconHover");o=true}if(this.TrayIcon.Options.balloonOnly&&p.wparam==1&&(p.lparam==1028||p.lparam==1029)){this.TrayIcon.emit("ToastDismissed");this.TrayIcon.remove();o=true}}});retVal.remove=function i(){this.MessagePump.WindowsConsole._shell32.Shell_NotifyIconA(TrayIconFlags.NIM_DELETE,this.MessagePump.NotifyData);this.MessagePump.stop();delete this.MessagePump.TrayIcon;delete this.MessagePump};return(retVal)}}}module.exports=new WindowsConsole();
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue