Added improved KVM support to MeshCmd.exe and MeshAgent
Ylian Saint-Hilaire committed
Jul 2, 2018 at 14:34 UTC
3dafa39e7925b31d5d15f1647b8c0f7ca06facf2
16 files changed
+1890
-42
agents/MeshCmd-signed.exe
Binary files a/agents/MeshCmd-signed.exe and b/agents/MeshCmd-signed.exe differ
agents/MeshCmd64-signed.exe
Binary files a/agents/MeshCmd64-signed.exe and b/agents/MeshCmd64-signed.exe differ
agents/MeshService-signed.exe
Binary files a/agents/MeshService-signed.exe and b/agents/MeshService-signed.exe differ
agents/MeshService.exe
Binary files a/agents/MeshService.exe and b/agents/MeshService.exe differ
agents/MeshService64-signed.exe
Binary files a/agents/MeshService64-signed.exe and b/agents/MeshService64-signed.exe differ
agents/MeshService64.exe
Binary files a/agents/MeshService64.exe and b/agents/MeshService64.exe differ
agents/meshcmd.js
+202
-11
@@ -877,7 +877,7 @@ function startLms(func) {
877
});
878
amtLms.on('notify', function (data, options, str, code) {
879
if (code == 'iAMT0052-3') {
880
- kvmGetData(true);
880
+ kvmGetData();
881
} else if (str != null) {
882
var notify = { date: Date.now(), str: str, code: code };
883
lmsNotifications.push(notify);
@@ -960,11 +960,18 @@ function setupMeiOsAdmin(func, state) {
960
if (func) { func(state); }
961
//var AllWsman = "CIM_SoftwareIdentity,IPS_SecIOService,IPS_ScreenSettingData,IPS_ProvisioningRecordLog,IPS_HostBasedSetupService,IPS_HostIPSettings,IPS_IPv6PortSettings".split(',');
962
//osamtstack.BatchEnum(null, AllWsman, startLmsWsmanResponse, null, true);
963
-
963
//*************************************
965
- //tempTimer = setInterval(function () { kvmGetData(true); }, 2000);
966
- //kvmGetData(false);
967
- //kvmSetData(JSON.stringify({ action: 'restart', ver: 1 }));
964
+
965
+ // Setup KVM data channel if this is Intel AMT 12 or above
966
+ amtMei.getVersion(function (x) {
967
+ var amtver = null;
968
+ try { for (var i in x.Versions) { if (x.Versions[i].Description == 'AMT') amtver = parseInt(x.Versions[i].Version.split('.')[0]); } } catch (e) {}
969
+ if ((amtver != null) && (amtver >= 12)) {
970
+ kvmGetData('skip'); // Clear any previous data, this is a dummy read to about handling old data.
971
+ tempTimer = setInterval(function () { kvmGetData(); }, 2000); // Start polling for KVM data.
972
+ kvmSetData(JSON.stringify({ action: 'restart', ver: 1 })); // Send a restart command to advise the console if present that MicroLMS just started.
973
+ }
974
+ });
975
});
976
}
977
@@ -973,20 +980,19 @@ function kvmGetData(tag) {
980
}
981
982
function kvmDataGetResponse(stack, name, response, status, tag) {
976
- if ((tag == true) && (status == 200) && (response.Body.ReturnValue == 0)) {
983
+ if ((tag != 'skip') && (status == 200) && (response.Body.ReturnValue == 0)) {
984
var val = null;
985
try { val = Buffer.from(response.Body.DataMessage, 'base64').toString(); } catch (e) { return }
979
- if (val != null) kvmProcessData(response.Body.RealmsBitmap, response.Body.MessageId, val);
986
+ if (val != null) { kvmProcessData(response.Body.RealmsBitmap, response.Body.MessageId, val); }
987
}
988
}
989
990
var webRtcDesktop = null;
991
function kvmProcessData(realms, messageId, val) {
985
- //console.log('kvmProcessData', val);
992
var data = null;
993
try { data = JSON.parse(val) } catch (e) { }
994
if ((data != null) && (data.action)) {
989
- if (data.action == 'present') { kvmSetData(JSON.stringify({ action: 'present', ver: 1 })); }
995
+ if (data.action == 'present') { kvmSetData(JSON.stringify({ action: 'present', ver: 1, platform: process.platform })); }
996
if (data.action == 'offer') {
997
webRtcDesktop = {};
998
var rtc = require('ILibWebRTC');
@@ -997,9 +1003,10 @@ function kvmProcessData(realms, messageId, val) {
1003
webRtcDesktop.rtcchannel = rtcchannel;
1004
var kvmmodule = require('meshDesktop');
1005
webRtcDesktop.kvm = kvmmodule.getRemoteDesktopStream();
1000
- webRtcDesktop.kvm.pipe(webRtcDesktop.rtcchannel, { end: false });
1001
- webRtcDesktop.rtcchannel.pipe(webRtcDesktop.kvm, { end: false });
1006
+ webRtcDesktop.kvm.pipe(webRtcDesktop.rtcchannel, { dataTypeSkip: 1, end: false });
1007
webRtcDesktop.rtcchannel.on('end', function () { webRtcCleanUp(); });
1008
+ webRtcDesktop.rtcchannel.on('data', function (x) { kvmCtrlData(this, x); });
1009
+ webRtcDesktop.rtcchannel.pipe(webRtcDesktop.kvm, { dataTypeSkip: 1, end: false });
1010
//webRtcDesktop.kvm.on('end', function () { console.log('WebRTC DataChannel closed2'); webRtcCleanUp(); });
1011
//webRtcDesktop.rtcchannel.on('data', function (data) { console.log('WebRTC data: ' + data); });
1012
});
@@ -1008,6 +1015,190 @@ function kvmProcessData(realms, messageId, val) {
1015
}
1016
}
1017
1018
+// Polyfill path.join
1019
+var path = {
1020
+ join: function () {
1021
+ var x = [];
1022
+ for (var i in arguments) {
1023
+ var w = arguments[i];
1024
+ if (w != null) {
1025
+ while (w.endsWith('/') || w.endsWith('\\')) { w = w.substring(0, w.length - 1); }
1026
+ if (i != 0) {
1027
+ while (w.startsWith('/') || w.startsWith('\\')) { w = w.substring(1); }
1028
+ }
1029
+ x.push(w);
1030
+ }
1031
+ }
1032
+ if (x.length == 0) return '/';
1033
+ return x.join('/');
1034
+ }
1035
+};
1036
+
1037
+// Get a formated response for a given directory path
1038
+function getDirectoryInfo(reqpath) {
1039
+ var response = { path: reqpath, dir: [] };
1040
+ if (((reqpath == undefined) || (reqpath == '')) && (process.platform == 'win32')) {
1041
+ // List all the drives in the root, or the root itself
1042
+ var results = null;
1043
+ try { results = fs.readDrivesSync(); } catch (e) { } // TODO: Anyway to get drive total size and free space? Could draw a progress bar.
1044
+ //console.log('a', objToString(results, 0, ' '));
1045
+ if (results != null) {
1046
+ for (var i = 0; i < results.length; ++i) {
1047
+ var drive = { n: results[i].name, t: 1 };
1048
+ if (results[i].type == 'REMOVABLE') { drive.dt = 'removable'; } // TODO: See if this is USB/CDROM or something else, we can draw icons.
1049
+ response.dir.push(drive);
1050
+ }
1051
+ }
1052
+ } else {
1053
+ // List all the files and folders in this path
1054
+ if (reqpath == '') { reqpath = '/'; }
1055
+ var xpath = path.join(reqpath, '*');
1056
+ var results = null;
1057
+
1058
+ try { results = fs.readdirSync(xpath); } catch (e) { }
1059
+ if (results != null) {
1060
+ for (var i = 0; i < results.length; ++i) {
1061
+ if ((results[i] != '.') && (results[i] != '..')) {
1062
+ var stat = null, p = path.join(reqpath, results[i]);
1063
+ try { stat = fs.statSync(p); } catch (e) { } // TODO: Get file size/date
1064
+ if ((stat != null) && (stat != undefined)) {
1065
+ if (stat.isDirectory() == true) {
1066
+ response.dir.push({ n: results[i], t: 2, d: stat.mtime });
1067
+ } else {
1068
+ response.dir.push({ n: results[i], t: 3, s: stat.size, d: stat.mtime });
1069
+ }
1070
+ }
1071
+ }
1072
+ }
1073
+ }
1074
+ }
1075
+ return response;
1076
+}
1077
+
1078
+// Process KVM control channel data
1079
+function kvmCtrlData(channel, cmd) {
1080
+ if (cmd.length > 0 && cmd.charCodeAt(0) != 123) {
1081
+ // This is upload data
1082
+ if (this.fileupload != null) {
1083
+ cmd = Buffer.from(cmd, 'base64');
1084
+ var header = cmd.readUInt32BE(0);
1085
+ if ((header == 0x01000000) || (header == 0x01000001)) {
1086
+ fs.writeSync(this.fileupload.fp, cmd.slice(4));
1087
+ channel.write({ action: 'upload', sub: 'ack', reqid: this.fileupload.reqid });
1088
+ if (header == 0x01000001) { fs.closeSync(this.fileupload.fp); this.fileupload = null; } // Close the file
1089
+ }
1090
+ }
1091
+ return;
1092
+ }
1093
+ //console.log('KVM Ctrl Data', cmd);
1094
+
1095
+ try { cmd = JSON.parse(cmd); } catch (ex) { console.error('Invalid JSON: ' + cmd); return; }
1096
+ if ((cmd.path != null) && (process.platform != 'win32') && (cmd.path[0] != '/')) { cmd.path = '/' + cmd.path; } // Add '/' to paths on non-windows
1097
+ switch (cmd.action) {
1098
+ case 'ls': {
1099
+ /*
1100
+ // Close the watcher if required
1101
+ var samepath = ((this.httprequest.watcher != undefined) && (cmd.path == this.httprequest.watcher.path));
1102
+ if ((this.httprequest.watcher != undefined) && (samepath == false)) {
1103
+ //console.log('Closing watcher: ' + this.httprequest.watcher.path);
1104
+ //this.httprequest.watcher.close(); // TODO: This line causes the agent to crash!!!!
1105
+ delete this.httprequest.watcher;
1106
+ }
1107
+ */
1108
+
1109
+ // Send the folder content to the browser
1110
+ var response = getDirectoryInfo(cmd.path);
1111
+ if (cmd.reqid != undefined) { response.reqid = cmd.reqid; }
1112
+ channel.write(response);
1113
+
1114
+ /*
1115
+ // Start the directory watcher
1116
+ if ((cmd.path != '') && (samepath == false)) {
1117
+ var watcher = fs.watch(cmd.path, onFileWatcher);
1118
+ watcher.tunnel = this.httprequest;
1119
+ watcher.path = cmd.path;
1120
+ this.httprequest.watcher = watcher;
1121
+ //console.log('Starting watcher: ' + this.httprequest.watcher.path);
1122
+ }
1123
+ */
1124
+ break;
1125
+ }
1126
+ case 'mkdir': {
1127
+ // Create a new empty folder
1128
+ fs.mkdirSync(cmd.path);
1129
+ break;
1130
+ }
1131
+ case 'rm': {
1132
+ // Remove many files or folders
1133
+ for (var i in cmd.delfiles) {
1134
+ var fullpath = path.join(cmd.path, cmd.delfiles[i]);
1135
+ try { fs.unlinkSync(fullpath); } catch (e) { console.log(e); }
1136
+ }
1137
+ break;
1138
+ }
1139
+ case 'rename': {
1140
+ // Rename a file or folder
1141
+ var oldfullpath = path.join(cmd.path, cmd.oldname);
1142
+ var newfullpath = path.join(cmd.path, cmd.newname);
1143
+ try { fs.renameSync(oldfullpath, newfullpath); } catch (e) { console.log(e); }
1144
+ break;
1145
+ }
1146
+ case 'download': {
1147
+ // Download a file, to browser
1148
+ var sendNextBlock = 0;
1149
+ if (cmd.sub == 'start') { // Setup the download
1150
+ if (this.filedownload != null) { channel.write({ action: 'download', sub: 'cancel', id: this.filedownload.id }); delete this.filedownload; }
1151
+ this.filedownload = { id: cmd.id, path: cmd.path, ptr: 0 }
1152
+ try { this.filedownload.f = fs.openSync(this.filedownload.path, 'rbN'); } catch (e) { channel.write({ action: 'download', sub: 'cancel', id: this.filedownload.id }); delete this.filedownload; }
1153
+ if (this.filedownload) { channel.write({ action: 'download', sub: 'start', id: cmd.id }); }
1154
+ } else if ((this.filedownload != null) && (cmd.id == this.filedownload.id)) { // Download commands
1155
+ if (cmd.sub == 'startack') { sendNextBlock = 8; } else if (cmd.sub == 'stop') { delete this.filedownload; } else if (cmd.sub == 'ack') { sendNextBlock = 1; }
1156
+ }
1157
+ // Send the next download block(s)
1158
+ while (sendNextBlock > 0) {
1159
+ sendNextBlock--;
1160
+ var buf = new Buffer(4096);
1161
+ var len = fs.readSync(this.filedownload.f, buf, 4, 4092, null);
1162
+ this.filedownload.ptr += len;
1163
+ if (len < 4092) { buf.writeInt32BE(0x01000001, 0); fs.closeSync(this.filedownload.f); delete this.filedownload; sendNextBlock = 0; } else { buf.writeInt32BE(0x01000000, 0); }
1164
+ channel.write(buf.slice(0, len + 4).toString('base64')); // Write as Base64
1165
+ }
1166
+ break;
1167
+ }
1168
+ case 'upload': {
1169
+ // Upload a file, from browser
1170
+ if (cmd.sub == 'start') { // Start the upload
1171
+ if (this.fileupload != null) { fs.closeSync(this.fileupload.fp); }
1172
+ if (!cmd.path || !cmd.name) break;
1173
+ this.fileupload = { reqid: cmd.reqid };
1174
+ var filepath = path.join(cmd.path, cmd.name);
1175
+ try { this.fileupload.fp = fs.openSync(filepath, 'wbN'); } catch (e) { }
1176
+ if (this.fileupload.fp) { channel.write({ action: 'upload', sub: 'start', reqid: this.fileupload.reqid }); } else { this.fileupload = null; channel.write({ action: 'upload', sub: 'error', reqid: this.fileupload.reqid }); }
1177
+ }
1178
+ else if (cmd.sub == 'cancel') { // Stop the upload
1179
+ if (this.fileupload != null) { fs.closeSync(this.fileupload.fp); this.fileupload = null; }
1180
+ }
1181
+ break;
1182
+ }
1183
+ case 'copy': {
1184
+ // Copy a bunch of files from scpath to dspath
1185
+ for (var i in cmd.names) {
1186
+ var sc = path.join(cmd.scpath, cmd.names[i]), ds = path.join(cmd.dspath, cmd.names[i]);
1187
+ if (sc != ds) { try { fs.copyFileSync(sc, ds); } catch (e) { } }
1188
+ }
1189
+ break;
1190
+ }
1191
+ case 'move': {
1192
+ // Move a bunch of files from scpath to dspath
1193
+ for (var i in cmd.names) {
1194
+ var sc = path.join(cmd.scpath, cmd.names[i]), ds = path.join(cmd.dspath, cmd.names[i]);
1195
+ if (sc != ds) { try { fs.copyFileSync(sc, ds); fs.unlinkSync(sc); } catch (e) { } }
1196
+ }
1197
+ break;
1198
+ }
1199
+ }
1200
+}
1201
+
1202
function webRtcCleanUp() {
1203
if (webRtcDesktop == null) return;
1204
if (webRtcDesktop.rtcchannel) {
agents/meshcore.js
+288
-6
@@ -1335,12 +1335,16 @@ function createMeshCore(agent) {
1335
var lme_heci = require('amt-lme');
1336
amtLmsState = 1;
1337
amtLms = new lme_heci();
1338
- amtLms.on('error', function (e) { amtLmsState = 0; amtLms = null; });
1339
- amtLms.on('connect', function () { amtLmsState = 2; });
1338
+ amtLms.on('error', function (e) { amtLmsState = 0; amtLms = null; obj.setupMeiOsAdmin(null, 1); });
1339
+ amtLms.on('connect', function () { amtLmsState = 2; obj.setupMeiOsAdmin(null, 2); });
1340
//amtLms.on('bind', function (map) { });
1341
- amtLms.on('notify', function (data, options, str) {
1342
- if (str != null) { sendConsoleText('Intel AMT LMS: ' + str); }
1343
- handleAmtNotification(data);
1341
+ amtLms.on('notify', function (data, options, str, code) {
1342
+ if (code == 'iAMT0052-3') {
1343
+ kvmGetData();
1344
+ } else {
1345
+ //if (str != null) { sendConsoleText('Intel AMT LMS: ' + str); }
1346
+ handleAmtNotification(data);
1347
+ }
1348
});
1349
} catch (e) { amtLmsState = -1; amtLms = null; }
1350
@@ -1369,10 +1373,288 @@ function createMeshCore(agent) {
1373
s.end = onWebSocketClosed;
1374
s.data = onWebSocketData;
1375
}
1372
-
1376
+
1377
+
1378
+ //
1379
+ // KVM Data Channel
1380
+ //
1381
+
1382
+ obj.setupMeiOsAdmin = function(func, state) {
1383
+ amtMei.getLocalSystemAccount(function (x) {
1384
+ var transport = require('amt-wsman-duk');
1385
+ var wsman = require('amt-wsman');
1386
+ var amt = require('amt');
1387
+ oswsstack = new wsman(transport, '127.0.0.1', 16992, x.user, x.pass, false);
1388
+ obj.osamtstack = new amt(oswsstack);
1389
+ if (func) { func(state); }
1390
+ //var AllWsman = "CIM_SoftwareIdentity,IPS_SecIOService,IPS_ScreenSettingData,IPS_ProvisioningRecordLog,IPS_HostBasedSetupService,IPS_HostIPSettings,IPS_IPv6PortSettings".split(',');
1391
+ //obj.osamtstack.BatchEnum(null, AllWsman, startLmsWsmanResponse, null, true);
1392
+ //*************************************
1393
+ // Setup KVM data channel if this is Intel AMT 12 or above
1394
+ amtMei.getVersion(function (x) {
1395
+ var amtver = null;
1396
+ try { for (var i in x.Versions) { if (x.Versions[i].Description == 'AMT') amtver = parseInt(x.Versions[i].Version.split('.')[0]); } } catch (e) { }
1397
+ if ((amtver != null) && (amtver >= 12)) {
1398
+ obj.kvmGetData('skip'); // Clear any previous data, this is a dummy read to about handling old data.
1399
+ obj.kvmTempTimer = setInterval(function () { obj.kvmGetData(); }, 2000); // Start polling for KVM data.
1400
+ obj.kvmSetData(JSON.stringify({ action: 'restart', ver: 1 })); // Send a restart command to advise the console if present that MicroLMS just started.
1401
+ }
1402
+ });
1403
+ });
1404
+ }
1405
+
1406
+ obj.kvmGetData = function(tag) {
1407
+ obj.osamtstack.IPS_KVMRedirectionSettingData_DataChannelRead(obj.kvmDataGetResponse, tag);
1408
+ }
1409
+
1410
+ obj.kvmDataGetResponse = function (stack, name, response, status, tag) {
1411
+ if ((tag != 'skip') && (status == 200) && (response.Body.ReturnValue == 0)) {
1412
+ var val = null;
1413
+ try { val = Buffer.from(response.Body.DataMessage, 'base64').toString(); } catch (e) { return }
1414
+ if (val != null) { obj.kvmProcessData(response.Body.RealmsBitmap, response.Body.MessageId, val); }
1415
+ }
1416
+ }
1417
+
1418
+ var webRtcDesktop = null;
1419
+ obj.kvmProcessData = function (realms, messageId, val) {
1420
+ var data = null;
1421
+ try { data = JSON.parse(val) } catch (e) { }
1422
+ if ((data != null) && (data.action)) {
1423
+ if (data.action == 'present') { obj.kvmSetData(JSON.stringify({ action: 'present', ver: 1, platform: process.platform })); }
1424
+ if (data.action == 'offer') {
1425
+ webRtcDesktop = {};
1426
+ var rtc = require('ILibWebRTC');
1427
+ webRtcDesktop.webrtc = rtc.createConnection();
1428
+ webRtcDesktop.webrtc.on('connected', function () { });
1429
+ webRtcDesktop.webrtc.on('disconnected', function () { webRtcCleanUp(); });
1430
+ webRtcDesktop.webrtc.on('dataChannel', function (rtcchannel) {
1431
+ webRtcDesktop.rtcchannel = rtcchannel;
1432
+ webRtcDesktop.kvm = mesh.getRemoteDesktopStream();
1433
+ webRtcDesktop.kvm.pipe(webRtcDesktop.rtcchannel, { dataTypeSkip: 1, end: false });
1434
+ webRtcDesktop.rtcchannel.on('end', function () { obj.webRtcCleanUp(); });
1435
+ webRtcDesktop.rtcchannel.on('data', function (x) { obj.kvmCtrlData(this, x); });
1436
+ webRtcDesktop.rtcchannel.pipe(webRtcDesktop.kvm, { dataTypeSkip: 1, end: false });
1437
+ //webRtcDesktop.kvm.on('end', function () { console.log('WebRTC DataChannel closed2'); webRtcCleanUp(); });
1438
+ //webRtcDesktop.rtcchannel.on('data', function (data) { console.log('WebRTC data: ' + data); });
1439
+ });
1440
+ obj.kvmSetData(JSON.stringify({ action: 'answer', ver: 1, sdp: webRtcDesktop.webrtc.setOffer(data.sdp) }));
1441
+ }
1442
+ }
1443
+ }
1444
+
1445
+ // Polyfill path.join
1446
+ var path = {
1447
+ join: function () {
1448
+ var x = [];
1449
+ for (var i in arguments) {
1450
+ var w = arguments[i];
1451
+ if (w != null) {
1452
+ while (w.endsWith('/') || w.endsWith('\\')) { w = w.substring(0, w.length - 1); }
1453
+ if (i != 0) { while (w.startsWith('/') || w.startsWith('\\')) { w = w.substring(1); } }
1454
+ x.push(w);
1455
+ }
1456
+ }
1457
+ if (x.length == 0) return '/';
1458
+ return x.join('/');
1459
+ }
1460
+ };
1461
+
1462
+ // Get a formated response for a given directory path
1463
+ obj.getDirectoryInfo = function(reqpath) {
1464
+ var response = { path: reqpath, dir: [] };
1465
+ if (((reqpath == undefined) || (reqpath == '')) && (process.platform == 'win32')) {
1466
+ // List all the drives in the root, or the root itself
1467
+ var results = null;
1468
+ try { results = fs.readDrivesSync(); } catch (e) { } // TODO: Anyway to get drive total size and free space? Could draw a progress bar.
1469
+ //console.log('a', objToString(results, 0, ' '));
1470
+ if (results != null) {
1471
+ for (var i = 0; i < results.length; ++i) {
1472
+ var drive = { n: results[i].name, t: 1 };
1473
+ if (results[i].type == 'REMOVABLE') { drive.dt = 'removable'; } // TODO: See if this is USB/CDROM or something else, we can draw icons.
1474
+ response.dir.push(drive);
1475
+ }
1476
+ }
1477
+ } else {
1478
+ // List all the files and folders in this path
1479
+ if (reqpath == '') { reqpath = '/'; }
1480
+ var xpath = path.join(reqpath, '*');
1481
+ var results = null;
1482
+
1483
+ try { results = fs.readdirSync(xpath); } catch (e) { }
1484
+ if (results != null) {
1485
+ for (var i = 0; i < results.length; ++i) {
1486
+ if ((results[i] != '.') && (results[i] != '..')) {
1487
+ var stat = null, p = path.join(reqpath, results[i]);
1488
+ try { stat = fs.statSync(p); } catch (e) { } // TODO: Get file size/date
1489
+ if ((stat != null) && (stat != undefined)) {
1490
+ if (stat.isDirectory() == true) {
1491
+ response.dir.push({ n: results[i], t: 2, d: stat.mtime });
1492
+ } else {
1493
+ response.dir.push({ n: results[i], t: 3, s: stat.size, d: stat.mtime });
1494
+ }
1495
+ }
1496
+ }
1497
+ }
1498
+ }
1499
+ }
1500
+ return response;
1501
+ }
1502
+
1503
+ // Process KVM control channel data
1504
+ obj.kvmCtrlData = function(channel, cmd) {
1505
+ if (cmd.length > 0 && cmd.charCodeAt(0) != 123) {
1506
+ // This is upload data
1507
+ if (this.fileupload != null) {
1508
+ cmd = Buffer.from(cmd, 'base64');
1509
+ var header = cmd.readUInt32BE(0);
1510
+ if ((header == 0x01000000) || (header == 0x01000001)) {
1511
+ fs.writeSync(this.fileupload.fp, cmd.slice(4));
1512
+ channel.write({ action: 'upload', sub: 'ack', reqid: this.fileupload.reqid });
1513
+ if (header == 0x01000001) { fs.closeSync(this.fileupload.fp); this.fileupload = null; } // Close the file
1514
+ }
1515
+ }
1516
+ return;
1517
+ }
1518
+ //console.log('KVM Ctrl Data', cmd);
1519
+
1520
+ try { cmd = JSON.parse(cmd); } catch (ex) { console.error('Invalid JSON: ' + cmd); return; }
1521
+ if ((cmd.path != null) && (process.platform != 'win32') && (cmd.path[0] != '/')) { cmd.path = '/' + cmd.path; } // Add '/' to paths on non-windows
1522
+ switch (cmd.action) {
1523
+ case 'ls': {
1524
+ /*
1525
+ // Close the watcher if required
1526
+ var samepath = ((this.httprequest.watcher != undefined) && (cmd.path == this.httprequest.watcher.path));
1527
+ if ((this.httprequest.watcher != undefined) && (samepath == false)) {
1528
+ //console.log('Closing watcher: ' + this.httprequest.watcher.path);
1529
+ //this.httprequest.watcher.close(); // TODO: This line causes the agent to crash!!!!
1530
+ delete this.httprequest.watcher;
1531
+ }
1532
+ */
1533
+
1534
+ // Send the folder content to the browser
1535
+ var response = getDirectoryInfo(cmd.path);
1536
+ if (cmd.reqid != undefined) { response.reqid = cmd.reqid; }
1537
+ channel.write(response);
1538
+
1539
+ /*
1540
+ // Start the directory watcher
1541
+ if ((cmd.path != '') && (samepath == false)) {
1542
+ var watcher = fs.watch(cmd.path, onFileWatcher);
1543
+ watcher.tunnel = this.httprequest;
1544
+ watcher.path = cmd.path;
1545
+ this.httprequest.watcher = watcher;
1546
+ //console.log('Starting watcher: ' + this.httprequest.watcher.path);
1547
+ }
1548
+ */
1549
+ break;
1550
+ }
1551
+ case 'mkdir': {
1552
+ // Create a new empty folder
1553
+ fs.mkdirSync(cmd.path);
1554
+ break;
1555
+ }
1556
+ case 'rm': {
1557
+ // Remove many files or folders
1558
+ for (var i in cmd.delfiles) {
1559
+ var fullpath = path.join(cmd.path, cmd.delfiles[i]);
1560
+ try { fs.unlinkSync(fullpath); } catch (e) { console.log(e); }
1561
+ }
1562
+ break;
1563
+ }
1564
+ case 'rename': {
1565
+ // Rename a file or folder
1566
+ try { fs.renameSync(path.join(cmd.path, cmd.oldname), path.join(cmd.path, cmd.newname)); } catch (e) { console.log(e); }
1567
+ break;
1568
+ }
1569
+ case 'download': {
1570
+ // Download a file, to browser
1571
+ var sendNextBlock = 0;
1572
+ if (cmd.sub == 'start') { // Setup the download
1573
+ if (this.filedownload != null) { channel.write({ action: 'download', sub: 'cancel', id: this.filedownload.id }); delete this.filedownload; }
1574
+ this.filedownload = { id: cmd.id, path: cmd.path, ptr: 0 }
1575
+ try { this.filedownload.f = fs.openSync(this.filedownload.path, 'rbN'); } catch (e) { channel.write({ action: 'download', sub: 'cancel', id: this.filedownload.id }); delete this.filedownload; }
1576
+ if (this.filedownload) { channel.write({ action: 'download', sub: 'start', id: cmd.id }); }
1577
+ } else if ((this.filedownload != null) && (cmd.id == this.filedownload.id)) { // Download commands
1578
+ if (cmd.sub == 'startack') { sendNextBlock = 8; } else if (cmd.sub == 'stop') { delete this.filedownload; } else if (cmd.sub == 'ack') { sendNextBlock = 1; }
1579
+ }
1580
+ // Send the next download block(s)
1581
+ while (sendNextBlock > 0) {
1582
+ sendNextBlock--;
1583
+ var buf = new Buffer(4096);
1584
+ var len = fs.readSync(this.filedownload.f, buf, 4, 4092, null);
1585
+ this.filedownload.ptr += len;
1586
+ if (len < 4092) { buf.writeInt32BE(0x01000001, 0); fs.closeSync(this.filedownload.f); delete this.filedownload; sendNextBlock = 0; } else { buf.writeInt32BE(0x01000000, 0); }
1587
+ channel.write(buf.slice(0, len + 4).toString('base64')); // Write as Base64
1588
+ }
1589
+ break;
1590
+ }
1591
+ case 'upload': {
1592
+ // Upload a file, from browser
1593
+ if (cmd.sub == 'start') { // Start the upload
1594
+ if (this.fileupload != null) { fs.closeSync(this.fileupload.fp); }
1595
+ if (!cmd.path || !cmd.name) break;
1596
+ this.fileupload = { reqid: cmd.reqid };
1597
+ var filepath = path.join(cmd.path, cmd.name);
1598
+ try { this.fileupload.fp = fs.openSync(filepath, 'wbN'); } catch (e) { }
1599
+ if (this.fileupload.fp) { channel.write({ action: 'upload', sub: 'start', reqid: this.fileupload.reqid }); } else { this.fileupload = null; channel.write({ action: 'upload', sub: 'error', reqid: this.fileupload.reqid }); }
1600
+ }
1601
+ else if (cmd.sub == 'cancel') { // Stop the upload
1602
+ if (this.fileupload != null) { fs.closeSync(this.fileupload.fp); this.fileupload = null; }
1603
+ }
1604
+ break;
1605
+ }
1606
+ case 'copy': {
1607
+ // Copy a bunch of files from scpath to dspath
1608
+ for (var i in cmd.names) {
1609
+ var sc = path.join(cmd.scpath, cmd.names[i]), ds = path.join(cmd.dspath, cmd.names[i]);
1610
+ if (sc != ds) { try { fs.copyFileSync(sc, ds); } catch (e) { } }
1611
+ }
1612
+ break;
1613
+ }
1614
+ case 'move': {
1615
+ // Move a bunch of files from scpath to dspath
1616
+ for (var i in cmd.names) {
1617
+ var sc = path.join(cmd.scpath, cmd.names[i]), ds = path.join(cmd.dspath, cmd.names[i]);
1618
+ if (sc != ds) { try { fs.copyFileSync(sc, ds); fs.unlinkSync(sc); } catch (e) { } }
1619
+ }
1620
+ break;
1621
+ }
1622
+ }
1623
+ }
1624
+
1625
+ obj.webRtcCleanUp = function() {
1626
+ if (webRtcDesktop == null) return;
1627
+ if (webRtcDesktop.rtcchannel) {
1628
+ try { webRtcDesktop.rtcchannel.close(); } catch (e) { }
1629
+ try { webRtcDesktop.rtcchannel.removeAllListeners('data'); } catch (e) { }
1630
+ try { webRtcDesktop.rtcchannel.removeAllListeners('end'); } catch (e) { }
1631
+ delete webRtcDesktop.rtcchannel;
1632
+ }
1633
+ if (webRtcDesktop.webrtc) {
1634
+ try { webRtcDesktop.webrtc.close(); } catch (e) { }
1635
+ try { webRtcDesktop.webrtc.removeAllListeners('connected'); } catch (e) { }
1636
+ try { webRtcDesktop.webrtc.removeAllListeners('disconnected'); } catch (e) { }
1637
+ try { webRtcDesktop.webrtc.removeAllListeners('dataChannel'); } catch (e) { }
1638
+ delete webRtcDesktop.webrtc;
1639
+ }
1640
+ if (webRtcDesktop.kvm) {
1641
+ try { webRtcDesktop.kvm.end(); } catch (e) { }
1642
+ delete webRtcDesktop.kvm;
1643
+ }
1644
+ webRtcDesktop = null;
1645
+ }
1646
+
1647
+ obj.kvmSetData = function(x) {
1648
+ obj.osamtstack.IPS_KVMRedirectionSettingData_DataChannelWrite(Buffer.from(x).toString('base64'), function () { });
1649
+ }
1650
+
1651
return obj;
1652
}
1653
1654
+//
1655
+// Module startup
1656
+//
1657
+
1658
var xexports = null, mainMeshCore = null;
1659
try { xexports = module.exports; } catch (e) { }
1660
agents/meshinstall-linux.sh
+2
-2
@@ -46,12 +46,12 @@ CheckInstallAgent() {
46
# echo "Detecting computer type..."
47
machinetype=$( uname -m )
48
machineid=0
49
- if [ $machinetype == 'x86_64' ]
49
+ if [ $machinetype == 'x86_64' ] || [ $machinetype == 'amd64' ]
50
then
51
# Linux x86, 64 bit
52
machineid=6
53
fi
54
- if [ $machinetype == 'x86' ]
54
+ if [ $machinetype == 'x86' ] || [ $machinetype == 'i686' ]
55
then
56
# Linux x86, 32 bit
57
machineid=5
agents/modules_meshcore/amt-wsman-duk.js
new
+144
@@ -0,0 +1,144 @@
1
+/*
2
+Copyright 2018 Intel Corporation
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+*/
16
+
17
+/**
18
+* @description WSMAN communication using duktape http
19
+* @author Ylian Saint-Hilaire
20
+* @version v0.2.0c
21
+*/
22
+
23
+// Construct a WSMAN communication object
24
+function CreateWsmanComm(/*host, port, user, pass, tls, extra*/)
25
+{
26
+ var obj = {};
27
+ obj.PendingAjax = []; // List of pending AJAX calls. When one frees up, another will start.
28
+ obj.ActiveAjaxCount = 0; // Number of currently active AJAX calls
29
+ obj.MaxActiveAjaxCount = 1; // Maximum number of activate AJAX calls at the same time.
30
+ obj.FailAllError = 0; // Set this to non-zero to fail all AJAX calls with that error status, 999 causes responses to be silent.
31
+ obj.digest = null;
32
+ obj.RequestCount = 0;
33
+
34
+ if (arguments.length == 1 && typeof(arguments[0] == 'object'))
35
+ {
36
+ obj.host = arguments[0].host;
37
+ obj.port = arguments[0].port;
38
+ obj.authToken = arguments[0].authToken;
39
+ obj.tls = arguments[0].tls;
40
+ }
41
+ else
42
+ {
43
+ obj.host = arguments[0];
44
+ obj.port = arguments[1];
45
+ obj.user = arguments[2];
46
+ obj.pass = arguments[3];
47
+ obj.tls = arguments[4];
48
+ }
49
+
50
+
51
+ // Private method
52
+ // pri = priority, if set to 1, the call is high priority and put on top of the stack.
53
+ obj.PerformAjax = function (postdata, callback, tag, pri, url, action) {
54
+ if ((obj.ActiveAjaxCount == 0 || ((obj.ActiveAjaxCount < obj.MaxActiveAjaxCount) && (obj.challengeParams != null))) && obj.PendingAjax.length == 0) {
55
+ // There are no pending AJAX calls, perform the call now.
56
+ obj.PerformAjaxEx(postdata, callback, tag, url, action);
57
+ } else {
58
+ // If this is a high priority call, put this call in front of the array, otherwise put it in the back.
59
+ if (pri == 1) { obj.PendingAjax.unshift([postdata, callback, tag, url, action]); } else { obj.PendingAjax.push([postdata, callback, tag, url, action]); }
60
+ }
61
+ }
62
+
63
+ // Private method
64
+ obj.PerformNextAjax = function () {
65
+ if (obj.ActiveAjaxCount >= obj.MaxActiveAjaxCount || obj.PendingAjax.length == 0) return;
66
+ var x = obj.PendingAjax.shift();
67
+ obj.PerformAjaxEx(x[0], x[1], x[2], x[3], x[4]);
68
+ obj.PerformNextAjax();
69
+ }
70
+
71
+ // Private method
72
+ obj.PerformAjaxEx = function (postdata, callback, tag, url, action) {
73
+ if (obj.FailAllError != 0) { if (obj.FailAllError != 999) { obj.gotNextMessagesError({ status: obj.FailAllError }, 'error', null, [postdata, callback, tag]); } return; }
74
+ if (!postdata) postdata = "";
75
+ //console.log("SEND: " + postdata); // DEBUG
76
+
77
+ // We are in a DukTape environement
78
+ if (obj.digest == null)
79
+ {
80
+ if (obj.authToken)
81
+ {
82
+ obj.digest = require('http-digest').create({ authToken: obj.authToken });
83
+ }
84
+ else
85
+ {
86
+ obj.digest = require('http-digest').create(obj.user, obj.pass);
87
+ }
88
+ obj.digest.http = require('http');
89
+ }
90
+ var request = { protocol: (obj.tls == 1 ? 'https:' : 'http:'), method: 'POST', host: obj.host, path: '/wsman', port: obj.port, rejectUnauthorized: false, checkServerIdentity: function (cert) { console.log('checkServerIdentity', JSON.stringify(cert)); } };
91
+ var req = obj.digest.request(request);
92
+ //console.log('Request ' + (obj.RequestCount++));
93
+ req.on('error', function (e) { obj.gotNextMessagesError({ status: 600 }, 'error', null, [postdata, callback, tag]); });
94
+ req.on('response', function (response) {
95
+ //console.log('Response: ' + response.statusCode);
96
+ if (response.statusCode != 200) {
97
+ //console.log('ERR:' + JSON.stringify(response));
98
+ obj.gotNextMessagesError({ status: response.statusCode }, 'error', null, [postdata, callback, tag]);
99
+ } else {
100
+ response.acc = '';
101
+ response.on('data', function (data2) { this.acc += data2; });
102
+ response.on('end', function () { obj.gotNextMessages(response.acc, 'success', { status: response.statusCode }, [postdata, callback, tag]); });
103
+ }
104
+ });
105
+
106
+ // Send POST body, this work with binary.
107
+ req.end(postdata);
108
+ obj.ActiveAjaxCount++;
109
+ return req;
110
+ }
111
+
112
+ // AJAX specific private method
113
+ obj.pendingAjaxCall = [];
114
+
115
+ // Private method
116
+ obj.gotNextMessages = function (data, status, request, callArgs) {
117
+ obj.ActiveAjaxCount--;
118
+ if (obj.FailAllError == 999) return;
119
+ //console.log("RECV: " + data); // DEBUG
120
+ if (obj.FailAllError != 0) { callArgs[1](null, obj.FailAllError, callArgs[2]); return; }
121
+ if (request.status != 200) { callArgs[1](null, request.status, callArgs[2]); return; }
122
+ callArgs[1](data, 200, callArgs[2]);
123
+ obj.PerformNextAjax();
124
+ }
125
+
126
+ // Private method
127
+ obj.gotNextMessagesError = function (request, status, errorThrown, callArgs) {
128
+ obj.ActiveAjaxCount--;
129
+ if (obj.FailAllError == 999) return;
130
+ if (obj.FailAllError != 0) { callArgs[1](null, obj.FailAllError, callArgs[2]); return; }
131
+ //if (status != 200) { console.log("ERROR, status=" + status + "\r\n\r\nreq=" + callArgs[0]); } // Debug: Display the request & response if something did not work.
132
+ if (obj.FailAllError != 999) { callArgs[1]({ Header: { HttpError: request.status } }, request.status, callArgs[2]); }
133
+ obj.PerformNextAjax();
134
+ }
135
+
136
+ // Cancel all pending queries with given status
137
+ obj.CancelAllQueries = function (s) {
138
+ while (obj.PendingAjax.length > 0) { var x = obj.PendingAjax.shift(); x[1](null, s, x[2]); }
139
+ }
140
+
141
+ return obj;
142
+}
143
+
144
+module.exports = CreateWsmanComm;
agents/modules_meshcore/amt-wsman.js
new
+211
@@ -0,0 +1,211 @@
1
+/*
2
+Copyright 2018 Intel Corporation
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+*/
16
+
17
+/**
18
+* @description Intel(r) AMT WSMAN Stack
19
+* @author Ylian Saint-Hilaire
20
+* @version v0.2.0
21
+*/
22
+
23
+// Construct a MeshServer object
24
+function WsmanStackCreateService(/*CreateWsmanComm, host, port, user, pass, tls, extra*/)
25
+{
26
+ var obj = {_ObjectID: 'WSMAN'};
27
+ //obj.onDebugMessage = null; // Set to a function if you want to get debug messages.
28
+ obj.NextMessageId = 1; // Next message number, used to label WSMAN calls.
29
+ obj.Address = '/wsman';
30
+ obj.xmlParser = require('amt-xml');
31
+
32
+ if (arguments.length == 1 && typeof (arguments[0] == 'object'))
33
+ {
34
+ var CreateWsmanComm = arguments[0].transport;
35
+ if (CreateWsmanComm) { obj.comm = new CreateWsmanComm(arguments[0]); }
36
+ }
37
+ else
38
+ {
39
+ var CreateWsmanComm = arguments[0];
40
+ if (CreateWsmanComm) { obj.comm = new CreateWsmanComm(arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6]); }
41
+ }
42
+
43
+ obj.PerformAjax = function PerformAjax(postdata, callback, tag, pri, namespaces) {
44
+ if (namespaces == null) namespaces = '';
45
+ obj.comm.PerformAjax('<?xml version=\"1.0\" encoding=\"utf-8\"?><Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns=\"http://www.w3.org/2003/05/soap-envelope\" ' + namespaces + '><Header><a:Action>' + postdata, function (data, status, tag) {
46
+ if (status != 200) { callback(obj, null, { Header: { HttpError: status } }, status, tag); return; }
47
+ var wsresponse = obj.xmlParser.ParseWsman(data);
48
+ if (!wsresponse || wsresponse == null) { callback(obj, null, { Header: { HttpError: status } }, 601, tag); } else { callback(obj, wsresponse.Header["ResourceURI"], wsresponse, 200, tag); }
49
+ }, tag, pri);
50
+ }
51
+
52
+ // Private method
53
+ //obj.Debug = function (msg) { /*console.log(msg);*/ }
54
+
55
+ // Cancel all pending queries with given status
56
+ obj.CancelAllQueries = function CancelAllQueries(s) { obj.comm.CancelAllQueries(s); }
57
+
58
+ // Get the last element of a URI string
59
+ obj.GetNameFromUrl = function (resuri) {
60
+ var x = resuri.lastIndexOf("/");
61
+ return (x == -1)?resuri:resuri.substring(x + 1);
62
+ }
63
+
64
+ // Perform a WSMAN Subscribe operation
65
+ obj.ExecSubscribe = function ExecSubscribe(resuri, delivery, url, callback, tag, pri, selectors, opaque, user, pass) {
66
+ var digest = "", digest2 = "", opaque = "";
67
+ if (user != null && pass != null) { digest = '<t:IssuedTokens xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:se="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><t:RequestSecurityTokenResponse><t:TokenType>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken</t:TokenType><t:RequestedSecurityToken><se:UsernameToken><se:Username>' + user + '</se:Username><se:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#PasswordText">' + pass + '</se:Password></se:UsernameToken></t:RequestedSecurityToken></t:RequestSecurityTokenResponse></t:IssuedTokens>'; digest2 = '<w:Auth Profile="http://schemas.dmtf.org/wbem/wsman/1/wsman/secprofile/http/digest"/>'; }
68
+ if (opaque != null) { opaque = '<a:ReferenceParameters><m:arg>' + opaque + '</m:arg></a:ReferenceParameters>'; }
69
+ if (delivery == 'PushWithAck') { delivery = 'dmtf.org/wbem/wsman/1/wsman/PushWithAck'; } else if (delivery == 'Push') { delivery = 'xmlsoap.org/ws/2004/08/eventing/DeliveryModes/Push'; }
70
+ var data = "http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>" + _PutObjToSelectorsXml(selectors) + digest + '</Header><Body><e:Subscribe><e:Delivery Mode="http://schemas.' + delivery + '"><e:NotifyTo><a:Address>' + url + '</a:Address>' + opaque + '</e:NotifyTo>' + digest2 + '</e:Delivery></e:Subscribe>';
71
+ obj.PerformAjax(data + "</Body></Envelope>", callback, tag, pri, 'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing" xmlns:m="http://x.com"');
72
+ }
73
+
74
+ // Perform a WSMAN UnSubscribe operation
75
+ obj.ExecUnSubscribe = function ExecUnSubscribe(resuri, callback, tag, pri, selectors) {
76
+ var data = "http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>" + _PutObjToSelectorsXml(selectors) + '</Header><Body><e:Unsubscribe/>';
77
+ obj.PerformAjax(data + "</Body></Envelope>", callback, tag, pri, 'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing"');
78
+ }
79
+
80
+ // Perform a WSMAN PUT operation
81
+ obj.ExecPut = function ExecPut(resuri, putobj, callback, tag, pri, selectors) {
82
+ var data = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Put</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60.000S</w:OperationTimeout>" + _PutObjToSelectorsXml(selectors) + '</Header><Body>' + _PutObjToBodyXml(resuri, putobj);
83
+ obj.PerformAjax(data + "</Body></Envelope>", callback, tag, pri);
84
+ }
85
+
86
+ // Perform a WSMAN CREATE operation
87
+ obj.ExecCreate = function ExecCreate(resuri, putobj, callback, tag, pri, selectors) {
88
+ var objname = obj.GetNameFromUrl(resuri);
89
+ var data = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Create</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>" + _PutObjToSelectorsXml(selectors) + "</Header><Body><g:" + objname + " xmlns:g=\"" + resuri + "\">";
90
+ for (var n in putobj) { data += "<g:" + n + ">" + putobj[n] + "</g:" + n + ">" }
91
+ obj.PerformAjax(data + "</g:" + objname + "></Body></Envelope>", callback, tag, pri);
92
+ }
93
+
94
+ // Perform a WSMAN DELETE operation
95
+ obj.ExecDelete = function ExecDelete(resuri, putobj, callback, tag, pri) {
96
+ var data = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>" + _PutObjToSelectorsXml(putobj) + "</Header><Body /></Envelope>";
97
+ obj.PerformAjax(data, callback, tag, pri);
98
+ }
99
+
100
+ // Perform a WSMAN GET operation
101
+ obj.ExecGet = function ExecGet(resuri, callback, tag, pri) {
102
+ obj.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/transfer/Get</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body /></Envelope>", callback, tag, pri);
103
+ }
104
+
105
+ // Perform a WSMAN method call operation
106
+ obj.ExecMethod = function ExecMethod(resuri, method, args, callback, tag, pri, selectors) {
107
+ var argsxml = "";
108
+ for (var i in args) { if (args[i] != null) { if (Array.isArray(args[i])) { for (var x in args[i]) { argsxml += "<r:" + i + ">" + args[i][x] + "</r:" + i + ">"; } } else { argsxml += "<r:" + i + ">" + args[i] + "</r:" + i + ">"; } } }
109
+ obj.ExecMethodXml(resuri, method, argsxml, callback, tag, pri, selectors);
110
+ }
111
+
112
+ // Perform a WSMAN method call operation. The arguments are already formatted in XML.
113
+ obj.ExecMethodXml = function ExecMethodXml(resuri, method, argsxml, callback, tag, pri, selectors) {
114
+ obj.PerformAjax(resuri + "/" + method + "</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>" + _PutObjToSelectorsXml(selectors) + "</Header><Body><r:" + method + '_INPUT' + " xmlns:r=\"" + resuri + "\">" + argsxml + "</r:" + method + "_INPUT></Body></Envelope>", callback, tag, pri);
115
+ }
116
+
117
+ // Perform a WSMAN ENUM operation
118
+ obj.ExecEnum = function ExecEnum(resuri, callback, tag, pri) {
119
+ obj.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body><Enumerate xmlns=\"http://schemas.xmlsoap.org/ws/2004/09/enumeration\" /></Body></Envelope>", callback, tag, pri);
120
+ }
121
+
122
+ // Perform a WSMAN PULL operation
123
+ obj.ExecPull = function ExecPull(resuri, enumctx, callback, tag, pri) {
124
+ obj.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body><Pull xmlns=\"http://schemas.xmlsoap.org/ws/2004/09/enumeration\"><EnumerationContext>" + enumctx + "</EnumerationContext><MaxElements>999</MaxElements><MaxCharacters>99999</MaxCharacters></Pull></Body></Envelope>", callback, tag, pri);
125
+ }
126
+
127
+ function _PutObjToBodyXml(resuri, putObj) {
128
+ if (!resuri || putObj == null) return '';
129
+ var objname = obj.GetNameFromUrl(resuri);
130
+ var result = '<r:' + objname + ' xmlns:r="' + resuri + '">';
131
+
132
+ for (var prop in putObj) {
133
+ if (!putObj.hasOwnProperty(prop) || prop.indexOf('__') === 0 || prop.indexOf('@') === 0) continue;
134
+ if (putObj[prop] == null || typeof putObj[prop] === 'function') continue;
135
+ if (typeof putObj[prop] === 'object' && putObj[prop]['ReferenceParameters']) {
136
+ result += '<r:' + prop + '><a:Address>' + putObj[prop].Address + '</a:Address><a:ReferenceParameters><w:ResourceURI>' + putObj[prop]['ReferenceParameters']["ResourceURI"] + '</w:ResourceURI><w:SelectorSet>';
137
+ var selectorArray = putObj[prop]['ReferenceParameters']['SelectorSet']['Selector'];
138
+ if (Array.isArray(selectorArray)) {
139
+ for (var i=0; i< selectorArray.length; i++) {
140
+ result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray[i]) + '>' + selectorArray[i]['Value'] + '</w:Selector>';
141
+ }
142
+ }
143
+ else {
144
+ result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray) + '>' + selectorArray['Value'] + '</w:Selector>';
145
+ }
146
+ result += '</w:SelectorSet></a:ReferenceParameters></r:' + prop + '>';
147
+ }
148
+ else {
149
+ if (Array.isArray(putObj[prop])) {
150
+ for (var i = 0; i < putObj[prop].length; i++) {
151
+ result += '<r:' + prop + '>' + putObj[prop][i].toString() + '</r:' + prop + '>';
152
+ }
153
+ } else {
154
+ result += '<r:' + prop + '>' + putObj[prop].toString() + '</r:' + prop + '>';
155
+ }
156
+ }
157
+ }
158
+
159
+ result += '</r:' + objname + '>';
160
+ return result;
161
+ }
162
+
163
+ /*
164
+ convert
165
+ { @Name: 'InstanceID', @AttrName: 'Attribute Value'}
166
+ into
167
+ ' Name="InstanceID" AttrName="Attribute Value" '
168
+ */
169
+ function _ObjectToXmlAttributes(objWithAttributes) {
170
+ if(!objWithAttributes) return '';
171
+ var result = ' ';
172
+ for (var propName in objWithAttributes) {
173
+ if (!objWithAttributes.hasOwnProperty(propName) || propName.indexOf('@') !== 0) continue;
174
+ result += propName.substring(1) + '="' + objWithAttributes[propName] + '" ';
175
+ }
176
+ return result;
177
+ }
178
+
179
+ function _PutObjToSelectorsXml(selectorSet) {
180
+ if (!selectorSet) return '';
181
+ if (typeof selectorSet == 'string') return selectorSet;
182
+ if (selectorSet['InstanceID']) return "<w:SelectorSet><w:Selector Name=\"InstanceID\">" + selectorSet['InstanceID'] + "</w:Selector></w:SelectorSet>";
183
+ var result = '<w:SelectorSet>';
184
+ for(var propName in selectorSet) {
185
+ if (!selectorSet.hasOwnProperty(propName)) continue;
186
+ result += '<w:Selector Name="' + propName + '">';
187
+ if (selectorSet[propName]['ReferenceParameters']) {
188
+ result += '<a:EndpointReference>';
189
+ result += '<a:Address>' + selectorSet[propName]['Address'] + '</a:Address><a:ReferenceParameters><w:ResourceURI>' + selectorSet[propName]['ReferenceParameters']['ResourceURI'] + '</w:ResourceURI><w:SelectorSet>';
190
+ var selectorArray = selectorSet[propName]['ReferenceParameters']['SelectorSet']['Selector'];
191
+ if (Array.isArray(selectorArray)) {
192
+ for (var i = 0; i < selectorArray.length; i++) {
193
+ result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray[i]) + '>' + selectorArray[i]['Value'] + '</w:Selector>';
194
+ }
195
+ } else {
196
+ result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray) + '>' + selectorArray['Value'] + '</w:Selector>';
197
+ }
198
+ result += '</w:SelectorSet></a:ReferenceParameters></a:EndpointReference>';
199
+ } else {
200
+ result += selectorSet[propName];
201
+ }
202
+ result += '</w:Selector>';
203
+ }
204
+ result += '</w:SelectorSet>';
205
+ return result;
206
+ }
207
+
208
+ return obj;
209
+}
210
+
211
+module.exports = WsmanStackCreateService;
agents/modules_meshcore/amt.js
new
+1018
@@ -0,0 +1,1018 @@
1
+/*
2
+Copyright 2018 Intel Corporation
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+*/
16
+
17
+/**
18
+* @fileoverview Intel(r) AMT Communication StackXX
19
+* @author Ylian Saint-Hilaire
20
+* @version v0.2.0b
21
+*/
22
+
23
+/**
24
+ * Construct a AmtStackCreateService object, this ia the main Intel AMT communication stack.
25
+ * @constructor
26
+ */
27
+function AmtStackCreateService(wsmanStack) {
28
+ var obj = new Object();
29
+ obj._ObjectID = 'AMT'
30
+ obj.wsman = wsmanStack;
31
+ obj.pfx = ["http://intel.com/wbem/wscim/1/amt-schema/1/", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/", "http://intel.com/wbem/wscim/1/ips-schema/1/"];
32
+ obj.PendingEnums = [];
33
+ obj.PendingBatchOperations = 0;
34
+ obj.ActiveEnumsCount = 0;
35
+ obj.MaxActiveEnumsCount = 1; // Maximum number of enumerations that can be done at the same time.
36
+ obj.onProcessChanged = null;
37
+ var _MaxProcess = 0;
38
+ var _LastProcess = 0;
39
+
40
+ // Return the number of pending actions
41
+ obj.GetPendingActions = function () { return (obj.PendingEnums.length * 2) + (obj.ActiveEnumsCount) + obj.wsman.comm.PendingAjax.length + obj.wsman.comm.ActiveAjaxCount + obj.PendingBatchOperations; }
42
+
43
+ // Private Method, Update the current processing status, this gives the application an idea of what progress is being done by the WSMAN stack
44
+ function _up() {
45
+ var x = obj.GetPendingActions();
46
+ if (_MaxProcess < x) _MaxProcess = x;
47
+ if (obj.onProcessChanged != null && _LastProcess != x) {
48
+ //console.log("Process Old=" + _LastProcess + ", New=" + x + ", PEnums=" + obj.PendingEnums.length + ", AEnums=" + obj.ActiveEnumsCount + ", PAjax=" + obj.wsman.comm.PendingAjax.length + ", AAjax=" + obj.wsman.comm.ActiveAjaxCount + ", PBatch=" + obj.PendingBatchOperations);
49
+ _LastProcess = x;
50
+ obj.onProcessChanged(x, _MaxProcess);
51
+ }
52
+ if (x == 0) _MaxProcess = 0;
53
+ }
54
+
55
+ // Perform a WSMAN "SUBSCRIBE" operation.
56
+ obj.Subscribe = function Subscribe(name, delivery, url, callback, tag, pri, selectors, opaque, user, pass) { obj.wsman.ExecSubscribe(obj.CompleteName(name), delivery, url, function (ws, resuri, response, xstatus) { _up(); callback.call(obj, obj, name, response, xstatus, tag); }, 0, pri, selectors, opaque, user, pass); _up(); }
57
+
58
+ // Perform a WSMAN "UNSUBSCRIBE" operation.
59
+ obj.UnSubscribe = function UnSubscribe(name, callback, tag, pri, selectors) { obj.wsman.ExecUnSubscribe(obj.CompleteName(name), function (ws, resuri, response, xstatus) { _up(); callback.call(obj, obj, name, response, xstatus, tag); }, 0, pri, selectors); _up(); }
60
+
61
+ // Perform a WSMAN "GET" operation.
62
+ obj.Get = function Get(name, callback, tag, pri) { obj.wsman.ExecGet(obj.CompleteName(name), function (ws, resuri, response, xstatus) { _up(); callback.call(obj, obj, name, response, xstatus, tag); }, 0, pri); _up(); }
63
+
64
+ // Perform a WSMAN "PUT" operation.
65
+ obj.Put = function Put(name, putobj, callback, tag, pri, selectors) { obj.wsman.ExecPut(obj.CompleteName(name), putobj, function (ws, resuri, response, xstatus) { _up(); callback.call(obj, obj, name, response, xstatus, tag); }, 0, pri, selectors); _up(); }
66
+
67
+ // Perform a WSMAN "CREATE" operation.
68
+ obj.Create = function Create(name, putobj, callback, tag, pri) { obj.wsman.ExecCreate(obj.CompleteName(name), putobj, function (ws, resuri, response, xstatus) { _up(); callback.call(obj, obj, name, response, xstatus, tag); }, 0, pri); _up(); }
69
+
70
+ // Perform a WSMAN "DELETE" operation.
71
+ obj.Delete = function Delete(name, putobj, callback, tag, pri) { obj.wsman.ExecDelete(obj.CompleteName(name), putobj, function (ws, resuri, response, xstatus) { _up(); callback.call(obj, obj, name, response, xstatus, tag); }, 0, pri); _up(); }
72
+
73
+ // Perform a WSMAN method call operation.
74
+ obj.Exec = function Exec(name, method, args, callback, tag, pri, selectors) { obj.wsman.ExecMethod(obj.CompleteName(name), method, args, function (ws, resuri, response, xstatus) { _up(); callback.call(obj, obj, name, obj.CompleteExecResponse(response), xstatus, tag); }, 0, pri, selectors); _up(); }
75
+
76
+ // Perform a WSMAN method call operation.
77
+ obj.ExecWithXml = function ExecWithXml(name, method, args, callback, tag, pri, selectors) { obj.wsman.ExecMethodXml(obj.CompleteName(name), method, execArgumentsToXml(args), function (ws, resuri, response, xstatus) { _up(); callback.call(obj, obj, name, obj.CompleteExecResponse(response), xstatus, tag); }, 0, pri, selectors); _up(); }
78
+
79
+ // Perform a WSMAN "ENUMERATE" operation.
80
+ obj.Enum = function Enum(name, callback, tag, pri) {
81
+ if (obj.ActiveEnumsCount < obj.MaxActiveEnumsCount) {
82
+ obj.ActiveEnumsCount++; obj.wsman.ExecEnum(obj.CompleteName(name), function (ws, resuri, response, xstatus, tag0) { _up(); _EnumStartSink(name, response, callback, resuri, xstatus, tag0); }, tag, pri);
83
+ } else {
84
+ obj.PendingEnums.push([name, callback, tag, pri]);
85
+ }
86
+ _up();
87
+ }
88
+
89
+ // Private method
90
+ function _EnumStartSink(name, response, callback, resuri, status, tag, pri) {
91
+ if (status != 200) { callback.call(obj, obj, name, null, status, tag); _EnumDoNext(1); return; }
92
+ if (response == null || response.Header["Method"] != "EnumerateResponse" || !response.Body["EnumerationContext"]) { callback.call(obj, obj, name, null, 603, tag); _EnumDoNext(1); return; }
93
+ var enumctx = response.Body["EnumerationContext"];
94
+ obj.wsman.ExecPull(resuri, enumctx, function (ws, resuri, response, xstatus) { _EnumContinueSink(name, response, callback, resuri, [], xstatus, tag, pri); });
95
+ }
96
+
97
+ // Private method
98
+ function _EnumContinueSink(name, response, callback, resuri, items, status, tag, pri) {
99
+ if (status != 200) { callback.call(obj, obj, name, null, status, tag); _EnumDoNext(1); return; }
100
+ if (response == null || response.Header["Method"] != "PullResponse") { callback.call(obj, obj, name, null, 604, tag); _EnumDoNext(1); return; }
101
+ for (var i in response.Body["Items"]) {
102
+ if (response.Body["Items"][i] instanceof Array) {
103
+ for (var j in response.Body["Items"][i]) { items.push(response.Body["Items"][i][j]); }
104
+ } else {
105
+ items.push(response.Body["Items"][i]);
106
+ }
107
+ }
108
+ if (response.Body["EnumerationContext"]) {
109
+ var enumctx = response.Body["EnumerationContext"];
110
+ obj.wsman.ExecPull(resuri, enumctx, function (ws, resuri, response, xstatus) { _EnumContinueSink(name, response, callback, resuri, items, xstatus, tag, 1); });
111
+ } else {
112
+ _EnumDoNext(1);
113
+ callback.call(obj, obj, name, items, status, tag);
114
+ _up();
115
+ }
116
+ }
117
+
118
+ // Private method
119
+ function _EnumDoNext(dec) {
120
+ obj.ActiveEnumsCount -= dec;
121
+ if (obj.ActiveEnumsCount >= obj.MaxActiveEnumsCount || obj.PendingEnums.length == 0) return;
122
+ var x = obj.PendingEnums.shift();
123
+ obj.Enum(x[0], x[1], x[2]);
124
+ _EnumDoNext(0);
125
+ }
126
+
127
+ // Perform a batch of WSMAN "ENUM" operations.
128
+ obj.BatchEnum = function (batchname, names, callback, tag, continueOnError, pri) {
129
+ obj.PendingBatchOperations += (names.length * 2);
130
+ _BatchNextEnum(batchname, Clone(names), callback, tag, {}, continueOnError, pri); _up();
131
+ }
132
+
133
+ function Clone(v) { return JSON.parse(JSON.stringify(v)); }
134
+
135
+ // Request each enum in the batch, stopping if something does not return status 200
136
+ function _BatchNextEnum(batchname, names, callback, tag, results, continueOnError, pri) {
137
+ obj.PendingBatchOperations -= 2;
138
+ var n = names.shift(), f = obj.Enum;
139
+ if (n[0] == '*') { f = obj.Get; n = n.substring(1); } // If the name starts with a star, do a GET instead of an ENUM. This will reduce round trips.
140
+ //console.log((f == obj.Get?'Get ':'Enum ') + n);
141
+ // Perform a GET/ENUM action
142
+ f(n, function (stack, name, responses, status, tag0) {
143
+ tag0[2][name] = { response: (responses==null?null:responses.Body), responses: responses, status: status };
144
+ if (tag0[1].length == 0 || status == 401 || (continueOnError != true && status != 200 && status != 400)) { obj.PendingBatchOperations -= (names.length * 2); _up(); callback.call(obj, obj, batchname, tag0[2], status, tag); }
145
+ else { _up(); _BatchNextEnum(batchname, names, callback, tag, tag0[2], pri); }
146
+ }, [batchname, names, results], pri);
147
+ _up();
148
+ }
149
+
150
+ // Perform a batch of WSMAN "GET" operations.
151
+ obj.BatchGet = function (batchname, names, callback, tag, pri) {
152
+ _FetchNext({ name: batchname, names: names, callback: callback, current: 0, responses: {}, tag: tag, pri: pri }); _up();
153
+ }
154
+
155
+ // Private method
156
+ function _FetchNext(batch) {
157
+ if (batch.names.length <= batch.current) {
158
+ batch.callback.call(obj, obj, batch.name, batch.responses, 200, batch.tag);
159
+ } else {
160
+ obj.wsman.ExecGet(obj.CompleteName(batch.names[batch.current]), function (ws, resuri, response, xstatus) { _Fetched(batch, response, xstatus); }, batch.pri);
161
+ batch.current++;
162
+ }
163
+ _up();
164
+ }
165
+
166
+ // Private method
167
+ function _Fetched(batch, response, status) {
168
+ if (response == null || status != 200) {
169
+ batch.callback.call(obj, obj, batch.name, null, status, batch.tag);
170
+ } else {
171
+ batch.responses[response.Header["Method"]] = response;
172
+ _FetchNext(batch);
173
+ }
174
+ }
175
+
176
+ // Private method
177
+ obj.CompleteName = function(name) {
178
+ if (name.indexOf("AMT_") == 0) return obj.pfx[0] + name;
179
+ if (name.indexOf("CIM_") == 0) return obj.pfx[1] + name;
180
+ if (name.indexOf("IPS_") == 0) return obj.pfx[2] + name;
181
+ }
182
+
183
+ obj.CompleteExecResponse = function (resp) {
184
+ if (resp && resp != null && resp.Body && (resp.Body["ReturnValue"] != undefined)) { resp.Body.ReturnValueStr = obj.AmtStatusToStr(resp.Body["ReturnValue"]); }
185
+ return resp;
186
+ }
187
+
188
+ obj.RequestPowerStateChange = function (PowerState, callback_func) {
189
+ obj.CIM_PowerManagementService_RequestPowerStateChange(PowerState, "<Address xmlns=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\"><ResourceURI xmlns=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem</ResourceURI><SelectorSet xmlns=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\"><Selector Name=\"CreationClassName\">CIM_ComputerSystem</Selector><Selector Name=\"Name\">ManagedSystem</Selector></SelectorSet></ReferenceParameters>", null, null, callback_func);
190
+ }
191
+
192
+ obj.SetBootConfigRole = function (Role, callback_func) {
193
+ obj.CIM_BootService_SetBootConfigRole("<Address xmlns=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\"><ResourceURI xmlns=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootConfigSetting</ResourceURI><SelectorSet xmlns=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\"><Selector Name=\"InstanceID\">Intel(r) AMT: Boot Configuration 0</Selector></SelectorSet></ReferenceParameters>", Role, callback_func);
194
+ }
195
+
196
+ // Cancel all pending queries with given status
197
+ obj.CancelAllQueries = function (s) {
198
+ obj.wsman.CancelAllQueries(s);
199
+ }
200
+
201
+ // Auto generated methods
202
+ obj.AMT_AgentPresenceWatchdog_RegisterAgent = function (callback_func, tag, pri, selectors) { obj.Exec("AMT_AgentPresenceWatchdog", "RegisterAgent", {}, callback_func, tag, pri, selectors); }
203
+ obj.AMT_AgentPresenceWatchdog_AssertPresence = function (SequenceNumber, callback_func, tag, pri, selectors) { obj.Exec("AMT_AgentPresenceWatchdog", "AssertPresence", { "SequenceNumber": SequenceNumber }, callback_func, tag, pri, selectors); }
204
+ obj.AMT_AgentPresenceWatchdog_AssertShutdown = function (SequenceNumber, callback_func, tag, pri, selectors) { obj.Exec("AMT_AgentPresenceWatchdog", "AssertShutdown", { "SequenceNumber": SequenceNumber }, callback_func, tag, pri, selectors); }
205
+ //obj.AMT_AgentPresenceWatchdog_RegisterAgent = function (callback_func) { obj.Exec("AMT_AgentPresenceWatchdog", "RegisterAgent", {}, callback_func); }
206
+ //obj.AMT_AgentPresenceWatchdog_AssertPresence = function (SequenceNumber, callback_func) { obj.Exec("AMT_AgentPresenceWatchdog", "AssertPresence", { "SequenceNumber": SequenceNumber }, callback_func); }
207
+ //obj.AMT_AgentPresenceWatchdog_AssertShutdown = function (SequenceNumber, callback_func) { obj.Exec("AMT_AgentPresenceWatchdog", "AssertShutdown", { "SequenceNumber": SequenceNumber }, callback_func); }
208
+ obj.AMT_AgentPresenceWatchdog_AddAction = function (OldState, NewState, EventOnTransition, ActionSd, ActionEac, callback_func, tag, pri, selectors) { obj.Exec("AMT_AgentPresenceWatchdog", "AddAction", { "OldState": OldState, "NewState": NewState, "EventOnTransition": EventOnTransition, "ActionSd": ActionSd, "ActionEac": ActionEac }, callback_func, tag, pri, selectors); }
209
+ obj.AMT_AgentPresenceWatchdog_DeleteAllActions = function (callback_func, tag, pri, selectors) { obj.Exec("AMT_AgentPresenceWatchdog", "DeleteAllActions", {}, callback_func, tag, pri, selectors); }
210
+ obj.AMT_AgentPresenceWatchdogAction_GetActionEac = function (callback_func) { obj.Exec("AMT_AgentPresenceWatchdogAction", "GetActionEac", {}, callback_func); }
211
+ obj.AMT_AgentPresenceWatchdogVA_RegisterAgent = function (callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "RegisterAgent", {}, callback_func); }
212
+ obj.AMT_AgentPresenceWatchdogVA_AssertPresence = function (SequenceNumber, callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "AssertPresence", { "SequenceNumber": SequenceNumber }, callback_func); }
213
+ obj.AMT_AgentPresenceWatchdogVA_AssertShutdown = function (SequenceNumber, callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "AssertShutdown", { "SequenceNumber": SequenceNumber }, callback_func); }
214
+ obj.AMT_AgentPresenceWatchdogVA_AddAction = function (OldState, NewState, EventOnTransition, ActionSd, ActionEac, callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "AddAction", { "OldState": OldState, "NewState": NewState, "EventOnTransition": EventOnTransition, "ActionSd": ActionSd, "ActionEac": ActionEac }, callback_func); }
215
+ obj.AMT_AgentPresenceWatchdogVA_DeleteAllActions = function (_method_dummy, callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "DeleteAllActions", { "_method_dummy": _method_dummy }, callback_func); }
216
+ obj.AMT_AlarmClockService_AddAlarm = function AlarmClockService_AddAlarm(alarmInstance, callback_func)
217
+ {
218
+ var id = alarmInstance.InstanceID;
219
+ var nm = alarmInstance.ElementName;
220
+ var start = alarmInstance.StartTime.Datetime;
221
+ var interval = alarmInstance.Interval ? alarmInstance.Interval.Datetime : undefined;
222
+ var doc = alarmInstance.DeleteOnCompletion;
223
+ var tpl = "<d:AlarmTemplate xmlns:d=\"http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AlarmClockService\" xmlns:s=\"http://intel.com/wbem/wscim/1/ips-schema/1/IPS_AlarmClockOccurrence\"><s:InstanceID>" + id + "</s:InstanceID><s:ElementName>" + nm + "</s:ElementName><s:StartTime><p:Datetime xmlns:p=\"http://schemas.dmtf.org/wbem/wscim/1/common\">" + start + "</p:Datetime></s:StartTime>" + ((interval!=undefined)?("<s:Interval><p:Interval xmlns:p=\"http://schemas.dmtf.org/wbem/wscim/1/common\">" + interval + "</p:Interval></s:Interval>"):"") + "<s:DeleteOnCompletion>" + doc + "</s:DeleteOnCompletion></d:AlarmTemplate>"
224
+ obj.wsman.ExecMethodXml(obj.CompleteName("AMT_AlarmClockService"), "AddAlarm", tpl, callback_func);
225
+ };
226
+ obj.AMT_AuditLog_ClearLog = function (callback_func) { obj.Exec("AMT_AuditLog", "ClearLog", {}, callback_func); }
227
+ obj.AMT_AuditLog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_AuditLog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
228
+ obj.AMT_AuditLog_ReadRecords = function (StartIndex, callback_func, tag) { obj.Exec("AMT_AuditLog", "ReadRecords", { "StartIndex": StartIndex }, callback_func, tag); }
229
+ obj.AMT_AuditLog_SetAuditLock = function (LockTimeoutInSeconds, Flag, Handle, callback_func) { obj.Exec("AMT_AuditLog", "SetAuditLock", { "LockTimeoutInSeconds": LockTimeoutInSeconds, "Flag": Flag, "Handle": Handle }, callback_func); }
230
+ obj.AMT_AuditLog_ExportAuditLogSignature = function (SigningMechanism, callback_func) { obj.Exec("AMT_AuditLog", "ExportAuditLogSignature", { "SigningMechanism": SigningMechanism }, callback_func); }
231
+ obj.AMT_AuditLog_SetSigningKeyMaterial = function (SigningMechanismType, SigningKey, LengthOfCertificates, Certificates, callback_func) { obj.Exec("AMT_AuditLog", "SetSigningKeyMaterial", { "SigningMechanismType": SigningMechanismType, "SigningKey": SigningKey, "LengthOfCertificates": LengthOfCertificates, "Certificates": Certificates }, callback_func); }
232
+ obj.AMT_AuditPolicyRule_SetAuditPolicy = function (Enable, AuditedAppID, EventID, PolicyType, callback_func) { obj.Exec("AMT_AuditPolicyRule", "SetAuditPolicy", { "Enable": Enable, "AuditedAppID": AuditedAppID, "EventID": EventID, "PolicyType": PolicyType }, callback_func); }
233
+ obj.AMT_AuditPolicyRule_SetAuditPolicyBulk = function (Enable, AuditedAppID, EventID, PolicyType, callback_func) { obj.Exec("AMT_AuditPolicyRule", "SetAuditPolicyBulk", { "Enable": Enable, "AuditedAppID": AuditedAppID, "EventID": EventID, "PolicyType": PolicyType }, callback_func); }
234
+ obj.AMT_AuthorizationService_AddUserAclEntryEx = function (DigestUsername, DigestPassword, KerberosUserSid, AccessPermission, Realms, callback_func) { obj.Exec("AMT_AuthorizationService", "AddUserAclEntryEx", { "DigestUsername": DigestUsername, "DigestPassword": DigestPassword, "KerberosUserSid": KerberosUserSid, "AccessPermission": AccessPermission, "Realms": Realms }, callback_func); }
235
+ obj.AMT_AuthorizationService_EnumerateUserAclEntries = function (StartIndex, callback_func) { obj.Exec("AMT_AuthorizationService", "EnumerateUserAclEntries", { "StartIndex": StartIndex }, callback_func); }
236
+ obj.AMT_AuthorizationService_GetUserAclEntryEx = function (Handle, callback_func, tag) { obj.Exec("AMT_AuthorizationService", "GetUserAclEntryEx", { "Handle": Handle }, callback_func, tag); }
237
+ obj.AMT_AuthorizationService_UpdateUserAclEntryEx = function (Handle, DigestUsername, DigestPassword, KerberosUserSid, AccessPermission, Realms, callback_func) { obj.Exec("AMT_AuthorizationService", "UpdateUserAclEntryEx", { "Handle": Handle, "DigestUsername": DigestUsername, "DigestPassword": DigestPassword, "KerberosUserSid": KerberosUserSid, "AccessPermission": AccessPermission, "Realms": Realms }, callback_func); }
238
+ obj.AMT_AuthorizationService_RemoveUserAclEntry = function (Handle, callback_func) { obj.Exec("AMT_AuthorizationService", "RemoveUserAclEntry", { "Handle": Handle }, callback_func); }
239
+ obj.AMT_AuthorizationService_SetAdminAclEntryEx = function (Username, DigestPassword, callback_func) { obj.Exec("AMT_AuthorizationService", "SetAdminAclEntryEx", { "Username": Username, "DigestPassword": DigestPassword }, callback_func); }
240
+ obj.AMT_AuthorizationService_GetAdminAclEntry = function (callback_func) { obj.Exec("AMT_AuthorizationService", "GetAdminAclEntry", {}, callback_func); }
241
+ obj.AMT_AuthorizationService_GetAdminAclEntryStatus = function (callback_func) { obj.Exec("AMT_AuthorizationService", "GetAdminAclEntryStatus", {}, callback_func); }
242
+ obj.AMT_AuthorizationService_GetAdminNetAclEntryStatus = function (callback_func) { obj.Exec("AMT_AuthorizationService", "GetAdminNetAclEntryStatus", {}, callback_func); }
243
+ obj.AMT_AuthorizationService_SetAclEnabledState = function (Handle, Enabled, callback_func, tag) { obj.Exec("AMT_AuthorizationService", "SetAclEnabledState", { "Handle": Handle, "Enabled": Enabled }, callback_func, tag); }
244
+ obj.AMT_AuthorizationService_GetAclEnabledState = function (Handle, callback_func, tag) { obj.Exec("AMT_AuthorizationService", "GetAclEnabledState", { "Handle": Handle }, callback_func, tag); }
245
+ obj.AMT_EndpointAccessControlService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
246
+ obj.AMT_EndpointAccessControlService_GetPosture = function (PostureType, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "GetPosture", { "PostureType": PostureType }, callback_func); }
247
+ obj.AMT_EndpointAccessControlService_GetPostureHash = function (PostureType, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "GetPostureHash", { "PostureType": PostureType }, callback_func); }
248
+ obj.AMT_EndpointAccessControlService_UpdatePostureState = function (UpdateType, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "UpdatePostureState", { "UpdateType": UpdateType }, callback_func); }
249
+ obj.AMT_EndpointAccessControlService_GetEacOptions = function (callback_func) { obj.Exec("AMT_EndpointAccessControlService", "GetEacOptions", {}, callback_func); }
250
+ obj.AMT_EndpointAccessControlService_SetEacOptions = function (EacVendors, PostureHashAlgorithm, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "SetEacOptions", { "EacVendors": EacVendors, "PostureHashAlgorithm": PostureHashAlgorithm }, callback_func); }
251
+ obj.AMT_EnvironmentDetectionSettingData_SetSystemDefensePolicy = function (Policy, callback_func) { obj.Exec("AMT_EnvironmentDetectionSettingData", "SetSystemDefensePolicy", { "Policy": Policy }, callback_func); }
252
+ obj.AMT_EnvironmentDetectionSettingData_EnableVpnRouting = function (Enable, callback_func) { obj.Exec("AMT_EnvironmentDetectionSettingData", "EnableVpnRouting", { "Enable": Enable }, callback_func); }
253
+ obj.AMT_EthernetPortSettings_SetLinkPreference = function (LinkPreference, Timeout, callback_func) { obj.Exec("AMT_EthernetPortSettings", "SetLinkPreference", { "LinkPreference": LinkPreference, "Timeout": Timeout }, callback_func); }
254
+ obj.AMT_HeuristicPacketFilterStatistics_ResetSelectedStats = function (SelectedStatistics, callback_func) { obj.Exec("AMT_HeuristicPacketFilterStatistics", "ResetSelectedStats", { "SelectedStatistics": SelectedStatistics }, callback_func); }
255
+ obj.AMT_KerberosSettingData_GetCredentialCacheState = function (callback_func) { obj.Exec("AMT_KerberosSettingData", "GetCredentialCacheState", {}, callback_func); }
256
+ obj.AMT_KerberosSettingData_SetCredentialCacheState = function (Enable, callback_func) { obj.Exec("AMT_KerberosSettingData", "SetCredentialCacheState", { "Enable": Enable }, callback_func); }
257
+ obj.AMT_MessageLog_CancelIteration = function (IterationIdentifier, callback_func) { obj.Exec("AMT_MessageLog", "CancelIteration", { "IterationIdentifier": IterationIdentifier }, callback_func); }
258
+ obj.AMT_MessageLog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_MessageLog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
259
+ obj.AMT_MessageLog_ClearLog = function (callback_func) { obj.Exec("AMT_MessageLog", "ClearLog", { }, callback_func); }
260
+ obj.AMT_MessageLog_GetRecords = function (IterationIdentifier, MaxReadRecords, callback_func, tag) { obj.Exec("AMT_MessageLog", "GetRecords", { "IterationIdentifier": IterationIdentifier, "MaxReadRecords": MaxReadRecords }, callback_func, tag); }
261
+ obj.AMT_MessageLog_GetRecord = function (IterationIdentifier, PositionToNext, callback_func) { obj.Exec("AMT_MessageLog", "GetRecord", { "IterationIdentifier": IterationIdentifier, "PositionToNext": PositionToNext }, callback_func); }
262
+ obj.AMT_MessageLog_PositionAtRecord = function (IterationIdentifier, MoveAbsolute, RecordNumber, callback_func) { obj.Exec("AMT_MessageLog", "PositionAtRecord", { "IterationIdentifier": IterationIdentifier, "MoveAbsolute": MoveAbsolute, "RecordNumber": RecordNumber }, callback_func); }
263
+ obj.AMT_MessageLog_PositionToFirstRecord = function (callback_func, tag) { obj.Exec("AMT_MessageLog", "PositionToFirstRecord", {}, callback_func, tag); }
264
+ obj.AMT_MessageLog_FreezeLog = function (Freeze, callback_func) { obj.Exec("AMT_MessageLog", "FreezeLog", { "Freeze": Freeze }, callback_func); }
265
+ obj.AMT_PublicKeyManagementService_AddCRL = function (Url, SerialNumbers, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "AddCRL", { "Url": Url, "SerialNumbers": SerialNumbers }, callback_func); }
266
+ obj.AMT_PublicKeyManagementService_ResetCRLList = function (_method_dummy, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "ResetCRLList", { "_method_dummy": _method_dummy }, callback_func); }
267
+ obj.AMT_PublicKeyManagementService_AddCertificate = function (CertificateBlob, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "AddCertificate", { "CertificateBlob": CertificateBlob }, callback_func); }
268
+ obj.AMT_PublicKeyManagementService_AddTrustedRootCertificate = function (CertificateBlob, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "AddTrustedRootCertificate", { "CertificateBlob": CertificateBlob }, callback_func); }
269
+ obj.AMT_PublicKeyManagementService_AddKey = function (KeyBlob, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "AddKey", { "KeyBlob": KeyBlob }, callback_func); }
270
+ obj.AMT_PublicKeyManagementService_GeneratePKCS10Request = function (KeyPair, DNName, Usage, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "GeneratePKCS10Request", { "KeyPair": KeyPair, "DNName": DNName, "Usage": Usage }, callback_func); }
271
+ obj.AMT_PublicKeyManagementService_GeneratePKCS10RequestEx = function (KeyPair, SigningAlgorithm, NullSignedCertificateRequest, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "GeneratePKCS10RequestEx", { "KeyPair": KeyPair, "SigningAlgorithm": SigningAlgorithm, "NullSignedCertificateRequest": NullSignedCertificateRequest }, callback_func); }
272
+ obj.AMT_PublicKeyManagementService_GenerateKeyPair = function (KeyAlgorithm, KeyLength, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "GenerateKeyPair", { "KeyAlgorithm": KeyAlgorithm, "KeyLength": KeyLength }, callback_func); }
273
+ obj.AMT_RedirectionService_RequestStateChange = function (RequestedState, callback_func) { obj.Exec("AMT_RedirectionService", "RequestStateChange", { "RequestedState": RequestedState }, callback_func); }
274
+ obj.AMT_RedirectionService_TerminateSession = function (SessionType, callback_func) { obj.Exec("AMT_RedirectionService", "TerminateSession", { "SessionType": SessionType }, callback_func); }
275
+ obj.AMT_RemoteAccessService_AddMpServer = function (AccessInfo, InfoFormat, Port, AuthMethod, Certificate, Username, Password, CN, callback_func) { obj.Exec("AMT_RemoteAccessService", "AddMpServer", { "AccessInfo": AccessInfo, "InfoFormat": InfoFormat, "Port": Port, "AuthMethod": AuthMethod, "Certificate": Certificate, "Username": Username, "Password": Password, "CN": CN }, callback_func); }
276
+ obj.AMT_RemoteAccessService_AddRemoteAccessPolicyRule = function (Trigger, TunnelLifeTime, ExtendedData, MpServer, callback_func) { obj.Exec("AMT_RemoteAccessService", "AddRemoteAccessPolicyRule", { "Trigger": Trigger, "TunnelLifeTime": TunnelLifeTime, "ExtendedData": ExtendedData, "MpServer": MpServer }, callback_func); }
277
+ obj.AMT_RemoteAccessService_CloseRemoteAccessConnection = function (_method_dummy, callback_func) { obj.Exec("AMT_RemoteAccessService", "CloseRemoteAccessConnection", { "_method_dummy": _method_dummy }, callback_func); }
278
+ obj.AMT_SetupAndConfigurationService_CommitChanges = function (_method_dummy, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "CommitChanges", { "_method_dummy": _method_dummy }, callback_func); }
279
+ obj.AMT_SetupAndConfigurationService_Unprovision = function (ProvisioningMode, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "Unprovision", { "ProvisioningMode": ProvisioningMode }, callback_func); }
280
+ obj.AMT_SetupAndConfigurationService_PartialUnprovision = function (_method_dummy, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "PartialUnprovision", { "_method_dummy": _method_dummy }, callback_func); }
281
+ obj.AMT_SetupAndConfigurationService_ResetFlashWearOutProtection = function (_method_dummy, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "ResetFlashWearOutProtection", { "_method_dummy": _method_dummy }, callback_func); }
282
+ obj.AMT_SetupAndConfigurationService_ExtendProvisioningPeriod = function (Duration, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "ExtendProvisioningPeriod", { "Duration": Duration }, callback_func); }
283
+ obj.AMT_SetupAndConfigurationService_SetMEBxPassword = function (Password, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "SetMEBxPassword", { "Password": Password }, callback_func); }
284
+ obj.AMT_SetupAndConfigurationService_SetTLSPSK = function (PID, PPS, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "SetTLSPSK", { "PID": PID, "PPS": PPS }, callback_func); }
285
+ obj.AMT_SetupAndConfigurationService_GetProvisioningAuditRecord = function (callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "GetProvisioningAuditRecord", {}, callback_func); }
286
+ obj.AMT_SetupAndConfigurationService_GetUuid = function (callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "GetUuid", {}, callback_func); }
287
+ obj.AMT_SetupAndConfigurationService_GetUnprovisionBlockingComponents = function (callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "GetUnprovisionBlockingComponents", {}, callback_func); }
288
+ obj.AMT_SetupAndConfigurationService_GetProvisioningAuditRecordV2 = function (callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "GetProvisioningAuditRecordV2", {}, callback_func); }
289
+ obj.AMT_SystemDefensePolicy_GetTimeout = function (callback_func) { obj.Exec("AMT_SystemDefensePolicy", "GetTimeout", {}, callback_func); }
290
+ obj.AMT_SystemDefensePolicy_SetTimeout = function (Timeout, callback_func) { obj.Exec("AMT_SystemDefensePolicy", "SetTimeout", { "Timeout": Timeout }, callback_func); }
291
+ obj.AMT_SystemDefensePolicy_UpdateStatistics = function (NetworkInterface, ResetOnRead, callback_func, tag, pri, selectors) { obj.Exec("AMT_SystemDefensePolicy", "UpdateStatistics", { "NetworkInterface": NetworkInterface, "ResetOnRead": ResetOnRead }, callback_func, tag, pri, selectors); }
292
+ obj.AMT_SystemPowerScheme_SetPowerScheme = function (callback_func, schemeInstanceId, tag) { obj.Exec("AMT_SystemPowerScheme", "SetPowerScheme", {}, callback_func, tag, 0, { "InstanceID": schemeInstanceId }); }
293
+ obj.AMT_TimeSynchronizationService_GetLowAccuracyTimeSynch = function (callback_func, tag) { obj.Exec("AMT_TimeSynchronizationService", "GetLowAccuracyTimeSynch", {}, callback_func, tag); }
294
+ obj.AMT_TimeSynchronizationService_SetHighAccuracyTimeSynch = function (Ta0, Tm1, Tm2, callback_func, tag) { obj.Exec("AMT_TimeSynchronizationService", "SetHighAccuracyTimeSynch", { "Ta0": Ta0, "Tm1": Tm1, "Tm2": Tm2 }, callback_func, tag); }
295
+ obj.AMT_UserInitiatedConnectionService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_UserInitiatedConnectionService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
296
+ obj.AMT_WebUIService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func, tag) { obj.Exec("AMT_WebUIService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func, tag); }
297
+ obj.AMT_WiFiPortConfigurationService_AddWiFiSettings = function (WiFiEndpoint, WiFiEndpointSettingsInput, IEEE8021xSettingsInput, ClientCredential, CACredential, callback_func) { obj.ExecWithXml("AMT_WiFiPortConfigurationService", "AddWiFiSettings", { "WiFiEndpoint": WiFiEndpoint, "WiFiEndpointSettingsInput": WiFiEndpointSettingsInput, "IEEE8021xSettingsInput": IEEE8021xSettingsInput, "ClientCredential": ClientCredential, "CACredential": CACredential }, callback_func); }
298
+ obj.AMT_WiFiPortConfigurationService_UpdateWiFiSettings = function (WiFiEndpointSettings, WiFiEndpointSettingsInput, IEEE8021xSettingsInput, ClientCredential, CACredential, callback_func) { obj.ExecWithXml("AMT_WiFiPortConfigurationService", "UpdateWiFiSettings", { "WiFiEndpointSettings": WiFiEndpointSettings, "WiFiEndpointSettingsInput": WiFiEndpointSettingsInput, "IEEE8021xSettingsInput": IEEE8021xSettingsInput, "ClientCredential": ClientCredential, "CACredential": CACredential }, callback_func); }
299
+ obj.AMT_WiFiPortConfigurationService_DeleteAllITProfiles = function (_method_dummy, callback_func) { obj.Exec("AMT_WiFiPortConfigurationService", "DeleteAllITProfiles", { "_method_dummy": _method_dummy }, callback_func); }
300
+ obj.AMT_WiFiPortConfigurationService_DeleteAllUserProfiles = function (_method_dummy, callback_func) { obj.Exec("AMT_WiFiPortConfigurationService", "DeleteAllUserProfiles", { "_method_dummy": _method_dummy }, callback_func); }
301
+ obj.CIM_Account_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_Account", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
302
+ obj.CIM_AccountManagementService_CreateAccount = function (System, AccountTemplate, callback_func) { obj.Exec("CIM_AccountManagementService", "CreateAccount", { "System": System, "AccountTemplate": AccountTemplate }, callback_func); }
303
+ obj.CIM_BootConfigSetting_ChangeBootOrder = function (Source, callback_func) { obj.Exec("CIM_BootConfigSetting", "ChangeBootOrder", { "Source": Source }, callback_func); }
304
+ obj.CIM_BootService_SetBootConfigRole = function (BootConfigSetting, Role, callback_func) { obj.Exec("CIM_BootService", "SetBootConfigRole", { "BootConfigSetting": BootConfigSetting, "Role": Role }, callback_func, 0, 1); }
305
+ obj.CIM_Card_ConnectorPower = function (Connector, PoweredOn, callback_func) { obj.Exec("CIM_Card", "ConnectorPower", { "Connector": Connector, "PoweredOn": PoweredOn }, callback_func); }
306
+ obj.CIM_Card_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_Card", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
307
+ obj.CIM_Chassis_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_Chassis", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
308
+ obj.CIM_Fan_SetSpeed = function (DesiredSpeed, callback_func) { obj.Exec("CIM_Fan", "SetSpeed", { "DesiredSpeed": DesiredSpeed }, callback_func); }
309
+ obj.CIM_KVMRedirectionSAP_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_KVMRedirectionSAP", "RequestStateChange", { "RequestedState": RequestedState/*, "TimeoutPeriod": TimeoutPeriod */}, callback_func); }
310
+ obj.CIM_MediaAccessDevice_LockMedia = function (Lock, callback_func) { obj.Exec("CIM_MediaAccessDevice", "LockMedia", { "Lock": Lock }, callback_func); }
311
+ obj.CIM_MediaAccessDevice_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_MediaAccessDevice", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
312
+ obj.CIM_MediaAccessDevice_Reset = function (callback_func) { obj.Exec("CIM_MediaAccessDevice", "Reset", {}, callback_func); }
313
+ obj.CIM_MediaAccessDevice_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_MediaAccessDevice", "EnableDevice", { "Enabled": Enabled }, callback_func); }
314
+ obj.CIM_MediaAccessDevice_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_MediaAccessDevice", "OnlineDevice", { "Online": Online }, callback_func); }
315
+ obj.CIM_MediaAccessDevice_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_MediaAccessDevice", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
316
+ obj.CIM_MediaAccessDevice_SaveProperties = function (callback_func) { obj.Exec("CIM_MediaAccessDevice", "SaveProperties", {}, callback_func); }
317
+ obj.CIM_MediaAccessDevice_RestoreProperties = function (callback_func) { obj.Exec("CIM_MediaAccessDevice", "RestoreProperties", {}, callback_func); }
318
+ obj.CIM_MediaAccessDevice_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_MediaAccessDevice", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
319
+ obj.CIM_PhysicalFrame_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_PhysicalFrame", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
320
+ obj.CIM_PhysicalPackage_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_PhysicalPackage", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
321
+ obj.CIM_PowerManagementService_RequestPowerStateChange = function (PowerState, ManagedElement, Time, TimeoutPeriod, callback_func) { obj.Exec("CIM_PowerManagementService", "RequestPowerStateChange", { "PowerState": PowerState, "ManagedElement": ManagedElement, "Time": Time, "TimeoutPeriod": TimeoutPeriod }, callback_func, 0, 1); }
322
+ obj.CIM_PowerSupply_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_PowerSupply", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
323
+ obj.CIM_PowerSupply_Reset = function (callback_func) { obj.Exec("CIM_PowerSupply", "Reset", {}, callback_func); }
324
+ obj.CIM_PowerSupply_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_PowerSupply", "EnableDevice", { "Enabled": Enabled }, callback_func); }
325
+ obj.CIM_PowerSupply_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_PowerSupply", "OnlineDevice", { "Online": Online }, callback_func); }
326
+ obj.CIM_PowerSupply_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_PowerSupply", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
327
+ obj.CIM_PowerSupply_SaveProperties = function (callback_func) { obj.Exec("CIM_PowerSupply", "SaveProperties", {}, callback_func); }
328
+ obj.CIM_PowerSupply_RestoreProperties = function (callback_func) { obj.Exec("CIM_PowerSupply", "RestoreProperties", {}, callback_func); }
329
+ obj.CIM_PowerSupply_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_PowerSupply", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
330
+ obj.CIM_Processor_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_Processor", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
331
+ obj.CIM_Processor_Reset = function (callback_func) { obj.Exec("CIM_Processor", "Reset", {}, callback_func); }
332
+ obj.CIM_Processor_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_Processor", "EnableDevice", { "Enabled": Enabled }, callback_func); }
333
+ obj.CIM_Processor_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_Processor", "OnlineDevice", { "Online": Online }, callback_func); }
334
+ obj.CIM_Processor_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_Processor", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
335
+ obj.CIM_Processor_SaveProperties = function (callback_func) { obj.Exec("CIM_Processor", "SaveProperties", {}, callback_func); }
336
+ obj.CIM_Processor_RestoreProperties = function (callback_func) { obj.Exec("CIM_Processor", "RestoreProperties", {}, callback_func); }
337
+ obj.CIM_Processor_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_Processor", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
338
+ obj.CIM_RecordLog_ClearLog = function (callback_func) { obj.Exec("CIM_RecordLog", "ClearLog", {}, callback_func); }
339
+ obj.CIM_RecordLog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_RecordLog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
340
+ obj.CIM_RedirectionService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_RedirectionService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
341
+ obj.CIM_Sensor_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_Sensor", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
342
+ obj.CIM_Sensor_Reset = function (callback_func) { obj.Exec("CIM_Sensor", "Reset", {}, callback_func); }
343
+ obj.CIM_Sensor_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_Sensor", "EnableDevice", { "Enabled": Enabled }, callback_func); }
344
+ obj.CIM_Sensor_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_Sensor", "OnlineDevice", { "Online": Online }, callback_func); }
345
+ obj.CIM_Sensor_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_Sensor", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
346
+ obj.CIM_Sensor_SaveProperties = function (callback_func) { obj.Exec("CIM_Sensor", "SaveProperties", {}, callback_func); }
347
+ obj.CIM_Sensor_RestoreProperties = function (callback_func) { obj.Exec("CIM_Sensor", "RestoreProperties", {}, callback_func); }
348
+ obj.CIM_Sensor_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_Sensor", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
349
+ obj.CIM_StatisticalData_ResetSelectedStats = function (SelectedStatistics, callback_func) { obj.Exec("CIM_StatisticalData", "ResetSelectedStats", { "SelectedStatistics": SelectedStatistics }, callback_func); }
350
+ obj.CIM_Watchdog_KeepAlive = function (callback_func) { obj.Exec("CIM_Watchdog", "KeepAlive", {}, callback_func); }
351
+ obj.CIM_Watchdog_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_Watchdog", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
352
+ obj.CIM_Watchdog_Reset = function (callback_func) { obj.Exec("CIM_Watchdog", "Reset", {}, callback_func); }
353
+ obj.CIM_Watchdog_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_Watchdog", "EnableDevice", { "Enabled": Enabled }, callback_func); }
354
+ obj.CIM_Watchdog_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_Watchdog", "OnlineDevice", { "Online": Online }, callback_func); }
355
+ obj.CIM_Watchdog_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_Watchdog", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
356
+ obj.CIM_Watchdog_SaveProperties = function (callback_func) { obj.Exec("CIM_Watchdog", "SaveProperties", {}, callback_func); }
357
+ obj.CIM_Watchdog_RestoreProperties = function (callback_func) { obj.Exec("CIM_Watchdog", "RestoreProperties", {}, callback_func); }
358
+ obj.CIM_Watchdog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_Watchdog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
359
+ obj.CIM_WiFiPort_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_WiFiPort", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
360
+ obj.CIM_WiFiPort_Reset = function (callback_func) { obj.Exec("CIM_WiFiPort", "Reset", {}, callback_func); }
361
+ obj.CIM_WiFiPort_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_WiFiPort", "EnableDevice", { "Enabled": Enabled }, callback_func); }
362
+ obj.CIM_WiFiPort_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_WiFiPort", "OnlineDevice", { "Online": Online }, callback_func); }
363
+ obj.CIM_WiFiPort_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_WiFiPort", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
364
+ obj.CIM_WiFiPort_SaveProperties = function (callback_func) { obj.Exec("CIM_WiFiPort", "SaveProperties", {}, callback_func); }
365
+ obj.CIM_WiFiPort_RestoreProperties = function (callback_func) { obj.Exec("CIM_WiFiPort", "RestoreProperties", {}, callback_func); }
366
+ obj.CIM_WiFiPort_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_WiFiPort", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
367
+ obj.IPS_HostBasedSetupService_Setup = function (NetAdminPassEncryptionType, NetworkAdminPassword, McNonce, Certificate, SigningAlgorithm, DigitalSignature, callback_func) { obj.Exec("IPS_HostBasedSetupService", "Setup", { "NetAdminPassEncryptionType": NetAdminPassEncryptionType, "NetworkAdminPassword": NetworkAdminPassword, "McNonce": McNonce, "Certificate": Certificate, "SigningAlgorithm": SigningAlgorithm, "DigitalSignature": DigitalSignature }, callback_func); }
368
+ obj.IPS_HostBasedSetupService_AddNextCertInChain = function (NextCertificate, IsLeafCertificate, IsRootCertificate, callback_func) { obj.Exec("IPS_HostBasedSetupService", "AddNextCertInChain", { "NextCertificate": NextCertificate, "IsLeafCertificate": IsLeafCertificate, "IsRootCertificate": IsRootCertificate }, callback_func); }
369
+ obj.IPS_HostBasedSetupService_AdminSetup = function (NetAdminPassEncryptionType, NetworkAdminPassword, McNonce, SigningAlgorithm, DigitalSignature, callback_func) { obj.Exec("IPS_HostBasedSetupService", "AdminSetup", { "NetAdminPassEncryptionType": NetAdminPassEncryptionType, "NetworkAdminPassword": NetworkAdminPassword, "McNonce": McNonce, "SigningAlgorithm": SigningAlgorithm, "DigitalSignature": DigitalSignature }, callback_func); }
370
+ obj.IPS_HostBasedSetupService_UpgradeClientToAdmin = function (McNonce, SigningAlgorithm, DigitalSignature, callback_func) { obj.Exec("IPS_HostBasedSetupService", "UpgradeClientToAdmin", { "McNonce": McNonce, "SigningAlgorithm": SigningAlgorithm, "DigitalSignature": DigitalSignature }, callback_func); }
371
+ obj.IPS_HostBasedSetupService_DisableClientControlMode = function (_method_dummy, callback_func) { obj.Exec("IPS_HostBasedSetupService", "DisableClientControlMode", { "_method_dummy": _method_dummy }, callback_func); }
372
+ obj.IPS_KVMRedirectionSettingData_TerminateSession = function (callback_func) { obj.Exec("IPS_KVMRedirectionSettingData", "TerminateSession", {}, callback_func); }
373
+ obj.IPS_KVMRedirectionSettingData_DataChannelRead = function (callback_func) { obj.Exec("IPS_KVMRedirectionSettingData", "DataChannelRead", {}, callback_func); }
374
+ obj.IPS_KVMRedirectionSettingData_DataChannelWrite = function (Data, callback_func) { obj.Exec("IPS_KVMRedirectionSettingData", "DataChannelWrite", { "DataMessage": Data }, callback_func); }
375
+ obj.IPS_OptInService_StartOptIn = function (callback_func) { obj.Exec("IPS_OptInService", "StartOptIn", {}, callback_func); }
376
+ obj.IPS_OptInService_CancelOptIn = function (callback_func) { obj.Exec("IPS_OptInService", "CancelOptIn", {}, callback_func); }
377
+ obj.IPS_OptInService_SendOptInCode = function (OptInCode, callback_func) { obj.Exec("IPS_OptInService", "SendOptInCode", { "OptInCode": OptInCode }, callback_func); }
378
+ obj.IPS_OptInService_StartService = function (callback_func) { obj.Exec("IPS_OptInService", "StartService", {}, callback_func); }
379
+ obj.IPS_OptInService_StopService = function (callback_func) { obj.Exec("IPS_OptInService", "StopService", {}, callback_func); }
380
+ obj.IPS_OptInService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("IPS_OptInService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
381
+ obj.IPS_ProvisioningRecordLog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("IPS_ProvisioningRecordLog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
382
+ obj.IPS_ProvisioningRecordLog_ClearLog = function (_method_dummy, callback_func) { obj.Exec("IPS_ProvisioningRecordLog", "ClearLog", { "_method_dummy": _method_dummy }, callback_func); }
383
+ obj.IPS_SecIOService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("IPS_SecIOService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
384
+
385
+ obj.AmtStatusToStr = function (code) { if (obj.AmtStatusCodes[code]) return obj.AmtStatusCodes[code]; else return "UNKNOWN_ERROR" }
386
+ obj.AmtStatusCodes = {
387
+ 0x0000: "SUCCESS",
388
+ 0x0001: "INTERNAL_ERROR",
389
+ 0x0002: "NOT_READY",
390
+ 0x0003: "INVALID_PT_MODE",
391
+ 0x0004: "INVALID_MESSAGE_LENGTH",
392
+ 0x0005: "TABLE_FINGERPRINT_NOT_AVAILABLE",
393
+ 0x0006: "INTEGRITY_CHECK_FAILED",
394
+ 0x0007: "UNSUPPORTED_ISVS_VERSION",
395
+ 0x0008: "APPLICATION_NOT_REGISTERED",
396
+ 0x0009: "INVALID_REGISTRATION_DATA",
397
+ 0x000A: "APPLICATION_DOES_NOT_EXIST",
398
+ 0x000B: "NOT_ENOUGH_STORAGE",
399
+ 0x000C: "INVALID_NAME",
400
+ 0x000D: "BLOCK_DOES_NOT_EXIST",
401
+ 0x000E: "INVALID_BYTE_OFFSET",
402
+ 0x000F: "INVALID_BYTE_COUNT",
403
+ 0x0010: "NOT_PERMITTED",
404
+ 0x0011: "NOT_OWNER",
405
+ 0x0012: "BLOCK_LOCKED_BY_OTHER",
406
+ 0x0013: "BLOCK_NOT_LOCKED",
407
+ 0x0014: "INVALID_GROUP_PERMISSIONS",
408
+ 0x0015: "GROUP_DOES_NOT_EXIST",
409
+ 0x0016: "INVALID_MEMBER_COUNT",
410
+ 0x0017: "MAX_LIMIT_REACHED",
411
+ 0x0018: "INVALID_AUTH_TYPE",
412
+ 0x0019: "AUTHENTICATION_FAILED",
413
+ 0x001A: "INVALID_DHCP_MODE",
414
+ 0x001B: "INVALID_IP_ADDRESS",
415
+ 0x001C: "INVALID_DOMAIN_NAME",
416
+ 0x001D: "UNSUPPORTED_VERSION",
417
+ 0x001E: "REQUEST_UNEXPECTED",
418
+ 0x001F: "INVALID_TABLE_TYPE",
419
+ 0x0020: "INVALID_PROVISIONING_STATE",
420
+ 0x0021: "UNSUPPORTED_OBJECT",
421
+ 0x0022: "INVALID_TIME",
422
+ 0x0023: "INVALID_INDEX",
423
+ 0x0024: "INVALID_PARAMETER",
424
+ 0x0025: "INVALID_NETMASK",
425
+ 0x0026: "FLASH_WRITE_LIMIT_EXCEEDED",
426
+ 0x0027: "INVALID_IMAGE_LENGTH",
427
+ 0x0028: "INVALID_IMAGE_SIGNATURE",
428
+ 0x0029: "PROPOSE_ANOTHER_VERSION",
429
+ 0x002A: "INVALID_PID_FORMAT",
430
+ 0x002B: "INVALID_PPS_FORMAT",
431
+ 0x002C: "BIST_COMMAND_BLOCKED",
432
+ 0x002D: "CONNECTION_FAILED",
433
+ 0x002E: "CONNECTION_TOO_MANY",
434
+ 0x002F: "RNG_GENERATION_IN_PROGRESS",
435
+ 0x0030: "RNG_NOT_READY",
436
+ 0x0031: "CERTIFICATE_NOT_READY",
437
+ 0x0400: "DISABLED_BY_POLICY",
438
+ 0x0800: "NETWORK_IF_ERROR_BASE",
439
+ 0x0801: "UNSUPPORTED_OEM_NUMBER",
440
+ 0x0802: "UNSUPPORTED_BOOT_OPTION",
441
+ 0x0803: "INVALID_COMMAND",
442
+ 0x0804: "INVALID_SPECIAL_COMMAND",
443
+ 0x0805: "INVALID_HANDLE",
444
+ 0x0806: "INVALID_PASSWORD",
445
+ 0x0807: "INVALID_REALM",
446
+ 0x0808: "STORAGE_ACL_ENTRY_IN_USE",
447
+ 0x0809: "DATA_MISSING",
448
+ 0x080A: "DUPLICATE",
449
+ 0x080B: "EVENTLOG_FROZEN",
450
+ 0x080C: "PKI_MISSING_KEYS",
451
+ 0x080D: "PKI_GENERATING_KEYS",
452
+ 0x080E: "INVALID_KEY",
453
+ 0x080F: "INVALID_CERT",
454
+ 0x0810: "CERT_KEY_NOT_MATCH",
455
+ 0x0811: "MAX_KERB_DOMAIN_REACHED",
456
+ 0x0812: "UNSUPPORTED",
457
+ 0x0813: "INVALID_PRIORITY",
458
+ 0x0814: "NOT_FOUND",
459
+ 0x0815: "INVALID_CREDENTIALS",
460
+ 0x0816: "INVALID_PASSPHRASE",
461
+ 0x0818: "NO_ASSOCIATION",
462
+ 0x081B: "AUDIT_FAIL",
463
+ 0x081C: "BLOCKING_COMPONENT",
464
+ 0x0821: "USER_CONSENT_REQUIRED",
465
+ 0x1000: "APP_INTERNAL_ERROR",
466
+ 0x1001: "NOT_INITIALIZED",
467
+ 0x1002: "LIB_VERSION_UNSUPPORTED",
468
+ 0x1003: "INVALID_PARAM",
469
+ 0x1004: "RESOURCES",
470
+ 0x1005: "HARDWARE_ACCESS_ERROR",
471
+ 0x1006: "REQUESTOR_NOT_REGISTERED",
472
+ 0x1007: "NETWORK_ERROR",
473
+ 0x1008: "PARAM_BUFFER_TOO_SHORT",
474
+ 0x1009: "COM_NOT_INITIALIZED_IN_THREAD",
475
+ 0x100A: "URL_REQUIRED"
476
+ }
477
+
478
+ //
479
+ // Methods used for getting the event log
480
+ //
481
+
482
+ obj.GetMessageLog = function (func, tag) {
483
+ obj.AMT_MessageLog_PositionToFirstRecord(_GetMessageLog0, [func, tag, []]);
484
+ }
485
+ function _GetMessageLog0(stack, name, responses, status, tag) {
486
+ if (status != 200 || responses.Body["ReturnValue"] != '0') { tag[0](obj, null, tag[2], status); return; }
487
+ obj.AMT_MessageLog_GetRecords(responses.Body["IterationIdentifier"], 390, _GetMessageLog1, tag);
488
+ }
489
+ function _GetMessageLog1(stack, name, responses, status, tag) {
490
+ if (status != 200 || responses.Body["ReturnValue"] != '0') { tag[0](obj, null, tag[2], status); return; }
491
+ var i, j, x, e, AmtMessages = tag[2], t = new Date(), TimeStamp, ra = responses.Body["RecordArray"];
492
+ if (typeof ra === 'string') { responses.Body["RecordArray"] = [responses.Body["RecordArray"]]; }
493
+
494
+ for (i in ra) {
495
+ e = Buffer.from(ra[i], 'base64');
496
+ if (e != null) {
497
+ TimeStamp = ReadIntX(e, 0);
498
+ if ((TimeStamp > 0) && (TimeStamp < 0xFFFFFFFF)) {
499
+ x = { 'DeviceAddress': e[4], 'EventSensorType': e[5], 'EventType': e[6], 'EventOffset': e[7], 'EventSourceType': e[8], 'EventSeverity': e[9], 'SensorNumber': e[10], 'Entity': e[11], 'EntityInstance': e[12], 'EventData': [], 'Time': new Date((TimeStamp + (t.getTimezoneOffset() * 60)) * 1000) };
500
+ for (j = 13; j < 21; j++) { x['EventData'].push(e[j]); }
501
+ x['EntityStr'] = _SystemEntityTypes[x['Entity']];
502
+ x['Desc'] = _GetEventDetailStr(x['EventSensorType'], x['EventOffset'], x['EventData'], x['Entity']);
503
+ if (!x['EntityStr']) x['EntityStr'] = "Unknown";
504
+ AmtMessages.push(x);
505
+ }
506
+ }
507
+ }
508
+
509
+ if (responses.Body["NoMoreRecords"] != true) { obj.AMT_MessageLog_GetRecords(responses.Body["IterationIdentifier"], 390, _GetMessageLog1, [tag[0], AmtMessages, tag[2]]); } else { tag[0](obj, AmtMessages, tag[2]); }
510
+ }
511
+
512
+ var _EventTrapSourceTypes = "Platform firmware (e.g. BIOS)|SMI handler|ISV system management software|Alert ASIC|IPMI|BIOS vendor|System board set vendor|System integrator|Third party add-in|OSV|NIC|System management card".split('|');
513
+ var _SystemFirmwareError = "Unspecified.|No system memory is physically installed in the system.|No usable system memory, all installed memory has experienced an unrecoverable failure.|Unrecoverable hard-disk/ATAPI/IDE device failure.|Unrecoverable system-board failure.|Unrecoverable diskette subsystem failure.|Unrecoverable hard-disk controller failure.|Unrecoverable PS/2 or USB keyboard failure.|Removable boot media not found.|Unrecoverable video controller failure.|No video device detected.|Firmware (BIOS) ROM corruption detected.|CPU voltage mismatch (processors that share same supply have mismatched voltage requirements)|CPU speed matching failure".split('|');
514
+ var _SystemFirmwareProgress = "Unspecified.|Memory initialization.|Starting hard-disk initialization and test|Secondary processor(s) initialization|User authentication|User-initiated system setup|USB resource configuration|PCI resource configuration|Option ROM initialization|Video initialization|Cache initialization|SM Bus initialization|Keyboard controller initialization|Embedded controller/management controller initialization|Docking station attachment|Enabling docking station|Docking station ejection|Disabling docking station|Calling operating system wake-up vector|Starting operating system boot process|Baseboard or motherboard initialization|reserved|Floppy initialization|Keyboard test|Pointing device test|Primary processor initialization".split('|');
515
+ var _SystemEntityTypes = "Unspecified|Other|Unknown|Processor|Disk|Peripheral|System management module|System board|Memory module|Processor module|Power supply|Add in card|Front panel board|Back panel board|Power system board|Drive backplane|System internal expansion board|Other system board|Processor board|Power unit|Power module|Power management board|Chassis back panel board|System chassis|Sub chassis|Other chassis board|Disk drive bay|Peripheral bay|Device bay|Fan cooling|Cooling unit|Cable interconnect|Memory device|System management software|BIOS|Intel(r) ME|System bus|Group|Intel(r) ME|External environment|Battery|Processing blade|Connectivity switch|Processor/memory module|I/O module|Processor I/O module|Management controller firmware|IPMI channel|PCI bus|PCI express bus|SCSI bus|SATA/SAS bus|Processor front side bus".split('|');
516
+ obj.RealmNames = "||Redirection|PT Administration|Hardware Asset|Remote Control|Storage|Event Manager|Storage Admin|Agent Presence Local|Agent Presence Remote|Circuit Breaker|Network Time|General Information|Firmware Update|EIT|LocalUN|Endpoint Access Control|Endpoint Access Control Admin|Event Log Reader|Audit Log|ACL Realm|||Local System".split('|');
517
+ obj.WatchdogCurrentStates = { 1: 'Not Started', 2: 'Stopped', 4: 'Running', 8: 'Expired', 16: 'Suspended' };
518
+
519
+ function _GetEventDetailStr(eventSensorType, eventOffset, eventDataField, entity) {
520
+
521
+ if (eventSensorType == 15)
522
+ {
523
+ if (eventDataField[0] == 235) return "Invalid Data";
524
+ if (eventOffset == 0) return _SystemFirmwareError[eventDataField[1]];
525
+ return _SystemFirmwareProgress[eventDataField[1]];
526
+ }
527
+
528
+ if (eventSensorType == 18 && eventDataField[0] == 170) // System watchdog event
529
+ {
530
+ return "Agent watchdog " + char2hex(eventDataField[4]) + char2hex(eventDataField[3]) + char2hex(eventDataField[2]) + char2hex(eventDataField[1]) + "-" + char2hex(eventDataField[6]) + char2hex(eventDataField[5]) + "-... changed to " + obj.WatchdogCurrentStates[eventDataField[7]];
531
+ }
532
+
533
+ //if (eventSensorType == 5 && eventOffset == 0) // System chassis
534
+ //{
535
+ // return "Case intrusion";
536
+ //}
537
+
538
+ //if (eventSensorType == 192 && eventOffset == 0 && eventDataField[0] == 170 && eventDataField[1] == 48)
539
+ //{
540
+ // if (eventDataField[2] == 0) return "A remote Serial Over LAN session was established.";
541
+ // if (eventDataField[2] == 1) return "Remote Serial Over LAN session finished. User control was restored.";
542
+ // if (eventDataField[2] == 2) return "A remote IDE-Redirection session was established.";
543
+ // if (eventDataField[2] == 3) return "Remote IDE-Redirection session finished. User control was restored.";
544
+ //}
545
+
546
+ //if (eventSensorType == 36)
547
+ //{
548
+ // long handle = ((long)(eventDataField[1]) << 24) + ((long)(eventDataField[2]) << 16) + ((long)(eventDataField[3]) << 8) + (long)(eventDataField[4]);
549
+ // string nic = string.Format("#{0}", eventDataField[0]);
550
+ // if (eventDataField[0] == 0xAA) nic = "wired"; // TODO: Add wireless *****
551
+ // //if (eventDataField[0] == 0xAA) nic = "wireless";
552
+
553
+ // if (handle == 4294967293) { return string.Format("All received packet filter was matched on {0} interface.", nic); }
554
+ // if (handle == 4294967292) { return string.Format("All outbound packet filter was matched on {0} interface.", nic); }
555
+ // if (handle == 4294967290) { return string.Format("Spoofed packet filter was matched on {0} interface.", nic); }
556
+ // return string.Format("Filter {0} was matched on {1} interface.", handle, nic);
557
+ //}
558
+
559
+ //if (eventSensorType == 192)
560
+ //{
561
+ // if (eventDataField[2] == 0) return "Security policy invoked. Some or all network traffic (TX) was stopped.";
562
+ // if (eventDataField[2] == 2) return "Security policy invoked. Some or all network traffic (RX) was stopped.";
563
+ // return "Security policy invoked.";
564
+ //}
565
+
566
+ //if (eventSensorType == 193)
567
+ //{
568
+ // if (eventDataField[0] == 0xAA && eventDataField[1] == 0x30 && eventDataField[2] == 0x00 && eventDataField[3] == 0x00) { return "User request for remote connection."; }
569
+ // if (eventDataField[0] == 0xAA && eventDataField[1] == 0x20 && eventDataField[2] == 0x03 && eventDataField[3] == 0x01) { return "EAC error: attempt to get posture while NAC in Intel(r) AMT is disabled."; // eventDataField = 0xAA20030100000000 }
570
+ // if (eventDataField[0] == 0xAA && eventDataField[1] == 0x20 && eventDataField[2] == 0x04 && eventDataField[3] == 0x00) { return "Certificate revoked. "; }
571
+ //}
572
+
573
+ if (eventSensorType == 6) return "Authentication failed " + (eventDataField[1] + (eventDataField[2] << 8)) + " times. The system may be under attack.";
574
+ if (eventSensorType == 30) return "No bootable media";
575
+ if (eventSensorType == 32) return "Operating system lockup or power interrupt";
576
+ if (eventSensorType == 35) return "System boot failure";
577
+ if (eventSensorType == 37) return "System firmware started (at least one CPU is properly executing).";
578
+ return "Unknown Sensor Type #" + eventSensorType;
579
+ }
580
+
581
+// ###BEGIN###{AuditLog}
582
+
583
+ // Useful link: https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Fsecurityadminevents.htm
584
+
585
+ var _AmtAuditStringTable =
586
+ {
587
+ 16: 'Security Admin',
588
+ 17: 'RCO',
589
+ 18: 'Redirection Manager',
590
+ 19: 'Firmware Update Manager',
591
+ 20: 'Security Audit Log',
592
+ 21: 'Network Time',
593
+ 22: 'Network Administration',
594
+ 23: 'Storage Administration',
595
+ 24: 'Event Manager',
596
+ 25: 'Circuit Breaker Manager',
597
+ 26: 'Agent Presence Manager',
598
+ 27: 'Wireless Configuration',
599
+ 28: 'EAC',
600
+ 29: 'KVM',
601
+ 30: 'User Opt-In Events',
602
+ 32: 'Screen Blanking',
603
+ 33: 'Watchdog Events',
604
+ 1600: 'Provisioning Started',
605
+ 1601: 'Provisioning Completed',
606
+ 1602: 'ACL Entry Added',
607
+ 1603: 'ACL Entry Modified',
608
+ 1604: 'ACL Entry Removed',
609
+ 1605: 'ACL Access with Invalid Credentials',
610
+ 1606: 'ACL Entry State',
611
+ 1607: 'TLS State Changed',
612
+ 1608: 'TLS Server Certificate Set',
613
+ 1609: 'TLS Server Certificate Remove',
614
+ 1610: 'TLS Trusted Root Certificate Added',
615
+ 1611: 'TLS Trusted Root Certificate Removed',
616
+ 1612: 'TLS Preshared Key Set',
617
+ 1613: 'Kerberos Settings Modified',
618
+ 1614: 'Kerberos Master Key Modified',
619
+ 1615: 'Flash Wear out Counters Reset',
620
+ 1616: 'Power Package Modified',
621
+ 1617: 'Set Realm Authentication Mode',
622
+ 1618: 'Upgrade Client to Admin Control Mode',
623
+ 1619: 'Unprovisioning Started',
624
+ 1700: 'Performed Power Up',
625
+ 1701: 'Performed Power Down',
626
+ 1702: 'Performed Power Cycle',
627
+ 1703: 'Performed Reset',
628
+ 1704: 'Set Boot Options',
629
+ 1800: 'IDER Session Opened',
630
+ 1801: 'IDER Session Closed',
631
+ 1802: 'IDER Enabled',
632
+ 1803: 'IDER Disabled',
633
+ 1804: 'SoL Session Opened',
634
+ 1805: 'SoL Session Closed',
635
+ 1806: 'SoL Enabled',
636
+ 1807: 'SoL Disabled',
637
+ 1808: 'KVM Session Started',
638
+ 1809: 'KVM Session Ended',
639
+ 1810: 'KVM Enabled',
640
+ 1811: 'KVM Disabled',
641
+ 1812: 'VNC Password Failed 3 Times',
642
+ 1900: 'Firmware Updated',
643
+ 1901: 'Firmware Update Failed',
644
+ 2000: 'Security Audit Log Cleared',
645
+ 2001: 'Security Audit Policy Modified',
646
+ 2002: 'Security Audit Log Disabled',
647
+ 2003: 'Security Audit Log Enabled',
648
+ 2004: 'Security Audit Log Exported',
649
+ 2005: 'Security Audit Log Recovered',
650
+ 2100: 'Intel(R) ME Time Set',
651
+ 2200: 'TCPIP Parameters Set',
652
+ 2201: 'Host Name Set',
653
+ 2202: 'Domain Name Set',
654
+ 2203: 'VLAN Parameters Set',
655
+ 2204: 'Link Policy Set',
656
+ 2205: 'IPv6 Parameters Set',
657
+ 2300: 'Global Storage Attributes Set',
658
+ 2301: 'Storage EACL Modified',
659
+ 2302: 'Storage FPACL Modified',
660
+ 2303: 'Storage Write Operation',
661
+ 2400: 'Alert Subscribed',
662
+ 2401: 'Alert Unsubscribed',
663
+ 2402: 'Event Log Cleared',
664
+ 2403: 'Event Log Frozen',
665
+ 2500: 'CB Filter Added',
666
+ 2501: 'CB Filter Removed',
667
+ 2502: 'CB Policy Added',
668
+ 2503: 'CB Policy Removed',
669
+ 2504: 'CB Default Policy Set',
670
+ 2505: 'CB Heuristics Option Set',
671
+ 2506: 'CB Heuristics State Cleared',
672
+ 2600: 'Agent Watchdog Added',
673
+ 2601: 'Agent Watchdog Removed',
674
+ 2602: 'Agent Watchdog Action Set',
675
+ 2700: 'Wireless Profile Added',
676
+ 2701: 'Wireless Profile Removed',
677
+ 2702: 'Wireless Profile Updated',
678
+ 2800: 'EAC Posture Signer SET',
679
+ 2801: 'EAC Enabled',
680
+ 2802: 'EAC Disabled',
681
+ 2803: 'EAC Posture State',
682
+ 2804: 'EAC Set Options',
683
+ 2900: 'KVM Opt-in Enabled',
684
+ 2901: 'KVM Opt-in Disabled',
685
+ 2902: 'KVM Password Changed',
686
+ 2903: 'KVM Consent Succeeded',
687
+ 2904: 'KVM Consent Failed',
688
+ 3000: 'Opt-In Policy Change',
689
+ 3001: 'Send Consent Code Event',
690
+ 3002: 'Start Opt-In Blocked Event'
691
+ }
692
+
693
+ // Return human readable extended audit log data
694
+ // TODO: Just put some of them here, but many more still need to be added, helpful link here:
695
+ // https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Fsecurityadminevents.htm
696
+ obj.GetAuditLogExtendedDataStr = function (id, data) {
697
+ if ((id == 1602 || id == 1604) && data[0] == 0) { return data.splice(2, 2 + data[1]).toString(); } // ACL Entry Added/Removed (Digest)
698
+ if (id == 1603) { if (data[1] == 0) { return data.splice(3).toString(); } return null; } // ACL Entry Modified
699
+ if (id == 1605) { return ["Invalid ME access", "Invalid MEBx access"][data[0]]; } // ACL Access with Invalid Credentials
700
+ if (id == 1606) { var r = ["Disabled", "Enabled"][data[0]]; if (data[1] == 0) { r += ", " + data[3]; } return r; } // ACL Entry State
701
+ if (id == 1607) { return "Remote " + ["NoAuth", "ServerAuth", "MutualAuth"][data[0]] + ", Local " + ["NoAuth", "ServerAuth", "MutualAuth"][data[1]]; } // TLS State Changed
702
+ if (id == 1617) { return obj.RealmNames[ReadInt(data, 0)] + ", " + ["NoAuth", "Auth", "Disabled"][data[4]]; } // Set Realm Authentication Mode
703
+ if (id == 1619) { return ["BIOS", "MEBx", "Local MEI", "Local WSMAN", "Remote WSAMN"][data[0]]; } // Intel AMT Unprovisioning Started
704
+ if (id == 1900) { return "From " + ReadShort(data, 0) + "." + ReadShort(data, 2) + "." + ReadShort(data, 4) + "." + ReadShort(data, 6) + " to " + ReadShort(data, 8) + "." + ReadShort(data, 10) + "." + ReadShort(data, 12) + "." + ReadShort(data, 14); } // Firmware Updated
705
+ if (id == 2100) { var t4 = new Date(); t4.setTime(ReadInt(data, 0) * 1000 + (new Date().getTimezoneOffset() * 60000)); return t4.toLocaleString(); } // Intel AMT Time Set
706
+ if (id == 3000) { return "From " + ["None", "KVM", "All"][data[0]] + " to " + ["None", "KVM", "All"][data[1]]; } // Opt-In Policy Change
707
+ if (id == 3001) { return ["Success", "Failed 3 times"][data[0]]; } // Send Consent Code Event
708
+ return null;
709
+ }
710
+
711
+ obj.GetAuditLog = function (func) {
712
+ obj.AMT_AuditLog_ReadRecords(1, _GetAuditLog0, [func, []]);
713
+ }
714
+
715
+ function MakeToArray(v) { if (!v || v == null || typeof v == 'object') return v; return [v]; }
716
+ function ReadShort(v, p) { return (v[p] << 8) + v[p + 1]; }
717
+ function ReadInt(v, p) { return (v[p] * 0x1000000) + (v[p + 1] << 16) + (v[p + 2] << 8) + v[p + 3]; } // We use "*0x1000000" instead of "<<24" because the shift converts the number to signed int32.
718
+ function ReadIntX(v, p) { return (v[p + 3] * 0x1000000) + (v[p + 2] << 16) + (v[p + 1] << 8) + v[p]; }
719
+ function btoa(x) { return Buffer.from(x).toString('base64'); }
720
+ function atob(x) { var z = null; try { z = Buffer.from(x, 'base64').toString(); } catch (e) { console.log(e); } return z; }
721
+
722
+ function _GetAuditLog0(stack, name, responses, status, tag) {
723
+ if (status != 200) { tag[0](obj, [], status); return; }
724
+ var ptr, i, e, es, x, r = tag[1], t = new Date(), TimeStamp;
725
+
726
+ if (responses.Body['RecordsReturned'] > 0) {
727
+ responses.Body['EventRecords'] = MakeToArray(responses.Body['EventRecords']);
728
+
729
+ for (i in responses.Body['EventRecords']) {
730
+ e = null;
731
+ try {
732
+ es = atob(responses.Body['EventRecords'][i]);
733
+ e = new Buffer(es);
734
+ } catch (ex) {
735
+ console.log(ex + " " + responses.Body['EventRecords'][i])
736
+ }
737
+
738
+ x = { 'AuditAppID': ReadShort(e, 0), 'EventID': ReadShort(e, 2), 'InitiatorType': e[4] };
739
+ x['AuditApp'] = _AmtAuditStringTable[x['AuditAppID']];
740
+ x['Event'] = _AmtAuditStringTable[(x['AuditAppID'] * 100) + x['EventID']];
741
+ if (!x['Event']) x['Event'] = '#' + x['EventID'];
742
+
743
+ // Read and process the initiator
744
+ if (x['InitiatorType'] == 0) {
745
+ // HTTP digest
746
+ var userlen = e[5];
747
+ x['Initiator'] = e.slice(6, 6 + userlen).toString();
748
+ ptr = 6 + userlen;
749
+ }
750
+ if (x['InitiatorType'] == 1) {
751
+ // Kerberos
752
+ x['KerberosUserInDomain'] = ReadInt(e, 5);
753
+ var userlen = e[9];
754
+ x['Initiator'] = GetSidString(e.slice(10, 10 + userlen));
755
+ ptr = 10 + userlen;
756
+ }
757
+ if (x['InitiatorType'] == 2) {
758
+ // Local
759
+ x['Initiator'] = 'Local';
760
+ ptr = 5;
761
+ }
762
+ if (x['InitiatorType'] == 3) {
763
+ // KVM Default Port
764
+ x['Initiator'] = 'KVM Default Port';
765
+ ptr = 5;
766
+ }
767
+
768
+ // Read timestamp
769
+ TimeStamp = ReadInt(e, ptr);
770
+ x['Time'] = new Date((TimeStamp + (t.getTimezoneOffset() * 60)) * 1000);
771
+ ptr += 4;
772
+
773
+ // Read network access
774
+ x['MCLocationType'] = e[ptr++];
775
+ var netlen = e[ptr++];
776
+
777
+ x['NetAddress'] = e.slice(ptr, ptr + netlen).toString();
778
+
779
+ // Read extended data
780
+ ptr += netlen;
781
+ var exlen = e[ptr++];
782
+ x['Ex'] = e.slice(ptr, ptr + exlen);
783
+ x['ExStr'] = obj.GetAuditLogExtendedDataStr((x['AuditAppID'] * 100) + x['EventID'], x['Ex']);
784
+ r.push(x);
785
+ }
786
+ }
787
+ if (responses.Body['TotalRecordCount'] > r.length) {
788
+ obj.AMT_AuditLog_ReadRecords(r.length + 1, _GetAuditLog0, [tag[0], r]);
789
+ } else {
790
+ tag[0](obj, r, status);
791
+ }
792
+ }
793
+
794
+ // ###END###{AuditLog}
795
+
796
+ /*
797
+ // ###BEGIN###{Certificates}
798
+
799
+ // Forge MD5
800
+ function hex_md5(str) { return forge.md.md5.create().update(str).digest().toHex(); }
801
+
802
+ // ###END###{Certificates}
803
+
804
+ // ###BEGIN###{!Certificates}
805
+
806
+ // TinyMD5 from https://github.com/jbt/js-crypto
807
+
808
+ // Perform MD5 setup
809
+ var md5_k = [];
810
+ for (var i = 0; i < 64;) { md5_k[i] = 0 | (Math.abs(Math.sin(++i)) * 4294967296); }
811
+
812
+ // Perform MD5 on raw string and return hex
813
+ function hex_md5(str) {
814
+ var b, c, d, j,
815
+ x = [],
816
+ str2 = unescape(encodeURI(str)),
817
+ a = str2.length,
818
+ h = [b = 1732584193, c = -271733879, ~b, ~c],
819
+ i = 0;
820
+
821
+ for (; i <= a;) x[i >> 2] |= (str2.charCodeAt(i) || 128) << 8 * (i++ % 4);
822
+
823
+ x[str = (a + 8 >> 6) * 16 + 14] = a * 8;
824
+ i = 0;
825
+
826
+ for (; i < str; i += 16) {
827
+ a = h; j = 0;
828
+ for (; j < 64;) {
829
+ a = [
830
+ d = a[3],
831
+ ((b = a[1] | 0) +
832
+ ((d = (
833
+ (a[0] +
834
+ [
835
+ b & (c = a[2]) | ~b & d,
836
+ d & b | ~d & c,
837
+ b ^ c ^ d,
838
+ c ^ (b | ~d)
839
+ ][a = j >> 4]
840
+ ) +
841
+ (md5_k[j] +
842
+ (x[[
843
+ j,
844
+ 5 * j + 1,
845
+ 3 * j + 5,
846
+ 7 * j
847
+ ][a] % 16 + i] | 0)
848
+ )
849
+ )) << (a = [
850
+ 7, 12, 17, 22,
851
+ 5, 9, 14, 20,
852
+ 4, 11, 16, 23,
853
+ 6, 10, 15, 21
854
+ ][4 * a + j++ % 4]) | d >>> 32 - a)
855
+ ),
856
+ b,
857
+ c
858
+ ];
859
+ }
860
+ for (j = 4; j;) h[--j] = h[j] + a[j];
861
+ }
862
+
863
+ str = '';
864
+ for (; j < 32;) str += ((h[j >> 3] >> ((1 ^ j++ & 7) * 4)) & 15).toString(16);
865
+ return str;
866
+ }
867
+
868
+ // ###END###{!Certificates}
869
+
870
+ // Perform MD5 on raw string and return raw string result
871
+ function rstr_md5(str) { return hex2rstr(hex_md5(str)); }
872
+ */
873
+ /*
874
+ Convert arguments into selector set and body XML. Used by AMT_WiFiPortConfigurationService_UpdateWiFiSettings.
875
+ args = {
876
+ "WiFiEndpoint": {
877
+ __parameterType: 'reference',
878
+ __resourceUri: 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpoint',
879
+ Name: 'WiFi Endpoint 0'
880
+ },
881
+ "WiFiEndpointSettingsInput":
882
+ {
883
+ __parameterType: 'instance',
884
+ __namespace: 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointSettings',
885
+ ElementName: document.querySelector('#editProfile-profileName').value,
886
+ InstanceID: 'Intel(r) AMT:WiFi Endpoint Settings ' + document.querySelector('#editProfile-profileName').value,
887
+ AuthenticationMethod: document.querySelector('#editProfile-networkAuthentication').value,
888
+ //BSSType: 3, // Intel(r) AMT supports only infrastructure networks
889
+ EncryptionMethod: document.querySelector('#editProfile-encryption').value,
890
+ SSID: document.querySelector('#editProfile-networkName').value,
891
+ Priority: 100,
892
+ PSKPassPhrase: document.querySelector('#editProfile-passPhrase').value
893
+ },
894
+ "IEEE8021xSettingsInput": null,
895
+ "ClientCredential": null,
896
+ "CACredential": null
897
+ },
898
+ */
899
+ function execArgumentsToXml(args) {
900
+ if (args === undefined || args === null) return null;
901
+
902
+ var result = '';
903
+ for (var argName in args) {
904
+ var arg = args[argName];
905
+ if (!arg) continue;
906
+ if (arg['__parameterType'] === 'reference') result += referenceToXml(argName, arg);
907
+ else result += instanceToXml(argName, arg);
908
+ //if(arg['__isInstance']) result += instanceToXml(argName, arg);
909
+ }
910
+ return result;
911
+ }
912
+
913
+ /**
914
+ * Convert JavaScript object into XML
915
+
916
+ <r:WiFiEndpointSettingsInput xmlns:q="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointSettings">
917
+ <q:ElementName>Wireless-Profile-Admin</q:ElementName>
918
+ <q:InstanceID>Intel(r) AMT:WiFi Endpoint Settings Wireless-Profile-Admin</q:InstanceID>
919
+ <q:AuthenticationMethod>6</q:AuthenticationMethod>
920
+ <q:EncryptionMethod>4</q:EncryptionMethod>
921
+ <q:Priority>100</q:Priority>
922
+ <q:PSKPassPhrase>P@ssw0rd</q:PSKPassPhrase>
923
+ </r:WiFiEndpointSettingsInput>
924
+ */
925
+ function instanceToXml(instanceName, inInstance) {
926
+ if (inInstance === undefined || inInstance === null) return null;
927
+
928
+ var hasNamespace = !!inInstance['__namespace'];
929
+ var startTag = hasNamespace ? '<q:' : '<';
930
+ var endTag = hasNamespace ? '</q:' : '</';
931
+ var namespaceDef = hasNamespace ? (' xmlns:q="' + inInstance['__namespace'] + '"') : '';
932
+ var result = '<r:' + instanceName + namespaceDef + '>';
933
+ for (var prop in inInstance) {
934
+ if (!inInstance.hasOwnProperty(prop) || prop.indexOf('__') === 0) continue;
935
+
936
+ if (typeof inInstance[prop] === 'function' || Array.isArray(inInstance[prop])) continue;
937
+
938
+ if (typeof inInstance[prop] === 'object') {
939
+ //result += startTag + prop +'>' + instanceToXml('prop', inInstance[prop]) + endTag + prop +'>';
940
+ console.error('only convert one level down...');
941
+ }
942
+ else {
943
+ result += startTag + prop + '>' + inInstance[prop].toString() + endTag + prop + '>';
944
+ }
945
+ }
946
+ result += '</r:' + instanceName + '>';
947
+ return result;
948
+ }
949
+
950
+
951
+ /**
952
+ * Convert a selector set into XML. Expect no nesting.
953
+ * {
954
+ * selectorName : selectorValue,
955
+ * selectorName : selectorValue,
956
+ * ... ...
957
+ * }
958
+
959
+ <r:WiFiEndpoint>
960
+ <a:Address>http://192.168.1.103:16992/wsman</a:Address>
961
+ <a:ReferenceParameters>
962
+ <w:ResourceURI>http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpoint</w:ResourceURI>
963
+ <w:SelectorSet>
964
+ <w:Selector Name="Name">WiFi Endpoint 0</w:Selector>
965
+ </w:SelectorSet>
966
+ </a:ReferenceParameters>
967
+ </r:WiFiEndpoint>
968
+
969
+ */
970
+ function referenceToXml(referenceName, inReference) {
971
+ if (inReference === undefined || inReference === null) return null;
972
+
973
+ var result = '<r:' + referenceName + '><a:Address>/wsman</a:Address><a:ReferenceParameters><w:ResourceURI>' + inReference['__resourceUri'] + '</w:ResourceURI><w:SelectorSet>';
974
+ for (var selectorName in inReference) {
975
+ if (!inReference.hasOwnProperty(selectorName) || selectorName.indexOf('__') === 0) continue;
976
+
977
+ if (typeof inReference[selectorName] === 'function' ||
978
+ typeof inReference[selectorName] === 'object' ||
979
+ Array.isArray(inReference[selectorName]))
980
+ continue;
981
+
982
+ result += '<w:Selector Name="' + selectorName + '">' + inReference[selectorName].toString() + '</w:Selector>';
983
+ }
984
+
985
+ result += '</w:SelectorSet></a:ReferenceParameters></r:' + referenceName + '>';
986
+ return result;
987
+ }
988
+
989
+ // Convert a byte array of SID into string
990
+ function GetSidString(sid) {
991
+ var r = "S-" + sid.charCodeAt(0) + "-" + sid.charCodeAt(7);
992
+ for (var i = 2; i < (sid.length / 4) ; i++) r += "-" + ReadIntX(sid, i * 4);
993
+ return r;
994
+ }
995
+
996
+ // Convert a SID readable string into bytes
997
+ function GetSidByteArray(sidString) {
998
+ if (!sidString || sidString == null) return null;
999
+ var sidParts = sidString.split('-');
1000
+
1001
+ // Make sure the SID has at least 4 parts and starts with 'S'
1002
+ if (sidParts.length < 4 || (sidParts[0] != 's' && sidParts[0] != 'S')) return null;
1003
+
1004
+ // Check that each part of the SID is really an integer
1005
+ for (var i = 1; i < sidParts.length; i++) { var y = parseInt(sidParts[i]); if (y != sidParts[i]) return null; sidParts[i] = y; }
1006
+
1007
+ // Version (8 bit) + Id count (8 bit) + 48 bit in big endian -- DO NOT use bitwise right shift operator. JavaScript converts the number into a 32 bit integer before shifting. In real world, it's highly likely this part is always 0.
1008
+ var r = String.fromCharCode(sidParts[1]) + String.fromCharCode(sidParts.length - 3) + ShortToStr(Math.floor(sidParts[2] / Math.pow(2, 32))) + IntToStr((sidParts[2]) & 0xFFFF);
1009
+
1010
+ // the rest are in 32 bit in little endian
1011
+ for (var i = 3; i < sidParts.length; i++) r += IntToStrX(sidParts[i]);
1012
+ return r;
1013
+ }
1014
+
1015
+ return obj;
1016
+}
1017
+
1018
+module.exports = AmtStackCreateService;
meshagent.js
+1
-1
@@ -73,7 +73,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
73
if (typeof msg == 'object') { msg = msg.toString('binary'); } // TODO: Could change this entire method to use Buffer instead of binary string
74
75
if (obj.authenticated == 2) { // We are authenticated
76
- if (msg.charCodeAt(0) == 123) { processAgentData(msg); }
76
+ if ((obj.agentUpdate == null) && (msg.charCodeAt(0) == 123)) { processAgentData(msg); } // Only process JSON messages if meshagent update is not in progress
77
if (msg.length < 2) return;
78
var cmdid = obj.common.ReadShort(msg, 0);
79
if (cmdid == 11) { // MeshCommand_CoreModuleHash
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.1.8-g",
3
+ "version": "0.1.8-k",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",
public/images/link5.png
Binary files /dev/null and b/public/images/link5.png differ
views/default.handlebars
+23
-21
@@ -311,7 +311,7 @@
311
<tr>
312
<td style=width:auto valign=top>
313
<div id="p10title">
314
- <h1><span id=p10deviceName></span> - General</h1>
314
+ <h1>General - <span id=p10deviceName></span></h1>
315
</div>
316
<div id=p10html></div>
317
</td>
@@ -327,7 +327,7 @@
327
</div>
328
<div id=p11 style=display:none>
329
<div id="p11title">
330
- <h1 id=p11deviceNameHeader><span id=p11deviceName></span> - Desktop</h1>
330
+ <h1 id=p11deviceNameHeader>Desktop - <span id=p11deviceName></span></h1>
331
</div>
332
<div id="p14warning" style='max-width:100%;display:none;cursor:pointer;margin-bottom:5px' onclick="showFeaturesDlg()">
333
<div class=icon2 style="float:left;margin:7px"></div>
@@ -406,7 +406,7 @@
406
</table>
407
</div>
408
<div id=p12 style=display:none>
409
- <div id="p12title"><h1><span id=p12deviceName></span> - Terminal</h1></div>
409
+ <div id="p12title"><h1>Terminal - <span id=p12deviceName></span></h1></div>
410
<div id="p12warning" style='max-width:100%;display:none;cursor:pointer;margin-bottom:5px' onclick=showFeaturesDlg()>
411
<div class="icon2" style="float:left;margin:7px"></div>
412
<div style='width:auto;border-radius:8px;padding:8px;background-color:lightsalmon'>Intel® AMT Redirection port or KVM feature is disabled<span id="p14warninga">, click here to enable it.</span></div>
@@ -461,7 +461,7 @@
461
</table>
462
</div>
463
<div id=p13 style=display:none>
464
- <div id="p13title"><h1><span id=p13deviceName></span> - Files</h1></div>
464
+ <div id="p13title"><h1>Files - <span id=p13deviceName></span></h1></div>
465
<table id="p13toolbar" style="width: 100%" cellpadding="0" cellspacing="0">
466
<tr>
467
<td style="background-color:#C0C0C0;border-bottom:2px solid black;padding:2px">
@@ -518,11 +518,11 @@
518
</table>
519
</div>
520
<div id=p14 style=display:none>
521
- <div id="p14title"><h1><span id=p14deviceName></span> - Intel® AMT</h1></div>
521
+ <div id="p14title"><h1>Intel® AMT - <span id=p14deviceName></span></h1></div>
522
<iframe id=p14iframe style="width:100%;height:650px;border:0;overflow:hidden" src="/commander.htm"></iframe>
523
</div>
524
<div id=p15 style=display:none>
525
- <div id="p15title"><h1><span id=p15deviceName></span> - Console</h1></div>
525
+ <div id="p15title"><h1>Console - <span id=p15deviceName></span></h1></div>
526
<table cellpadding=0 cellspacing=0 style="width:100%;padding:0px;padding:0px;margin-top:0px">
527
<tr>
528
<td style=background:#C0C0C0>
@@ -559,7 +559,7 @@
559
</table>
560
</div>
561
<div id=p16 style=display:none>
562
- <div id="p16title"><h1><span id=p16deviceName></span> - Events</h1></div>
562
+ <div id="p16title"><h1>Events - <span id=p16deviceName></span></h1></div>
563
<div style=width:100%;height:24px;background-color:#d3d9d6;margin-bottom:4px>
564
<div class=style7 style=width:16px;height:100%;float:left> </div>
565
<div class=h1 style=height:100%;float:left> </div>
@@ -2116,20 +2116,22 @@
2116
if (x == '') {
2117
for (var d in nodes) { nodes[d].v = true; }
2118
} else {
2119
- var rs = x.split(/\s+/).join('|'), rx = new RegExp(rs);
2120
- for (var d in nodes) {
2121
- nodes[d].v = (rx.test(nodes[d].name.toLowerCase())) || (nodes[d].rnamel != null && rx.test(nodes[d].rnamel.toLowerCase()));
2122
- if ((nodes[d].v == false) && nodes[d].tags) {
2123
- for (var s in nodes[d].tags) {
2124
- if (rx.test(nodes[d].tags[s].toLowerCase())) {
2125
- nodes[d].v = true;
2126
- break;
2127
- } else {
2128
- nodes[d].v = false;
2119
+ try {
2120
+ var rs = x.split(/\s+/).join('|'), rx = new RegExp(rs); // In some cases (like +), this can throw an exception.
2121
+ for (var d in nodes) {
2122
+ nodes[d].v = (rx.test(nodes[d].name.toLowerCase())) || (nodes[d].rnamel != null && rx.test(nodes[d].rnamel.toLowerCase()));
2123
+ if ((nodes[d].v == false) && nodes[d].tags) {
2124
+ for (var s in nodes[d].tags) {
2125
+ if (rx.test(nodes[d].tags[s].toLowerCase())) {
2126
+ nodes[d].v = true;
2127
+ break;
2128
+ } else {
2129
+ nodes[d].v = false;
2130
+ }
2131
}
2132
}
2133
}
2132
- }
2134
+ } catch (ex) { for (var d in nodes) { nodes[d].v = true; } }
2135
}
2136
updateDevices();
2137
}
@@ -2819,7 +2821,7 @@
2821
// Add node name
2822
var nname = EscapeHtml(node.name);
2823
if (nname.length == 0) { nname = '<i>None</i>'; }
2822
- if ((meshrights & 4) != 0) { nname = '<span onclick=showEditNodeValueDialog(0) style=cursor:pointer>' + nname + '</span>'; }
2824
+ if ((meshrights & 4) != 0) { nname = '<span title="Click here to edit the server-side device name" onclick=showEditNodeValueDialog(0) style=cursor:pointer>' + nname + ' <img src="images/link5.png" /></span>'; }
2825
QH('p10deviceName', nname);
2826
QH('p11deviceName', nname);
2827
QH('p12deviceName', nname);
@@ -4084,7 +4086,7 @@
4086
QV('p13bigfail', false);
4087
QV('p13bigok', false);
4088
} else {
4087
- p13dragtimer = setTimeout("QV('p13bigfail',false);QV('p13bigok',false);p13dragtimer=null;", 200);
4089
+ p13dragtimer = setTimeout(function () { QV('p13bigfail',false); QV('p13bigok',false); p13dragtimer=null; }, 10);
4090
}
4091
}
4092
@@ -5041,7 +5043,7 @@
5043
QV('bigok', false);
5044
//QV('p5fileCatchAllInput', false);
5045
} else {
5044
- p5dragtimer = setTimeout("QV('bigfail',false);QV('bigok',false);p5dragtimer=null;", 200);
5046
+ p5dragtimer = setTimeout(function () { QV('bigfail',false); QV('bigok',false); p5dragtimer=null; }, 10);
5047
}
5048
}
5049