Slim down meshcore, removed WSMAN from agent.
Ylian Saint-Hilaire committed
Oct 27, 2020 at 23:55 UTC
e3ae2733afa20ea1599a6e85e3d17865196f28e5
13 files changed
+511
-3341
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/meshcmd.js
+1
-1
@@ -1161,7 +1161,7 @@ function configureAmt2() {
1161
console.log("Unable to get Intel AMT UUID: " + apfarg.clientuuid);
1162
exit(1); return;
1163
} else {
1164
- settings.apftunnel = require('apfclient')({ debug: (settings.debuglevel > 0) }, apfarg);
1164
+ settings.apftunnel = require('amt-apfclient')({ debug: (settings.debuglevel > 0) }, apfarg);
1165
settings.apftunnel.onJsonControl = configureJsonControl;
1166
settings.apftunnel.onChannelClosed = function () { exit(0); }
1167
try {
agents/meshcore.js
+16
-103
@@ -213,7 +213,7 @@ function createMeshCore(agent) {
213
if (amt == null) return;
214
var func = function amtStateFunc(state) { if (state != null) { amtStateFunc.pipe._send({ cmd: 'amtstate', value: state }); } }
215
func.pipe = this;
216
- amt.getAmtInfo(func);
216
+ amt.getMeiState(11, func);
217
break;
218
case 'sessions':
219
this._send({ cmd: 'sessions', sessions: tunnelUserCount });
@@ -408,7 +408,6 @@ function createMeshCore(agent) {
408
var wifiScannerLib = null;
409
var wifiScanner = null;
410
var networkMonitor = null;
411
- var amtscanner = null;
411
var nextTunnelIndex = 1;
412
var apftunnel = null;
413
var tunnelUserCount = { terminal: {}, files: {}, tcp: {}, udp: {}, msg: {} }; // List of userid->count sessions for terminal, files and TCP/UDP routing
@@ -471,22 +470,6 @@ function createMeshCore(agent) {
470
471
mesh.DAIPC = obj.DAIPC;
472
474
- /*
475
- var AMTScanner = require("AMTScanner");
476
- var scan = new AMTScanner();
477
-
478
- scan.on("found", function (data) {
479
- if (typeof data === 'string') {
480
- console.log(data);
481
- } else {
482
- console.log(JSON.stringify(data, null, " "));
483
- }
484
- });
485
- scan.scan("10.2.55.140", 1000);
486
- scan.scan("10.2.55.139-10.2.55.145", 1000);
487
- scan.scan("10.2.55.128/25", 2000);
488
- */
489
-
473
/*
474
// Try to load up the network monitor
475
try {
@@ -497,13 +480,6 @@ function createMeshCore(agent) {
480
} catch (e) { networkMonitor = null; }
481
*/
482
500
- // Try to load up the Intel AMT scanner
501
- try {
502
- var AMTScannerModule = require('amt-scanner');
503
- amtscanner = new AMTScannerModule();
504
- //amtscanner.on('found', function (data) { if (typeof data != 'string') { data = JSON.stringify(data, null, " "); } sendConsoleText(data); });
505
- } catch (e) { amtscanner = null; }
506
-
483
// Fetch the SMBios Tables
484
var SMBiosTables = null;
485
var SMBiosTablesRaw = null;
@@ -547,7 +523,7 @@ function createMeshCore(agent) {
523
mesh.SendCommand(meshCoreObj);
524
});
525
amt.onStateChange = function (state) { if (state == 2) { sendPeriodicServerUpdate(1); } }
550
- amt.start();
526
+ amt.reset();
527
}
528
}
529
});
@@ -1086,7 +1062,7 @@ function createMeshCore(agent) {
1062
case 'amtconfig': {
1063
// Perform Intel AMT activation and/or configuration
1064
if ((apftunnel != null) || (amt == null) || (typeof data.user != 'string') || (typeof data.pass != 'string')) break;
1089
- getMeiState(15, function (state) {
1065
+ amt.getMeiState(15, function (state) {
1066
if ((apftunnel != null) || (amt == null)) return;
1067
if ((state == null) || (state.ProvisioningState == null)) return;
1068
if ((state.UUID == null) || (state.UUID.length != 36)) return; // Bad UUID
@@ -1102,10 +1078,10 @@ function createMeshCore(agent) {
1078
meiState: state // MEI state will be passed to MPS server
1079
};
1080
addAmtEvent('LMS tunnel start.');
1105
- apftunnel = require('apfclient')({ debug: false }, apfarg);
1081
+ apftunnel = require('amt-apfclient')({ debug: false }, apfarg);
1082
apftunnel.onJsonControl = function (data) {
1083
if (data.action == 'console') { addAmtEvent(data.msg); } // Add console message to AMT event log
1108
- if (data.action == 'mestate') { getMeiState(15, function (state) { apftunnel.updateMeiState(state); }); } // Update the MEI state
1084
+ if (data.action == 'mestate') { amt.getMeiState(15, function (state) { apftunnel.updateMeiState(state); }); } // Update the MEI state
1085
if (data.action == 'deactivate') { // Request CCM deactivation
1086
var amtMeiModule, amtMei;
1087
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { if (apftunnel) apftunnel.sendMeiDeactivationState(1); return; }
@@ -2614,8 +2590,9 @@ function createMeshCore(agent) {
2590
var response = null;
2591
switch (cmd) {
2592
case 'help': { // Displays available commands
2617
- var fin = '', f = '', availcommands = 'amtconfig,amtevents,coredump,service,fdsnapshot,fdcount,startupoptions,alert,agentsize,versions,help,info,osinfo,args,print,type,dbkeys,dbget,dbset,dbcompact,eval,parseuri,httpget,nwslist,plugin,wsconnect,wssend,wsclose,notify,ls,ps,kill,amt,netinfo,location,power,wakeonlan,setdebug,smbios,rawsmbios,toast,lock,users,sendcaps,openurl,getscript,getclip,setclip,log,av,cpuinfo,sysinfo,apf,scanwifi,scanamt,wallpaper,agentmsg';
2593
+ var fin = '', f = '', availcommands = 'coredump,service,fdsnapshot,fdcount,startupoptions,alert,agentsize,versions,help,info,osinfo,args,print,type,dbkeys,dbget,dbset,dbcompact,eval,parseuri,httpget,nwslist,plugin,wsconnect,wssend,wsclose,notify,ls,ps,kill,netinfo,location,power,wakeonlan,setdebug,smbios,rawsmbios,toast,lock,users,sendcaps,openurl,getscript,getclip,setclip,log,av,cpuinfo,sysinfo,apf,scanwifi,wallpaper,agentmsg';
2594
if (process.platform == 'win32') { availcommands += ',safemode,wpfhwacceleration,uac'; }
2595
+ if (amt != null) { availcommands += ',amt,amtconfig,amtevents'; }
2596
if (process.platform != 'freebsd') { availcommands += ',vm';}
2597
if (require('MeshAgent').maxKvmTileSize != null) { availcommands += ',kvmmode'; }
2598
try { require('zip-reader'); availcommands += ',zip,unzip'; } catch (e) { }
@@ -3431,13 +3408,13 @@ function createMeshCore(agent) {
3408
}
3409
case 'amt': { // Show Intel AMT status
3410
if (amt != null) {
3434
- amt.getAmtInfo(function (state) {
3435
- var resp = 'Intel AMT not detected.';
3411
+ amt.getMeiState(9, function (state) {
3412
+ var resp = "Intel AMT not detected.";
3413
if (state != null) { resp = objToString(state, 0, ' ', true); }
3414
sendConsoleText(resp, sessionid);
3415
});
3416
} else {
3440
- response = 'Intel AMT not detected.';
3417
+ response = "Intel AMT not detected.";
3418
}
3419
break;
3420
}
@@ -3489,32 +3466,6 @@ function createMeshCore(agent) {
3466
} else { response = "Wifi module not present."; }
3467
break;
3468
}
3492
- case 'scanamt': {
3493
- if (amtscanner != null) {
3494
- if (args['_'].length != 1) {
3495
- response = 'Usage examples:\r\n scanamt 1.2.3.4\r\n scanamt 1.2.3.0-1.2.3.255\r\n scanamt 1.2.3.0/24\r\n'; // Display correct command usage
3496
- } else {
3497
- response = 'Scanning: ' + args['_'][0] + '...';
3498
- amtscanner.scan(args['_'][0], 2000, function (data) {
3499
- if (data.length > 0) {
3500
- var r = '', pstates = ['NotActivated', 'InActivation', 'Activated'];
3501
- for (var i in data) {
3502
- var x = data[i];
3503
- if (r != '') { r += '\r\n'; }
3504
- r += x.address + ' - Intel AMT v' + x.majorVersion + '.' + x.minorVersion;
3505
- if (x.provisioningState < 3) { r += (', ' + pstates[x.provisioningState]); }
3506
- if (x.provisioningState == 2) { r += (', ' + x.openPorts.join(', ')); }
3507
- r += '.';
3508
- }
3509
- } else {
3510
- r = 'No Intel AMT found.';
3511
- }
3512
- sendConsoleText(r);
3513
- });
3514
- }
3515
- } else { response = "Intel AMT scanner module not present."; }
3516
- break;
3517
- }
3469
case 'modules': {
3470
response = JSON.stringify(addedModules);
3471
break;
@@ -3570,9 +3521,9 @@ function createMeshCore(agent) {
3521
break;
3522
}
3523
case 'amtconfig': {
3524
+ if (amt == null) { response = "Intel AMT not detected."; break; }
3525
if (apftunnel != null) { response = "Intel AMT server tunnel already active"; break; }
3574
- if (amt == null) { response = "No Intel AMT support delected"; break; }
3575
- getMeiState(15, function (state) {
3526
+ amt.getMeiState(15, function (state) {
3527
var rx = '';
3528
if ((state == null) || (state.ProvisioningState == null)) { rx = "Intel AMT not ready for configuration."; } else {
3529
var apfarg = {
@@ -3590,10 +3541,10 @@ function createMeshCore(agent) {
3541
rx = "Unable to get Intel AMT UUID";
3542
} else {
3543
addAmtEvent('User LMS tunnel start.');
3593
- apftunnel = require('apfclient')({ debug: false }, apfarg);
3544
+ apftunnel = require('amt-apfclient')({ debug: false }, apfarg);
3545
apftunnel.onJsonControl = function (data) {
3546
if (data.action == 'console') { addAmtEvent(data.msg); require('MeshAgent').SendCommand({ action: 'msg', type: 'console', value: data.msg }); } // Display a console message
3596
- if (data.action == 'mestate') { getMeiState(15, function (state) { apftunnel.updateMeiState(state); }); } // Update the MEI state
3547
+ if (data.action == 'mestate') { amt.getMeiState(15, function (state) { apftunnel.updateMeiState(state); }); } // Update the MEI state
3548
if (data.action == 'deactivate') { // Request CCM deactivation
3549
var amtMeiModule, amtMei;
3550
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { apftunnel.sendMeiDeactivationState(1); return; }
@@ -3637,7 +3588,7 @@ function createMeshCore(agent) {
3588
if ((apfarg.clientuuid == null) || (apfarg.clientuuid.length != 36)) {
3589
response = "Unable to get Intel AMT UUID: " + apfarg.clientuuid;
3590
} else {
3640
- apftunnel = require('apfclient')({ debug: false }, apfarg);
3591
+ apftunnel = require('amt-apfclient')({ debug: false }, apfarg);
3592
apftunnel.onJsonControl = function (data) {
3593
if (data.action == 'console') { require('MeshAgent').SendCommand({ action: 'msg', type: 'console', value: data.msg }); }
3594
if (data.action == 'close') { try { apftunnel.disconnect(); } catch (e) { } apftunnel = null; }
@@ -3761,7 +3712,7 @@ function createMeshCore(agent) {
3712
3713
if ((flags & 1) && (amt != null)) {
3714
// If we have a connected MEI, get Intel ME information
3764
- amt.getAmtInfo(function (meinfo) {
3715
+ amt.getMeiState(11, function (meinfo) {
3716
try {
3717
if (meinfo == null) return;
3718
var intelamt = {};
@@ -3871,44 +3822,6 @@ function createMeshCore(agent) {
3822
s.data = onWebSocketData;
3823
}
3824
3874
- // Get Intel MEI State in a flexible way
3875
- // Flags: 1 = Versions, 2 = OsAdmin, 4 = Hashes, 8 = Network
3876
- function getMeiState(flags, func) {
3877
- var amtMeiModule, amtMei;
3878
- try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { func(null); return; }
3879
- amtMei.on('error', function (e) { func(null); return; });
3880
- try {
3881
- var amtMeiTmpState = { OsHostname: require('os').hostname(), Flags: 0 }; // Flags: 1=EHBC, 2=CCM, 4=ACM
3882
- amtMei.getProtocolVersion(function (result) { if (result != null) { amtMeiTmpState.MeiVersion = result; } });
3883
- if ((flags & 1) != 0) { amtMei.getVersion(function (result) { if (result) { amtMeiTmpState.Versions = {}; for (var version in result.Versions) { amtMeiTmpState.Versions[result.Versions[version].Description] = result.Versions[version].Version; } } }); }
3884
- amtMei.getProvisioningMode(function (result) { if (result) { amtMeiTmpState.ProvisioningMode = result.mode; } });
3885
- amtMei.getProvisioningState(function (result) { if (result) { amtMeiTmpState.ProvisioningState = result.state; } }); // 0: "Not Activated (Pre)", 1: "Not Activated (In)", 2: "Activated"
3886
- amtMei.getEHBCState(function (result) { if ((result != null) && (result.EHBC == true)) { amtMeiTmpState.Flags += 1; } });
3887
- amtMei.getControlMode(function (result) { if (result != null) { if (result.controlMode == 1) { amtMeiTmpState.Flags += 2; } if (result.controlMode == 2) { amtMeiTmpState.Flags += 4; } } }); // Flag 2 = CCM, 4 = ACM
3888
- //amtMei.getMACAddresses(function (result) { if (result) { amtMeiTmpState.mac = result; } });
3889
- if ((flags & 8) != 0) {
3890
- amtMei.getLanInterfaceSettings(0, function (result) {
3891
- if (result) {
3892
- amtMeiTmpState.net0 = result;
3893
- var fqdn = null, interfaces = require('os').networkInterfaces(); // Look for the DNS suffix for the Intel AMT Ethernet interface
3894
- for (var i in interfaces) { for (var j in interfaces[i]) { if ((interfaces[i][j].mac == result.mac) && (interfaces[i][j].fqdn != null) && (interfaces[i][j].fqdn != '')) { amtMeiTmpState.OsDnsSuffix = interfaces[i][j].fqdn; } } }
3895
- }
3896
- });
3897
- amtMei.getLanInterfaceSettings(1, function (result) { if (result) { amtMeiTmpState.net1 = result; } });
3898
- }
3899
- amtMei.getUuid(function (result) { if ((result != null) && (result.uuid != null)) { amtMeiTmpState.UUID = result.uuid; } });
3900
- if ((flags & 2) != 0) { amtMei.getLocalSystemAccount(function (x) { if ((x != null) && x.user && x.pass) { amtMeiTmpState.OsAdmin = { user: x.user, pass: x.pass }; } }); }
3901
- amtMei.getDnsSuffix(function (result) { if (result != null) { amtMeiTmpState.DnsSuffix = result; } if ((flags & 4) == 0) { if (func != null) { func(amtMeiTmpState); } } });
3902
- if ((flags & 4) != 0) {
3903
- amtMei.getHashHandles(function (handles) {
3904
- if ((handles != null) && (handles.length > 0)) { amtMeiTmpState.Hashes = []; } else { func(amtMeiTmpState); }
3905
- var exitOnCount = handles.length;
3906
- for (var i = 0; i < handles.length; ++i) { this.getCertHashEntry(handles[i], function (hashresult) { amtMeiTmpState.Hashes.push(hashresult); if (--exitOnCount == 0) { if (func != null) { func(amtMeiTmpState); } } }); }
3907
- });
3908
- }
3909
- } catch (e) { if (func != null) { func(null); } return; }
3910
- }
3911
-
3825
return obj;
3826
}
3827
agents/modules_meshcmd/amt-apfclient.js
renamed
agents/modules_meshcore/amt-apfclient.js
renamed
+456
-456
@@ -1,457 +1,457 @@
1
-/*
2
-Copyright 2018-2020 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 APF/CIRA Client for Duktape
19
-* @author Joko Sastriawan & Ylian Saint-Hilaire
20
-* @copyright Intel Corporation 2020
21
-* @license Apache-2.0
22
-* @version v0.0.2
23
-*/
24
-
25
-function CreateAPFClient(parent, args) {
26
- if ((args.clientuuid == null) || (args.clientuuid.length != 36)) return null; // Require a UUID if this exact length
27
-
28
- var obj = {};
29
- obj.parent = parent;
30
- obj.args = args;
31
- obj.http = require('http');
32
- obj.net = require('net');
33
- obj.forwardClient = null;
34
- obj.downlinks = {};
35
- obj.pfwd_idx = 0;
36
- obj.timer = null; // Keep alive timer
37
-
38
- // obj.onChannelClosed
39
- // obj.onJsonControl
40
-
41
- // Function copied from common.js
42
- function ReadInt(v, p) { return (v.charCodeAt(p) * 0x1000000) + (v.charCodeAt(p + 1) << 16) + (v.charCodeAt(p + 2) << 8) + v.charCodeAt(p + 3); }; // We use "*0x1000000" instead of "<<24" because the shift converts the number to signed int32.
43
- function IntToStr(v) { return String.fromCharCode((v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF); };
44
- function hex2rstr(d) { var r = '', m = ('' + d).match(/../g), t; while (t = m.shift()) { r += String.fromCharCode('0x' + t); } return r; };
45
- function char2hex(i) { return (i + 0x100).toString(16).substr(-2).toUpperCase(); }; // Convert decimal to hex
46
- function rstr2hex(input) { var r = '', i; for (i = 0; i < input.length; i++) { r += char2hex(input.charCodeAt(i)); } return r; }; // Convert a raw string to a hex string
47
- function d2h(d) { return (d / 256 + 1 / 512).toString(16).substring(2, 4); }
48
- function buf2hex(input) { var r = '', i; for (i = 0; i < input.length; i++) { r += d2h(input[i]); } return r; };
49
- function Debug(str) { if (obj.parent.debug) { console.log(str); } }
50
- function guidToStr(g) { return g.substring(6, 8) + g.substring(4, 6) + g.substring(2, 4) + g.substring(0, 2) + "-" + g.substring(10, 12) + g.substring(8, 10) + "-" + g.substring(14, 16) + g.substring(12, 14) + "-" + g.substring(16, 20) + "-" + g.substring(20); }
51
- function strToGuid(s) { s = s.replace(/-/g, ''); var ret = s.substring(6, 8) + s.substring(4, 6) + s.substring(2, 4) + s.substring(0, 2) + s.substring(10, 12) + s.substring(8, 10) + s.substring(14, 16) + s.substring(12, 14) + s.substring(16, 20) + s.substring(20); return ret; }
52
- function binzerostring(len) { var res = ''; for (var l = 0; l < len; l++) { res += String.fromCharCode(0 & 0xFF); } return res; }
53
-
54
- // CIRA state
55
- var CIRASTATE = {
56
- INITIAL: 0,
57
- PROTOCOL_VERSION_SENT: 1,
58
- AUTH_SERVICE_REQUEST_SENT: 2,
59
- AUTH_REQUEST_SENT: 3,
60
- PFWD_SERVICE_REQUEST_SENT: 4,
61
- GLOBAL_REQUEST_SENT: 5,
62
- FAILED: -1
63
- }
64
- obj.cirastate = CIRASTATE.INITIAL;
65
-
66
- // REDIR state
67
- var REDIR_TYPE = {
68
- REDIR_UNKNOWN: 0,
69
- REDIR_SOL: 1,
70
- REDIR_KVM: 2,
71
- REDIR_IDER: 3
72
- }
73
-
74
- // redirection start command
75
- obj.RedirectStartSol = String.fromCharCode(0x10, 0x00, 0x00, 0x00, 0x53, 0x4F, 0x4C, 0x20);
76
- obj.RedirectStartKvm = String.fromCharCode(0x10, 0x01, 0x00, 0x00, 0x4b, 0x56, 0x4d, 0x52);
77
- obj.RedirectStartIder = String.fromCharCode(0x10, 0x00, 0x00, 0x00, 0x49, 0x44, 0x45, 0x52);
78
-
79
- // Intel AMT forwarded port list for non-TLS mode
80
- //var pfwd_ports = [16992, 623, 16994, 5900];
81
- var pfwd_ports = [ 16992, 16993 ];
82
-
83
- // protocol definitions
84
- var APFProtocol = {
85
- UNKNOWN: 0,
86
- DISCONNECT: 1,
87
- SERVICE_REQUEST: 5,
88
- SERVICE_ACCEPT: 6,
89
- USERAUTH_REQUEST: 50,
90
- USERAUTH_FAILURE: 51,
91
- USERAUTH_SUCCESS: 52,
92
- GLOBAL_REQUEST: 80,
93
- REQUEST_SUCCESS: 81,
94
- REQUEST_FAILURE: 82,
95
- CHANNEL_OPEN: 90,
96
- CHANNEL_OPEN_CONFIRMATION: 91,
97
- CHANNEL_OPEN_FAILURE: 92,
98
- CHANNEL_WINDOW_ADJUST: 93,
99
- CHANNEL_DATA: 94,
100
- CHANNEL_CLOSE: 97,
101
- PROTOCOLVERSION: 192,
102
- KEEPALIVE_REQUEST: 208,
103
- KEEPALIVE_REPLY: 209,
104
- KEEPALIVE_OPTIONS_REQUEST: 210,
105
- KEEPALIVE_OPTIONS_REPLY: 211,
106
- JSON_CONTROL: 250 // This is a Mesh specific command that sends JSON to and from the MPS server.
107
- }
108
-
109
- var APFDisconnectCode = {
110
- HOST_NOT_ALLOWED_TO_CONNECT: 1,
111
- PROTOCOL_ERROR: 2,
112
- KEY_EXCHANGE_FAILED: 3,
113
- RESERVED: 4,
114
- MAC_ERROR: 5,
115
- COMPRESSION_ERROR: 6,
116
- SERVICE_NOT_AVAILABLE: 7,
117
- PROTOCOL_VERSION_NOT_SUPPORTED: 8,
118
- HOST_KEY_NOT_VERIFIABLE: 9,
119
- CONNECTION_LOST: 10,
120
- BY_APPLICATION: 11,
121
- TOO_MANY_CONNECTIONS: 12,
122
- AUTH_CANCELLED_BY_USER: 13,
123
- NO_MORE_AUTH_METHODS_AVAILABLE: 14,
124
- INVALID_CREDENTIALS: 15,
125
- CONNECTION_TIMED_OUT: 16,
126
- BY_POLICY: 17,
127
- TEMPORARILY_UNAVAILABLE: 18
128
- }
129
-
130
- var APFChannelOpenFailCodes = {
131
- ADMINISTRATIVELY_PROHIBITED: 1,
132
- CONNECT_FAILED: 2,
133
- UNKNOWN_CHANNEL_TYPE: 3,
134
- RESOURCE_SHORTAGE: 4,
135
- }
136
-
137
- var APFChannelOpenFailureReasonCode = {
138
- AdministrativelyProhibited: 1,
139
- ConnectFailed: 2,
140
- UnknownChannelType: 3,
141
- ResourceShortage: 4,
142
- }
143
-
144
- obj.onSecureConnect = function onSecureConnect(resp, ws, head) {
145
- Debug("APF Secure WebSocket connected.");
146
- //console.log(JSON.stringify(resp));
147
- obj.forwardClient.tag = { accumulator: [] };
148
- obj.forwardClient.ws = ws;
149
- obj.forwardClient.ws.on('end', function () {
150
- Debug("APF: Connection is closing.");
151
- if (obj.timer != null) { clearInterval(obj.timer); obj.timer = null; }
152
- if (obj.onChannelClosed) { obj.onChannelClosed(obj); }
153
- });
154
-
155
- obj.forwardClient.ws.on('data', function (data) {
156
- obj.forwardClient.tag.accumulator += hex2rstr(buf2hex(data));
157
- try {
158
- var len = 0;
159
- do {
160
- len = ProcessData(obj.forwardClient);
161
- if (len > 0) { obj.forwardClient.tag.accumulator = obj.forwardClient.tag.accumulator.slice(len); }
162
- if (obj.cirastate == CIRASTATE.FAILED) {
163
- Debug("APF: in a failed state, destroying socket.");
164
- obj.forwardClient.ws.end();
165
- }
166
- } while (len > 0);
167
- } catch (ex) { Debug(ex); }
168
- });
169
-
170
- obj.forwardClient.ws.on('error', function (e) {
171
- Debug("APF: Connection error, ending connecting.");
172
- if (obj.timer != null) { clearInterval(obj.timer); obj.timer = null; }
173
- });
174
-
175
- obj.state = CIRASTATE.INITIAL;
176
- if ((typeof obj.args.conntype == 'number') && (obj.args.conntype != 0)) {
177
- SendJsonControl(obj.forwardClient.ws, { action: 'connType', value: obj.args.conntype });
178
- if (obj.args.meiState != null) { SendJsonControl(obj.forwardClient.ws, { action: 'meiState', value: obj.args.meiState }); }
179
- }
180
- SendProtocolVersion(obj.forwardClient.ws, obj.args.clientuuid);
181
- SendServiceRequest(obj.forwardClient.ws, 'auth@amt.intel.com');
182
- }
183
-
184
- obj.updateMeiState = function (state) { SendJsonControl(obj.forwardClient.ws, { action: 'meiState', value: state }); }
185
- obj.sendMeiDeactivationState = function (state) { SendJsonControl(obj.forwardClient.ws, { action: 'deactivate', value: state }); }
186
-
187
- function SendJsonControl(socket, o) {
188
- var data = JSON.stringify(o)
189
- socket.write(String.fromCharCode(APFProtocol.JSON_CONTROL) + IntToStr(data.length) + data);
190
- Debug("APF: Send JSON control: " + data);
191
- }
192
-
193
- function SendProtocolVersion(socket, uuid) {
194
- var data = String.fromCharCode(APFProtocol.PROTOCOLVERSION) + IntToStr(1) + IntToStr(0) + IntToStr(0) + hex2rstr(strToGuid(uuid)) + binzerostring(64);
195
- socket.write(data);
196
- Debug("APF: Send protocol version 1 0 " + uuid);
197
- obj.cirastate = CIRASTATE.PROTOCOL_VERSION_SENT;
198
- }
199
-
200
- function SendServiceRequest(socket, service) {
201
- var data = String.fromCharCode(APFProtocol.SERVICE_REQUEST) + IntToStr(service.length) + service;
202
- socket.write(data);
203
- Debug("APF: Send service request " + service);
204
- if (service == 'auth@amt.intel.com') {
205
- obj.cirastate = CIRASTATE.AUTH_SERVICE_REQUEST_SENT;
206
- } else if (service == 'pfwd@amt.intel.com') {
207
- obj.cirastate = CIRASTATE.PFWD_SERVICE_REQUEST_SENT;
208
- }
209
- }
210
-
211
- function SendUserAuthRequest(socket, user, pass) {
212
- var service = "pfwd@amt.intel.com";
213
- var data = String.fromCharCode(APFProtocol.USERAUTH_REQUEST) + IntToStr(user.length) + user + IntToStr(service.length) + service;
214
- //password auth
215
- data += IntToStr(8) + 'password';
216
- data += binzerostring(1) + IntToStr(pass.length) + pass;
217
- socket.write(data);
218
- Debug("APF: Send username password authentication to MPS");
219
- obj.cirastate = CIRASTATE.AUTH_REQUEST_SENT;
220
- }
221
-
222
- function SendGlobalRequestPfwd(socket, amthostname, amtport) {
223
- var tcpipfwd = 'tcpip-forward';
224
- var data = String.fromCharCode(APFProtocol.GLOBAL_REQUEST) + IntToStr(tcpipfwd.length) + tcpipfwd + binzerostring(1, 1);
225
- data += IntToStr(amthostname.length) + amthostname + IntToStr(amtport);
226
- socket.write(data);
227
- Debug("APF: Send tcpip-forward " + amthostname + ":" + amtport);
228
- obj.cirastate = CIRASTATE.GLOBAL_REQUEST_SENT;
229
- }
230
-
231
- function SendKeepAliveRequest(socket) {
232
- socket.write(String.fromCharCode(APFProtocol.KEEPALIVE_REQUEST) + IntToStr(255));
233
- Debug("APF: Send keepalive request");
234
- }
235
-
236
- function SendKeepAliveReply(socket, cookie) {
237
- socket.write(String.fromCharCode(APFProtocol.KEEPALIVE_REPLY) + IntToStr(cookie));
238
- Debug("APF: Send keepalive reply");
239
- }
240
-
241
- function ProcessData(socket) {
242
- var cmd = socket.tag.accumulator.charCodeAt(0);
243
- var len = socket.tag.accumulator.length;
244
- var data = socket.tag.accumulator;
245
- if (len == 0) { return 0; }
246
-
247
- // Respond to MPS according to obj.cirastate
248
- switch (cmd) {
249
- case APFProtocol.SERVICE_ACCEPT: {
250
- var slen = ReadInt(data, 1), service = data.substring(5, 6 + slen);
251
- Debug("APF: Service request to " + service + " accepted.");
252
- if (service == 'auth@amt.intel.com') {
253
- if (obj.cirastate >= CIRASTATE.AUTH_SERVICE_REQUEST_SENT) {
254
- SendUserAuthRequest(socket.ws, obj.args.mpsuser, obj.args.mpspass);
255
- }
256
- } else if (service == 'pfwd@amt.intel.com') {
257
- if (obj.cirastate >= CIRASTATE.PFWD_SERVICE_REQUEST_SENT) {
258
- SendGlobalRequestPfwd(socket.ws, obj.args.clientname, pfwd_ports[obj.pfwd_idx++]);
259
- }
260
- }
261
- return 5 + slen;
262
- }
263
- case APFProtocol.REQUEST_SUCCESS: {
264
- if (len >= 5) {
265
- var port = ReadInt(data, 1);
266
- Debug("APF: Request to port forward " + port + " successful.");
267
- // iterate to pending port forward request
268
- if (obj.pfwd_idx < pfwd_ports.length) {
269
- SendGlobalRequestPfwd(socket.ws, obj.args.clientname, pfwd_ports[obj.pfwd_idx++]);
270
- } else {
271
- // no more port forward, now setup timer to send keep alive
272
- Debug("APF: Start keep alive for every " + obj.args.mpskeepalive + " ms.");
273
- obj.timer = setInterval(function () {
274
- SendKeepAliveRequest(obj.forwardClient.ws);
275
- }, obj.args.mpskeepalive);//
276
- }
277
- return 5;
278
- }
279
- Debug("APF: Request successful.");
280
- return 1;
281
- }
282
- case APFProtocol.USERAUTH_SUCCESS: {
283
- Debug("APF: User Authentication successful");
284
- // Send Pfwd service request
285
- SendServiceRequest(socket.ws, 'pfwd@amt.intel.com');
286
- return 1;
287
- }
288
- case APFProtocol.USERAUTH_FAILURE: {
289
- Debug("APF: User Authentication failed");
290
- obj.cirastate = CIRASTATE.FAILED;
291
- return 14;
292
- }
293
- case APFProtocol.KEEPALIVE_REQUEST: {
294
- Debug("APF: Keep Alive Request with cookie: " + ReadInt(data, 1));
295
- SendKeepAliveReply(socket.ws, ReadInt(data, 1));
296
- return 5;
297
- }
298
- case APFProtocol.KEEPALIVE_REPLY: {
299
- Debug("APF: Keep Alive Reply with cookie: " + ReadInt(data, 1));
300
- return 5;
301
- }
302
- // Channel management
303
- case APFProtocol.CHANNEL_OPEN: {
304
- // Parse CHANNEL OPEN request
305
- var p_res = parseChannelOpen(data);
306
- Debug("APF: CHANNEL_OPEN request: " + JSON.stringify(p_res));
307
- // Check if target port is in pfwd_ports
308
- if (pfwd_ports.indexOf(p_res.target_port) >= 0) {
309
- // Connect socket to that port
310
- var chan = obj.net.createConnection({ host: obj.args.clientaddress, port: p_res.target_port }, function () {
311
- //require('MeshAgent').SendCommand({ action: 'msg', type: 'console', value: "CHANNEL_OPEN-open" });
312
- // obj.downlinks[p_res.sender_chan].setEncoding('binary');//assume everything is binary, not interpreting
313
- SendChannelOpenConfirm(socket.ws, p_res);
314
- });
315
-
316
- // Setup flow control
317
- chan.maxInWindow = p_res.window_size; // Oddly, we are using the same window size as the other side.
318
- chan.curInWindow = 0;
319
-
320
- chan.on('data', function (ddata) {
321
- // Relay data to fordwardclient
322
- // TODO: Implement flow control
323
- SendChannelData(socket.ws, p_res.sender_chan, ddata);
324
- });
325
-
326
- chan.on('error', function (e) {
327
- //Debug("Downlink connection error: " + e);
328
- SendChannelOpenFailure(socket.ws, p_res);
329
- });
330
-
331
- chan.on('end', function () {
332
- var chan = obj.downlinks[p_res.sender_chan];
333
- if (chan != null) {
334
- Debug("Socket ends.");
335
- try { SendChannelClose(socket.ws, p_res.sender_chan); } catch (ex) { }
336
- delete obj.downlinks[p_res.sender_chan];
337
- }
338
- });
339
-
340
- obj.downlinks[p_res.sender_chan] = chan;
341
- } else {
342
- // Not a supported port, fail the connection
343
- SendChannelOpenFailure(socket.ws, p_res);
344
- }
345
- return p_res.len;
346
- }
347
- case APFProtocol.CHANNEL_OPEN_CONFIRMATION: {
348
- Debug("APF: CHANNEL_OPEN_CONFIRMATION");
349
- return 17;
350
- }
351
- case APFProtocol.CHANNEL_CLOSE: {
352
- var rcpt_chan = ReadInt(data, 1);
353
- Debug("APF: CHANNEL_CLOSE: " + rcpt_chan);
354
- try { obj.downlinks[rcpt_chan].end(); } catch (ex) { }
355
- return 5;
356
- }
357
- case APFProtocol.CHANNEL_DATA: {
358
- Debug("APF: CHANNEL_DATA: " + JSON.stringify(rstr2hex(data)));
359
- var rcpt_chan = ReadInt(data, 1);
360
- var chan_data_len = ReadInt(data, 5);
361
- var chan_data = data.substring(9, 9 + chan_data_len);
362
- var chan = obj.downlinks[rcpt_chan];
363
- if (chan != null) {
364
- chan.curInWindow += chan_data_len;
365
- try {
366
- chan.write(Buffer.from(chan_data, 'binary'), function () {
367
- Debug("Write completed.");
368
- // If the incoming window is over half used, send an adjust.
369
- if (this.curInWindow > (this.maxInWindow / 2)) { SendChannelWindowAdjust(socket.ws, rcpt_chan, this.curInWindow); this.curInWindow = 0; }
370
- });
371
- } catch (ex) { Debug("Cannot forward data to downlink socket."); }
372
- }
373
- return 9 + chan_data_len;
374
- }
375
- case APFProtocol.CHANNEL_WINDOW_ADJUST: {
376
- Debug("APF: CHANNEL_WINDOW_ADJUST");
377
- return 9;
378
- }
379
- case APFProtocol.JSON_CONTROL: {
380
- Debug("APF: JSON_CONTROL");
381
- var len = ReadInt(data, 1);
382
- if (obj.onJsonControl) { var o = null; try { o = JSON.parse(data.substring(5, 5 + len)); } catch (ex) { } if (o != null) { obj.onJsonControl(o); } }
383
- return 5 + len;
384
- }
385
- default: {
386
- Debug("CMD: " + cmd + " is not implemented.");
387
- obj.cirastate = CIRASTATE.FAILED;
388
- return 0;
389
- }
390
- }
391
- }
392
-
393
- function parseChannelOpen(data) {
394
- var result = { cmd: APFProtocol.CHANNEL_OPEN };
395
- var chan_type_slen = ReadInt(data, 1);
396
- result.chan_type = data.substring(5, 5 + chan_type_slen);
397
- result.sender_chan = ReadInt(data, 5 + chan_type_slen);
398
- result.window_size = ReadInt(data, 9 + chan_type_slen);
399
- var c_len = ReadInt(data, 17 + chan_type_slen);
400
- result.target_address = data.substring(21 + chan_type_slen, 21 + chan_type_slen + c_len);
401
- result.target_port = ReadInt(data, 21 + chan_type_slen + c_len);
402
- var o_len = ReadInt(data, 25 + chan_type_slen + c_len);
403
- result.origin_address = data.substring(29 + chan_type_slen + c_len, 29 + chan_type_slen + c_len + o_len);
404
- result.origin_port = ReadInt(data, 29 + chan_type_slen + c_len + o_len);
405
- result.len = 33 + chan_type_slen + c_len + o_len;
406
- return result;
407
- }
408
-
409
- function SendChannelOpenFailure(socket, chan_data) {
410
- socket.write(String.fromCharCode(APFProtocol.CHANNEL_OPEN_FAILURE) + IntToStr(chan_data.sender_chan) + IntToStr(2) + IntToStr(0) + IntToStr(0));
411
- Debug("APF: Send ChannelOpenFailure");
412
- }
413
-
414
- function SendChannelOpenConfirm(socket, chan_data) {
415
- socket.write(String.fromCharCode(APFProtocol.CHANNEL_OPEN_CONFIRMATION) + IntToStr(chan_data.sender_chan) + IntToStr(chan_data.sender_chan) + IntToStr(chan_data.window_size) + IntToStr(0xFFFFFFFF));
416
- Debug("APF: Send ChannelOpenConfirmation");
417
- }
418
-
419
- function SendChannelWindowAdjust(socket, chan, size) {
420
- socket.write(String.fromCharCode(APFProtocol.CHANNEL_WINDOW_ADJUST) + IntToStr(chan) + IntToStr(size));
421
- Debug("APF: Send ChannelWindowAdjust, channel: " + chan + ", size: " + size);
422
- }
423
-
424
- function SendChannelData(socket, chan, data) {
425
- socket.write(Buffer.concat([Buffer.from(String.fromCharCode(APFProtocol.CHANNEL_DATA) + IntToStr(chan) + IntToStr(data.length), 'binary'), data]));
426
- Debug("APF: Send ChannelData: " + data.toString('hex'));
427
- }
428
-
429
- function SendChannelClose(socket, chan) {
430
- socket.write(String.fromCharCode(APFProtocol.CHANNEL_CLOSE) + IntToStr(chan));
431
- Debug("APF: Send ChannelClose ");
432
- }
433
-
434
- obj.connect = function () {
435
- if (obj.forwardClient != null) {
436
- try { obj.forwardClient.ws.end(); } catch (ex) { Debug(ex); }
437
- //obj.forwardClient = null;
438
- }
439
- obj.cirastate = CIRASTATE.INITIAL;
440
- obj.pfwd_idx = 0;
441
-
442
- //obj.forwardClient = new obj.ws(obj.args.mpsurl, obj.tlsoptions);
443
- //obj.forwardClient.on("open", obj.onSecureConnect);
444
-
445
- var wsoptions = obj.http.parseUri(obj.args.mpsurl);
446
- wsoptions.rejectUnauthorized = 0;
447
- obj.forwardClient = obj.http.request(wsoptions);
448
- obj.forwardClient.upgrade = obj.onSecureConnect;
449
- obj.forwardClient.end(); // end request, trigger completion of HTTP request
450
- }
451
-
452
- obj.disconnect = function () { try { obj.forwardClient.ws.end(); } catch (ex) { Debug(ex); } }
453
-
454
- return obj;
455
-}
456
-
1
+/*
2
+Copyright 2018-2020 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 APF/CIRA Client for Duktape
19
+* @author Joko Sastriawan & Ylian Saint-Hilaire
20
+* @copyright Intel Corporation 2020
21
+* @license Apache-2.0
22
+* @version v0.0.2
23
+*/
24
+
25
+function CreateAPFClient(parent, args) {
26
+ if ((args.clientuuid == null) || (args.clientuuid.length != 36)) return null; // Require a UUID if this exact length
27
+
28
+ var obj = {};
29
+ obj.parent = parent;
30
+ obj.args = args;
31
+ obj.http = require('http');
32
+ obj.net = require('net');
33
+ obj.forwardClient = null;
34
+ obj.downlinks = {};
35
+ obj.pfwd_idx = 0;
36
+ obj.timer = null; // Keep alive timer
37
+
38
+ // obj.onChannelClosed
39
+ // obj.onJsonControl
40
+
41
+ // Function copied from common.js
42
+ function ReadInt(v, p) { return (v.charCodeAt(p) * 0x1000000) + (v.charCodeAt(p + 1) << 16) + (v.charCodeAt(p + 2) << 8) + v.charCodeAt(p + 3); }; // We use "*0x1000000" instead of "<<24" because the shift converts the number to signed int32.
43
+ function IntToStr(v) { return String.fromCharCode((v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF); };
44
+ function hex2rstr(d) { var r = '', m = ('' + d).match(/../g), t; while (t = m.shift()) { r += String.fromCharCode('0x' + t); } return r; };
45
+ function char2hex(i) { return (i + 0x100).toString(16).substr(-2).toUpperCase(); }; // Convert decimal to hex
46
+ function rstr2hex(input) { var r = '', i; for (i = 0; i < input.length; i++) { r += char2hex(input.charCodeAt(i)); } return r; }; // Convert a raw string to a hex string
47
+ function d2h(d) { return (d / 256 + 1 / 512).toString(16).substring(2, 4); }
48
+ function buf2hex(input) { var r = '', i; for (i = 0; i < input.length; i++) { r += d2h(input[i]); } return r; };
49
+ function Debug(str) { if (obj.parent.debug) { console.log(str); } }
50
+ function guidToStr(g) { return g.substring(6, 8) + g.substring(4, 6) + g.substring(2, 4) + g.substring(0, 2) + "-" + g.substring(10, 12) + g.substring(8, 10) + "-" + g.substring(14, 16) + g.substring(12, 14) + "-" + g.substring(16, 20) + "-" + g.substring(20); }
51
+ function strToGuid(s) { s = s.replace(/-/g, ''); var ret = s.substring(6, 8) + s.substring(4, 6) + s.substring(2, 4) + s.substring(0, 2) + s.substring(10, 12) + s.substring(8, 10) + s.substring(14, 16) + s.substring(12, 14) + s.substring(16, 20) + s.substring(20); return ret; }
52
+ function binzerostring(len) { var res = ''; for (var l = 0; l < len; l++) { res += String.fromCharCode(0 & 0xFF); } return res; }
53
+
54
+ // CIRA state
55
+ var CIRASTATE = {
56
+ INITIAL: 0,
57
+ PROTOCOL_VERSION_SENT: 1,
58
+ AUTH_SERVICE_REQUEST_SENT: 2,
59
+ AUTH_REQUEST_SENT: 3,
60
+ PFWD_SERVICE_REQUEST_SENT: 4,
61
+ GLOBAL_REQUEST_SENT: 5,
62
+ FAILED: -1
63
+ }
64
+ obj.cirastate = CIRASTATE.INITIAL;
65
+
66
+ // REDIR state
67
+ var REDIR_TYPE = {
68
+ REDIR_UNKNOWN: 0,
69
+ REDIR_SOL: 1,
70
+ REDIR_KVM: 2,
71
+ REDIR_IDER: 3
72
+ }
73
+
74
+ // redirection start command
75
+ obj.RedirectStartSol = String.fromCharCode(0x10, 0x00, 0x00, 0x00, 0x53, 0x4F, 0x4C, 0x20);
76
+ obj.RedirectStartKvm = String.fromCharCode(0x10, 0x01, 0x00, 0x00, 0x4b, 0x56, 0x4d, 0x52);
77
+ obj.RedirectStartIder = String.fromCharCode(0x10, 0x00, 0x00, 0x00, 0x49, 0x44, 0x45, 0x52);
78
+
79
+ // Intel AMT forwarded port list for non-TLS mode
80
+ //var pfwd_ports = [16992, 623, 16994, 5900];
81
+ var pfwd_ports = [ 16992, 16993 ];
82
+
83
+ // protocol definitions
84
+ var APFProtocol = {
85
+ UNKNOWN: 0,
86
+ DISCONNECT: 1,
87
+ SERVICE_REQUEST: 5,
88
+ SERVICE_ACCEPT: 6,
89
+ USERAUTH_REQUEST: 50,
90
+ USERAUTH_FAILURE: 51,
91
+ USERAUTH_SUCCESS: 52,
92
+ GLOBAL_REQUEST: 80,
93
+ REQUEST_SUCCESS: 81,
94
+ REQUEST_FAILURE: 82,
95
+ CHANNEL_OPEN: 90,
96
+ CHANNEL_OPEN_CONFIRMATION: 91,
97
+ CHANNEL_OPEN_FAILURE: 92,
98
+ CHANNEL_WINDOW_ADJUST: 93,
99
+ CHANNEL_DATA: 94,
100
+ CHANNEL_CLOSE: 97,
101
+ PROTOCOLVERSION: 192,
102
+ KEEPALIVE_REQUEST: 208,
103
+ KEEPALIVE_REPLY: 209,
104
+ KEEPALIVE_OPTIONS_REQUEST: 210,
105
+ KEEPALIVE_OPTIONS_REPLY: 211,
106
+ JSON_CONTROL: 250 // This is a Mesh specific command that sends JSON to and from the MPS server.
107
+ }
108
+
109
+ var APFDisconnectCode = {
110
+ HOST_NOT_ALLOWED_TO_CONNECT: 1,
111
+ PROTOCOL_ERROR: 2,
112
+ KEY_EXCHANGE_FAILED: 3,
113
+ RESERVED: 4,
114
+ MAC_ERROR: 5,
115
+ COMPRESSION_ERROR: 6,
116
+ SERVICE_NOT_AVAILABLE: 7,
117
+ PROTOCOL_VERSION_NOT_SUPPORTED: 8,
118
+ HOST_KEY_NOT_VERIFIABLE: 9,
119
+ CONNECTION_LOST: 10,
120
+ BY_APPLICATION: 11,
121
+ TOO_MANY_CONNECTIONS: 12,
122
+ AUTH_CANCELLED_BY_USER: 13,
123
+ NO_MORE_AUTH_METHODS_AVAILABLE: 14,
124
+ INVALID_CREDENTIALS: 15,
125
+ CONNECTION_TIMED_OUT: 16,
126
+ BY_POLICY: 17,
127
+ TEMPORARILY_UNAVAILABLE: 18
128
+ }
129
+
130
+ var APFChannelOpenFailCodes = {
131
+ ADMINISTRATIVELY_PROHIBITED: 1,
132
+ CONNECT_FAILED: 2,
133
+ UNKNOWN_CHANNEL_TYPE: 3,
134
+ RESOURCE_SHORTAGE: 4,
135
+ }
136
+
137
+ var APFChannelOpenFailureReasonCode = {
138
+ AdministrativelyProhibited: 1,
139
+ ConnectFailed: 2,
140
+ UnknownChannelType: 3,
141
+ ResourceShortage: 4,
142
+ }
143
+
144
+ obj.onSecureConnect = function onSecureConnect(resp, ws, head) {
145
+ Debug("APF Secure WebSocket connected.");
146
+ //console.log(JSON.stringify(resp));
147
+ obj.forwardClient.tag = { accumulator: [] };
148
+ obj.forwardClient.ws = ws;
149
+ obj.forwardClient.ws.on('end', function () {
150
+ Debug("APF: Connection is closing.");
151
+ if (obj.timer != null) { clearInterval(obj.timer); obj.timer = null; }
152
+ if (obj.onChannelClosed) { obj.onChannelClosed(obj); }
153
+ });
154
+
155
+ obj.forwardClient.ws.on('data', function (data) {
156
+ obj.forwardClient.tag.accumulator += hex2rstr(buf2hex(data));
157
+ try {
158
+ var len = 0;
159
+ do {
160
+ len = ProcessData(obj.forwardClient);
161
+ if (len > 0) { obj.forwardClient.tag.accumulator = obj.forwardClient.tag.accumulator.slice(len); }
162
+ if (obj.cirastate == CIRASTATE.FAILED) {
163
+ Debug("APF: in a failed state, destroying socket.");
164
+ obj.forwardClient.ws.end();
165
+ }
166
+ } while (len > 0);
167
+ } catch (ex) { Debug(ex); }
168
+ });
169
+
170
+ obj.forwardClient.ws.on('error', function (e) {
171
+ Debug("APF: Connection error, ending connecting.");
172
+ if (obj.timer != null) { clearInterval(obj.timer); obj.timer = null; }
173
+ });
174
+
175
+ obj.state = CIRASTATE.INITIAL;
176
+ if ((typeof obj.args.conntype == 'number') && (obj.args.conntype != 0)) {
177
+ SendJsonControl(obj.forwardClient.ws, { action: 'connType', value: obj.args.conntype });
178
+ if (obj.args.meiState != null) { SendJsonControl(obj.forwardClient.ws, { action: 'meiState', value: obj.args.meiState }); }
179
+ }
180
+ SendProtocolVersion(obj.forwardClient.ws, obj.args.clientuuid);
181
+ SendServiceRequest(obj.forwardClient.ws, 'auth@amt.intel.com');
182
+ }
183
+
184
+ obj.updateMeiState = function (state) { SendJsonControl(obj.forwardClient.ws, { action: 'meiState', value: state }); }
185
+ obj.sendMeiDeactivationState = function (state) { SendJsonControl(obj.forwardClient.ws, { action: 'deactivate', value: state }); }
186
+
187
+ function SendJsonControl(socket, o) {
188
+ var data = JSON.stringify(o)
189
+ socket.write(String.fromCharCode(APFProtocol.JSON_CONTROL) + IntToStr(data.length) + data);
190
+ Debug("APF: Send JSON control: " + data);
191
+ }
192
+
193
+ function SendProtocolVersion(socket, uuid) {
194
+ var data = String.fromCharCode(APFProtocol.PROTOCOLVERSION) + IntToStr(1) + IntToStr(0) + IntToStr(0) + hex2rstr(strToGuid(uuid)) + binzerostring(64);
195
+ socket.write(data);
196
+ Debug("APF: Send protocol version 1 0 " + uuid);
197
+ obj.cirastate = CIRASTATE.PROTOCOL_VERSION_SENT;
198
+ }
199
+
200
+ function SendServiceRequest(socket, service) {
201
+ var data = String.fromCharCode(APFProtocol.SERVICE_REQUEST) + IntToStr(service.length) + service;
202
+ socket.write(data);
203
+ Debug("APF: Send service request " + service);
204
+ if (service == 'auth@amt.intel.com') {
205
+ obj.cirastate = CIRASTATE.AUTH_SERVICE_REQUEST_SENT;
206
+ } else if (service == 'pfwd@amt.intel.com') {
207
+ obj.cirastate = CIRASTATE.PFWD_SERVICE_REQUEST_SENT;
208
+ }
209
+ }
210
+
211
+ function SendUserAuthRequest(socket, user, pass) {
212
+ var service = "pfwd@amt.intel.com";
213
+ var data = String.fromCharCode(APFProtocol.USERAUTH_REQUEST) + IntToStr(user.length) + user + IntToStr(service.length) + service;
214
+ //password auth
215
+ data += IntToStr(8) + 'password';
216
+ data += binzerostring(1) + IntToStr(pass.length) + pass;
217
+ socket.write(data);
218
+ Debug("APF: Send username password authentication to MPS");
219
+ obj.cirastate = CIRASTATE.AUTH_REQUEST_SENT;
220
+ }
221
+
222
+ function SendGlobalRequestPfwd(socket, amthostname, amtport) {
223
+ var tcpipfwd = 'tcpip-forward';
224
+ var data = String.fromCharCode(APFProtocol.GLOBAL_REQUEST) + IntToStr(tcpipfwd.length) + tcpipfwd + binzerostring(1, 1);
225
+ data += IntToStr(amthostname.length) + amthostname + IntToStr(amtport);
226
+ socket.write(data);
227
+ Debug("APF: Send tcpip-forward " + amthostname + ":" + amtport);
228
+ obj.cirastate = CIRASTATE.GLOBAL_REQUEST_SENT;
229
+ }
230
+
231
+ function SendKeepAliveRequest(socket) {
232
+ socket.write(String.fromCharCode(APFProtocol.KEEPALIVE_REQUEST) + IntToStr(255));
233
+ Debug("APF: Send keepalive request");
234
+ }
235
+
236
+ function SendKeepAliveReply(socket, cookie) {
237
+ socket.write(String.fromCharCode(APFProtocol.KEEPALIVE_REPLY) + IntToStr(cookie));
238
+ Debug("APF: Send keepalive reply");
239
+ }
240
+
241
+ function ProcessData(socket) {
242
+ var cmd = socket.tag.accumulator.charCodeAt(0);
243
+ var len = socket.tag.accumulator.length;
244
+ var data = socket.tag.accumulator;
245
+ if (len == 0) { return 0; }
246
+
247
+ // Respond to MPS according to obj.cirastate
248
+ switch (cmd) {
249
+ case APFProtocol.SERVICE_ACCEPT: {
250
+ var slen = ReadInt(data, 1), service = data.substring(5, 6 + slen);
251
+ Debug("APF: Service request to " + service + " accepted.");
252
+ if (service == 'auth@amt.intel.com') {
253
+ if (obj.cirastate >= CIRASTATE.AUTH_SERVICE_REQUEST_SENT) {
254
+ SendUserAuthRequest(socket.ws, obj.args.mpsuser, obj.args.mpspass);
255
+ }
256
+ } else if (service == 'pfwd@amt.intel.com') {
257
+ if (obj.cirastate >= CIRASTATE.PFWD_SERVICE_REQUEST_SENT) {
258
+ SendGlobalRequestPfwd(socket.ws, obj.args.clientname, pfwd_ports[obj.pfwd_idx++]);
259
+ }
260
+ }
261
+ return 5 + slen;
262
+ }
263
+ case APFProtocol.REQUEST_SUCCESS: {
264
+ if (len >= 5) {
265
+ var port = ReadInt(data, 1);
266
+ Debug("APF: Request to port forward " + port + " successful.");
267
+ // iterate to pending port forward request
268
+ if (obj.pfwd_idx < pfwd_ports.length) {
269
+ SendGlobalRequestPfwd(socket.ws, obj.args.clientname, pfwd_ports[obj.pfwd_idx++]);
270
+ } else {
271
+ // no more port forward, now setup timer to send keep alive
272
+ Debug("APF: Start keep alive for every " + obj.args.mpskeepalive + " ms.");
273
+ obj.timer = setInterval(function () {
274
+ SendKeepAliveRequest(obj.forwardClient.ws);
275
+ }, obj.args.mpskeepalive);//
276
+ }
277
+ return 5;
278
+ }
279
+ Debug("APF: Request successful.");
280
+ return 1;
281
+ }
282
+ case APFProtocol.USERAUTH_SUCCESS: {
283
+ Debug("APF: User Authentication successful");
284
+ // Send Pfwd service request
285
+ SendServiceRequest(socket.ws, 'pfwd@amt.intel.com');
286
+ return 1;
287
+ }
288
+ case APFProtocol.USERAUTH_FAILURE: {
289
+ Debug("APF: User Authentication failed");
290
+ obj.cirastate = CIRASTATE.FAILED;
291
+ return 14;
292
+ }
293
+ case APFProtocol.KEEPALIVE_REQUEST: {
294
+ Debug("APF: Keep Alive Request with cookie: " + ReadInt(data, 1));
295
+ SendKeepAliveReply(socket.ws, ReadInt(data, 1));
296
+ return 5;
297
+ }
298
+ case APFProtocol.KEEPALIVE_REPLY: {
299
+ Debug("APF: Keep Alive Reply with cookie: " + ReadInt(data, 1));
300
+ return 5;
301
+ }
302
+ // Channel management
303
+ case APFProtocol.CHANNEL_OPEN: {
304
+ // Parse CHANNEL OPEN request
305
+ var p_res = parseChannelOpen(data);
306
+ Debug("APF: CHANNEL_OPEN request: " + JSON.stringify(p_res));
307
+ // Check if target port is in pfwd_ports
308
+ if (pfwd_ports.indexOf(p_res.target_port) >= 0) {
309
+ // Connect socket to that port
310
+ var chan = obj.net.createConnection({ host: obj.args.clientaddress, port: p_res.target_port }, function () {
311
+ //require('MeshAgent').SendCommand({ action: 'msg', type: 'console', value: "CHANNEL_OPEN-open" });
312
+ // obj.downlinks[p_res.sender_chan].setEncoding('binary');//assume everything is binary, not interpreting
313
+ SendChannelOpenConfirm(socket.ws, p_res);
314
+ });
315
+
316
+ // Setup flow control
317
+ chan.maxInWindow = p_res.window_size; // Oddly, we are using the same window size as the other side.
318
+ chan.curInWindow = 0;
319
+
320
+ chan.on('data', function (ddata) {
321
+ // Relay data to fordwardclient
322
+ // TODO: Implement flow control
323
+ SendChannelData(socket.ws, p_res.sender_chan, ddata);
324
+ });
325
+
326
+ chan.on('error', function (e) {
327
+ //Debug("Downlink connection error: " + e);
328
+ SendChannelOpenFailure(socket.ws, p_res);
329
+ });
330
+
331
+ chan.on('end', function () {
332
+ var chan = obj.downlinks[p_res.sender_chan];
333
+ if (chan != null) {
334
+ Debug("Socket ends.");
335
+ try { SendChannelClose(socket.ws, p_res.sender_chan); } catch (ex) { }
336
+ delete obj.downlinks[p_res.sender_chan];
337
+ }
338
+ });
339
+
340
+ obj.downlinks[p_res.sender_chan] = chan;
341
+ } else {
342
+ // Not a supported port, fail the connection
343
+ SendChannelOpenFailure(socket.ws, p_res);
344
+ }
345
+ return p_res.len;
346
+ }
347
+ case APFProtocol.CHANNEL_OPEN_CONFIRMATION: {
348
+ Debug("APF: CHANNEL_OPEN_CONFIRMATION");
349
+ return 17;
350
+ }
351
+ case APFProtocol.CHANNEL_CLOSE: {
352
+ var rcpt_chan = ReadInt(data, 1);
353
+ Debug("APF: CHANNEL_CLOSE: " + rcpt_chan);
354
+ try { obj.downlinks[rcpt_chan].end(); } catch (ex) { }
355
+ return 5;
356
+ }
357
+ case APFProtocol.CHANNEL_DATA: {
358
+ Debug("APF: CHANNEL_DATA: " + JSON.stringify(rstr2hex(data)));
359
+ var rcpt_chan = ReadInt(data, 1);
360
+ var chan_data_len = ReadInt(data, 5);
361
+ var chan_data = data.substring(9, 9 + chan_data_len);
362
+ var chan = obj.downlinks[rcpt_chan];
363
+ if (chan != null) {
364
+ chan.curInWindow += chan_data_len;
365
+ try {
366
+ chan.write(Buffer.from(chan_data, 'binary'), function () {
367
+ Debug("Write completed.");
368
+ // If the incoming window is over half used, send an adjust.
369
+ if (this.curInWindow > (this.maxInWindow / 2)) { SendChannelWindowAdjust(socket.ws, rcpt_chan, this.curInWindow); this.curInWindow = 0; }
370
+ });
371
+ } catch (ex) { Debug("Cannot forward data to downlink socket."); }
372
+ }
373
+ return 9 + chan_data_len;
374
+ }
375
+ case APFProtocol.CHANNEL_WINDOW_ADJUST: {
376
+ Debug("APF: CHANNEL_WINDOW_ADJUST");
377
+ return 9;
378
+ }
379
+ case APFProtocol.JSON_CONTROL: {
380
+ Debug("APF: JSON_CONTROL");
381
+ var len = ReadInt(data, 1);
382
+ if (obj.onJsonControl) { var o = null; try { o = JSON.parse(data.substring(5, 5 + len)); } catch (ex) { } if (o != null) { obj.onJsonControl(o); } }
383
+ return 5 + len;
384
+ }
385
+ default: {
386
+ Debug("CMD: " + cmd + " is not implemented.");
387
+ obj.cirastate = CIRASTATE.FAILED;
388
+ return 0;
389
+ }
390
+ }
391
+ }
392
+
393
+ function parseChannelOpen(data) {
394
+ var result = { cmd: APFProtocol.CHANNEL_OPEN };
395
+ var chan_type_slen = ReadInt(data, 1);
396
+ result.chan_type = data.substring(5, 5 + chan_type_slen);
397
+ result.sender_chan = ReadInt(data, 5 + chan_type_slen);
398
+ result.window_size = ReadInt(data, 9 + chan_type_slen);
399
+ var c_len = ReadInt(data, 17 + chan_type_slen);
400
+ result.target_address = data.substring(21 + chan_type_slen, 21 + chan_type_slen + c_len);
401
+ result.target_port = ReadInt(data, 21 + chan_type_slen + c_len);
402
+ var o_len = ReadInt(data, 25 + chan_type_slen + c_len);
403
+ result.origin_address = data.substring(29 + chan_type_slen + c_len, 29 + chan_type_slen + c_len + o_len);
404
+ result.origin_port = ReadInt(data, 29 + chan_type_slen + c_len + o_len);
405
+ result.len = 33 + chan_type_slen + c_len + o_len;
406
+ return result;
407
+ }
408
+
409
+ function SendChannelOpenFailure(socket, chan_data) {
410
+ socket.write(String.fromCharCode(APFProtocol.CHANNEL_OPEN_FAILURE) + IntToStr(chan_data.sender_chan) + IntToStr(2) + IntToStr(0) + IntToStr(0));
411
+ Debug("APF: Send ChannelOpenFailure");
412
+ }
413
+
414
+ function SendChannelOpenConfirm(socket, chan_data) {
415
+ socket.write(String.fromCharCode(APFProtocol.CHANNEL_OPEN_CONFIRMATION) + IntToStr(chan_data.sender_chan) + IntToStr(chan_data.sender_chan) + IntToStr(chan_data.window_size) + IntToStr(0xFFFFFFFF));
416
+ Debug("APF: Send ChannelOpenConfirmation");
417
+ }
418
+
419
+ function SendChannelWindowAdjust(socket, chan, size) {
420
+ socket.write(String.fromCharCode(APFProtocol.CHANNEL_WINDOW_ADJUST) + IntToStr(chan) + IntToStr(size));
421
+ Debug("APF: Send ChannelWindowAdjust, channel: " + chan + ", size: " + size);
422
+ }
423
+
424
+ function SendChannelData(socket, chan, data) {
425
+ socket.write(Buffer.concat([Buffer.from(String.fromCharCode(APFProtocol.CHANNEL_DATA) + IntToStr(chan) + IntToStr(data.length), 'binary'), data]));
426
+ Debug("APF: Send ChannelData: " + data.toString('hex'));
427
+ }
428
+
429
+ function SendChannelClose(socket, chan) {
430
+ socket.write(String.fromCharCode(APFProtocol.CHANNEL_CLOSE) + IntToStr(chan));
431
+ Debug("APF: Send ChannelClose ");
432
+ }
433
+
434
+ obj.connect = function () {
435
+ if (obj.forwardClient != null) {
436
+ try { obj.forwardClient.ws.end(); } catch (ex) { Debug(ex); }
437
+ //obj.forwardClient = null;
438
+ }
439
+ obj.cirastate = CIRASTATE.INITIAL;
440
+ obj.pfwd_idx = 0;
441
+
442
+ //obj.forwardClient = new obj.ws(obj.args.mpsurl, obj.tlsoptions);
443
+ //obj.forwardClient.on("open", obj.onSecureConnect);
444
+
445
+ var wsoptions = obj.http.parseUri(obj.args.mpsurl);
446
+ wsoptions.rejectUnauthorized = 0;
447
+ obj.forwardClient = obj.http.request(wsoptions);
448
+ obj.forwardClient.upgrade = obj.onSecureConnect;
449
+ obj.forwardClient.end(); // end request, trigger completion of HTTP request
450
+ }
451
+
452
+ obj.disconnect = function () { try { obj.forwardClient.ws.end(); } catch (ex) { Debug(ex); } }
453
+
454
+ return obj;
455
+}
456
+
457
module.exports = CreateAPFClient;
\ No newline at end of file
agents/modules_meshcore/amt-lme.js
+1
-444
@@ -305,7 +305,7 @@ function lme_heci(options) {
305
try { notify = xmlParser.ParseWsman(httpData); } catch (e) { }
306
307
// Event the http data
308
- if (notify != null) { this.LMS.emit('notify', notify, channel.options, _lmsNotifyToString(notify), _lmsNotifyToCode(notify)); }
308
+ if (notify != null) { this.LMS.emit('notify', notify, channel.options, _lmsNotifyToCode(notify)); }
309
310
// Send channel close
311
var buffer = Buffer.alloc(5);
@@ -458,447 +458,4 @@ function _lmsNotifyToCode(notify) {
458
return msgid;
459
}
460
461
-function _lmsNotifyToString(notify) {
462
- if ((notify == null) || (notify.Body == null) || (notify.Body.MessageID == null)) return null;
463
- var msgid = notify.Body.MessageID;
464
- try { msgid += '-' + notify.Body.MessageArguments[0]; } catch (e) { }
465
- if (lmsEvents[msgid]) { return lmsEvents[msgid]; }
466
- return null;
467
-}
468
-
469
-var lmsEvents = {
470
- "iAMT0001": "System Defense Policy %1s triggered.",
471
- "iAMT0002": "Agent Presence Agent %1s not started.",
472
- "iAMT0003": "Agent Presence Agent %1s stopped.",
473
- "iAMT0004": "Agent Presence Agent %1s running.",
474
- "iAMT0005": "Agent Presence Agent %1s expired.",
475
- "iAMT0006": "Agent Presence Agent %1s suspended.",
476
- "iAMT0007": "Host software attempt to disable AMT Network link detected.",
477
- "iAMT0008": "Host software attempt to disable AMT Network link detected -- Host Network link blocked.",
478
- "iAMT0009": "AMT clock or FLASH wear-out protection disabled.",
479
- "iAMT0010": "Intel(R) AMT Network Interface %1s heuristics defense slow threshold trespassed.",
480
- "iAMT0011": "Intel(R) AMT Network Interface %1s heuristics defense fast threshold trespassed.",
481
- "iAMT0012": "Intel(R) AMT Network Interface %1s heuristics defense factory defined threshold trespassed.",
482
- "iAMT0013": "Intel(R) AMT Network Interface %1s heuristics defense Encounter timeout expired.",
483
- "iAMT0014": "General certificate error.",
484
- "iAMT0015": "Certificate expired.",
485
- "iAMT0016": "No trusted root certificate.",
486
- "iAMT0017": "Not configured to work with server certificate.",
487
- "iAMT0018": "Certificate revoked.",
488
- "iAMT0019": "RSA exponent too large.",
489
- "iAMT0020": "RSA modulus too large.",
490
- "iAMT0021": "Unsupported digest.",
491
- "iAMT0022": "Distinguished name too long.",
492
- "iAMT0023": "Key usage missing.",
493
- "iAMT0024": "General SSL handshake error.",
494
- "iAMT0025": "General 802.1x error.",
495
- "iAMT0026": "AMT Diagnostic AlertEAC error - General NAC error.",
496
- "iAMT0027": "AMT Diagnostic AlertEAC error - attempt to get a NAC posture while AMT NAC is disabled.",
497
- "iAMT0028": "AMT Diagnostic AlertEAC error - attempt to get a posture of an unsupported type.",
498
- "iAMT0029": "Audit log storage is 50% full.",
499
- "iAMT0030": "Audit log storage is 75% full.",
500
- "iAMT0031": "Audit log storage is 85% full.",
501
- "iAMT0032": "Audit log storage is 95% full.",
502
- "iAMT0033": "Audit log storage is full.",
503
- "iAMT0034": "Firmware Update Event - Partial.",
504
- "iAMT0035": "Firmware Update Event - Failure.",
505
- "iAMT0036": "Remote connectivity initiated.",
506
- "iAMT0037": "ME Presence event.",
507
- "iAMT0038-0": "AMT is being unprovisioned using BIOS command.",
508
- "iAMT0038-1": "AMT is being unprovisioned using Local MEI command.",
509
- "iAMT0038-2": "AMT is being unprovisioned using Local WS-MAN/SOAP command.",
510
- "iAMT0038-3": "AMT is being unprovisioned using Remote WS-MAN/SOAP command.",
511
- "iAMT0039": "HW Asset Error.",
512
- "iAMT0050": "User Notification Alert - General Notification.",
513
- "iAMT0050-16": "User Notification Alert - Circuit Breaker notification (CB Drop TX filter hit.).",
514
- "iAMT0050-17": "User Notification Alert - Circuit Breaker notification (CB Rate Limit TX filter hit.).",
515
- "iAMT0050-18": "User Notification Alert - Circuit Breaker notification (CB Drop RX filter hit.).",
516
- "iAMT0050-19": "User Notification Alert - Circuit Breaker notification (CB Rate Limit RX filter hit.).",
517
- "iAMT0050-32": "User Notification Alert - EAC notification.",
518
- "iAMT0050-48": "User Notification Alert - Remote diagnostics - (Remote Redirection session started - SOL).",
519
- "iAMT0050-49": "User Notification Alert - Remote diagnostics - (Remote Redirection session stopped - SOL).",
520
- "iAMT0050-50": "User Notification Alert - Remote diagnostics. (Remote Redirection session started - IDE-R).",
521
- "iAMT0050-51": "User Notification Alert - Remote diagnostics. (Remote Redirection session stopped - IDE-R).",
522
- "iAMT0050-66": "User Notification Alert - WLAN notification (Host profile mismatch - Management Interface ignored).",
523
- "iAMT0050-67": "User Notification Alert - WLAN notification (Management device overrides host radio).",
524
- "iAMT0050-68": "User Notification Alert - WLAN notification (Host profile security mismatch).",
525
- "iAMT0050-69": "User Notification Alert - WLAN notification (Management device relinquishes control over host Radio).",
526
- "iAMT0051": "User Notification Alert - SecIo event.",
527
- "iAMT0051-0": "User Notification Alert - SecIo event semaphore at host.",
528
- "iAMT0051-1": "User Notification Alert - semaphore at ME.",
529
- "iAMT0051-2": "User Notification Alert - SecIo event - semaphore timeout.",
530
- "iAMT0052": "User Notification Alert - KVM session event.",
531
- "iAMT0052-0": "User Notification Alert - KVM session requested.",
532
- "iAMT0052-1": "User Notification Alert - KVM session started.",
533
- "iAMT0052-2": "User Notification Alert - KVM session stopped.",
534
- "iAMT0052-3": "User Notification Alert - KVM data channel.",
535
- "iAMT0053": "User Notification Alert - RCS notification.",
536
- "iAMT0053-50": "User Notification Alert - RCS notification (HW button pressed. Connection initiated automatically).",
537
- "iAMT0053-52": "User Notification Alert - RCS notification (HW button pressed. Connection wasn't initiated automatically).",
538
- "iAMT0053-53": "User Notification Alert - RCS notification (Contracts updated).",
539
- "iAMT0054": "User Notification Alert - WLAN notification. Wireless Profile sync enablement state changed.",
540
- "iAMT0055": "User Notification Alert - Provisioning state change notification.",
541
- "iAMT0055-0": "User Notification Alert - Provisioning state change notification - Pre-configuration.",
542
- "iAMT0055-1": "User Notification Alert - Provisioning state change notification - In configuration.",
543
- "iAMT0055-2": "User Notification Alert - Provisioning state change notification - Post-configuration.",
544
- "iAMT0055-3": "User Notification Alert - Provisioning state change notification - Unprovision process has started.",
545
- "iAMT0056": "User Notification Alert - System Defense change notification.",
546
- "iAMT0057": "User Notification Alert - Network State change notification.",
547
- "iAMT0058": "User Notification Alert - Remote Access change notification.",
548
- "iAMT0058-1": "User Notification Alert - Remote Access change notification - tunnel is closed.",
549
- //"iAMT0058-1": "User Notification Alert - Remote Access change notification - tunnel is open.", // TODO
550
- "iAMT0059": "User Notification Alert - KVM enabled event.",
551
- "iAMT0059-0": "User Notification Alert - KVM enabled event - KVM disabled.",
552
- "iAMT0059-1": "User Notification Alert - KVM enabled event - KVM enabled (both from MEBx and PTNI).",
553
- "iAMT0060": "User Notification Alert - SecIO configuration event.",
554
- "iAMT0061": "ME FW reset occurred.",
555
- "iAMT0062": "User Notification Alert - IpSyncEnabled event.",
556
- "iAMT0062-0": "User Notification Alert - IpSyncEnabled event - IpSync disabled.",
557
- "iAMT0062-1": "User Notification Alert - IpSyncEnabled event - IpSync enabled.",
558
- "iAMT0063": "User Notification Alert - HTTP Proxy sync enabled event.",
559
- "iAMT0063-0": "User Notification Alert - HTTP Proxy sync enabled event - HTTP Proxy Sync disabled.",
560
- "iAMT0063-1": "User Notification Alert - HTTP Proxy sync enabled event - HTTP Proxy Sync enabled.",
561
- "iAMT0064": "User Notification Alert - User Consent event.",
562
- "iAMT0064-1": "User Notification Alert - User Consent event - User Consent granted.",
563
- "iAMT0064-2": "User Notification Alert - User Consent event - User Consent ended.",
564
- "iAMT0067-0": "Graceful Remote Control Operation - Shutdown.",
565
- "iAMT0067-1": "Graceful Remote Control Operation - Reset.",
566
- "iAMT0067-2": "Graceful Remote Control Operation - Hibernate.",
567
- "iAMT0068-0": "Link Protection Notification - No link protection.",
568
- "iAMT0068-1": "Link Protection Notification - Passive link protection.",
569
- "iAMT0068-2": "Link Protection Notification - High link protection.",
570
- "iAMT0069-0": "Local Time Sync Enablement Notification - Local Time Sync Disabled.",
571
- "iAMT0069-1": "Local Time Sync Enablement Notification - Local Time Sync Enabled.",
572
- "iAMT0070": "Host Reset Triggered by WD Expiration Notification.",
573
- "PLAT0004": "The chassis %1s was opened.",
574
- "PLAT0005": "The chassis %1s was closed.",
575
- "PLAT0006": "The drive bay %1s was opened.",
576
- "PLAT0007": "The drive bay %1s was closed.",
577
- "PLAT0008": "The I/O card area %1s was opened.",
578
- "PLAT0009": "The I/O card area %1s was closed.",
579
- "PLAT0010": "The processor area %1s was opened.",
580
- "PLAT0011": "The processor area %1s was closed.",
581
- "PLAT0012": "The LAN %1s has been disconnected.",
582
- "PLAT0013": "The LAN %1s has been connected.",
583
- "PLAT0016": "The permission to insert package %1s has been granted.",
584
- "PLAT0017": "The permission to insert package %1s has been removed.",
585
- "PLAT0018": "The fan card area %1s is open.",
586
- "PLAT0019": "The fan card area %1s is closed.",
587
- "PLAT0022": "The computer system %1s has detected a secure mode violation.",
588
- "PLAT0024": "The computer system %1s has detected a pre-boot user password violation.",
589
- "PLAT0026": "The computer system %1s has detected a pre-boot setup password violation.",
590
- "PLAT0028": "The computer system %1s has detected a network boot password violation.",
591
- "PLAT0030": "The computer system %1s has detected a password violation.",
592
- "PLAT0032": "The management controller %1s has detected an out-of-band password violation.",
593
- "PLAT0034": "The processor %1s has been added.",
594
- "PLAT0035": "The processor %1s has been removed.",
595
- "PLAT0036": "An over-temperature condition has been detected on the processor %1s.",
596
- "PLAT0037": "An over-temperature condition has been removed on the processor %1s.",
597
- "PLAT0038": "The processor %1s is operating in a degraded State.",
598
- "PLAT0039": "The processor %1s is no longer operating in a degraded State.",
599
- "PLAT0040": "The processor %1s has failed.",
600
- "PLAT0042": "The processor %1s has failed.",
601
- "PLAT0044": "The processor %1s has failed.",
602
- "PLAT0046": "The processor %1s has failed.",
603
- "PLAT0048": "The processor %1s has failed.",
604
- "PLAT0060": "The processor %1s has been enabled.",
605
- "PLAT0061": "The processor %1s has been disabled.",
606
- "PLAT0062": "The processor %1s has a configuration mismatch.",
607
- "PLAT0064": "A terminator has been detected on the processor %1s.",
608
- "PLAT0084": "The Power Supply %1s has been added.",
609
- "PLAT0085": "The Power Supply %1s has been removed.",
610
- "PLAT0086": "The Power Supply %1s has failed.",
611
- "PLAT0088": "Failure predicted on power supply %1s.",
612
- "PLAT0096": "The input to power supply %1s has been lost or fallen out of range.",
613
- "PLAT0098": "The power supply %1s is operating in an input state that is out of range.",
614
- "PLAT0099": "The power supply %1s has returned to a normal input state.",
615
- "PLAT0100": "The power supply %1s has lost input.",
616
- "PLAT0104": "The power supply %1s has a configuration mismatch.",
617
- "PLAT0106": "Power supply %1s has been disabled.",
618
- "PLAT0107": "Power supply %1s has been enabled.",
619
- "PLAT0108": "Power supply %1s has been power cycled.",
620
- "PLAT0110": "Power supply %1s has encountered an error during power down.",
621
- "PLAT0112": "Power supply %1s has lost power.",
622
- "PLAT0114": "Soft power control has failed for power supply %1s.",
623
- "PLAT0116": "Power supply %1s has failed.",
624
- "PLAT0118": "Failure predicted on power supply %1s.",
625
- "PLAT0120": "Memory subsystem failure.",
626
- "PLAT0122": "DIMM missing.",
627
- "PLAT0124": "Memory error detected & corrected for DIMM %1s.",
628
- "PLAT0128": "Memory DIMM %1s added.",
629
- "PLAT0129": "Memory DIMM %1s removed.",
630
- "PLAT0130": "Memory DIMM %1s enabled.",
631
- "PLAT0131": "Memory DIMM %1s disabled.",
632
- "PLAT0134": "Memory parity error for DIMM %1s.",
633
- "PLAT0136": "Memory scrub failure for DIMM %1s.",
634
- "PLAT0138": "Memory uncorrectable error detected for DIMM %1s.",
635
- "PLAT0140": "Memory sparing initiated for DIMM %1s.",
636
- "PLAT0141": "Memory sparing concluded for DIMM %1s.",
637
- "PLAT0142": "Memory DIMM %1s Throttled.",
638
- "PLAT0144": "Memory logging limit reached for DIMM %1s.",
639
- "PLAT0145": "Memory logging limit removed for DIMM %1s.",
640
- "PLAT0146": "An over-temperature condition has been detected on the Memory DIMM %1s.",
641
- "PLAT0147": "An over-temperature condition has been removed on the Memory DIMM %1s.",
642
- "PLAT0162": "The drive %1s has been added.",
643
- "PLAT0163": "The drive %1s has been removed.",
644
- "PLAT0164": "The drive %1s has been disabled due to a detected fault.",
645
- "PLAT0167": "The drive %1s has been enabled.",
646
- "PLAT0168": "Failure predicted on drive %1s.",
647
- "PLAT0170": "Hot spare enabled for %1s.",
648
- "PLAT0171": "Hot spare disabled for %1s.",
649
- "PLAT0172": "Consistency check has begun for %1s.",
650
- "PLAT0173": "Consistency check completed for %1s.",
651
- "PLAT0174": "Array %1s is in critical condition.",
652
- "PLAT0176": "Array %1s has failed.",
653
- "PLAT0177": "Array %1s has been restored.",
654
- "PLAT0178": "Rebuild in progress for array %1s.",
655
- "PLAT0179": "Rebuild completed for array %1s.",
656
- "PLAT0180": "Rebuild Aborted for array %1s.",
657
- "PLAT0184": "The system %1s encountered a POST error.",
658
- "PLAT0186": "The system %1s encountered a firmware hang.",
659
- "PLAT0188": "The system %1s encountered firmware progress.",
660
- "PLAT0192": "The log %1s has been disabled.",
661
- "PLAT0193": "The log %1s has been enabled.",
662
- "PLAT0194": "The log %1s has been disabled.",
663
- "PLAT0195": "The log %1s has been enabled.",
664
- "PLAT0196": "The log %1s has been disabled.",
665
- "PLAT0198": "The log %1s has been enabled.",
666
- "PLAT0200": "The log %1s has been cleared.",
667
- "PLAT0202": "The log %1s is full.",
668
- "PLAT0203": "The log %1s is no longer full.",
669
- "PLAT0204": "The log %1s is almost full.",
670
- "PLAT0208": "The log %1s has a configuration error.",
671
- "PLAT0210": "The system %1s has been reconfigured.",
672
- "PLAT0212": "The system %1s has encountered an OEM system boot event.",
673
- "PLAT0214": "The system %1s has encountered an unknown system hardware fault.",
674
- "PLAT0216": "The system %1s has generated an auxiliary log entry.",
675
- "PLAT0218": "The system %1s has executed a PEF action.",
676
- "PLAT0220": "The system %1s has synchronized the system clock.",
677
- "PLAT0222": "A diagnostic interrupt has occurred on system %1s.",
678
- "PLAT0224": "A bus timeout has occurred on system %1s.",
679
- "PLAT0226": "An I/O channel check NMI has occurred on system %1s.",
680
- "PLAT0228": "A software NMI has occurred on system %1s.",
681
- "PLAT0230": "System %1s has recovered from an NMI.",
682
- "PLAT0232": "A PCI PERR has occurred on system %1s.",
683
- "PLAT0234": "A PCI SERR has occurred on system %1s.",
684
- "PLAT0236": "An EISA fail safe timeout occurred on system %1s.",
685
- "PLAT0238": "A correctable bus error has occurred on system %1s.",
686
- "PLAT0240": "An uncorrectable bus error has occurred on system %1s.",
687
- "PLAT0242": "A fatal NMI error has occurred on system %1s.",
688
- "PLAT0244": "A fatal bus error has occurred on system %1s.",
689
- "PLAT0246": "A bus on system %1s is operating in a degraded state.",
690
- "PLAT0247": "A bus on system %1s is no longer operating in a degraded state.",
691
- "PLAT0248": "The power button %1s has been pressed.",
692
- "PLAT0249": "The power button %1s has been released.",
693
- "PLAT0250": "The sleep button %1s has been pressed.",
694
- "PLAT0251": "The sleep button %1s has been released.",
695
- "PLAT0252": "The reset button %1s has been pressed.",
696
- "PLAT0253": "The reset button %1s has been released.",
697
- "PLAT0254": "The latch to %1s has been opened.",
698
- "PLAT0255": "The latch to %1s has been closed.",
699
- "PLAT0256": "The service request %1s has been enabled.",
700
- "PLAT0257": "The service request %1s has been completed.",
701
- "PLAT0258": "Power control of system %1s has failed.",
702
- "PLAT0262": "The network port %1s has been connected.",
703
- "PLAT0263": "The network port %1s has been disconnected.",
704
- "PLAT0266": "The connector %1s has encountered a configuration error.",
705
- "PLAT0267": "The connector %1s configuration error has been repaired.",
706
- "PLAT0272": "Power on for system %1s.",
707
- "PLAT0274": "Power cycle hard requested for system %1s.",
708
- "PLAT0276": "Power cycle soft requested for system %1s.",
709
- "PLAT0278": "PXE boot requested for system %1s.",
710
- "PLAT0280": "Diagnostics boot requested for system %1s.",
711
- "PLAT0282": "System restart requested for system %1s.",
712
- "PLAT0284": "System restart begun for system %1s.",
713
- "PLAT0286": "No bootable media available for system %1s.",
714
- "PLAT0288": "Non-bootable media selected for system %1s.",
715
- "PLAT0290": "PXE server not found for system %1s.",
716
- "PLAT0292": "User timeout on boot for system %1s.",
717
- "PLAT0296": "System %1s boot from floppy initiated.",
718
- "PLAT0298": "System %1s boot from local drive initiated.",
719
- "PLAT0300": "System %1s boot from PXE on network port initiated.",
720
- "PLAT0302": "System %1s boot diagnostics initiated.",
721
- "PLAT0304": "System %1s boot from CD initiated.",
722
- "PLAT0306": "System %1s boot from ROM initiated.",
723
- "PLAT0312": "System %1s boot initiated.",
724
- "PLAT0320": "Critical stop during OS load on system %1s.",
725
- "PLAT0322": "Run-time critical stop on system %1s.",
726
- "PLAT0324": "OS graceful stop on system %1s.",
727
- "PLAT0326": "OS graceful shutdown begun on system %1s.",
728
- "PLAT0327": "OS graceful shutdown completed on system %1s.",
729
- "PLAT0328": "Agent not responding on system %1s.",
730
- "PLAT0329": "Agent has begun responding on system %1s.",
731
- "PLAT0330": "Fault in slot on system %1s.",
732
- "PLAT0331": "Fault condition removed on system %1s.",
733
- "PLAT0332": "Identifying slot on system %1s.",
734
- "PLAT0333": "Identify stopped on slot for system %1s.",
735
- "PLAT0334": "Package installed in slot for system %1s.",
736
- "PLAT0336": "Slot empty system %1s.",
737
- "PLAT0338": "Slot in system %1s is ready for installation.",
738
- "PLAT0340": "Slot in system %1s is ready for removal.",
739
- "PLAT0342": "Power is off on slot of system %1s.",
740
- "PLAT0344": "Power is on for slot of system %1s.",
741
- "PLAT0346": "Removal requested for slot of system %1s.",
742
- "PLAT0348": "Interlock activated on slot of system %1s.",
743
- "PLAT0349": "Interlock de-asserted on slot of system %1s.",
744
- "PLAT0350": "Slot disabled on system %1s.",
745
- "PLAT0351": "Slot enabled on system %1s.",
746
- "PLAT0352": "Slot of system %1s holds spare.",
747
- "PLAT0353": "Slot of system %1s no longer holds spare.",
748
- "PLAT0354": "Computer system %1s enabled.",
749
- "PLAT0356": "Computer system %1s is in sleep - light mode.",
750
- "PLAT0358": "Computer system %1s is in hibernate.",
751
- "PLAT0360": "Computer system %1s is in standby.",
752
- "PLAT0362": "Computer system %1s is in soft off mode.",
753
- "PLAT0364": "Computer system %1s is in hard off mode.",
754
- "PLAT0366": "Computer system %1s is sleeping.",
755
- "PLAT0368": "Watchdog timer expired for %1s.",
756
- "PLAT0370": "Reboot of system initiated by watchdog %1s.",
757
- "PLAT0372": "Powering off system initiated by watchdog %1s.",
758
- "PLAT0374": "Power cycle of system initiated by watchdog %1s.",
759
- "PLAT0376": "Watchdog timer interrupt occurred for %1s.",
760
- "PLAT0378": "A page alert has been generated for system %1s.",
761
- "PLAT0380": "A LAN alert has been generated for system %1s.",
762
- "PLAT0382": "An event trap has been generated for system %1s.",
763
- "PLAT0384": "An SNMP trap has been generated for system %1s.",
764
- "PLAT0390": "%1s detected as present.",
765
- "PLAT0392": "%1s detected as absent.",
766
- "PLAT0394": "%1s has been disabled.",
767
- "PLAT0395": "%1s has been enabled.",
768
- "PLAT0396": "Heartbeat lost for LAN %1s.",
769
- "PLAT0397": "Heartbeat detected for LAN %1s.",
770
- "PLAT0398": "Sensor %1s is unavailable or degraded on management system.",
771
- "PLAT0399": "Sensor %1s has returned to normal on management system.",
772
- "PLAT0400": "Controller %1s is unavailable or degraded on management system.",
773
- "PLAT0401": "Controller %1s has returned to normal on management system.",
774
- "PLAT0402": "Management system %1s is off-line.",
775
- "PLAT0404": "Management system %1s is disabled.",
776
- "PLAT0405": "Management system %1s is enabled.",
777
- "PLAT0406": "Sensor %1s has failed on management system.",
778
- "PLAT0408": "FRU %1s has failed on management system.",
779
- "PLAT0424": "The battery %1s is critically low.",
780
- "PLAT0427": "The battery %1s is no longer critically low.",
781
- "PLAT0430": "The battery %1s has been removed from unit.",
782
- "PLAT0431": "The battery %1s has been added.",
783
- "PLAT0432": "The battery %1s has failed.",
784
- "PLAT0434": "Session audit is deactivated on system %1s.",
785
- "PLAT0435": "Session audit is activated on system %1s.",
786
- "PLAT0436": "A hardware change occurred on system %1s.",
787
- "PLAT0438": "A firmware or software change occurred on system %1s.",
788
- "PLAT0440": "A hardware incompatibility was detected on system %1s.",
789
- "PLAT0442": "A firmware or software incompatibility was detected on system %1s.",
790
- "PLAT0444": "Invalid or unsupported hardware was detected on system %1s.",
791
- "PLAT0446": "Invalid or unsupported firmware or software was detected on system %1s.",
792
- "PLAT0448": "A successful hardware change was detected on system %1s.",
793
- "PLAT0450": "A successful software or firmware change was detected on system %1s.",
794
- "PLAT0464": "FRU %1s not installed on system.",
795
- "PLAT0465": "FRU %1s installed on system.",
796
- "PLAT0466": "Activation requested for FRU %1s on system.",
797
- "PLAT0467": "FRU %1s on system is active.",
798
- "PLAT0468": "Activation in progress for FRU %1s on system.",
799
- "PLAT0470": "Deactivation request for FRU %1s on system.",
800
- "PLAT0471": "FRU %1s on system is in standby or \"hot spare\" state.",
801
- "PLAT0472": "Deactivation in progress for FRU %1s on system.",
802
- "PLAT0474": "Communication lost with FRU %1s on system.",
803
- "PLAT0476": "Numeric sensor %1s going low (lower non-critical).",
804
- "PLAT0478": "Numeric sensor %1s going high (lower non-critical).",
805
- "PLAT0480": "Numeric sensor %1s going low (lower critical).",
806
- "PLAT0482": "Numeric sensor %1s going high (lower critical).",
807
- "PLAT0484": "Numeric sensor %1s going low (lower non-recoverable).",
808
- "PLAT0486": "Numeric sensor %1s going high (lower non-critical).",
809
- "PLAT0488": "Numeric sensor %1s going low (upper non-critical).",
810
- "PLAT0490": "Numeric sensor %1s going high (upper non-critical).",
811
- "PLAT0492": "Numeric sensor %1s going low (upper critical).",
812
- "PLAT0494": "Numeric sensor %1s going high (upper critical).",
813
- "PLAT0496": "Numeric sensor %1s going low (upper non-recoverable).",
814
- "PLAT0498": "Numeric sensor %1s going high (upper non-recoverable).",
815
- "PLAT0500": "Sensor %1s has transitioned to idle.",
816
- "PLAT0502": "Sensor %1s has transitioned to active.",
817
- "PLAT0504": "Sensor %1s has transitioned to busy.",
818
- "PLAT0508": "Sensor %1s has asserted.",
819
- "PLAT0509": "Sensor %1s has de-asserted.",
820
- "PLAT0510": "Sensor %1s is asserting predictive failure.",
821
- "PLAT0511": "Sensor %1s is de-asserting predictive failure.",
822
- "PLAT0512": "Sensor %1s has indicated limit exceeded.",
823
- "PLAT0513": "Sensor %1s has indicated limit no longer exceeded.",
824
- "PLAT0514": "Sensor %1s has indicated performance met.",
825
- "PLAT0516": "Sensor %1s has indicated performance lags.",
826
- "PLAT0518": "Sensor %1s has transitioned to normal state.",
827
- "PLAT0520": "Sensor %1s has transitioned from normal to non-critical state.",
828
- "PLAT0522": "Sensor %1s has transitioned to critical from a less severe state.",
829
- "PLAT0524": "Sensor %1s has transitioned to non-recoverable from a less severe state.",
830
- "PLAT0526": "Sensor %1s has transitioned to non-critical from a more severe state.",
831
- "PLAT0528": "Sensor %1s has transitioned to critical from a non-recoverable state.",
832
- "PLAT0530": "Sensor %1s has transitioned to non-recoverable.",
833
- "PLAT0532": "Sensor %1s indicates a monitor state.",
834
- "PLAT0534": "Sensor %1s has an informational state.",
835
- "PLAT0536": "Device %1s has been added.",
836
- "PLAT0537": "Device %1s has been removed from unit.",
837
- "PLAT0538": "Device %1s has been enabled.",
838
- "PLAT0539": "Device %1s has been disabled.",
839
- "PLAT0540": "Sensor %1s has indicated a running state.",
840
- "PLAT0544": "Sensor %1s has indicated a power off state.",
841
- "PLAT0546": "Sensor %1s has indicated an on-line state.",
842
- "PLAT0548": "Sensor %1s has indicated an off-line state.",
843
- "PLAT0550": "Sensor %1s has indicated an off-duty state.",
844
- "PLAT0552": "Sensor %1s has indicated a degraded state.",
845
- "PLAT0554": "Sensor %1s has indicated a power save state.",
846
- "PLAT0556": "Sensor %1s has indicated an install error.",
847
- "PLAT0558": "Redundancy %1s has been lost.",
848
- "PLAT0560": "Redundancy %1s has been reduced.",
849
- "PLAT0561": "Redundancy %1s has been restored.",
850
- "PLAT0562": "%1s has transitioned to a D0 power state.",
851
- "PLAT0564": "%1s has transitioned to a D1 power state.",
852
- "PLAT0566": "%1s has transitioned to a D2 power state.",
853
- "PLAT0568": "%1s has transitioned to a D3 power state.",
854
- "PLAT0720": "The System %1s encountered firmware progress - memory initialization entry.",
855
- "PLAT0721": "The System %1s encountered firmware progress - memory initialization exit.",
856
- "PLAT0722": "The System %1s encountered firmware progress - hard drive initialization entry.",
857
- "PLAT0723": "The System %1s encountered firmware progress - hard drive initialization exit.",
858
- "PLAT0724": "The System %1s encountered firmware progress - user authentication.",
859
- "PLAT0728": "The System %1s encountered firmware progress - USR resource configuration entry.",
860
- "PLAT0729": "The System %1s encountered firmware progress - USR resource configuration exit.",
861
- "PLAT0730": "The System %1s encountered firmware progress - PCI recource configuration entry.",
862
- "PLAT0731": "The System %1s encountered firmware progress - PCI recource configuration exit.",
863
- "PLAT0732": "The System %1s encountered firmware progress - Option ROM initialization entry.",
864
- "PLAT0733": "The System %1s encountered firmware progress - Option ROM initialization entry exit.",
865
- "PLAT0734": "The System %1s encountered firmware progress -video initialization entry entry.",
866
- "PLAT0735": "The System %1s encountered firmware progress - video initialization entry exit.",
867
- "PLAT0736": "The System %1s encountered firmware progress - cache initialization entry.",
868
- "PLAT0737": "The System %1s encountered firmware progress - cache initialization exit.",
869
- "PLAT0738": "The System %1s encountered firmware progress - keyboard controller initialization entry.",
870
- "PLAT0739": "The System %1s encountered firmware progress - keyboard controller initialization exit.",
871
- "PLAT0740": "The System %1s encountered firmware progress - motherboard initialization entry.",
872
- "PLAT0741": "The System %1s encountered firmware progress - motherboard initialization exit.",
873
- "PLAT0742": "The System %1s encountered firmware progress - floppy disk initialization entry.",
874
- "PLAT0743": "The System %1s encountered firmware progress - floppy disk initialization exit.",
875
- "PLAT0744": "The System %1s encountered firmware progress - keyboard test entry.",
876
- "PLAT0745": "The System %1s encountered firmware progress - keyboard test exit.",
877
- "PLAT0746": "The System %1s encountered firmware progress - pointing device test entry.",
878
- "PLAT0747": "The System %1s encountered firmware progress - pointing device test exit.",
879
- "PLAT0750": "The System %1s encountered firmware progress - dock enable entry.",
880
- "PLAT0751": "The System %1s encountered firmware progress - dock enable exit.",
881
- "PLAT0752": "The System %1s encountered firmware progress - dock disable entry.",
882
- "PLAT0753": "The System %1s encountered firmware progress - dock disable exit.",
883
- "PLAT0760": "The System %1s encountered firmware progress - start OS boot process.",
884
- "PLAT0762": "The System %1s encountered firmware progress - call OS wake vector.",
885
- "PLAT0764": "The System %1s encountered firmware progress - unrecoverable keyboard failure.",
886
- "PLAT0766": "The System %1s encountered firmware progress - no video device detected.",
887
- "PLAT0768": "The System %1s encountered firmware progress - SMART alert detected on drive.",
888
- "PLAT0770": "The System %1s encountered firmware progress - unrecoverable boot device failure.",
889
- "PLAT0789": "Corrupt BIOS detected.",
890
- "PLAT0790": "The System %1s encountered PCI configuration failure.",
891
- "PLAT0791": "The System %1s encountered a video subsystem failure.",
892
- "PLAT0792": "The System %1s encountered a storage subsystem failure.",
893
- "PLAT0793": "The System %1s encountered a USB subsystem failure.",
894
- "PLAT0794": "The System %1s has detected no memory in the system.",
895
- "PLAT0795": "The System %1s encountered a motherboard failure.",
896
- "PLAT0796": "The System %1s encountered a memory Regulator Voltage Bad.",
897
- "PLAT0797": "%1s PCI reset is not deasserting.",
898
- "PLAT0798": "%1s Non-Motherboard Regulator Failure.",
899
- "PLAT0799": "%1s Power Supply Cable failure.",
900
- "PLAT0800": "%1s Motherboard regulator failure.",
901
- "PLAT0801": "%1s System component compatibility mismatch."
902
-}
903
-
461
module.exports = lme_heci;
agents/modules_meshcore/amt-manage.js
+37
-665
@@ -30,9 +30,6 @@ function AmtManager(agent, db, isdebug) {
30
var amtMei = null, amtMeiState = 0;
31
var amtLms = null, amtLmsState = 0;
32
var amtGetVersionResult = null;
33
- var oswsstack = null;
34
- var osamtstack = null;
35
- var amtpolicy = null;
33
var obj = this;
34
var mestate;
35
var trustedHashes = null;;
@@ -43,41 +40,19 @@ function AmtManager(agent, db, isdebug) {
40
obj._lmsstate = 0;
41
obj._mapping = [];
42
46
- obj.on('newListener', function (name, callback)
47
- {
48
- if(name == 'portBinding_LMS')
49
- {
50
- callback.call(this, this._mapping);
51
- }
43
+ obj.on('newListener', function (name, callback) {
44
+ if (name == 'portBinding_LMS') { callback.call(this, this._mapping); }
45
});
46
47
Object.defineProperty(obj, 'lmsstate',
48
{
56
- get: function ()
57
- {
58
- return (this._lmsstate);
59
- },
60
- set: function (value)
61
- {
62
- if (this._lmsstate != value)
63
- {
64
- this._lmsstate = value;
65
- this.emit('stateChange_LMS', value);
66
- }
67
- }
49
+ get: function () { return (this._lmsstate); },
50
+ set: function (value) { if (this._lmsstate != value) { this._lmsstate = value; this.emit('stateChange_LMS', value); } }
51
});
52
53
obj.state = 0;
54
obj.onStateChange = null;
55
obj.setDebug = function (x) { isdebug = x; }
73
-
74
- // Set current Intel AMT activation policy
75
- obj.setPolicy = function (policy, forceApply) {
76
- if (forceApply || (JSON.stringify(amtpolicy) != JSON.stringify(policy))) {
77
- amtpolicy = policy;
78
- if (applyPolicyTimer == null) { applyPolicyTimer = setTimeout(obj.applyPolicy, 8000); }
79
- }
80
- }
56
57
// Try to load up the MEI module
58
var rebindToMeiRetrys = 0;
@@ -91,14 +66,12 @@ function AmtManager(agent, db, isdebug) {
66
amtMei.on('error', function (e) { debug('MEI error'); amtMei = null; amtMeiState = -1; obj.state = -1; if (obj.onStateChange != null) { obj.onStateChange(amtMeiState); } });
67
amtMei.getVersion(function (result) {
68
if (result == null) {
94
- amtMeiState = -1;
95
- obj.state = -1;
69
+ obj.state = amtMeiState = -1;
70
if (obj.onStateChange != null) { obj.onStateChange(amtMeiState); }
71
if (rebindToMeiRetrys < 10) { setTimeout(obj.reset, 10000); }
72
} else {
73
amtGetVersionResult = result;
100
- amtMeiState = 2;
101
- obj.state = 2;
74
+ obj.state = amtMeiState = 2;
75
rebindToMeiRetrys = 0;
76
if (obj.onStateChange != null) { obj.onStateChange(amtMeiState); }
77
//debug('MEI binded');
@@ -108,28 +81,44 @@ function AmtManager(agent, db, isdebug) {
81
} catch (ex) { debug("MEI exception: " + ex); amtMei = null; amtMeiState = -1; obj.state = -1; }
82
}
83
111
- // Get Intel AMT information using MEI
112
- var amtMeiTmpState = null;
113
- obj.getAmtInfo = function(func) {
84
+ // Get Intel MEI State in a flexible way
85
+ // Flags: 1 = Versions, 2 = OsAdmin, 4 = Hashes, 8 = Network
86
+ obj.getMeiState = function(flags, func) {
87
if ((amtMei == null) || (amtMeiState < 2)) { if (func != null) { func(null); } return; }
88
try {
116
- amtMeiTmpState = { Flags: 0 }; // Flags: 1=EHBC, 2=CCM, 4=ACM
89
+ var amtMeiTmpState = { OsHostname: require('os').hostname(), Flags: 0 }; // Flags: 1=EHBC, 2=CCM, 4=ACM
90
amtMei.getProtocolVersion(function (result) { if (result != null) { amtMeiTmpState.MeiVersion = result; } });
118
- amtMei.getVersion(function (result) { if (result) { amtMeiTmpState.Versions = {}; for (var version in result.Versions) { amtMeiTmpState.Versions[result.Versions[version].Description] = result.Versions[version].Version; } } });
91
+ if ((flags & 1) != 0) { amtMei.getVersion(function (result) { if (result) { amtMeiTmpState.Versions = {}; for (var version in result.Versions) { amtMeiTmpState.Versions[result.Versions[version].Description] = result.Versions[version].Version; } } }); }
92
amtMei.getProvisioningMode(function (result) { if (result) { amtMeiTmpState.ProvisioningMode = result.mode; } });
120
- amtMei.getProvisioningState(function (result) { if (result) { amtMeiTmpState.ProvisioningState = result.state; } });
93
+ amtMei.getProvisioningState(function (result) { if (result) { amtMeiTmpState.ProvisioningState = result.state; } }); // 0: "Not Activated (Pre)", 1: "Not Activated (In)", 2: "Activated"
94
amtMei.getEHBCState(function (result) { if ((result != null) && (result.EHBC == true)) { amtMeiTmpState.Flags += 1; } });
95
amtMei.getControlMode(function (result) { if (result != null) { if (result.controlMode == 1) { amtMeiTmpState.Flags += 2; } if (result.controlMode == 2) { amtMeiTmpState.Flags += 4; } } }); // Flag 2 = CCM, 4 = ACM
96
//amtMei.getMACAddresses(function (result) { if (result) { amtMeiTmpState.mac = result; } });
124
- amtMei.getLanInterfaceSettings(0, function (result) { if (result) { amtMeiTmpState.net0 = result; } });
125
- amtMei.getLanInterfaceSettings(1, function (result) { if (result) { amtMeiTmpState.net1 = result; } });
97
+ if ((flags & 8) != 0) {
98
+ amtMei.getLanInterfaceSettings(0, function (result) {
99
+ if (result) {
100
+ amtMeiTmpState.net0 = result;
101
+ var fqdn = null, interfaces = require('os').networkInterfaces(); // Look for the DNS suffix for the Intel AMT Ethernet interface
102
+ for (var i in interfaces) { for (var j in interfaces[i]) { if ((interfaces[i][j].mac == result.mac) && (interfaces[i][j].fqdn != null) && (interfaces[i][j].fqdn != '')) { amtMeiTmpState.OsDnsSuffix = interfaces[i][j].fqdn; } } }
103
+ }
104
+ });
105
+ amtMei.getLanInterfaceSettings(1, function (result) { if (result) { amtMeiTmpState.net1 = result; } });
106
+ }
107
amtMei.getUuid(function (result) { if ((result != null) && (result.uuid != null)) { amtMeiTmpState.UUID = result.uuid; } });
127
- amtMei.getDnsSuffix(function (result) { if (result != null) { amtMeiTmpState.DNS = result; } if (func != null) { func(amtMeiTmpState); } });
108
+ if ((flags & 2) != 0) { amtMei.getLocalSystemAccount(function (x) { if ((x != null) && x.user && x.pass) { amtMeiTmpState.OsAdmin = { user: x.user, pass: x.pass }; } }); }
109
+ amtMei.getDnsSuffix(function (result) { if (result != null) { amtMeiTmpState.DnsSuffix = result; } if ((flags & 4) == 0) { if (func != null) { func(amtMeiTmpState); } } });
110
+ if ((flags & 4) != 0) {
111
+ amtMei.getHashHandles(function (handles) {
112
+ if ((handles != null) && (handles.length > 0)) { amtMeiTmpState.Hashes = []; } else { func(amtMeiTmpState); }
113
+ var exitOnCount = handles.length;
114
+ for (var i = 0; i < handles.length; ++i) { this.getCertHashEntry(handles[i], function (hashresult) { amtMeiTmpState.Hashes.push(hashresult); if (--exitOnCount == 0) { if (func != null) { func(amtMeiTmpState); } } }); }
115
+ });
116
+ }
117
} catch (e) { if (func != null) { func(null); } return; }
118
}
119
120
// Called on MicroLMS Intel AMT user notification
132
- var handleAmtNotification = function(notifyMsg) {
121
+ var handleAmtNotification = function (notifyMsg) {
122
if ((notifyMsg == null) || (notifyMsg.Body == null) || (notifyMsg.Body.MessageID == null) || (notifyMsg.Body.MessageArguments == null)) return null;
123
var amtMessage = notifyMsg.Body.MessageID, amtMessageArg = notifyMsg.Body.MessageArguments[0], notify = null;
124
@@ -149,632 +138,15 @@ function AmtManager(agent, db, isdebug) {
138
obj.lmsstate = 0;
139
try {
140
var lme_heci = require('amt-lme');
152
- amtLmsState = 1;
153
- obj.lmsstate = 1;
141
+ obj.lmsstate = amtLmsState = 1;
142
amtLms = new lme_heci();
155
- amtLms.on('error', function (e) { amtLmsState = 0; obj.lmsstate = 0; amtLms = null; debug("LMS error: " + e); setupMeiOsAdmin(1); });
156
- amtLms.on('connect', function () { amtLmsState = 2; obj.lmsstate = 2; debug("LMS connected"); setupMeiOsAdmin(2); });
157
- amtLms.on('bind', function (map)
158
- {
159
- obj._mapping = map;
160
- obj.emit('portBinding_LMS', map);
161
- });
162
- amtLms.on('notify', function (data, options, str, code) {
163
- //debug('LMS notify');
164
- if (code == 'iAMT0052-3') {
165
- kvmGetData();
166
- } else {
167
- //if (str != null) { debug('Intel AMT LMS: ' + str); }
168
- handleAmtNotification(data);
169
- }
170
- });
143
+ amtLms.on('error', function (e) { amtLmsState = 0; obj.lmsstate = 0; amtLms = null; debug("LMS error: " + e); });
144
+ amtLms.on('connect', function () { amtLmsState = 2; obj.lmsstate = 2; debug("LMS connected"); });
145
+ amtLms.on('bind', function (map) { obj._mapping = map; obj.emit('portBinding_LMS', map); });
146
+ amtLms.on('notify', function (data, options, code) { handleAmtNotification(data); });
147
} catch (e) { amtLmsState = -1; obj.lmsstate = -1; amtLms = null; }
148
}
149
174
-
175
- //
176
- // KVM Data Channel
177
- //
178
-
179
- var setupMeiOsAdmin = function (state) {
180
- //debug('Setup MEI OS Admin');
181
- if ((amtMei == null) || (amtMeiState < 2) || (amtGetVersionResult == null)) { return; } // If there is no MEI, don't bother with obj.
182
- amtMei.getLocalSystemAccount(function (x) {
183
- if (x == null) return;
184
- //debug('getLocalSystemAccount ' + JSON.stringify(x));
185
- var transport = require('amt-wsman-duk');
186
- var wsman = require('amt-wsman');
187
- var amt = require('amt');
188
- oswsstack = new wsman(transport, '127.0.0.1', 16992, x.user, x.pass, false);
189
- osamtstack = new amt(oswsstack);
190
- //if (func) { func(state); }
191
-
192
- // We got the $$OsAdmin account setup.
193
- amtMeiState = 3;
194
- obj.state = 3;
195
- if (obj.onStateChange != null) { obj.onStateChange(amtMeiState); }
196
- if (applyPolicyTimer == null) { obj.applyPolicy(); }
197
-
198
- //var AllWsman = "CIM_SoftwareIdentity,IPS_SecIOService,IPS_ScreenSettingData,IPS_ProvisioningRecordLog,IPS_HostBasedSetupService,IPS_HostIPSettings,IPS_IPv6PortSettings".split(',');
199
- //osamtstack.BatchEnum(null, AllWsman, startLmsWsmanResponse, null, true);
200
- //*************************************
201
- // Setup KVM data channel if this is Intel AMT 12 or above
202
- var amtver = null;
203
- try { for (var i in amtGetVersionResult.Versions) { if (amtGetVersionResult.Versions[i].Description == 'AMT') amtver = parseInt(amtGetVersionResult.Versions[i].Version.split('.')[0]); } } catch (e) { }
204
- if ((amtver != null) && (amtver >= 12)) {
205
- //debug('KVM data channel setup');
206
- kvmGetData('skip'); // Clear any previous data, this is a dummy read to about handling old data.
207
- obj.kvmTempTimer = setInterval(function () { kvmGetData(); }, 2000); // Start polling for KVM data.
208
- kvmSetData(JSON.stringify({ action: 'restart', ver: 1 })); // Send a restart command to advise the console if present that MicroLMS just started.
209
- }
210
- });
211
- }
212
-
213
- var kvmGetData = function (tag) {
214
- osamtstack.IPS_KVMRedirectionSettingData_DataChannelRead(obj.kvmDataGetResponse, tag);
215
- }
216
-
217
- var kvmDataGetResponse = function (stack, name, response, status, tag) {
218
- if ((tag != 'skip') && (status == 200) && (response.Body.ReturnValue == 0)) {
219
- var val = null;
220
- try { val = Buffer.from(response.Body.DataMessage, 'base64').toString(); } catch (e) { return }
221
- if (val != null) { obj.kvmProcessData(response.Body.RealmsBitmap, response.Body.MessageId, val); }
222
- }
223
- }
224
-
225
- var webRtcDesktop = null;
226
- var kvmProcessData = function (realms, messageId, val) {
227
- var data = null;
228
- try { data = JSON.parse(val) } catch (e) { }
229
- if ((data != null) && (data.action)) {
230
- if (data.action == 'present') { kvmSetData(JSON.stringify({ action: 'present', ver: 1, platform: process.platform })); }
231
- if (data.action == 'offer') {
232
- webRtcDesktop = {};
233
- var rtc = require('ILibWebRTC');
234
- webRtcDesktop.webrtc = rtc.createConnection();
235
- webRtcDesktop.webrtc.on('connected', function () { });
236
- webRtcDesktop.webrtc.on('disconnected', function () { obj.webRtcCleanUp(); });
237
- webRtcDesktop.webrtc.on('dataChannel', function (rtcchannel) {
238
- webRtcDesktop.rtcchannel = rtcchannel;
239
- webRtcDesktop.kvm = mesh.getRemoteDesktopStream();
240
- webRtcDesktop.kvm.pipe(webRtcDesktop.rtcchannel, { dataTypeSkip: 1, end: false });
241
- webRtcDesktop.rtcchannel.on('end', function () { obj.webRtcCleanUp(); });
242
- webRtcDesktop.rtcchannel.on('data', function (x) { obj.kvmCtrlData(this, x); });
243
- webRtcDesktop.rtcchannel.pipe(webRtcDesktop.kvm, { dataTypeSkip: 1, end: false });
244
- //webRtcDesktop.kvm.on('end', function () { debug('WebRTC DataChannel closed2'); obj.webRtcCleanUp(); });
245
- //webRtcDesktop.rtcchannel.on('data', function (data) { debug('WebRTC data: ' + data); });
246
- });
247
- kvmSetData(JSON.stringify({ action: 'answer', ver: 1, sdp: webRtcDesktop.webrtc.setOffer(data.sdp) }));
248
- }
249
- }
250
- }
251
-
252
- // Process KVM control channel data
253
- var kvmCtrlData = function (channel, cmd) {
254
- if (cmd.length > 0 && cmd.charCodeAt(0) != 123) {
255
- // This is upload data
256
- if (obj.fileupload != null) {
257
- cmd = Buffer.from(cmd, 'base64');
258
- var header = cmd.readUInt32BE(0);
259
- if ((header == 0x01000000) || (header == 0x01000001)) {
260
- fs.writeSync(obj.fileupload.fp, cmd.slice(4));
261
- channel.write({ action: 'upload', sub: 'ack', reqid: obj.fileupload.reqid });
262
- if (header == 0x01000001) { fs.closeSync(obj.fileupload.fp); obj.fileupload = null; } // Close the file
263
- }
264
- }
265
- return;
266
- }
267
- debug('KVM Ctrl Data: ' + cmd);
268
- //sendConsoleText('KVM Ctrl Data: ' + cmd);
269
-
270
- try { cmd = JSON.parse(cmd); } catch (ex) { debug('Invalid JSON: ' + cmd); return; }
271
- if ((cmd.path != null) && (process.platform != 'win32') && (cmd.path[0] != '/')) { cmd.path = '/' + cmd.path; } // Add '/' to paths on non-windows
272
- switch (cmd.action) {
273
- case 'ping': {
274
- // This is a keep alive
275
- channel.write({ action: 'pong' });
276
- break;
277
- }
278
- case 'lock': {
279
- // Lock the current user out of the desktop
280
- if (process.platform == 'win32') { var child = require('child_process'); child.execFile(process.env['windir'] + '\\system32\\cmd.exe', ['/c', 'RunDll32.exe user32.dll,LockWorkStation'], { type: 1 }); }
281
- break;
282
- }
283
- case 'ls': {
284
- /*
285
- // Close the watcher if required
286
- var samepath = ((obj.httprequest.watcher != undefined) && (cmd.path == obj.httprequest.watcher.path));
287
- if ((obj.httprequest.watcher != undefined) && (samepath == false)) {
288
- //console.log('Closing watcher: ' + obj.httprequest.watcher.path);
289
- //obj.httprequest.watcher.close(); // TODO: This line causes the agent to crash!!!!
290
- delete obj.httprequest.watcher;
291
- }
292
- */
293
-
294
- // Send the folder content to the browser
295
- var response = getDirectoryInfo(cmd.path);
296
- if (cmd.reqid != undefined) { response.reqid = cmd.reqid; }
297
- channel.write(response);
298
-
299
- /*
300
- // Start the directory watcher
301
- if ((cmd.path != '') && (samepath == false)) {
302
- var watcher = fs.watch(cmd.path, onFileWatcher);
303
- watcher.tunnel = obj.httprequest;
304
- watcher.path = cmd.path;
305
- obj.httprequest.watcher = watcher;
306
- //console.log('Starting watcher: ' + obj.httprequest.watcher.path);
307
- }
308
- */
309
- break;
310
- }
311
- case 'mkdir': {
312
- // Create a new empty folder
313
- fs.mkdirSync(cmd.path);
314
- break;
315
- }
316
- case 'rm': {
317
- // Remove many files or folders
318
- for (var i in cmd.delfiles) {
319
- var fullpath = path.join(cmd.path, cmd.delfiles[i]);
320
- try { fs.unlinkSync(fullpath); } catch (e) { debug(e); }
321
- }
322
- break;
323
- }
324
- case 'rename': {
325
- // Rename a file or folder
326
- try { fs.renameSync(path.join(cmd.path, cmd.oldname), path.join(cmd.path, cmd.newname)); } catch (e) { debug(e); }
327
- break;
328
- }
329
- case 'download': {
330
- // Download a file, to browser
331
- var sendNextBlock = 0;
332
- if (cmd.sub == 'start') { // Setup the download
333
- if (obj.filedownload != null) { channel.write({ action: 'download', sub: 'cancel', id: obj.filedownload.id }); delete obj.filedownload; }
334
- obj.filedownload = { id: cmd.id, path: cmd.path, ptr: 0 }
335
- try { obj.filedownload.f = fs.openSync(obj.filedownload.path, 'rbN'); } catch (e) { channel.write({ action: 'download', sub: 'cancel', id: obj.filedownload.id }); delete obj.filedownload; }
336
- if (obj.filedownload) { channel.write({ action: 'download', sub: 'start', id: cmd.id }); }
337
- } else if ((obj.filedownload != null) && (cmd.id == obj.filedownload.id)) { // Download commands
338
- if (cmd.sub == 'startack') { sendNextBlock = 8; } else if (cmd.sub == 'stop') { delete obj.filedownload; } else if (cmd.sub == 'ack') { sendNextBlock = 1; }
339
- }
340
- // Send the next download block(s)
341
- while (sendNextBlock > 0) {
342
- sendNextBlock--;
343
- var buf = Buffer.alloc(4096);
344
- var len = fs.readSync(obj.filedownload.f, buf, 4, 4092, null);
345
- obj.filedownload.ptr += len;
346
- if (len < 4092) { buf.writeInt32BE(0x01000001, 0); fs.closeSync(obj.filedownload.f); delete obj.filedownload; sendNextBlock = 0; } else { buf.writeInt32BE(0x01000000, 0); }
347
- channel.write(buf.slice(0, len + 4).toString('base64')); // Write as Base64
348
- }
349
- break;
350
- }
351
- case 'upload': {
352
- // Upload a file, from browser
353
- if (cmd.sub == 'start') { // Start the upload
354
- if (obj.fileupload != null) { fs.closeSync(obj.fileupload.fp); }
355
- if (!cmd.path || !cmd.name) break;
356
- obj.fileupload = { reqid: cmd.reqid };
357
- var filepath = path.join(cmd.path, cmd.name);
358
- try { obj.fileupload.fp = fs.openSync(filepath, 'wbN'); } catch (e) { }
359
- if (obj.fileupload.fp) { channel.write({ action: 'upload', sub: 'start', reqid: obj.fileupload.reqid }); } else { obj.fileupload = null; channel.write({ action: 'upload', sub: 'error', reqid: obj.fileupload.reqid }); }
360
- }
361
- else if (cmd.sub == 'cancel') { // Stop the upload
362
- if (obj.fileupload != null) { fs.closeSync(obj.fileupload.fp); obj.fileupload = null; }
363
- }
364
- break;
365
- }
366
- case 'copy': {
367
- // Copy a bunch of files from scpath to dspath
368
- for (var i in cmd.names) {
369
- var sc = path.join(cmd.scpath, cmd.names[i]), ds = path.join(cmd.dspath, cmd.names[i]);
370
- if (sc != ds) { try { fs.copyFileSync(sc, ds); } catch (e) { } }
371
- }
372
- break;
373
- }
374
- case 'move': {
375
- // Move a bunch of files from scpath to dspath
376
- for (var i in cmd.names) {
377
- var sc = path.join(cmd.scpath, cmd.names[i]), ds = path.join(cmd.dspath, cmd.names[i]);
378
- if (sc != ds) { try { fs.copyFileSync(sc, ds); fs.unlinkSync(sc); } catch (e) { } }
379
- }
380
- break;
381
- }
382
- default: {
383
- debug('Invalid KVM command: ' + cmd);
384
- break;
385
- }
386
- }
387
- }
388
-
389
- var webRtcCleanUp = function () {
390
- debug('webRtcCleanUp');
391
- if (webRtcDesktop == null) return;
392
- if (webRtcDesktop.rtcchannel) {
393
- try { webRtcDesktop.rtcchannel.close(); } catch (e) { }
394
- try { webRtcDesktop.rtcchannel.removeAllListeners('data'); } catch (e) { }
395
- try { webRtcDesktop.rtcchannel.removeAllListeners('end'); } catch (e) { }
396
- delete webRtcDesktop.rtcchannel;
397
- }
398
- if (webRtcDesktop.webrtc) {
399
- try { webRtcDesktop.webrtc.close(); } catch (e) { }
400
- try { webRtcDesktop.webrtc.removeAllListeners('connected'); } catch (e) { }
401
- try { webRtcDesktop.webrtc.removeAllListeners('disconnected'); } catch (e) { }
402
- try { webRtcDesktop.webrtc.removeAllListeners('dataChannel'); } catch (e) { }
403
- delete webRtcDesktop.webrtc;
404
- }
405
- if (webRtcDesktop.kvm) {
406
- try { webRtcDesktop.kvm.end(); } catch (e) { }
407
- delete webRtcDesktop.kvm;
408
- }
409
- webRtcDesktop = null;
410
- }
411
-
412
- var kvmSetData = function (x) {
413
- osamtstack.IPS_KVMRedirectionSettingData_DataChannelWrite(Buffer.from(x).toString('base64'), function () { });
414
- }
415
-
416
- // Delete a directory with a files and directories within it
417
- var deleteFolderRecursive = function(path, rec) {
418
- if (fs.existsSync(path)) {
419
- if (rec == true) {
420
- fs.readdirSync(obj.path.join(path, '*')).forEach(function (file, index) {
421
- var curPath = obj.path.join(path, file);
422
- if (fs.statSync(curPath).isDirectory()) { // recurse
423
- deleteFolderRecursive(curPath, true);
424
- } else { // delete file
425
- fs.unlinkSync(curPath);
426
- }
427
- });
428
- }
429
- fs.unlinkSync(path);
430
- }
431
- };
432
-
433
- // Polyfill path.join
434
- var path = {
435
- join: function () {
436
- var x = [];
437
- for (var i in arguments) {
438
- var w = arguments[i];
439
- if (w != null) {
440
- while (w.endsWith('/') || w.endsWith('\\')) { w = w.substring(0, w.length - 1); }
441
- if (i != 0) { while (w.startsWith('/') || w.startsWith('\\')) { w = w.substring(1); } }
442
- x.push(w);
443
- }
444
- }
445
- if (x.length == 0) return '/';
446
- return x.join('/');
447
- }
448
- };
449
-
450
- function md5hex(str) { return require('MD5Stream').create().syncHash(str).toString('hex'); }
451
-
452
- //
453
- // Deactivate Intel AMT CCM
454
- //
455
-
456
- // When called, this will use MEI to deactivate Intel AMT when it's in CCM mode. Simply calls "unprovision" on MEI and checks the return code.
457
- obj.deactivateCCM = function() {
458
- amtMei.unprovision(1, function (status) {
459
- if (status == 0) {
460
- debug('Success deactivating Intel AMT CCM.');
461
- agent.SendCommand({ "action": "coreinfo", "intelamt": { "state": 0, "flags": 0 } });
462
- applyPolicyTimer = setTimeout(obj.applyPolicy, 8000);
463
- } else {
464
- debug('Intel AMT CCM deactivation error: ' + status);
465
- }
466
- });
467
- }
468
-
469
- //
470
- // Get Intel AMT activation hashes
471
- //
472
- obj.getTrustedHashes = function (func, tag) {
473
- if (trustedHashes != null) { func(tag); }
474
- trustedHashes = [];
475
- amtMei.getHashHandles(function (handles) {
476
- var exitOnCount = handles.length;
477
- for (var i = 0; i < handles.length; ++i) {
478
- this.getCertHashEntry(handles[i], function (result) {
479
- if (result.isActive == 1) { trustedHashes.push(result.certificateHash.toLowerCase()); }
480
- if (--exitOnCount == 0) { func(tag); }
481
- });
482
- }
483
- });
484
- }
485
-
486
- //
487
- // Activate Intel AMT to ACM
488
- //
489
-
490
- obj.activeToACM = function (mestate) {
491
- if ((mestate.ProvisioningState != 0) || (amtpolicy == null) || (amtpolicy.match == null)) return; // Can't activate unless in "PRE" activation mode & policy is present.
492
- var trustedFqdn = null;
493
- if ((mestate.net0 == null) && (mestate.net0.enabled != 0)) return; // Can't activate unless wired interface is active
494
- if (mestate.DNS) { trustedFqdn = mestate.DNS; } // If Intel AMT has a trusted DNS suffix set, use that one.
495
- else {
496
- // Look for the DNS suffix for the Intel AMT Ethernet interface
497
- var interfaces = require('os').networkInterfaces();
498
- for (var i in interfaces) {
499
- for (var j in interfaces[i]) {
500
- if ((interfaces[i][j].mac == mestate.net0.mac) && (interfaces[i][j].fqdn != null) && (interfaces[i][j].fqdn != '')) { trustedFqdn = interfaces[i][j].fqdn.toLowerCase(); }
501
- }
502
- }
503
- }
504
- if (trustedFqdn == null) return; // No trusted DNS suffix.
505
-
506
- // Check if we have a ACM policy match
507
- var hashMatch = null;
508
- for (var i in amtpolicy.match) { var m = amtpolicy.match[i]; if (m.cn == trustedFqdn) { for (var j in trustedHashes) { if ((trustedHashes[j] == m.sha256) || (trustedHashes[j] == m.sha1)) { hashMatch = trustedHashes[j]; } } } }
509
- if (hashMatch == null) return; // No certificate / FQDN match
510
-
511
- // Fetch Intel AMT realm and activation nonce and get ready to ACM activation...
512
- if (osamtstack != null) {
513
- osamtstack.BatchEnum(null, ['*AMT_GeneralSettings', '*IPS_HostBasedSetupService'], activeToACM2, { fqdn: trustedFqdn, hash: hashMatch, uuid: mestate.UUID });
514
- } else {
515
- amtMei.getLocalSystemAccount(function (x) {
516
- if ((x != null) && x.user && x.pass) {
517
- var transport = require('amt-wsman-duk');
518
- var wsman = require('amt-wsman');
519
- var amt = require('amt');
520
- oswsstack = new wsman(transport, '127.0.0.1', 16992, x.user, x.pass, false);
521
- osamtstack = new amt(oswsstack);
522
- osamtstack.BatchEnum(null, ['*AMT_GeneralSettings', '*IPS_HostBasedSetupService'], activeToACM2, { fqdn: trustedFqdn, hash: hashMatch, uuid: mestate.UUID });
523
- }
524
- });
525
- }
526
- }
527
-
528
- function activeToACM2(stack, name, responses, status, tag) {
529
- if (status != 200) return;
530
- var fwNonce = responses['IPS_HostBasedSetupService'].response['ConfigurationNonce'];
531
- var digestRealm = responses['AMT_GeneralSettings'].response['DigestRealm'];
532
- agent.SendCommand({ "action": "acmactivate", "nonce": fwNonce, "realm": digestRealm, "fqdn": tag.fqdn, "hash": tag.hash, "uuid": tag.uuid });
533
- }
534
-
535
- // Called when the server responds with a ACM activation signature.
536
- obj.setAcmResponse = function (acmdata) { acmdata.index = 0; performAcmActivation(acmdata); }
537
-
538
- // Recursive function to inject the provisioning certificates into AMT in the proper order and completes ACM activation
539
- function performAcmActivation(acmdata) {
540
- var leaf = (acmdata.index == 0), root = (acmdata.index == (acmdata.certs.length - 1));
541
- if ((acmdata.index < acmdata.certs.length) && (acmdata.certs[acmdata.index] != null)) {
542
- osamtstack.IPS_HostBasedSetupService_AddNextCertInChain(acmdata.certs[acmdata.index], leaf, root, function (stack, name, responses, status) {
543
- if (status !== 200) { debug('AddNextCertInChain status=' + status); return; }
544
- else if (responses['Body']['ReturnValue'] !== 0) { debug('AddNextCertInChain error=' + responses['Body']['ReturnValue']); return; }
545
- else { acmdata.index++; performAcmActivation(acmdata); }
546
- });
547
- } else {
548
- osamtstack.IPS_HostBasedSetupService_AdminSetup(2, acmdata.password, acmdata.nonce, 2, acmdata.signature,
549
- function (stack, name, responses, status) {
550
- if ((status == 200) && (responses['Body']['ReturnValue'] == 0)) {
551
- // ACM activation success, force an update to the server so it can get our new state.
552
- if (obj.onStateChange != null) { obj.onStateChange(2); }
553
- }
554
- }
555
- );
556
- }
557
- }
558
-
559
- //
560
- // Activate Intel AMT to CCM
561
- //
562
-
563
- obj.makePass = function(length) {
564
- var buf = Buffer.alloc(length), text = "", possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
565
- buf.randomFill(); // Fills buffer with secure random from OpenSSL.
566
- for (var i = 0; i < length; i++) { text += possible.charAt(buf[i] % possible.length); }
567
- return text;
568
- }
569
-
570
- obj.activeToCCM = function (adminpass) {
571
- if ((adminpass == null) || (adminpass == '')) { adminpass = 'P@0s' + obj.makePass(23); }
572
- intelAmtAdminPass = adminpass;
573
- if (osamtstack != null) {
574
- osamtstack.BatchEnum(null, ['*AMT_GeneralSettings', '*IPS_HostBasedSetupService'], activeToCCMEx2, adminpass);
575
- } else {
576
- //debug('Trying to get local account info...');
577
- amtMei.getLocalSystemAccount(function (x) {
578
- if ((x != null) && x.user && x.pass) {
579
- //debug('Intel AMT local account info: User=' + x.user + ', Pass=' + x.pass + '.');
580
- var transport = require('amt-wsman-duk');
581
- var wsman = require('amt-wsman');
582
- var amt = require('amt');
583
- oswsstack = new wsman(transport, '127.0.0.1', 16992, x.user, x.pass, false);
584
- osamtstack = new amt(oswsstack);
585
- //debug('Trying to get Intel AMT activation information...');
586
- osamtstack.BatchEnum(null, ['*AMT_GeneralSettings', '*IPS_HostBasedSetupService'], activeToCCMEx2, adminpass);
587
- } else {
588
- //debug('Unable to get $$OsAdmin password.');
589
- }
590
- });
591
- }
592
- }
593
-
594
- var activeToCCMEx2 = function(stack, name, responses, status, adminpass) {
595
- if (status != 200) { debug('Failed to fetch activation information, status ' + status); }
596
- else if (responses['IPS_HostBasedSetupService'].response['AllowedControlModes'].length != 2) { debug('Client control mode activation not allowed'); }
597
- else { stack.IPS_HostBasedSetupService_Setup(2, md5hex('admin:' + responses['AMT_GeneralSettings'].response['DigestRealm'] + ':' + adminpass).substring(0, 32), null, null, null, null, activeToCCMEx3); }
598
- }
599
-
600
- var activeToCCMEx3 = function(stack, name, responses, status) {
601
- if (status != 200) { debug('Failed to activate, status ' + status); }
602
- else if (responses.Body.ReturnValue != 0) { debug('Client control mode activation failed: ' + responses.Body.ReturnValueStr); }
603
- else {
604
- debug('Intel AMT CCM activation success.');
605
- db.Put('amtCCMPass', intelAmtAdminPass);
606
- agent.SendCommand({ "action": "coreinfo", "intelamt": { "state": 2, "flags": 2, "user": "admin", "pass": intelAmtAdminPass } });
607
- }
608
- applyPolicyTimer = setTimeout(obj.applyPolicy, 8000);
609
- }
610
-
611
- obj.start = function () {
612
- // Try to load Intel AMT policy
613
- var amtPolicy = null;
614
- try { amtPolicy = JSON.parse(db.Get('amtPolicy')); } catch (ex) { debug('Exception loading amtPolicy'); }
615
- //if (amtPolicy == null) { debug('no amtPolicy'); } else { debug('Loaded amtPolicy: ' + JSON.stringify(amtPolicy)); }
616
- try { intelAmtAdminPass = db.Get('amtCCMPass'); } catch (ex) { }
617
- if (typeof intelAmtAdminPass != 'string') { intelAmtAdminPass = null; }
618
- obj.reset();
619
- }
620
-
621
- // Apply Intel AMT policy
622
- var intelAmtAdminPass, wsstack, amtstack, applyPolicyTimer, policyWsmanRetry = 0;
623
- obj.applyPolicy = function () {
624
- applyPolicyTimer = null;
625
- if ((amtMeiState != 3) || (amtpolicy == null) || (typeof amtpolicy != 'object') || (typeof amtpolicy.type != 'number') || (amtpolicy.type == 0)) return;
626
- if ((amtpolicy.password != null) && (amtpolicy.password != '')) { intelAmtAdminPass = amtpolicy.password; }
627
- obj.getAmtInfo(function (meinfo) {
628
- if ((amtpolicy.type == 1) && (meinfo.ProvisioningState == 2) && ((meinfo.Flags & 2) != 0)) {
629
- // CCM Deactivation Policy.
630
- wsstack = amtstack = null;
631
- obj.deactivateCCM();
632
- } else if ((amtpolicy.type == 2) && (meinfo.ProvisioningState == 0)) {
633
- // CCM Activation Policy
634
- wsstack = amtstack = null;
635
- if ((amtpolicy.password == null) || (amtpolicy.password == '')) { intelAmtAdminPass = null; }
636
- obj.activeToCCM(intelAmtAdminPass);
637
- } else if ((amtpolicy.type == 2) && (meinfo.ProvisioningState == 2) && (intelAmtAdminPass != null) && ((meinfo.Flags & 2) != 0)) {
638
- // Perform password test
639
- var transport = require('amt-wsman-duk');
640
- var wsman = require('amt-wsman');
641
- var amt = require('amt');
642
- wsstack = new wsman(transport, '127.0.0.1', 16992, 'admin', intelAmtAdminPass, false);
643
- amtstack = new amt(wsstack);
644
- var wsmanQuery = ['*AMT_GeneralSettings', '*IPS_HostBasedSetupService', '*AMT_RedirectionService', '*CIM_KVMRedirectionSAP', 'AMT_PublicKeyCertificate', '*AMT_EnvironmentDetectionSettingData'];
645
- if (amtpolicy.cirasetup == 2) { wsmanQuery.push("AMT_ManagementPresenceRemoteSAP", "AMT_RemoteAccessCredentialContext", "AMT_RemoteAccessPolicyAppliesToMPS", "AMT_RemoteAccessPolicyRule", "*AMT_UserInitiatedConnectionService", "AMT_MPSUsernamePassword"); }
646
- try { amtstack.BatchEnum(null, wsmanQuery, wsmanPassTestResponse); } catch (ex) { debug(ex); }
647
- } else if ((amtpolicy.type == 3) && (meinfo.ProvisioningState == 0) && (agent.isControlChannelConnected)) {
648
- // ACM Activation Policy
649
- obj.getTrustedHashes(obj.activeToACM, meinfo);
650
- } else {
651
- // Other possible cases...
652
- }
653
- });
654
- }
655
-
656
- function wsmanPassTestResponse(stack, name, responses, status) {
657
- if (status != 200) {
658
- if (status == 401) {
659
- if (amtpolicy.badpass == 1) { obj.deactivateCCM(); } // Incorrect password, reactivate
660
- } else {
661
- if (++policyWsmanRetry < 20) {
662
- if (policyWsmanRetry == 10) { debug('WSMAN fault, MEI Reset'); obj.reset(); }
663
- var wsmanQuery = ['*AMT_GeneralSettings', '*IPS_HostBasedSetupService', '*AMT_RedirectionService', '*CIM_KVMRedirectionSAP', 'AMT_PublicKeyCertificate', '*AMT_EnvironmentDetectionSettingData'];
664
- if (amtpolicy.cirasetup == 2) { wsmanQuery.push("AMT_ManagementPresenceRemoteSAP", "AMT_RemoteAccessCredentialContext", "AMT_RemoteAccessPolicyAppliesToMPS", "AMT_RemoteAccessPolicyRule", "*AMT_UserInitiatedConnectionService", "AMT_MPSUsernamePassword"); }
665
- try { amtstack.BatchEnum(null, wsmanQuery, wsmanPassTestResponse); } catch (ex) { debug(ex); }
666
- } else {
667
- debug('WSMAN fault, status=' + status);
668
- policyWsmanRetry = 0;
669
- }
670
- }
671
- } else {
672
- policyWsmanRetry = 0;
673
- var s = {};
674
- s.redir = (responses['AMT_RedirectionService'].response["ListenerEnabled"] == true);
675
- s.sol = ((responses['AMT_RedirectionService'].response["EnabledState"] & 2) != 0);
676
- s.ider = ((responses['AMT_RedirectionService'].response["EnabledState"] & 1) != 0);
677
- s.kvm = (responses['CIM_KVMRedirectionSAP'] != null) && ((responses['CIM_KVMRedirectionSAP'].response["EnabledState"] == 6 && responses['CIM_KVMRedirectionSAP'].response["RequestedState"] == 2) || responses['CIM_KVMRedirectionSAP'].response["EnabledState"] == 2 || responses['CIM_KVMRedirectionSAP'].response["EnabledState"] == 6);
678
-
679
- // Enable Ping and RMCP if disabled
680
- if ((responses['AMT_GeneralSettings'].response['PingResponseEnabled'] != true) || (responses['AMT_GeneralSettings'].response['RmcpPingResponseEnabled'] != true)) {
681
- responses['AMT_GeneralSettings'].response['PingResponseEnabled'] = true;
682
- responses['AMT_GeneralSettings'].response['RmcpPingResponseEnabled'] = true;
683
- amtstack.Put('AMT_GeneralSettings', responses['AMT_GeneralSettings'].response, function (stack, name, response, status) { if (status != 200) { debug("Enable PING PUT Error " + status); } }, 0, 1)
684
- }
685
-
686
- // Enable redirection port, SOL and IDER if needed
687
- if ((s.redir == false) || (s.sol == false) || (s.ider == false)) {
688
- var r = responses['AMT_RedirectionService'].response;
689
- r["ListenerEnabled"] = true; // Turn on the redirection port
690
- r["EnabledState"] = 32768 + 1 + 2; // Turn on IDER (1) and SOL (2)
691
- amtstack.AMT_RedirectionService_RequestStateChange(r["EnabledState"], function (stack, name, response, status) { if (status != 200) { debug("Enable Redirection EXEC Error " + status); } });
692
- }
693
-
694
- // Enable KVM if needed
695
- if ((responses['CIM_KVMRedirectionSAP'] != null) && (s.kvm == false)) {
696
- amtstack.CIM_KVMRedirectionSAP_RequestStateChange(2, 0,
697
- function (stack, name, response, status) {
698
- if (status != 200) { messagebox("Error", "KVMRedirectionSAP, RequestStateChange Error " + status); return; }
699
- amtstack.Put("AMT_RedirectionService", r, function (stack, name, response, status) { if (status != 200) { debug("Enable KVM PUT Error " + status); } }, 0, 1)
700
- }
701
- );
702
- }
703
-
704
- // Check if the MeshCentral root certificate is present
705
- if (typeof amtpolicy.rootcert == 'string') {
706
- var rootFound = false, xxCertificates = responses["AMT_PublicKeyCertificate"].responses;
707
- for (var i in xxCertificates) { if ((xxCertificates[i]["X509Certificate"] == amtpolicy.rootcert) && (xxCertificates[i]["TrustedRootCertficate"] == true)) { rootFound = true; } }
708
- if (rootFound == false) { amtstack.AMT_PublicKeyManagementService_AddTrustedRootCertificate(amtpolicy.rootcert, function (stack, name, response, status) { if (status != 200) { debug("Add root cert EXEC Error " + status); } }); }
709
- }
710
-
711
- // If CIRA needs to be setup
712
- if ((amtpolicy.cirasetup == 2) && (amtpolicy.ciraserver != null)) {
713
- var serverFound = false, xxCiraServers = responses["AMT_ManagementPresenceRemoteSAP"].responses;
714
- for (var i in xxCiraServers) { if ((xxCiraServers[i].AccessInfo == amtpolicy.ciraserver.name) && (xxCiraServers[i].Port == amtpolicy.ciraserver.port)) { serverFound = xxCiraServers[i].Name; } }
715
- if (serverFound == false) {
716
- // TODO: Remove all CIRA activation policies.
717
- // amtstack.Delete('AMT_RemoteAccessPolicyRule', { 'PolicyRuleName': name }, editMpsPolicyOk2);
718
- // TODO: Remove all other MPS servers.
719
-
720
- // Add our MPS server
721
- amtstack.AMT_RemoteAccessService_AddMpServer(amtpolicy.ciraserver.name, 201, amtpolicy.ciraserver.port, 2, null, amtpolicy.ciraserver.user, amtpolicy.ciraserver.pass, null, function (stack, name, response, status) {
722
- if (status != 200) {
723
- debug("Add MPS server EXEC Error " + status);
724
- } else {
725
- serverFound = false;
726
- var x = response.Body.MpServer.ReferenceParameters.SelectorSet.Selector;
727
- for (var i in x) { if (x[i]['@Name'] == 'Name') { serverFound = x[i]['Value']; } }
728
- if (serverFound != false) { checkCiraTriggerPolicy(responses, serverFound); }
729
- }
730
- });
731
- } else {
732
- checkCiraTriggerPolicy(responses, serverFound);
733
- }
734
- } else if (amtpolicy.cirasetup == 1) {
735
- // This call will clear environement detection if needed.
736
- checkEnvironmentDetection(responses);
737
- }
738
- }
739
- }
740
-
741
- function checkCiraTriggerPolicy(responses, serverInstanceName) {
742
- // Check CIRA activation policy
743
- var server1 = '<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="Name">' + serverInstanceName + '</Selector></SelectorSet></ReferenceParameters>';
744
- amtstack.AMT_RemoteAccessService_AddRemoteAccessPolicyRule(2, 0, 'AAAAAAAAAAo=', [server1], null, function (stack, name, response, status) {
745
- if (status != 200) {
746
- debug("Add AddRemoteAccessPolicyRule Error " + status);
747
- } else {
748
- //debug('AMT_RemoteAccessService_AddRemoteAccessPolicyRule Response:' + JSON.stringify(response));
749
- checkEnvironmentDetection(responses);
750
- }
751
- });
752
- }
753
-
754
- // Check environement detection. This will set or clear the environement detection strings as needed.
755
- function checkEnvironmentDetection(responses) {
756
- var t2 = [];
757
- if ((amtpolicy.ciraserver != null) && (amtpolicy.ciraserver.home != null)) { t2 = amtpolicy.ciraserver.home; }
758
- var t = responses["AMT_EnvironmentDetectionSettingData"].response;
759
- t['DetectionStrings'] = MakeToArray(t['DetectionStrings']);
760
- if (CompareStrArrays(t['DetectionStrings'], t2) == false) {
761
- t['DetectionStrings'] = t2;
762
- amtstack.Put('AMT_EnvironmentDetectionSettingData', t, function (stack, name, response, status) { if (status != 200) { debug("Put AMT_EnvironmentDetectionSettingData Error " + status); } }, 0, 1);
763
- }
764
- }
765
-
766
- // Imperfect compare of two string arrays.
767
- function CompareStrArrays(arr1, arr2) {
768
- if (arr1 == arr2) return true;
769
- if (arr1 == null) { arr1 = []; }
770
- if (arr2 == null) { arr2 = []; }
771
- if (arr1.length != arr2.length) return false;
772
- for (var i in arr1) { if (arr2.indexOf(arr1[i]) == -1) return false; }
773
- return true;
774
- }
775
-
776
- function MakeToArray(v) { if (!v || v == null || typeof v == "object") return v; return [v]; };
777
-
150
}
151
152
module.exports = AmtManager;
agents/modules_meshcore/amt-scanner.js
deleted
-109
@@ -1,109 +0,0 @@
1
-/*
2
-Copyright 2018-2020 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 Meshcentral Intel AMT Local Scanner
19
-* @author Ylian Saint-Hilaire & Joko Sastriawan
20
-* @version v0.0.1
21
-*/
22
-
23
-// Construct a Intel AMT Scanner object
24
-
25
-function AMTScanner() {
26
- var emitterUtils = require('events').inherits(this);
27
- emitterUtils.createEvent('found');
28
-
29
- this.dgram = require('dgram');
30
-
31
- this.buildRmcpPing = function (tag) {
32
- var packet = Buffer.from('06000006000011BE80000000', 'hex');
33
- packet[9] = tag;
34
- return packet;
35
- };
36
-
37
- this.parseRmcpPacket = function (server, data, rinfo, func) {
38
- if (data == null || data.length < 20) return;
39
- var res = {};
40
- if (((data[12] == 0) || (data[13] != 0) || (data[14] != 1) || (data[15] != 0x57)) && (data[21] & 32)) {
41
- res.servertag = data[9];
42
- res.minorVersion = data[18] & 0x0F;
43
- res.majorVersion = (data[18] >> 4) & 0x0F;
44
- res.provisioningState = data[19] & 0x03; // Pre = 0, In = 1, Post = 2
45
-
46
- var openPort = (data[16] * 256) + data[17];
47
- var dualPorts = ((data[19] & 0x04) != 0) ? true : false;
48
- res.openPorts = [openPort];
49
- res.address = rinfo.address;
50
- if (dualPorts == true) { res.openPorts = [16992, 16993]; }
51
- if (func !== undefined) {
52
- func(server, res);
53
- }
54
- }
55
- }
56
-
57
- this.parseIPv4Range = function (range) {
58
- if (range == undefined || range == null) return null;
59
- var x = range.split('-');
60
- if (x.length == 2) { return { min: this.parseIpv4Addr(x[0]), max: this.parseIpv4Addr(x[1]) }; }
61
- x = range.split('/');
62
- if (x.length == 2) {
63
- var ip = this.parseIpv4Addr(x[0]), masknum = parseInt(x[1]), mask = 0;
64
- if (masknum <= 16 || masknum > 32) return null;
65
- masknum = 32 - masknum;
66
- for (var i = 0; i < masknum; i++) { mask = (mask << 1); mask++; }
67
- return { min: (ip & (0xFFFFFFFF - mask))+1, max: (ip & (0xFFFFFFFF - mask)) + mask -1 };//remove network and broadcast address to avoid irrecoverable socket error
68
- }
69
- x = this.parseIpv4Addr(range);
70
- if (x == null) return null;
71
- return { min: x, max: x };
72
- };
73
-
74
- // Parse IP address. Takes a
75
- this.parseIpv4Addr = function (addr) {
76
- var x = addr.split('.');
77
- if (x.length == 4) { return (parseInt(x[0]) << 24) + (parseInt(x[1]) << 16) + (parseInt(x[2]) << 8) + (parseInt(x[3]) << 0); }
78
- return null;
79
- }
80
-
81
- // IP address number to string
82
- this.IPv4NumToStr = function (num) {
83
- return ((num >> 24) & 0xFF) + '.' + ((num >> 16) & 0xFF) + '.' + ((num >> 8) & 0xFF) + '.' + (num & 0xFF);
84
- }
85
-
86
- this.scan = function (rangestr, timeout, callback) {
87
- var iprange = this.parseIPv4Range(rangestr);
88
- var rmcp = this.buildRmcpPing(0);
89
- var server = this.dgram.createSocket({ type: 'udp4' });
90
- server.parent = this;
91
- server.scanResults = [];
92
- server.on('error', function (err) { console.log('Error:' + err); });
93
- server.on('message', function (msg, rinfo) { if (rinfo.size > 4) { this.parent.parseRmcpPacket(this, msg, rinfo, function (s, res) { s.scanResults.push(res); }) }; });
94
- server.on('listening', function () { for (var i = iprange.min; i <= iprange.max; i++) {
95
- server.send(rmcp, 623, server.parent.IPv4NumToStr(i)); } });
96
- server.bind({ address: '0.0.0.0', port: 0, exclusive: true });
97
- var tmout = setTimeout(function cb() {
98
- //console.log("Server closed");
99
- server.close();
100
- if (callback) {
101
- callback(server.scanResults);
102
- }
103
- server.parent.emit('found', server.scanResults);
104
- delete server;
105
- }, timeout);
106
- };
107
-}
108
-
109
-module.exports = AMTScanner;
agents/modules_meshcore/amt-wsman-duk.js
deleted
-147
@@ -1,147 +0,0 @@
1
-/*
2
-Copyright 2018-2020 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
-
92
- var req = obj.digest.request(request);
93
- //console.log('Request ' + (obj.RequestCount++));
94
-
95
- req.on('error', function (e) { obj.gotNextMessagesError({ status: 600 }, 'error', null, [postdata, callback, tag]); });
96
- req.on('response', function (response) {
97
- //console.log('Response: ' + response.statusCode);
98
- if (response.statusCode != 200) {
99
- //console.log('ERR:' + JSON.stringify(response));
100
- obj.gotNextMessagesError({ status: response.statusCode }, 'error', null, [postdata, callback, tag]);
101
- } else {
102
- response.acc = '';
103
- response.on('data', function (data2) { this.acc += data2; });
104
- response.on('end', function () { obj.gotNextMessages(response.acc, 'success', { status: response.statusCode }, [postdata, callback, tag]); });
105
- }
106
- });
107
-
108
- // Send POST body, this work with binary.
109
- req.end(postdata);
110
-
111
- obj.ActiveAjaxCount++;
112
- return req;
113
- }
114
-
115
- // AJAX specific private method
116
- obj.pendingAjaxCall = [];
117
-
118
- // Private method
119
- obj.gotNextMessages = function (data, status, request, callArgs) {
120
- obj.ActiveAjaxCount--;
121
- if (obj.FailAllError == 999) return;
122
- //console.log("RECV: " + data); // DEBUG
123
- if (obj.FailAllError != 0) { callArgs[1](null, obj.FailAllError, callArgs[2]); return; }
124
- if (request.status != 200) { callArgs[1](null, request.status, callArgs[2]); return; }
125
- callArgs[1](data, 200, callArgs[2]);
126
- obj.PerformNextAjax();
127
- }
128
-
129
- // Private method
130
- obj.gotNextMessagesError = function (request, status, errorThrown, callArgs) {
131
- obj.ActiveAjaxCount--;
132
- if (obj.FailAllError == 999) return;
133
- if (obj.FailAllError != 0) { callArgs[1](null, obj.FailAllError, callArgs[2]); return; }
134
- //if (status != 200) { console.log("ERROR, status=" + status + "\r\n\r\nreq=" + callArgs[0]); } // Debug: Display the request & response if something did not work.
135
- if (obj.FailAllError != 999) { callArgs[1]({ Header: { HttpError: request.status } }, request.status, callArgs[2]); }
136
- obj.PerformNextAjax();
137
- }
138
-
139
- // Cancel all pending queries with given status
140
- obj.CancelAllQueries = function (s) {
141
- while (obj.PendingAjax.length > 0) { var x = obj.PendingAjax.shift(); x[1](null, s, x[2]); }
142
- }
143
-
144
- return obj;
145
-}
146
-
147
-module.exports = CreateWsmanComm;
agents/modules_meshcore/amt-wsman.js
deleted
-211
@@ -1,211 +0,0 @@
1
-/*
2
-Copyright 2018-2020 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 == null) || (selectorSet == 'null')) 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-xml.js
deleted
-189
@@ -1,189 +0,0 @@
1
-/*
2
-Copyright 2018-2020 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
-try { Object.defineProperty(Array.prototype, "peek", { value: function () { return (this.length > 0 ? this[this.length - 1] : undefined); } }); } catch (e) { }
18
-
19
-
20
-// Parse XML and return JSON
21
-module.exports.ParseWsman = function (xml) {
22
- try {
23
- if (!xml.childNodes) xml = _turnToXml(xml);
24
- var r = { Header: {} }, header = xml.getElementsByTagName("Header")[0], t;
25
- if (!header) header = xml.getElementsByTagName("a:Header")[0];
26
- if (!header) return null;
27
- for (var i = 0; i < header.childNodes.length; i++) {
28
- var child = header.childNodes[i];
29
- r.Header[child.localName] = child.textContent;
30
- }
31
- var body = xml.getElementsByTagName("Body")[0];
32
- if (!body) body = xml.getElementsByTagName("a:Body")[0];
33
- if (!body) return null;
34
- if (body.childNodes.length > 0) {
35
- t = body.childNodes[0].localName;
36
- var x = t.indexOf('_OUTPUT');
37
- if ((x != -1) && (x == (t.length - 7))) { t = t.substring(0, t.length - 7); }
38
- r.Header['Method'] = t;
39
- r.Body = _ParseWsmanRec(body.childNodes[0]);
40
- }
41
- return r;
42
- } catch (e) {
43
- console.error("Unable to parse XML: " + xml, e);
44
- return null;
45
- }
46
-}
47
-
48
-// Private method
49
-function _ParseWsmanRec(node) {
50
- var data, r = {};
51
- for (var i = 0; i < node.childNodes.length; i++) {
52
- var child = node.childNodes[i];
53
- if ((child.childElementCount == null) || (child.childElementCount == 0)) { data = child.textContent; } else { data = _ParseWsmanRec(child); }
54
- if (data == 'true') data = true; // Convert 'true' into true
55
- if (data == 'false') data = false; // Convert 'false' into false
56
- if ((parseInt(data) + '') === data) data = parseInt(data); // Convert integers
57
-
58
- var childObj = data;
59
- if ((child.attributes != null) && (child.attributes.length > 0)) {
60
- childObj = { 'Value': data };
61
- for (var j = 0; j < child.attributes.length; j++) {
62
- childObj['@' + child.attributes[j].name] = child.attributes[j].value;
63
- }
64
- }
65
-
66
- if (r[child.localName] instanceof Array) { r[child.localName].push(childObj); }
67
- else if (r[child.localName] == null) { r[child.localName] = childObj; }
68
- else { r[child.localName] = [r[child.localName], childObj]; }
69
- }
70
- return r;
71
-}
72
-
73
-function _PutObjToBodyXml(resuri, putObj) {
74
- if (!resuri || putObj == null) return '';
75
- var objname = obj.GetNameFromUrl(resuri);
76
- var result = '<r:' + objname + ' xmlns:r="' + resuri + '">';
77
-
78
- for (var prop in putObj) {
79
- if (!putObj.hasOwnProperty(prop) || prop.indexOf('__') === 0 || prop.indexOf('@') === 0) continue;
80
- if (putObj[prop] == null || typeof putObj[prop] === 'function') continue;
81
- if (typeof putObj[prop] === 'object' && putObj[prop]['ReferenceParameters']) {
82
- result += '<r:' + prop + '><a:Address>' + putObj[prop].Address + '</a:Address><a:ReferenceParameters><w:ResourceURI>' + putObj[prop]['ReferenceParameters']["ResourceURI"] + '</w:ResourceURI><w:SelectorSet>';
83
- var selectorArray = putObj[prop]['ReferenceParameters']['SelectorSet']['Selector'];
84
- if (Array.isArray(selectorArray)) {
85
- for (var i = 0; i < selectorArray.length; i++) {
86
- result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray[i]) + '>' + selectorArray[i]['Value'] + '</w:Selector>';
87
- }
88
- }
89
- else {
90
- result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray) + '>' + selectorArray['Value'] + '</w:Selector>';
91
- }
92
- result += '</w:SelectorSet></a:ReferenceParameters></r:' + prop + '>';
93
- }
94
- else {
95
- if (Array.isArray(putObj[prop])) {
96
- for (var i = 0; i < putObj[prop].length; i++) {
97
- result += '<r:' + prop + '>' + putObj[prop][i].toString() + '</r:' + prop + '>';
98
- }
99
- } else {
100
- result += '<r:' + prop + '>' + putObj[prop].toString() + '</r:' + prop + '>';
101
- }
102
- }
103
- }
104
-
105
- result += '</r:' + objname + '>';
106
- return result;
107
-}
108
-
109
-// This is a drop-in replacement to _turnToXml() that works without xml parser dependency.
110
-function _treeBuilder() {
111
- this.tree = [];
112
- this.push = function (element) { this.tree.push(element); };
113
- this.pop = function () { var element = this.tree.pop(); if (this.tree.length > 0) { var x = this.tree.peek(); x.childNodes.push(element); x.childElementCount = x.childNodes.length; } return (element); };
114
- this.peek = function () { return (this.tree.peek()); }
115
- this.addNamespace = function (prefix, namespace) { this.tree.peek().nsTable[prefix] = namespace; if (this.tree.peek().attributes.length > 0) { for (var i = 0; i < this.tree.peek().attributes; ++i) { var a = this.tree.peek().attributes[i]; if (prefix == '*' && a.name == a.localName) { a.namespace = namespace; } else if (prefix != '*' && a.name != a.localName) { var pfx = a.name.split(':')[0]; if (pfx == prefix) { a.namespace = namespace; } } } } }
116
- this.getNamespace = function (prefix) { for (var i = this.tree.length - 1; i >= 0; --i) { if (this.tree[i].nsTable[prefix] != null) { return (this.tree[i].nsTable[prefix]); } } return null; }
117
-}
118
-function _turnToXml(text) { if (text == null) return null; return ({ childNodes: [_turnToXmlRec(text)], getElementsByTagName: _getElementsByTagName, getChildElementsByTagName: _getChildElementsByTagName, getElementsByTagNameNS: _getElementsByTagNameNS }); }
119
-function _getElementsByTagNameNS(ns, name) { var ret = []; _xmlTraverseAllRec(this.childNodes, function (node) { if (node.localName == name && (node.namespace == ns || ns == '*')) { ret.push(node); } }); return ret; }
120
-function _getElementsByTagName(name) { var ret = []; _xmlTraverseAllRec(this.childNodes, function (node) { if (node.localName == name) { ret.push(node); } }); return ret; }
121
-function _getChildElementsByTagName(name) { var ret = []; if (this.childNodes != null) { for (var node in this.childNodes) { if (this.childNodes[node].localName == name) { ret.push(this.childNodes[node]); } } } return (ret); }
122
-function _getChildElementsByTagNameNS(ns, name) { var ret = []; if (this.childNodes != null) { for (var node in this.childNodes) { if (this.childNodes[node].localName == name && (ns == '*' || this.childNodes[node].namespace == ns)) { ret.push(this.childNodes[node]); } } } return (ret); }
123
-function _xmlTraverseAllRec(nodes, func) { for (var i in nodes) { func(nodes[i]); if (nodes[i].childNodes) { _xmlTraverseAllRec(nodes[i].childNodes, func); } } }
124
-function _turnToXmlRec(text) {
125
- try {
126
- if (text == null) return null;
127
- var elementStack = new _treeBuilder(), lastElement = null, x1 = text.split('<'), ret = [], element = null, currentElementName = null;
128
- for (var i in x1) {
129
- var x2 = x1[i].split('>'), x3 = x2[0].split(' '), elementName = x3[0];
130
- if ((elementName.length > 0) && (elementName[0] != '?')) {
131
- if (elementName[0] != '/') {
132
- var attributes = [], localName, localname2 = elementName.split(' ')[0].split(':'), localName = (localname2.length > 1) ? localname2[1] : localname2[0];
133
- Object.defineProperty(attributes, "get",
134
- {
135
- value: function () {
136
- if (arguments.length == 1) {
137
- for (var a in this) { if (this[a].name == arguments[0]) { return (this[a]); } }
138
- }
139
- else if (arguments.length == 2) {
140
- for (var a in this) { if (this[a].name == arguments[1] && (arguments[0] == '*' || this[a].namespace == arguments[0])) { return (this[a]); } }
141
- }
142
- else {
143
- throw ('attributes.get(): Invalid number of parameters');
144
- }
145
- }
146
- });
147
- elementStack.push({ name: elementName, localName: localName, getChildElementsByTagName: _getChildElementsByTagName, getElementsByTagNameNS: _getElementsByTagNameNS, getChildElementsByTagNameNS: _getChildElementsByTagNameNS, attributes: attributes, childNodes: [], nsTable: {} });
148
- // Parse Attributes
149
- if (x3.length > 0) {
150
- var skip = false;
151
- for (var j in x3) {
152
- if (x3[j] == '/') {
153
- // This is an empty Element
154
- elementStack.peek().namespace = elementStack.peek().name == elementStack.peek().localName ? elementStack.getNamespace('*') : elementStack.getNamespace(elementStack.peek().name.substring(0, elementStack.peek().name.indexOf(':')));
155
- elementStack.peek().textContent = '';
156
- lastElement = elementStack.pop();
157
- skip = true;
158
- break;
159
- }
160
- var k = x3[j].indexOf('=');
161
- if (k > 0) {
162
- var attrName = x3[j].substring(0, k);
163
- var attrValue = x3[j].substring(k + 2, x3[j].length - 1);
164
- var attrNS = elementStack.getNamespace('*');
165
-
166
- if (attrName == 'xmlns') {
167
- elementStack.addNamespace('*', attrValue);
168
- attrNS = attrValue;
169
- } else if (attrName.startsWith('xmlns:')) {
170
- elementStack.addNamespace(attrName.substring(6), attrValue);
171
- } else {
172
- var ax = attrName.split(':');
173
- if (ax.length == 2) { attrName = ax[1]; attrNS = elementStack.getNamespace(ax[0]); }
174
- }
175
- var x = { name: attrName, value: attrValue }
176
- if (attrNS != null) x.namespace = attrNS;
177
- elementStack.peek().attributes.push(x);
178
- }
179
- }
180
- if (skip) { continue; }
181
- }
182
- elementStack.peek().namespace = elementStack.peek().name == elementStack.peek().localName ? elementStack.getNamespace('*') : elementStack.getNamespace(elementStack.peek().name.substring(0, elementStack.peek().name.indexOf(':')));
183
- if (x2[1]) { elementStack.peek().textContent = x2[1]; }
184
- } else { lastElement = elementStack.pop(); }
185
- }
186
- }
187
- } catch (ex) { return null; }
188
- return lastElement;
189
-}
agents/modules_meshcore/amt.js
deleted
-1016
@@ -1,1016 +0,0 @@
1
-/*
2
-Copyright 2018-2020 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_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); }
206
- obj.AMT_AgentPresenceWatchdog_DeleteAllActions = function (callback_func, tag, pri, selectors) { obj.Exec("AMT_AgentPresenceWatchdog", "DeleteAllActions", {}, callback_func, tag, pri, selectors); }
207
- obj.AMT_AgentPresenceWatchdogAction_GetActionEac = function (callback_func) { obj.Exec("AMT_AgentPresenceWatchdogAction", "GetActionEac", {}, callback_func); }
208
- obj.AMT_AgentPresenceWatchdogVA_RegisterAgent = function (callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "RegisterAgent", {}, callback_func); }
209
- obj.AMT_AgentPresenceWatchdogVA_AssertPresence = function (SequenceNumber, callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "AssertPresence", { "SequenceNumber": SequenceNumber }, callback_func); }
210
- obj.AMT_AgentPresenceWatchdogVA_AssertShutdown = function (SequenceNumber, callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "AssertShutdown", { "SequenceNumber": SequenceNumber }, callback_func); }
211
- 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); }
212
- obj.AMT_AgentPresenceWatchdogVA_DeleteAllActions = function (_method_dummy, callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "DeleteAllActions", { "_method_dummy": _method_dummy }, callback_func); }
213
- obj.AMT_AlarmClockService_AddAlarm = function AlarmClockService_AddAlarm(alarmInstance, callback_func)
214
- {
215
- var id = alarmInstance.InstanceID;
216
- var nm = alarmInstance.ElementName;
217
- var start = alarmInstance.StartTime.Datetime;
218
- var interval = alarmInstance.Interval ? alarmInstance.Interval.Datetime : undefined;
219
- var doc = alarmInstance.DeleteOnCompletion;
220
- 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>"
221
- obj.wsman.ExecMethodXml(obj.CompleteName("AMT_AlarmClockService"), "AddAlarm", tpl, callback_func);
222
- };
223
- obj.AMT_AuditLog_ClearLog = function (callback_func) { obj.Exec("AMT_AuditLog", "ClearLog", {}, callback_func); }
224
- obj.AMT_AuditLog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_AuditLog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
225
- obj.AMT_AuditLog_ReadRecords = function (StartIndex, callback_func, tag) { obj.Exec("AMT_AuditLog", "ReadRecords", { "StartIndex": StartIndex }, callback_func, tag); }
226
- obj.AMT_AuditLog_SetAuditLock = function (LockTimeoutInSeconds, Flag, Handle, callback_func) { obj.Exec("AMT_AuditLog", "SetAuditLock", { "LockTimeoutInSeconds": LockTimeoutInSeconds, "Flag": Flag, "Handle": Handle }, callback_func); }
227
- obj.AMT_AuditLog_ExportAuditLogSignature = function (SigningMechanism, callback_func) { obj.Exec("AMT_AuditLog", "ExportAuditLogSignature", { "SigningMechanism": SigningMechanism }, callback_func); }
228
- 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); }
229
- 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); }
230
- 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); }
231
- 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); }
232
- obj.AMT_AuthorizationService_EnumerateUserAclEntries = function (StartIndex, callback_func) { obj.Exec("AMT_AuthorizationService", "EnumerateUserAclEntries", { "StartIndex": StartIndex }, callback_func); }
233
- obj.AMT_AuthorizationService_GetUserAclEntryEx = function (Handle, callback_func, tag) { obj.Exec("AMT_AuthorizationService", "GetUserAclEntryEx", { "Handle": Handle }, callback_func, tag); }
234
- 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); }
235
- obj.AMT_AuthorizationService_RemoveUserAclEntry = function (Handle, callback_func) { obj.Exec("AMT_AuthorizationService", "RemoveUserAclEntry", { "Handle": Handle }, callback_func); }
236
- obj.AMT_AuthorizationService_SetAdminAclEntryEx = function (Username, DigestPassword, callback_func) { obj.Exec("AMT_AuthorizationService", "SetAdminAclEntryEx", { "Username": Username, "DigestPassword": DigestPassword }, callback_func); }
237
- obj.AMT_AuthorizationService_GetAdminAclEntry = function (callback_func) { obj.Exec("AMT_AuthorizationService", "GetAdminAclEntry", {}, callback_func); }
238
- obj.AMT_AuthorizationService_GetAdminAclEntryStatus = function (callback_func) { obj.Exec("AMT_AuthorizationService", "GetAdminAclEntryStatus", {}, callback_func); }
239
- obj.AMT_AuthorizationService_GetAdminNetAclEntryStatus = function (callback_func) { obj.Exec("AMT_AuthorizationService", "GetAdminNetAclEntryStatus", {}, callback_func); }
240
- obj.AMT_AuthorizationService_SetAclEnabledState = function (Handle, Enabled, callback_func, tag) { obj.Exec("AMT_AuthorizationService", "SetAclEnabledState", { "Handle": Handle, "Enabled": Enabled }, callback_func, tag); }
241
- obj.AMT_AuthorizationService_GetAclEnabledState = function (Handle, callback_func, tag) { obj.Exec("AMT_AuthorizationService", "GetAclEnabledState", { "Handle": Handle }, callback_func, tag); }
242
- obj.AMT_EndpointAccessControlService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
243
- obj.AMT_EndpointAccessControlService_GetPosture = function (PostureType, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "GetPosture", { "PostureType": PostureType }, callback_func); }
244
- obj.AMT_EndpointAccessControlService_GetPostureHash = function (PostureType, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "GetPostureHash", { "PostureType": PostureType }, callback_func); }
245
- obj.AMT_EndpointAccessControlService_UpdatePostureState = function (UpdateType, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "UpdatePostureState", { "UpdateType": UpdateType }, callback_func); }
246
- obj.AMT_EndpointAccessControlService_GetEacOptions = function (callback_func) { obj.Exec("AMT_EndpointAccessControlService", "GetEacOptions", {}, callback_func); }
247
- obj.AMT_EndpointAccessControlService_SetEacOptions = function (EacVendors, PostureHashAlgorithm, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "SetEacOptions", { "EacVendors": EacVendors, "PostureHashAlgorithm": PostureHashAlgorithm }, callback_func); }
248
- obj.AMT_EnvironmentDetectionSettingData_SetSystemDefensePolicy = function (Policy, callback_func) { obj.Exec("AMT_EnvironmentDetectionSettingData", "SetSystemDefensePolicy", { "Policy": Policy }, callback_func); }
249
- obj.AMT_EnvironmentDetectionSettingData_EnableVpnRouting = function (Enable, callback_func) { obj.Exec("AMT_EnvironmentDetectionSettingData", "EnableVpnRouting", { "Enable": Enable }, callback_func); }
250
- obj.AMT_EthernetPortSettings_SetLinkPreference = function (LinkPreference, Timeout, callback_func) { obj.Exec("AMT_EthernetPortSettings", "SetLinkPreference", { "LinkPreference": LinkPreference, "Timeout": Timeout }, callback_func); }
251
- obj.AMT_HeuristicPacketFilterStatistics_ResetSelectedStats = function (SelectedStatistics, callback_func) { obj.Exec("AMT_HeuristicPacketFilterStatistics", "ResetSelectedStats", { "SelectedStatistics": SelectedStatistics }, callback_func); }
252
- obj.AMT_KerberosSettingData_GetCredentialCacheState = function (callback_func) { obj.Exec("AMT_KerberosSettingData", "GetCredentialCacheState", {}, callback_func); }
253
- obj.AMT_KerberosSettingData_SetCredentialCacheState = function (Enable, callback_func) { obj.Exec("AMT_KerberosSettingData", "SetCredentialCacheState", { "Enable": Enable }, callback_func); }
254
- obj.AMT_MessageLog_CancelIteration = function (IterationIdentifier, callback_func) { obj.Exec("AMT_MessageLog", "CancelIteration", { "IterationIdentifier": IterationIdentifier }, callback_func); }
255
- obj.AMT_MessageLog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_MessageLog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
256
- obj.AMT_MessageLog_ClearLog = function (callback_func) { obj.Exec("AMT_MessageLog", "ClearLog", { }, callback_func); }
257
- obj.AMT_MessageLog_GetRecords = function (IterationIdentifier, MaxReadRecords, callback_func, tag) { obj.Exec("AMT_MessageLog", "GetRecords", { "IterationIdentifier": IterationIdentifier, "MaxReadRecords": MaxReadRecords }, callback_func, tag); }
258
- obj.AMT_MessageLog_GetRecord = function (IterationIdentifier, PositionToNext, callback_func) { obj.Exec("AMT_MessageLog", "GetRecord", { "IterationIdentifier": IterationIdentifier, "PositionToNext": PositionToNext }, callback_func); }
259
- obj.AMT_MessageLog_PositionAtRecord = function (IterationIdentifier, MoveAbsolute, RecordNumber, callback_func) { obj.Exec("AMT_MessageLog", "PositionAtRecord", { "IterationIdentifier": IterationIdentifier, "MoveAbsolute": MoveAbsolute, "RecordNumber": RecordNumber }, callback_func); }
260
- obj.AMT_MessageLog_PositionToFirstRecord = function (callback_func, tag) { obj.Exec("AMT_MessageLog", "PositionToFirstRecord", {}, callback_func, tag); }
261
- obj.AMT_MessageLog_FreezeLog = function (Freeze, callback_func) { obj.Exec("AMT_MessageLog", "FreezeLog", { "Freeze": Freeze }, callback_func); }
262
- obj.AMT_PublicKeyManagementService_AddCRL = function (Url, SerialNumbers, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "AddCRL", { "Url": Url, "SerialNumbers": SerialNumbers }, callback_func); }
263
- obj.AMT_PublicKeyManagementService_ResetCRLList = function (_method_dummy, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "ResetCRLList", { "_method_dummy": _method_dummy }, callback_func); }
264
- obj.AMT_PublicKeyManagementService_AddCertificate = function (CertificateBlob, callback_func, tag) { obj.Exec("AMT_PublicKeyManagementService", "AddCertificate", { "CertificateBlob": CertificateBlob }, callback_func, tag); }
265
- obj.AMT_PublicKeyManagementService_AddTrustedRootCertificate = function (CertificateBlob, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "AddTrustedRootCertificate", { "CertificateBlob": CertificateBlob }, callback_func); }
266
- obj.AMT_PublicKeyManagementService_AddKey = function (KeyBlob, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "AddKey", { "KeyBlob": KeyBlob }, callback_func); }
267
- obj.AMT_PublicKeyManagementService_GeneratePKCS10Request = function (KeyPair, DNName, Usage, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "GeneratePKCS10Request", { "KeyPair": KeyPair, "DNName": DNName, "Usage": Usage }, callback_func); }
268
- obj.AMT_PublicKeyManagementService_GeneratePKCS10RequestEx = function (KeyPair, SigningAlgorithm, NullSignedCertificateRequest, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "GeneratePKCS10RequestEx", { "KeyPair": KeyPair, "SigningAlgorithm": SigningAlgorithm, "NullSignedCertificateRequest": NullSignedCertificateRequest }, callback_func); }
269
- obj.AMT_PublicKeyManagementService_GenerateKeyPair = function (KeyAlgorithm, KeyLength, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "GenerateKeyPair", { "KeyAlgorithm": KeyAlgorithm, "KeyLength": KeyLength }, callback_func); }
270
- obj.AMT_RedirectionService_RequestStateChange = function (RequestedState, callback_func) { obj.Exec("AMT_RedirectionService", "RequestStateChange", { "RequestedState": RequestedState }, callback_func); }
271
- obj.AMT_RedirectionService_TerminateSession = function (SessionType, callback_func) { obj.Exec("AMT_RedirectionService", "TerminateSession", { "SessionType": SessionType }, callback_func); }
272
- 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); }
273
- 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); }
274
- obj.AMT_RemoteAccessService_CloseRemoteAccessConnection = function (_method_dummy, callback_func) { obj.Exec("AMT_RemoteAccessService", "CloseRemoteAccessConnection", { "_method_dummy": _method_dummy }, callback_func); }
275
- obj.AMT_SetupAndConfigurationService_CommitChanges = function (_method_dummy, callback_func, tag) { obj.Exec("AMT_SetupAndConfigurationService", "CommitChanges", { "_method_dummy": _method_dummy }, callback_func, tag); }
276
- obj.AMT_SetupAndConfigurationService_Unprovision = function (ProvisioningMode, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "Unprovision", { "ProvisioningMode": ProvisioningMode }, callback_func); }
277
- obj.AMT_SetupAndConfigurationService_PartialUnprovision = function (_method_dummy, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "PartialUnprovision", { "_method_dummy": _method_dummy }, callback_func); }
278
- obj.AMT_SetupAndConfigurationService_ResetFlashWearOutProtection = function (_method_dummy, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "ResetFlashWearOutProtection", { "_method_dummy": _method_dummy }, callback_func); }
279
- obj.AMT_SetupAndConfigurationService_ExtendProvisioningPeriod = function (Duration, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "ExtendProvisioningPeriod", { "Duration": Duration }, callback_func); }
280
- obj.AMT_SetupAndConfigurationService_SetMEBxPassword = function (Password, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "SetMEBxPassword", { "Password": Password }, callback_func); }
281
- obj.AMT_SetupAndConfigurationService_SetTLSPSK = function (PID, PPS, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "SetTLSPSK", { "PID": PID, "PPS": PPS }, callback_func); }
282
- obj.AMT_SetupAndConfigurationService_GetProvisioningAuditRecord = function (callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "GetProvisioningAuditRecord", {}, callback_func); }
283
- obj.AMT_SetupAndConfigurationService_GetUuid = function (callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "GetUuid", {}, callback_func); }
284
- obj.AMT_SetupAndConfigurationService_GetUnprovisionBlockingComponents = function (callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "GetUnprovisionBlockingComponents", {}, callback_func); }
285
- obj.AMT_SetupAndConfigurationService_GetProvisioningAuditRecordV2 = function (callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "GetProvisioningAuditRecordV2", {}, callback_func); }
286
- obj.AMT_SystemDefensePolicy_GetTimeout = function (callback_func) { obj.Exec("AMT_SystemDefensePolicy", "GetTimeout", {}, callback_func); }
287
- obj.AMT_SystemDefensePolicy_SetTimeout = function (Timeout, callback_func) { obj.Exec("AMT_SystemDefensePolicy", "SetTimeout", { "Timeout": Timeout }, callback_func); }
288
- 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); }
289
- obj.AMT_SystemPowerScheme_SetPowerScheme = function (callback_func, schemeInstanceId, tag) { obj.Exec("AMT_SystemPowerScheme", "SetPowerScheme", {}, callback_func, tag, 0, { "InstanceID": schemeInstanceId }); }
290
- obj.AMT_TimeSynchronizationService_GetLowAccuracyTimeSynch = function (callback_func, tag) { obj.Exec("AMT_TimeSynchronizationService", "GetLowAccuracyTimeSynch", {}, callback_func, tag); }
291
- 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); }
292
- obj.AMT_TLSCredentialContext_Create = function AMT_TLSCredentialContext_Create(ElementInContext, ElementProvidingContext, callback_func, tag) { obj.Create("AMT_TLSCredentialContext", { "ElementInContext": ElementInContext, "ElementProvidingContext": ElementProvidingContext }, callback_func, tag); }
293
- obj.AMT_UserInitiatedConnectionService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_UserInitiatedConnectionService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
294
- obj.AMT_WebUIService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func, tag) { obj.Exec("AMT_WebUIService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func, tag); }
295
- 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); }
296
- 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); }
297
- obj.AMT_WiFiPortConfigurationService_DeleteAllITProfiles = function (_method_dummy, callback_func) { obj.Exec("AMT_WiFiPortConfigurationService", "DeleteAllITProfiles", { "_method_dummy": _method_dummy }, callback_func); }
298
- obj.AMT_WiFiPortConfigurationService_DeleteAllUserProfiles = function (_method_dummy, callback_func) { obj.Exec("AMT_WiFiPortConfigurationService", "DeleteAllUserProfiles", { "_method_dummy": _method_dummy }, callback_func); }
299
- obj.CIM_Account_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_Account", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
300
- obj.CIM_AccountManagementService_CreateAccount = function (System, AccountTemplate, callback_func) { obj.Exec("CIM_AccountManagementService", "CreateAccount", { "System": System, "AccountTemplate": AccountTemplate }, callback_func); }
301
- obj.CIM_BootConfigSetting_ChangeBootOrder = function (Source, callback_func) { obj.Exec("CIM_BootConfigSetting", "ChangeBootOrder", { "Source": Source }, callback_func); }
302
- obj.CIM_BootService_SetBootConfigRole = function (BootConfigSetting, Role, callback_func) { obj.Exec("CIM_BootService", "SetBootConfigRole", { "BootConfigSetting": BootConfigSetting, "Role": Role }, callback_func, 0, 1); }
303
- obj.CIM_Card_ConnectorPower = function (Connector, PoweredOn, callback_func) { obj.Exec("CIM_Card", "ConnectorPower", { "Connector": Connector, "PoweredOn": PoweredOn }, callback_func); }
304
- obj.CIM_Card_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_Card", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
305
- obj.CIM_Chassis_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_Chassis", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
306
- obj.CIM_Fan_SetSpeed = function (DesiredSpeed, callback_func) { obj.Exec("CIM_Fan", "SetSpeed", { "DesiredSpeed": DesiredSpeed }, callback_func); }
307
- obj.CIM_KVMRedirectionSAP_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_KVMRedirectionSAP", "RequestStateChange", { "RequestedState": RequestedState/*, "TimeoutPeriod": TimeoutPeriod */}, callback_func); }
308
- obj.CIM_MediaAccessDevice_LockMedia = function (Lock, callback_func) { obj.Exec("CIM_MediaAccessDevice", "LockMedia", { "Lock": Lock }, callback_func); }
309
- obj.CIM_MediaAccessDevice_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_MediaAccessDevice", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
310
- obj.CIM_MediaAccessDevice_Reset = function (callback_func) { obj.Exec("CIM_MediaAccessDevice", "Reset", {}, callback_func); }
311
- obj.CIM_MediaAccessDevice_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_MediaAccessDevice", "EnableDevice", { "Enabled": Enabled }, callback_func); }
312
- obj.CIM_MediaAccessDevice_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_MediaAccessDevice", "OnlineDevice", { "Online": Online }, callback_func); }
313
- obj.CIM_MediaAccessDevice_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_MediaAccessDevice", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
314
- obj.CIM_MediaAccessDevice_SaveProperties = function (callback_func) { obj.Exec("CIM_MediaAccessDevice", "SaveProperties", {}, callback_func); }
315
- obj.CIM_MediaAccessDevice_RestoreProperties = function (callback_func) { obj.Exec("CIM_MediaAccessDevice", "RestoreProperties", {}, callback_func); }
316
- obj.CIM_MediaAccessDevice_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_MediaAccessDevice", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
317
- obj.CIM_PhysicalFrame_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_PhysicalFrame", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
318
- obj.CIM_PhysicalPackage_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_PhysicalPackage", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
319
- 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); }
320
- obj.CIM_PowerSupply_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_PowerSupply", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
321
- obj.CIM_PowerSupply_Reset = function (callback_func) { obj.Exec("CIM_PowerSupply", "Reset", {}, callback_func); }
322
- obj.CIM_PowerSupply_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_PowerSupply", "EnableDevice", { "Enabled": Enabled }, callback_func); }
323
- obj.CIM_PowerSupply_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_PowerSupply", "OnlineDevice", { "Online": Online }, callback_func); }
324
- obj.CIM_PowerSupply_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_PowerSupply", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
325
- obj.CIM_PowerSupply_SaveProperties = function (callback_func) { obj.Exec("CIM_PowerSupply", "SaveProperties", {}, callback_func); }
326
- obj.CIM_PowerSupply_RestoreProperties = function (callback_func) { obj.Exec("CIM_PowerSupply", "RestoreProperties", {}, callback_func); }
327
- obj.CIM_PowerSupply_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_PowerSupply", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
328
- obj.CIM_Processor_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_Processor", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
329
- obj.CIM_Processor_Reset = function (callback_func) { obj.Exec("CIM_Processor", "Reset", {}, callback_func); }
330
- obj.CIM_Processor_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_Processor", "EnableDevice", { "Enabled": Enabled }, callback_func); }
331
- obj.CIM_Processor_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_Processor", "OnlineDevice", { "Online": Online }, callback_func); }
332
- obj.CIM_Processor_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_Processor", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
333
- obj.CIM_Processor_SaveProperties = function (callback_func) { obj.Exec("CIM_Processor", "SaveProperties", {}, callback_func); }
334
- obj.CIM_Processor_RestoreProperties = function (callback_func) { obj.Exec("CIM_Processor", "RestoreProperties", {}, callback_func); }
335
- obj.CIM_Processor_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_Processor", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
336
- obj.CIM_RecordLog_ClearLog = function (callback_func) { obj.Exec("CIM_RecordLog", "ClearLog", {}, callback_func); }
337
- obj.CIM_RecordLog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_RecordLog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
338
- obj.CIM_RedirectionService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_RedirectionService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
339
- obj.CIM_Sensor_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_Sensor", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
340
- obj.CIM_Sensor_Reset = function (callback_func) { obj.Exec("CIM_Sensor", "Reset", {}, callback_func); }
341
- obj.CIM_Sensor_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_Sensor", "EnableDevice", { "Enabled": Enabled }, callback_func); }
342
- obj.CIM_Sensor_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_Sensor", "OnlineDevice", { "Online": Online }, callback_func); }
343
- obj.CIM_Sensor_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_Sensor", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
344
- obj.CIM_Sensor_SaveProperties = function (callback_func) { obj.Exec("CIM_Sensor", "SaveProperties", {}, callback_func); }
345
- obj.CIM_Sensor_RestoreProperties = function (callback_func) { obj.Exec("CIM_Sensor", "RestoreProperties", {}, callback_func); }
346
- obj.CIM_Sensor_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_Sensor", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
347
- obj.CIM_StatisticalData_ResetSelectedStats = function (SelectedStatistics, callback_func) { obj.Exec("CIM_StatisticalData", "ResetSelectedStats", { "SelectedStatistics": SelectedStatistics }, callback_func); }
348
- obj.CIM_Watchdog_KeepAlive = function (callback_func) { obj.Exec("CIM_Watchdog", "KeepAlive", {}, callback_func); }
349
- obj.CIM_Watchdog_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_Watchdog", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
350
- obj.CIM_Watchdog_Reset = function (callback_func) { obj.Exec("CIM_Watchdog", "Reset", {}, callback_func); }
351
- obj.CIM_Watchdog_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_Watchdog", "EnableDevice", { "Enabled": Enabled }, callback_func); }
352
- obj.CIM_Watchdog_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_Watchdog", "OnlineDevice", { "Online": Online }, callback_func); }
353
- obj.CIM_Watchdog_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_Watchdog", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
354
- obj.CIM_Watchdog_SaveProperties = function (callback_func) { obj.Exec("CIM_Watchdog", "SaveProperties", {}, callback_func); }
355
- obj.CIM_Watchdog_RestoreProperties = function (callback_func) { obj.Exec("CIM_Watchdog", "RestoreProperties", {}, callback_func); }
356
- obj.CIM_Watchdog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_Watchdog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
357
- obj.CIM_WiFiPort_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_WiFiPort", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
358
- obj.CIM_WiFiPort_Reset = function (callback_func) { obj.Exec("CIM_WiFiPort", "Reset", {}, callback_func); }
359
- obj.CIM_WiFiPort_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_WiFiPort", "EnableDevice", { "Enabled": Enabled }, callback_func); }
360
- obj.CIM_WiFiPort_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_WiFiPort", "OnlineDevice", { "Online": Online }, callback_func); }
361
- obj.CIM_WiFiPort_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_WiFiPort", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
362
- obj.CIM_WiFiPort_SaveProperties = function (callback_func) { obj.Exec("CIM_WiFiPort", "SaveProperties", {}, callback_func); }
363
- obj.CIM_WiFiPort_RestoreProperties = function (callback_func) { obj.Exec("CIM_WiFiPort", "RestoreProperties", {}, callback_func); }
364
- obj.CIM_WiFiPort_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_WiFiPort", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
365
- 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); }
366
- obj.IPS_HostBasedSetupService_AddNextCertInChain = function (NextCertificate, IsLeafCertificate, IsRootCertificate, callback_func) { obj.Exec("IPS_HostBasedSetupService", "AddNextCertInChain", { "NextCertificate": NextCertificate, "IsLeafCertificate": IsLeafCertificate, "IsRootCertificate": IsRootCertificate }, callback_func); }
367
- 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); }
368
- obj.IPS_HostBasedSetupService_UpgradeClientToAdmin = function (McNonce, SigningAlgorithm, DigitalSignature, callback_func) { obj.Exec("IPS_HostBasedSetupService", "UpgradeClientToAdmin", { "McNonce": McNonce, "SigningAlgorithm": SigningAlgorithm, "DigitalSignature": DigitalSignature }, callback_func); }
369
- obj.IPS_HostBasedSetupService_DisableClientControlMode = function (_method_dummy, callback_func) { obj.Exec("IPS_HostBasedSetupService", "DisableClientControlMode", { "_method_dummy": _method_dummy }, callback_func); }
370
- obj.IPS_KVMRedirectionSettingData_TerminateSession = function (callback_func) { obj.Exec("IPS_KVMRedirectionSettingData", "TerminateSession", {}, callback_func); }
371
- obj.IPS_KVMRedirectionSettingData_DataChannelRead = function (callback_func) { obj.Exec("IPS_KVMRedirectionSettingData", "DataChannelRead", {}, callback_func); }
372
- obj.IPS_KVMRedirectionSettingData_DataChannelWrite = function (Data, callback_func) { obj.Exec("IPS_KVMRedirectionSettingData", "DataChannelWrite", { "DataMessage": Data }, callback_func); }
373
- obj.IPS_OptInService_StartOptIn = function (callback_func) { obj.Exec("IPS_OptInService", "StartOptIn", {}, callback_func); }
374
- obj.IPS_OptInService_CancelOptIn = function (callback_func) { obj.Exec("IPS_OptInService", "CancelOptIn", {}, callback_func); }
375
- obj.IPS_OptInService_SendOptInCode = function (OptInCode, callback_func) { obj.Exec("IPS_OptInService", "SendOptInCode", { "OptInCode": OptInCode }, callback_func); }
376
- obj.IPS_OptInService_StartService = function (callback_func) { obj.Exec("IPS_OptInService", "StartService", {}, callback_func); }
377
- obj.IPS_OptInService_StopService = function (callback_func) { obj.Exec("IPS_OptInService", "StopService", {}, callback_func); }
378
- obj.IPS_OptInService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("IPS_OptInService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
379
- obj.IPS_ProvisioningRecordLog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("IPS_ProvisioningRecordLog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
380
- obj.IPS_ProvisioningRecordLog_ClearLog = function (_method_dummy, callback_func) { obj.Exec("IPS_ProvisioningRecordLog", "ClearLog", { "_method_dummy": _method_dummy }, callback_func); }
381
- obj.IPS_SecIOService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("IPS_SecIOService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
382
-
383
- obj.AmtStatusToStr = function (code) { if (obj.AmtStatusCodes[code]) return obj.AmtStatusCodes[code]; else return "UNKNOWN_ERROR" }
384
- obj.AmtStatusCodes = {
385
- 0x0000: "SUCCESS",
386
- 0x0001: "INTERNAL_ERROR",
387
- 0x0002: "NOT_READY",
388
- 0x0003: "INVALID_PT_MODE",
389
- 0x0004: "INVALID_MESSAGE_LENGTH",
390
- 0x0005: "TABLE_FINGERPRINT_NOT_AVAILABLE",
391
- 0x0006: "INTEGRITY_CHECK_FAILED",
392
- 0x0007: "UNSUPPORTED_ISVS_VERSION",
393
- 0x0008: "APPLICATION_NOT_REGISTERED",
394
- 0x0009: "INVALID_REGISTRATION_DATA",
395
- 0x000A: "APPLICATION_DOES_NOT_EXIST",
396
- 0x000B: "NOT_ENOUGH_STORAGE",
397
- 0x000C: "INVALID_NAME",
398
- 0x000D: "BLOCK_DOES_NOT_EXIST",
399
- 0x000E: "INVALID_BYTE_OFFSET",
400
- 0x000F: "INVALID_BYTE_COUNT",
401
- 0x0010: "NOT_PERMITTED",
402
- 0x0011: "NOT_OWNER",
403
- 0x0012: "BLOCK_LOCKED_BY_OTHER",
404
- 0x0013: "BLOCK_NOT_LOCKED",
405
- 0x0014: "INVALID_GROUP_PERMISSIONS",
406
- 0x0015: "GROUP_DOES_NOT_EXIST",
407
- 0x0016: "INVALID_MEMBER_COUNT",
408
- 0x0017: "MAX_LIMIT_REACHED",
409
- 0x0018: "INVALID_AUTH_TYPE",
410
- 0x0019: "AUTHENTICATION_FAILED",
411
- 0x001A: "INVALID_DHCP_MODE",
412
- 0x001B: "INVALID_IP_ADDRESS",
413
- 0x001C: "INVALID_DOMAIN_NAME",
414
- 0x001D: "UNSUPPORTED_VERSION",
415
- 0x001E: "REQUEST_UNEXPECTED",
416
- 0x001F: "INVALID_TABLE_TYPE",
417
- 0x0020: "INVALID_PROVISIONING_STATE",
418
- 0x0021: "UNSUPPORTED_OBJECT",
419
- 0x0022: "INVALID_TIME",
420
- 0x0023: "INVALID_INDEX",
421
- 0x0024: "INVALID_PARAMETER",
422
- 0x0025: "INVALID_NETMASK",
423
- 0x0026: "FLASH_WRITE_LIMIT_EXCEEDED",
424
- 0x0027: "INVALID_IMAGE_LENGTH",
425
- 0x0028: "INVALID_IMAGE_SIGNATURE",
426
- 0x0029: "PROPOSE_ANOTHER_VERSION",
427
- 0x002A: "INVALID_PID_FORMAT",
428
- 0x002B: "INVALID_PPS_FORMAT",
429
- 0x002C: "BIST_COMMAND_BLOCKED",
430
- 0x002D: "CONNECTION_FAILED",
431
- 0x002E: "CONNECTION_TOO_MANY",
432
- 0x002F: "RNG_GENERATION_IN_PROGRESS",
433
- 0x0030: "RNG_NOT_READY",
434
- 0x0031: "CERTIFICATE_NOT_READY",
435
- 0x0400: "DISABLED_BY_POLICY",
436
- 0x0800: "NETWORK_IF_ERROR_BASE",
437
- 0x0801: "UNSUPPORTED_OEM_NUMBER",
438
- 0x0802: "UNSUPPORTED_BOOT_OPTION",
439
- 0x0803: "INVALID_COMMAND",
440
- 0x0804: "INVALID_SPECIAL_COMMAND",
441
- 0x0805: "INVALID_HANDLE",
442
- 0x0806: "INVALID_PASSWORD",
443
- 0x0807: "INVALID_REALM",
444
- 0x0808: "STORAGE_ACL_ENTRY_IN_USE",
445
- 0x0809: "DATA_MISSING",
446
- 0x080A: "DUPLICATE",
447
- 0x080B: "EVENTLOG_FROZEN",
448
- 0x080C: "PKI_MISSING_KEYS",
449
- 0x080D: "PKI_GENERATING_KEYS",
450
- 0x080E: "INVALID_KEY",
451
- 0x080F: "INVALID_CERT",
452
- 0x0810: "CERT_KEY_NOT_MATCH",
453
- 0x0811: "MAX_KERB_DOMAIN_REACHED",
454
- 0x0812: "UNSUPPORTED",
455
- 0x0813: "INVALID_PRIORITY",
456
- 0x0814: "NOT_FOUND",
457
- 0x0815: "INVALID_CREDENTIALS",
458
- 0x0816: "INVALID_PASSPHRASE",
459
- 0x0818: "NO_ASSOCIATION",
460
- 0x081B: "AUDIT_FAIL",
461
- 0x081C: "BLOCKING_COMPONENT",
462
- 0x0821: "USER_CONSENT_REQUIRED",
463
- 0x1000: "APP_INTERNAL_ERROR",
464
- 0x1001: "NOT_INITIALIZED",
465
- 0x1002: "LIB_VERSION_UNSUPPORTED",
466
- 0x1003: "INVALID_PARAM",
467
- 0x1004: "RESOURCES",
468
- 0x1005: "HARDWARE_ACCESS_ERROR",
469
- 0x1006: "REQUESTOR_NOT_REGISTERED",
470
- 0x1007: "NETWORK_ERROR",
471
- 0x1008: "PARAM_BUFFER_TOO_SHORT",
472
- 0x1009: "COM_NOT_INITIALIZED_IN_THREAD",
473
- 0x100A: "URL_REQUIRED"
474
- }
475
-
476
- //
477
- // Methods used for getting the event log
478
- //
479
-
480
- obj.GetMessageLog = function (func, tag) {
481
- obj.AMT_MessageLog_PositionToFirstRecord(_GetMessageLog0, [func, tag, []]);
482
- }
483
- function _GetMessageLog0(stack, name, responses, status, tag) {
484
- if (status != 200 || responses.Body["ReturnValue"] != '0') { tag[0](obj, null, tag[2], status); return; }
485
- obj.AMT_MessageLog_GetRecords(responses.Body["IterationIdentifier"], 390, _GetMessageLog1, tag);
486
- }
487
- function _GetMessageLog1(stack, name, responses, status, tag) {
488
- if (status != 200 || responses.Body["ReturnValue"] != '0') { tag[0](obj, null, tag[2], status); return; }
489
- var i, j, x, e, AmtMessages = tag[2], t = new Date(), TimeStamp, ra = responses.Body["RecordArray"];
490
- if (typeof ra === 'string') { responses.Body["RecordArray"] = [responses.Body["RecordArray"]]; }
491
-
492
- for (i in ra) {
493
- e = Buffer.from(ra[i], 'base64');
494
- if (e != null) {
495
- TimeStamp = ReadIntX(e, 0);
496
- if ((TimeStamp > 0) && (TimeStamp < 0xFFFFFFFF)) {
497
- 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) };
498
- for (j = 13; j < 21; j++) { x['EventData'].push(e[j]); }
499
- x['EntityStr'] = _SystemEntityTypes[x['Entity']];
500
- x['Desc'] = _GetEventDetailStr(x['EventSensorType'], x['EventOffset'], x['EventData'], x['Entity']);
501
- if (!x['EntityStr']) x['EntityStr'] = "Unknown";
502
- AmtMessages.push(x);
503
- }
504
- }
505
- }
506
-
507
- 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]); }
508
- }
509
-
510
- 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('|');
511
- 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('|');
512
- 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('|');
513
- 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('|');
514
- 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('|');
515
- obj.WatchdogCurrentStates = { 1: 'Not Started', 2: 'Stopped', 4: 'Running', 8: 'Expired', 16: 'Suspended' };
516
-
517
- function _GetEventDetailStr(eventSensorType, eventOffset, eventDataField, entity) {
518
-
519
- if (eventSensorType == 15)
520
- {
521
- if (eventDataField[0] == 235) return "Invalid Data";
522
- if (eventOffset == 0) return _SystemFirmwareError[eventDataField[1]];
523
- return _SystemFirmwareProgress[eventDataField[1]];
524
- }
525
-
526
- if (eventSensorType == 18 && eventDataField[0] == 170) // System watchdog event
527
- {
528
- 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]];
529
- }
530
-
531
- //if (eventSensorType == 5 && eventOffset == 0) // System chassis
532
- //{
533
- // return "Case intrusion";
534
- //}
535
-
536
- //if (eventSensorType == 192 && eventOffset == 0 && eventDataField[0] == 170 && eventDataField[1] == 48)
537
- //{
538
- // if (eventDataField[2] == 0) return "A remote Serial Over LAN session was established.";
539
- // if (eventDataField[2] == 1) return "Remote Serial Over LAN session finished. User control was restored.";
540
- // if (eventDataField[2] == 2) return "A remote IDE-Redirection session was established.";
541
- // if (eventDataField[2] == 3) return "Remote IDE-Redirection session finished. User control was restored.";
542
- //}
543
-
544
- //if (eventSensorType == 36)
545
- //{
546
- // long handle = ((long)(eventDataField[1]) << 24) + ((long)(eventDataField[2]) << 16) + ((long)(eventDataField[3]) << 8) + (long)(eventDataField[4]);
547
- // string nic = string.Format("#{0}", eventDataField[0]);
548
- // if (eventDataField[0] == 0xAA) nic = "wired"; // TODO: Add wireless *****
549
- // //if (eventDataField[0] == 0xAA) nic = "wireless";
550
-
551
- // if (handle == 4294967293) { return string.Format("All received packet filter was matched on {0} interface.", nic); }
552
- // if (handle == 4294967292) { return string.Format("All outbound packet filter was matched on {0} interface.", nic); }
553
- // if (handle == 4294967290) { return string.Format("Spoofed packet filter was matched on {0} interface.", nic); }
554
- // return string.Format("Filter {0} was matched on {1} interface.", handle, nic);
555
- //}
556
-
557
- //if (eventSensorType == 192)
558
- //{
559
- // if (eventDataField[2] == 0) return "Security policy invoked. Some or all network traffic (TX) was stopped.";
560
- // if (eventDataField[2] == 2) return "Security policy invoked. Some or all network traffic (RX) was stopped.";
561
- // return "Security policy invoked.";
562
- //}
563
-
564
- //if (eventSensorType == 193)
565
- //{
566
- // if (eventDataField[0] == 0xAA && eventDataField[1] == 0x30 && eventDataField[2] == 0x00 && eventDataField[3] == 0x00) { return "User request for remote connection."; }
567
- // 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 }
568
- // if (eventDataField[0] == 0xAA && eventDataField[1] == 0x20 && eventDataField[2] == 0x04 && eventDataField[3] == 0x00) { return "Certificate revoked. "; }
569
- //}
570
-
571
- if (eventSensorType == 6) return "Authentication failed " + (eventDataField[1] + (eventDataField[2] << 8)) + " times. The system may be under attack.";
572
- if (eventSensorType == 30) return "No bootable media";
573
- if (eventSensorType == 32) return "Operating system lockup or power interrupt";
574
- if (eventSensorType == 35) return "System boot failure";
575
- if (eventSensorType == 37) return "System firmware started (at least one CPU is properly executing).";
576
- return "Unknown Sensor Type #" + eventSensorType;
577
- }
578
-
579
-// ###BEGIN###{AuditLog}
580
-
581
- // Useful link: https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Fsecurityadminevents.htm
582
-
583
- var _AmtAuditStringTable =
584
- {
585
- 16: 'Security Admin',
586
- 17: 'RCO',
587
- 18: 'Redirection Manager',
588
- 19: 'Firmware Update Manager',
589
- 20: 'Security Audit Log',
590
- 21: 'Network Time',
591
- 22: 'Network Administration',
592
- 23: 'Storage Administration',
593
- 24: 'Event Manager',
594
- 25: 'Circuit Breaker Manager',
595
- 26: 'Agent Presence Manager',
596
- 27: 'Wireless Configuration',
597
- 28: 'EAC',
598
- 29: 'KVM',
599
- 30: 'User Opt-In Events',
600
- 32: 'Screen Blanking',
601
- 33: 'Watchdog Events',
602
- 1600: 'Provisioning Started',
603
- 1601: 'Provisioning Completed',
604
- 1602: 'ACL Entry Added',
605
- 1603: 'ACL Entry Modified',
606
- 1604: 'ACL Entry Removed',
607
- 1605: 'ACL Access with Invalid Credentials',
608
- 1606: 'ACL Entry State',
609
- 1607: 'TLS State Changed',
610
- 1608: 'TLS Server Certificate Set',
611
- 1609: 'TLS Server Certificate Remove',
612
- 1610: 'TLS Trusted Root Certificate Added',
613
- 1611: 'TLS Trusted Root Certificate Removed',
614
- 1612: 'TLS Preshared Key Set',
615
- 1613: 'Kerberos Settings Modified',
616
- 1614: 'Kerberos Main Key Modified',
617
- 1615: 'Flash Wear out Counters Reset',
618
- 1616: 'Power Package Modified',
619
- 1617: 'Set Realm Authentication Mode',
620
- 1618: 'Upgrade Client to Admin Control Mode',
621
- 1619: 'Unprovisioning Started',
622
- 1700: 'Performed Power Up',
623
- 1701: 'Performed Power Down',
624
- 1702: 'Performed Power Cycle',
625
- 1703: 'Performed Reset',
626
- 1704: 'Set Boot Options',
627
- 1800: 'IDER Session Opened',
628
- 1801: 'IDER Session Closed',
629
- 1802: 'IDER Enabled',
630
- 1803: 'IDER Disabled',
631
- 1804: 'SoL Session Opened',
632
- 1805: 'SoL Session Closed',
633
- 1806: 'SoL Enabled',
634
- 1807: 'SoL Disabled',
635
- 1808: 'KVM Session Started',
636
- 1809: 'KVM Session Ended',
637
- 1810: 'KVM Enabled',
638
- 1811: 'KVM Disabled',
639
- 1812: 'VNC Password Failed 3 Times',
640
- 1900: 'Firmware Updated',
641
- 1901: 'Firmware Update Failed',
642
- 2000: 'Security Audit Log Cleared',
643
- 2001: 'Security Audit Policy Modified',
644
- 2002: 'Security Audit Log Disabled',
645
- 2003: 'Security Audit Log Enabled',
646
- 2004: 'Security Audit Log Exported',
647
- 2005: 'Security Audit Log Recovered',
648
- 2100: 'Intel(R) ME Time Set',
649
- 2200: 'TCPIP Parameters Set',
650
- 2201: 'Host Name Set',
651
- 2202: 'Domain Name Set',
652
- 2203: 'VLAN Parameters Set',
653
- 2204: 'Link Policy Set',
654
- 2205: 'IPv6 Parameters Set',
655
- 2300: 'Global Storage Attributes Set',
656
- 2301: 'Storage EACL Modified',
657
- 2302: 'Storage FPACL Modified',
658
- 2303: 'Storage Write Operation',
659
- 2400: 'Alert Subscribed',
660
- 2401: 'Alert Unsubscribed',
661
- 2402: 'Event Log Cleared',
662
- 2403: 'Event Log Frozen',
663
- 2500: 'CB Filter Added',
664
- 2501: 'CB Filter Removed',
665
- 2502: 'CB Policy Added',
666
- 2503: 'CB Policy Removed',
667
- 2504: 'CB Default Policy Set',
668
- 2505: 'CB Heuristics Option Set',
669
- 2506: 'CB Heuristics State Cleared',
670
- 2600: 'Agent Watchdog Added',
671
- 2601: 'Agent Watchdog Removed',
672
- 2602: 'Agent Watchdog Action Set',
673
- 2700: 'Wireless Profile Added',
674
- 2701: 'Wireless Profile Removed',
675
- 2702: 'Wireless Profile Updated',
676
- 2800: 'EAC Posture Signer SET',
677
- 2801: 'EAC Enabled',
678
- 2802: 'EAC Disabled',
679
- 2803: 'EAC Posture State',
680
- 2804: 'EAC Set Options',
681
- 2900: 'KVM Opt-in Enabled',
682
- 2901: 'KVM Opt-in Disabled',
683
- 2902: 'KVM Password Changed',
684
- 2903: 'KVM Consent Succeeded',
685
- 2904: 'KVM Consent Failed',
686
- 3000: 'Opt-In Policy Change',
687
- 3001: 'Send Consent Code Event',
688
- 3002: 'Start Opt-In Blocked Event'
689
- }
690
-
691
- // Return human readable extended audit log data
692
- // TODO: Just put some of them here, but many more still need to be added, helpful link here:
693
- // https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Fsecurityadminevents.htm
694
- obj.GetAuditLogExtendedDataStr = function (id, data) {
695
- if ((id == 1602 || id == 1604) && data[0] == 0) { return bufToArray(data).splice(2, 2 + data[1]).toString(); } // ACL Entry Added/Removed (Digest)
696
- if (id == 1603) { if (data[1] == 0) { return bufToArray(data).splice(3).toString(); } return null; } // ACL Entry Modified
697
- if (id == 1605) { return ["Invalid ME access", "Invalid MEBx access"][data[0]]; } // ACL Access with Invalid Credentials
698
- if (id == 1606) { var r = ["Disabled", "Enabled"][data[0]]; if (data[1] == 0) { r += ", " + data[3]; } return r; } // ACL Entry State
699
- if (id == 1607) { return "Remote " + ["NoAuth", "ServerAuth", "MutualAuth"][data[0]] + ", Local " + ["NoAuth", "ServerAuth", "MutualAuth"][data[1]]; } // TLS State Changed
700
- if (id == 1617) { return obj.RealmNames[ReadInt(data, 0)] + ", " + ["NoAuth", "Auth", "Disabled"][data[4]]; } // Set Realm Authentication Mode
701
- if (id == 1619) { return ["BIOS", "MEBx", "Local MEI", "Local WSMAN", "Remote WSAMN"][data[0]]; } // Intel AMT Unprovisioning Started
702
- 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
703
- if (id == 2100) { var t4 = new Date(); t4.setTime(ReadInt(data, 0) * 1000 + (new Date().getTimezoneOffset() * 60000)); return t4.toLocaleString(); } // Intel AMT Time Set
704
- if (id == 3000) { return "From " + ["None", "KVM", "All"][data[0]] + " to " + ["None", "KVM", "All"][data[1]]; } // Opt-In Policy Change
705
- if (id == 3001) { return ["Success", "Failed 3 times"][data[0]]; } // Send Consent Code Event
706
- return null;
707
- }
708
-
709
- obj.GetAuditLog = function (func) {
710
- obj.AMT_AuditLog_ReadRecords(1, _GetAuditLog0, [func, []]);
711
- }
712
-
713
- function MakeToArray(v) { if (!v || v == null || typeof v == 'object') return v; return [v]; }
714
- function ReadShort(v, p) { return (v[p] << 8) + v[p + 1]; }
715
- 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.
716
- function ReadIntX(v, p) { return (v[p + 3] * 0x1000000) + (v[p + 2] << 16) + (v[p + 1] << 8) + v[p]; }
717
- function btoa(x) { return Buffer.from(x).toString('base64'); }
718
- function atob(x) { var z = null; try { z = Buffer.from(x, 'base64').toString(); } catch (e) { console.log(e); } return z; }
719
- function bufToArray(buf) { var r = []; for (var i in buf) { r.push(buf[i]); } return r; }
720
-
721
- function _GetAuditLog0(stack, name, responses, status, tag) {
722
- if (status != 200) { tag[0](obj, [], status); return; }
723
- var ptr, i, e, x, r = tag[1], t = new Date(), TimeStamp;
724
-
725
- if (responses.Body['RecordsReturned'] > 0) {
726
- responses.Body['EventRecords'] = MakeToArray(responses.Body['EventRecords']);
727
-
728
- for (i in responses.Body['EventRecords']) {
729
- e = null;
730
- try {
731
- e = Buffer.from(responses.Body['EventRecords'][i], 'base64');
732
- } catch (ex) {
733
- console.log(ex + " " + responses.Body['EventRecords'][i])
734
- }
735
-
736
- x = { 'AuditAppID': ReadShort(e, 0), 'EventID': ReadShort(e, 2), 'InitiatorType': e[4] };
737
- x['AuditApp'] = _AmtAuditStringTable[x['AuditAppID']];
738
- x['Event'] = _AmtAuditStringTable[(x['AuditAppID'] * 100) + x['EventID']];
739
- if (!x['Event']) x['Event'] = '#' + x['EventID'];
740
-
741
- // Read and process the initiator
742
- if (x['InitiatorType'] == 0) {
743
- // HTTP digest
744
- var userlen = e[5];
745
- x['Initiator'] = e.slice(6, 6 + userlen).toString();
746
- ptr = 6 + userlen;
747
- }
748
- if (x['InitiatorType'] == 1) {
749
- // Kerberos
750
- x['KerberosUserInDomain'] = ReadInt(e, 5);
751
- var userlen = e[9];
752
- x['Initiator'] = GetSidString(e.slice(10, 10 + userlen));
753
- ptr = 10 + userlen;
754
- }
755
- if (x['InitiatorType'] == 2) {
756
- // Local
757
- x['Initiator'] = 'Local';
758
- ptr = 5;
759
- }
760
- if (x['InitiatorType'] == 3) {
761
- // KVM Default Port
762
- x['Initiator'] = 'KVM Default Port';
763
- ptr = 5;
764
- }
765
-
766
- // Read timestamp
767
- TimeStamp = ReadInt(e, ptr);
768
- x['Time'] = new Date((TimeStamp + (t.getTimezoneOffset() * 60)) * 1000);
769
- ptr += 4;
770
-
771
- // Read network access
772
- x['MCLocationType'] = e[ptr++];
773
- var netlen = e[ptr++];
774
-
775
- x['NetAddress'] = e.slice(ptr, ptr + netlen).toString();
776
-
777
- // Read extended data
778
- ptr += netlen;
779
- var exlen = e[ptr++];
780
- x['Ex'] = e.slice(ptr, ptr + exlen);
781
- x['ExStr'] = obj.GetAuditLogExtendedDataStr((x['AuditAppID'] * 100) + x['EventID'], x['Ex']);
782
- r.push(x);
783
- }
784
- }
785
- if (responses.Body['TotalRecordCount'] > r.length) {
786
- obj.AMT_AuditLog_ReadRecords(r.length + 1, _GetAuditLog0, [tag[0], r]);
787
- } else {
788
- tag[0](obj, r, status);
789
- }
790
- }
791
-
792
- // ###END###{AuditLog}
793
-
794
- /*
795
- // ###BEGIN###{Certificates}
796
-
797
- // Forge MD5
798
- function hex_md5(str) { return forge.md.md5.create().update(str).digest().toHex(); }
799
-
800
- // ###END###{Certificates}
801
-
802
- // ###BEGIN###{!Certificates}
803
-
804
- // TinyMD5 from https://github.com/jbt/js-crypto
805
-
806
- // Perform MD5 setup
807
- var md5_k = [];
808
- for (var i = 0; i < 64;) { md5_k[i] = 0 | (Math.abs(Math.sin(++i)) * 4294967296); }
809
-
810
- // Perform MD5 on raw string and return hex
811
- function hex_md5(str) {
812
- var b, c, d, j,
813
- x = [],
814
- str2 = unescape(encodeURI(str)),
815
- a = str2.length,
816
- h = [b = 1732584193, c = -271733879, ~b, ~c],
817
- i = 0;
818
-
819
- for (; i <= a;) x[i >> 2] |= (str2.charCodeAt(i) || 128) << 8 * (i++ % 4);
820
-
821
- x[str = (a + 8 >> 6) * 16 + 14] = a * 8;
822
- i = 0;
823
-
824
- for (; i < str; i += 16) {
825
- a = h; j = 0;
826
- for (; j < 64;) {
827
- a = [
828
- d = a[3],
829
- ((b = a[1] | 0) +
830
- ((d = (
831
- (a[0] +
832
- [
833
- b & (c = a[2]) | ~b & d,
834
- d & b | ~d & c,
835
- b ^ c ^ d,
836
- c ^ (b | ~d)
837
- ][a = j >> 4]
838
- ) +
839
- (md5_k[j] +
840
- (x[[
841
- j,
842
- 5 * j + 1,
843
- 3 * j + 5,
844
- 7 * j
845
- ][a] % 16 + i] | 0)
846
- )
847
- )) << (a = [
848
- 7, 12, 17, 22,
849
- 5, 9, 14, 20,
850
- 4, 11, 16, 23,
851
- 6, 10, 15, 21
852
- ][4 * a + j++ % 4]) | d >>> 32 - a)
853
- ),
854
- b,
855
- c
856
- ];
857
- }
858
- for (j = 4; j;) h[--j] = h[j] + a[j];
859
- }
860
-
861
- str = '';
862
- for (; j < 32;) str += ((h[j >> 3] >> ((1 ^ j++ & 7) * 4)) & 15).toString(16);
863
- return str;
864
- }
865
-
866
- // ###END###{!Certificates}
867
-
868
- // Perform MD5 on raw string and return raw string result
869
- function rstr_md5(str) { return hex2rstr(hex_md5(str)); }
870
- */
871
- /*
872
- Convert arguments into selector set and body XML. Used by AMT_WiFiPortConfigurationService_UpdateWiFiSettings.
873
- args = {
874
- "WiFiEndpoint": {
875
- __parameterType: 'reference',
876
- __resourceUri: 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpoint',
877
- Name: 'WiFi Endpoint 0'
878
- },
879
- "WiFiEndpointSettingsInput":
880
- {
881
- __parameterType: 'instance',
882
- __namespace: 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointSettings',
883
- ElementName: document.querySelector('#editProfile-profileName').value,
884
- InstanceID: 'Intel(r) AMT:WiFi Endpoint Settings ' + document.querySelector('#editProfile-profileName').value,
885
- AuthenticationMethod: document.querySelector('#editProfile-networkAuthentication').value,
886
- //BSSType: 3, // Intel(r) AMT supports only infrastructure networks
887
- EncryptionMethod: document.querySelector('#editProfile-encryption').value,
888
- SSID: document.querySelector('#editProfile-networkName').value,
889
- Priority: 100,
890
- PSKPassPhrase: document.querySelector('#editProfile-passPhrase').value
891
- },
892
- "IEEE8021xSettingsInput": null,
893
- "ClientCredential": null,
894
- "CACredential": null
895
- },
896
- */
897
- function execArgumentsToXml(args) {
898
- if (args === undefined || args === null) return null;
899
-
900
- var result = '';
901
- for (var argName in args) {
902
- var arg = args[argName];
903
- if (!arg) continue;
904
- if (arg['__parameterType'] === 'reference') result += referenceToXml(argName, arg);
905
- else result += instanceToXml(argName, arg);
906
- //if(arg['__isInstance']) result += instanceToXml(argName, arg);
907
- }
908
- return result;
909
- }
910
-
911
- /**
912
- * Convert JavaScript object into XML
913
-
914
- <r:WiFiEndpointSettingsInput xmlns:q="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointSettings">
915
- <q:ElementName>Wireless-Profile-Admin</q:ElementName>
916
- <q:InstanceID>Intel(r) AMT:WiFi Endpoint Settings Wireless-Profile-Admin</q:InstanceID>
917
- <q:AuthenticationMethod>6</q:AuthenticationMethod>
918
- <q:EncryptionMethod>4</q:EncryptionMethod>
919
- <q:Priority>100</q:Priority>
920
- <q:PSKPassPhrase>P@ssw0rd</q:PSKPassPhrase>
921
- </r:WiFiEndpointSettingsInput>
922
- */
923
- function instanceToXml(instanceName, inInstance) {
924
- if (inInstance === undefined || inInstance === null) return null;
925
-
926
- var hasNamespace = !!inInstance['__namespace'];
927
- var startTag = hasNamespace ? '<q:' : '<';
928
- var endTag = hasNamespace ? '</q:' : '</';
929
- var namespaceDef = hasNamespace ? (' xmlns:q="' + inInstance['__namespace'] + '"') : '';
930
- var result = '<r:' + instanceName + namespaceDef + '>';
931
- for (var prop in inInstance) {
932
- if (!inInstance.hasOwnProperty(prop) || prop.indexOf('__') === 0) continue;
933
-
934
- if (typeof inInstance[prop] === 'function' || Array.isArray(inInstance[prop])) continue;
935
-
936
- if (typeof inInstance[prop] === 'object') {
937
- //result += startTag + prop +'>' + instanceToXml('prop', inInstance[prop]) + endTag + prop +'>';
938
- console.error('only convert one level down...');
939
- }
940
- else {
941
- result += startTag + prop + '>' + inInstance[prop].toString() + endTag + prop + '>';
942
- }
943
- }
944
- result += '</r:' + instanceName + '>';
945
- return result;
946
- }
947
-
948
-
949
- /**
950
- * Convert a selector set into XML. Expect no nesting.
951
- * {
952
- * selectorName : selectorValue,
953
- * selectorName : selectorValue,
954
- * ... ...
955
- * }
956
-
957
- <r:WiFiEndpoint>
958
- <a:Address>http://192.168.1.103:16992/wsman</a:Address>
959
- <a:ReferenceParameters>
960
- <w:ResourceURI>http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpoint</w:ResourceURI>
961
- <w:SelectorSet>
962
- <w:Selector Name="Name">WiFi Endpoint 0</w:Selector>
963
- </w:SelectorSet>
964
- </a:ReferenceParameters>
965
- </r:WiFiEndpoint>
966
-
967
- */
968
- function referenceToXml(referenceName, inReference) {
969
- if (inReference === undefined || inReference === null) return null;
970
-
971
- var result = '<r:' + referenceName + '><a:Address>/wsman</a:Address><a:ReferenceParameters><w:ResourceURI>' + inReference['__resourceUri'] + '</w:ResourceURI><w:SelectorSet>';
972
- for (var selectorName in inReference) {
973
- if (!inReference.hasOwnProperty(selectorName) || selectorName.indexOf('__') === 0) continue;
974
-
975
- if (typeof inReference[selectorName] === 'function' ||
976
- typeof inReference[selectorName] === 'object' ||
977
- Array.isArray(inReference[selectorName]))
978
- continue;
979
-
980
- result += '<w:Selector Name="' + selectorName + '">' + inReference[selectorName].toString() + '</w:Selector>';
981
- }
982
-
983
- result += '</w:SelectorSet></a:ReferenceParameters></r:' + referenceName + '>';
984
- return result;
985
- }
986
-
987
- // Convert a byte array of SID into string
988
- function GetSidString(sid) {
989
- var r = "S-" + sid.charCodeAt(0) + "-" + sid.charCodeAt(7);
990
- for (var i = 2; i < (sid.length / 4); i++) r += "-" + ReadIntX(sid, i * 4);
991
- return r;
992
- }
993
-
994
- // Convert a SID readable string into bytes
995
- function GetSidByteArray(sidString) {
996
- if (!sidString || sidString == null) return null;
997
- var sidParts = sidString.split('-');
998
-
999
- // Make sure the SID has at least 4 parts and starts with 'S'
1000
- if (sidParts.length < 4 || (sidParts[0] != 's' && sidParts[0] != 'S')) return null;
1001
-
1002
- // Check that each part of the SID is really an integer
1003
- for (var i = 1; i < sidParts.length; i++) { var y = parseInt(sidParts[i]); if (y != sidParts[i]) return null; sidParts[i] = y; }
1004
-
1005
- // 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.
1006
- var r = String.fromCharCode(sidParts[1]) + String.fromCharCode(sidParts.length - 3) + ShortToStr(Math.floor(sidParts[2] / Math.pow(2, 32))) + IntToStr((sidParts[2]) & 0xFFFF);
1007
-
1008
- // the rest are in 32 bit in little endian
1009
- for (var i = 3; i < sidParts.length; i++) r += IntToStrX(sidParts[i]);
1010
- return r;
1011
- }
1012
-
1013
- return obj;
1014
-}
1015
-
1016
-module.exports = AmtStackCreateService;