Add AMT stack and disable _socket debug on apfserver.js
jsastriawan committed
Sep 19, 2019 at 12:25 UTC
bea2e83de991b2872eaa81fd0c2dad693aa3e8c1
5 files changed
+2082
-1
amt/amt-wsman-comm.js
new
+659
@@ -0,0 +1,659 @@
1
+/**
2
+* @description Intel(r) AMT WSMAN communication using Node.js TLS
3
+* @author Ylian Saint-Hilaire
4
+* @version v0.2.0b
5
+*/
6
+
7
+// Construct a MeshServer object
8
+var CreateWsmanComm = function (host, port, user, pass, tls, tlsoptions, parent, mode) {
9
+ //console.log('CreateWsmanComm', host, port, user, pass, tls, tlsoptions);
10
+
11
+ var obj = {};
12
+ obj.PendingAjax = []; // List of pending AJAX calls. When one frees up, another will start.
13
+ obj.ActiveAjaxCount = 0; // Number of currently active AJAX calls
14
+ obj.MaxActiveAjaxCount = 1; // Maximum number of activate AJAX calls at the same time.
15
+ obj.FailAllError = 0; // Set this to non-zero to fail all AJAX calls with that error status, 999 causes responses to be silent.
16
+ obj.challengeParams = null;
17
+ obj.noncecounter = 1;
18
+ obj.authcounter = 0;
19
+
20
+ obj.Address = '/wsman';
21
+ obj.challengeParams = null;
22
+ obj.noncecounter = 1;
23
+ obj.authcounter = 0;
24
+ obj.cnonce = Math.random().toString(36).substring(7); // Generate a random client nonce
25
+
26
+ obj.net = require('net');
27
+ obj.tls = require('tls');
28
+ obj.crypto = require('crypto');
29
+ obj.constants = require('constants');
30
+ obj.socket = null;
31
+ obj.socketState = 0;
32
+ obj.kerberosDone = 0;
33
+ obj.amtVersion = null;
34
+
35
+ obj.host = host;
36
+ obj.port = port;
37
+ obj.user = user;
38
+ obj.pass = pass;
39
+ obj.xtls = tls;
40
+ obj.xtlsoptions = tlsoptions;
41
+ obj.parent = parent;
42
+ obj.mode = mode;//0: webrelay; 1: direct, 2: CIRA, 3: APF relay
43
+ obj.xtlsFingerprint;
44
+ obj.xtlsCertificate = null;
45
+ obj.xtlsCheck = 0; // 0 = No TLS, 1 = CA Checked, 2 = Pinned, 3 = Untrusted
46
+ obj.xtlsSkipHostCheck = 0;
47
+ obj.xtlsMethod = 0;
48
+ obj.xtlsDataReceived = false;
49
+ obj.digestRealmMatch = null;
50
+ obj.digestRealm = null;
51
+
52
+ // Private method
53
+ obj.Debug = function (msg) { console.log(msg); }
54
+
55
+ // Private method
56
+ // pri = priority, if set to 1, the call is high priority and put on top of the stack.
57
+ obj.PerformAjax = function (postdata, callback, tag, pri, url, action) {
58
+ if ((obj.ActiveAjaxCount == 0 || ((obj.ActiveAjaxCount < obj.MaxActiveAjaxCount) && (obj.challengeParams != null))) && obj.PendingAjax.length == 0) {
59
+ // There are no pending AJAX calls, perform the call now.
60
+ obj.PerformAjaxEx(postdata, callback, tag, url, action);
61
+ } else {
62
+ // If this is a high priority call, put this call in front of the array, otherwise put it in the back.
63
+ if (pri == 1) { obj.PendingAjax.unshift([postdata, callback, tag, url, action]); } else { obj.PendingAjax.push([postdata, callback, tag, url, action]); }
64
+ }
65
+ }
66
+
67
+ // Private method
68
+ obj.PerformNextAjax = function () {
69
+ if (obj.ActiveAjaxCount >= obj.MaxActiveAjaxCount || obj.PendingAjax.length == 0) return;
70
+ var x = obj.PendingAjax.shift();
71
+ obj.PerformAjaxEx(x[0], x[1], x[2], x[3], x[4]);
72
+ obj.PerformNextAjax();
73
+ }
74
+
75
+ // Private method
76
+ obj.PerformAjaxEx = function (postdata, callback, tag, url, action) {
77
+ if (obj.FailAllError != 0) { obj.gotNextMessagesError({ status: obj.FailAllError }, 'error', null, [postdata, callback, tag, url, action]); return; }
78
+ if (!postdata) postdata = "";
79
+ //obj.Debug("SEND: " + postdata); // DEBUG
80
+
81
+ obj.ActiveAjaxCount++;
82
+ return obj.PerformAjaxExNodeJS(postdata, callback, tag, url, action);
83
+ }
84
+
85
+ // NODE.js specific private method
86
+ obj.pendingAjaxCall = [];
87
+
88
+ // NODE.js specific private method
89
+ obj.PerformAjaxExNodeJS = function (postdata, callback, tag, url, action) { obj.PerformAjaxExNodeJS2(postdata, callback, tag, url, action, 5); }
90
+
91
+ // NODE.js specific private method
92
+ obj.PerformAjaxExNodeJS2 = function (postdata, callback, tag, url, action, retry) {
93
+ if (retry <= 0 || obj.FailAllError != 0) {
94
+ // Too many retry, fail here.
95
+ obj.ActiveAjaxCount--;
96
+ if (obj.FailAllError != 999) obj.gotNextMessages(null, 'error', { status: ((obj.FailAllError == 0) ? 408 : obj.FailAllError) }, [postdata, callback, tag, url, action]); // 408 is timeout error
97
+ obj.PerformNextAjax();
98
+ return;
99
+ }
100
+ obj.pendingAjaxCall.push([postdata, callback, tag, url, action, retry]);
101
+ if (obj.socketState == 0) { obj.xxConnectHttpSocket(); }
102
+ else if (obj.socketState == 2) { obj.sendRequest(postdata, url, action); }
103
+ }
104
+
105
+ // NODE.js specific private method
106
+ obj.sendRequest = function (postdata, url, action) {
107
+ url = url ? url : "/wsman";
108
+ action = action ? action : "POST";
109
+ var h = action + " " + url + " HTTP/1.1\r\n";
110
+ if (obj.challengeParams != null) {
111
+ obj.digestRealm = obj.challengeParams["realm"];
112
+ if (obj.digestRealmMatch && (obj.digestRealm != obj.digestRealmMatch)) {
113
+ obj.FailAllError = 997; // Cause all new responses to be silent. 997 = Digest Realm check error
114
+ obj.CancelAllQueries(997);
115
+ return;
116
+ }
117
+ }
118
+ if ((obj.user == '*') && (kerberos != null)) {
119
+ // Kerberos Auth
120
+ if (obj.kerberosDone == 0) {
121
+ var ticketName = 'HTTP' + ((obj.tls == 1) ? 'S' : '') + '/' + ((obj.pass == '') ? (obj.host + ':' + obj.port) : obj.pass);
122
+ // Ask for the new Kerberos ticket
123
+ //console.log('kerberos.getTicket', ticketName);
124
+ var ticketReturn = kerberos.getTicket(ticketName);
125
+ if (ticketReturn.returnCode == 0 || ticketReturn.returnCode == 0x90312) {
126
+ h += 'Authorization: Negotiate ' + ticketReturn.ticket + '\r\n';
127
+ if (process.platform.indexOf('win') >= 0) {
128
+ // Clear kerberos tickets on both 32 and 64bit Windows platforms
129
+ try { require('child_process').exec('%windir%\\system32\\klist purge', function (error, stdout, stderr) { if (error) { require('child_process').exec('%windir%\\sysnative\\klist purge', function (error, stdout, stderr) { if (error) { console.error('Unable to purge kerberos tickets'); } }); } }); } catch (e) { console.log(e); }
130
+ }
131
+ } else {
132
+ console.log('Unexpected Kerberos error code: ' + ticketReturn.returnCode);
133
+ }
134
+ obj.kerberosDone = 1;
135
+ }
136
+ } else if (obj.challengeParams != null) {
137
+ var response = hex_md5(hex_md5(obj.user + ':' + obj.challengeParams["realm"] + ':' + obj.pass) + ':' + obj.challengeParams["nonce"] + ':' + obj.noncecounter + ':' + obj.cnonce + ':' + obj.challengeParams["qop"] + ':' + hex_md5(action + ':' + url));
138
+ h += 'Authorization: ' + obj.renderDigest({ "username": obj.user, "realm": obj.challengeParams["realm"], "nonce": obj.challengeParams["nonce"], "uri": url, "qop": obj.challengeParams["qop"], "response": response, "nc": obj.noncecounter++, "cnonce": obj.cnonce }) + '\r\n';
139
+ }
140
+ h += 'Host: ' + obj.host + ':' + obj.port + '\r\nContent-Length: ' + postdata.length + '\r\n\r\n' + postdata; // Use Content-Length
141
+ //h += 'Host: ' + obj.host + ':' + obj.port + '\r\nTransfer-Encoding: chunked\r\n\r\n' + postdata.length.toString(16).toUpperCase() + '\r\n' + postdata + '\r\n0\r\n\r\n'; // Use Chunked-Encoding
142
+ obj.xxSend(h);
143
+ //console.log("SEND: " + h); // Display send packet
144
+ }
145
+
146
+ // NODE.js specific private method
147
+ obj.parseDigest = function (header) {
148
+ var t = header.substring(7).split(',');
149
+ for (i in t) t[i] = t[i].trim();
150
+ return t.reduce(function (obj, s) { var parts = s.split('='); obj[parts[0]] = parts[1].replace(new RegExp('\"', 'g'), ''); return obj; }, {})
151
+ }
152
+
153
+ // NODE.js specific private method
154
+ obj.renderDigest = function (params) {
155
+ var paramsnames = [];
156
+ for (i in params) { paramsnames.push(i); }
157
+ return 'Digest ' + paramsnames.reduce(function (s1, ii) { return s1 + ',' + ii + '="' + params[ii] + '"' }, '').substring(1);
158
+ }
159
+
160
+ // NODE.js specific private method
161
+ obj.xxConnectHttpSocket = function () {
162
+ //obj.Debug("xxConnectHttpSocket");
163
+ obj.socketParseState = 0;
164
+ obj.socketAccumulator = '';
165
+ obj.socketHeader = null;
166
+ obj.socketData = '';
167
+ obj.socketState = 1;
168
+ obj.kerberosDone = 0;
169
+
170
+ if (obj.mode==0 && obj.xtlsoptions && obj.xtlsoptions.meshServerConnect) { //Webrelay
171
+ // Use the websocket wrapper to connect to MeshServer server
172
+ obj.socket = CreateWebSocketWrapper(obj.xtlsoptions.host, obj.xtlsoptions.port, '/webrelay.ashx?user=' + encodeURIComponent(obj.xtlsoptions.username) + '&pass=' + encodeURIComponent(obj.xtlsoptions.password) + '&host=' + encodeURIComponent(obj.host) + '&p=1&tls1only=' + obj.xtlsMethod, obj.xtlsoptions.xtlsFingerprint);
173
+ obj.socket.setEncoding('binary');
174
+ obj.socket.setTimeout(6000); // Set socket idle timeout
175
+ obj.socket.ondata = obj.xxOnSocketData;
176
+ obj.socket.onclose = function () { if (obj.xtlsDataReceived == false) { obj.xtlsMethod = 1 - obj.xtlsMethod; } obj.xxOnSocketClosed(); }
177
+ obj.socket.ontimeout = function () { if (obj.xtlsDataReceived == false) { obj.xtlsMethod = 1 - obj.xtlsMethod; } obj.xxOnSocketClosed(); }
178
+ obj.socket.connect(obj.xxOnSocketConnected);
179
+ obj.socket.setNoDelay(true); // Disable nagle. We will encode each WSMAN request as a single send block and want to send it at once. This may help Intel AMT handle pipelining?
180
+ } else if (obj.mode==1 ) { //Direct
181
+ if (obj.xtls != 1) {
182
+ // Connect without TLS
183
+ obj.socket = new obj.net.Socket();
184
+ obj.socket.setEncoding('binary');
185
+ obj.socket.setTimeout(6000); // Set socket idle timeout
186
+ obj.socket.on('data', obj.xxOnSocketData);
187
+ obj.socket.on('close', obj.xxOnSocketClosed);
188
+ obj.socket.on('timeout', obj.xxOnSocketClosed);
189
+ obj.socket.connect(obj.port, obj.host, obj.xxOnSocketConnected);
190
+ } else {
191
+ // Connect with TLS
192
+ var options = { secureProtocol: ((obj.xtlsMethod == 0) ? 'SSLv23_method' : 'TLSv1_method'), ciphers: 'RSA+AES:!aNULL:!MD5:!DSS', secureOptions: obj.constants.SSL_OP_NO_SSLv2 | obj.constants.SSL_OP_NO_SSLv3 | obj.constants.SSL_OP_NO_COMPRESSION | obj.constants.SSL_OP_CIPHER_SERVER_PREFERENCE, rejectUnauthorized: false };
193
+ if (obj.xtlsoptions) {
194
+ if (obj.xtlsoptions.ca) options.ca = obj.xtlsoptions.ca;
195
+ if (obj.xtlsoptions.cert) options.cert = obj.xtlsoptions.cert;
196
+ if (obj.xtlsoptions.key) options.key = obj.xtlsoptions.key;
197
+ obj.xtlsoptions = options;
198
+ }
199
+ obj.socket = obj.tls.connect(obj.port, obj.host, obj.xtlsoptions, obj.xxOnSocketConnected);
200
+ obj.socket.setEncoding('binary');
201
+ obj.socket.setTimeout(6000); // Set socket idle timeout
202
+ obj.socket.on('data', obj.xxOnSocketData);
203
+ obj.socket.on('close', obj.xxOnSocketClosed);
204
+ obj.socket.on('timeout', obj.xxOnSocketClosed);
205
+ obj.socket.on('error', function (e) { if (e.message && e.message.indexOf('sslv3 alert bad record mac') >= 0) { obj.xtlsMethod = 1 - obj.xtlsMethod; } });
206
+ }
207
+ obj.socket.setNoDelay(true); // Disable nagle. We will encode each WSMAN request as a single send block and want to send it at once. This may help Intel AMT handle pipelining?
208
+ } else if (obj.mode==2 || obj.mode==3) { // CIRA and APF
209
+ if (obj.mode==2) { // CIRA
210
+ var ciraconn = obj.parent.mpsserver.ciraConnections[obj.host];
211
+ obj.socket = obj.parent.mpsserver.SetupCiraChannel(ciraconn, obj.port);
212
+ } else { //APF
213
+ var apfconn = obj.parent.apfserver.apfConnections[obj.host];
214
+ obj.socket = obj.parent.apfserver.SetupCiraChannel(apfconn, obj.port);
215
+ }
216
+ obj.socket.onData = function (ccon, data) {
217
+ _OnSocketData(data);
218
+ }
219
+
220
+ obj.socket.onStateChange = function (ccon, state) {
221
+ if (state == 0) {
222
+ try {
223
+ obj.socketParseState = 0;
224
+ obj.socketAccumulator = '';
225
+ obj.socketHeader = null;
226
+ obj.socketData = '';
227
+ obj.socketState = 0;
228
+ _OnSocketClosed();
229
+ } catch (e) { }
230
+ } else if (state == 2) {
231
+ // channel open success
232
+ _OnSocketConnected();
233
+ }
234
+ }
235
+ }
236
+ }
237
+
238
+ // Get the certificate of Intel AMT
239
+ obj.getPeerCertificate = function () { if (obj.xtls == 1) { return obj.socket.getPeerCertificate(); } return null; }
240
+ obj.getPeerCertificateFingerprint = function () { if (obj.xtls == 1) { return obj.socket.getPeerCertificate().fingerprint.split(':').join('').toLowerCase(); } return null; }
241
+
242
+ // NODE.js specific private method
243
+ obj.xxOnSocketConnected = function () {
244
+ if (obj.socket == null) return;
245
+ // check TLS certificate for webrelay and direct only
246
+ if (obj.mode < 2 && obj.xtls == 1) {
247
+ obj.xtlsCertificate = obj.socket.getPeerCertificate();
248
+
249
+ // ###BEGIN###{Certificates}
250
+ // Setup the forge certificate check
251
+ var camatch = 0;
252
+ if (obj.xtlsoptions.ca) {
253
+ var forgeCert = forge.pki.certificateFromAsn1(forge.asn1.fromDer(atob(obj.xtlsCertificate.raw.toString('base64'))));
254
+ var caStore = forge.pki.createCaStore(obj.xtlsoptions.ca);
255
+ // Got thru all certificates in the store and look for a match.
256
+ for (var i in caStore.certs) {
257
+ if (camatch == 0) {
258
+ var c = caStore.certs[i], verified = false;
259
+ try { verified = c.verify(forgeCert); } catch (e) { }
260
+ if (verified == true) { camatch = c; }
261
+ }
262
+ }
263
+ // We found a match, check that the CommonName matches the hostname
264
+ if ((obj.xtlsSkipHostCheck == 0) && (camatch != 0)) {
265
+ amtcertname = forgeCert.subject.getField('CN').value;
266
+ if (amtcertname.toLowerCase() != obj.host.toLowerCase()) { camatch = 0; }
267
+ }
268
+ }
269
+ if ((camatch == 0) && (obj.xtlsFingerprint != 0) && (obj.xtlsCertificate.fingerprint.split(':').join('').toLowerCase() != obj.xtlsFingerprint)) {
270
+ obj.FailAllError = 998; // Cause all new responses to be silent. 998 = TLS Certificate check error
271
+ obj.CancelAllQueries(998);
272
+ return;
273
+ }
274
+ if ((obj.xtlsFingerprint == 0) && (camatch == 0)) { obj.xtlsCheck = 3; } else { obj.xtlsCheck = (camatch == 0) ? 2 : 1; }
275
+ // ###END###{Certificates}
276
+ // ###BEGIN###{!Certificates}
277
+ if ((obj.xtlsFingerprint != 0) && (obj.xtlsCertificate.fingerprint.split(':').join('').toLowerCase() != obj.xtlsFingerprint)) {
278
+ obj.FailAllError = 998; // Cause all new responses to be silent. 998 = TLS Certificate check error
279
+ obj.CancelAllQueries(998);
280
+ return;
281
+ }
282
+ obj.xtlsCheck = 2;
283
+ // ###END###{!Certificates}
284
+ } else { obj.xtlsCheck = 0; }
285
+ obj.socketState = 2;
286
+ obj.socketParseState = 0;
287
+ for (i in obj.pendingAjaxCall) { obj.sendRequest(obj.pendingAjaxCall[i][0], obj.pendingAjaxCall[i][3], obj.pendingAjaxCall[i][4]); }
288
+ }
289
+
290
+ // NODE.js specific private method
291
+ obj.xxOnSocketData = function (data) {
292
+ obj.xtlsDataReceived = true;
293
+ if (urlvars && urlvars['wsmantrace']) { console.log("WSMAN-RECV(" + data.length + "): " + data); }
294
+ if (typeof data === 'object') {
295
+ // This is an ArrayBuffer, convert it to a string array (used in IE)
296
+ var binary = "", bytes = new Uint8Array(data), length = bytes.byteLength;
297
+ for (var i = 0; i < length; i++) { binary += String.fromCharCode(bytes[i]); }
298
+ data = binary;
299
+ }
300
+ else if (typeof data !== 'string') return;
301
+
302
+ obj.socketAccumulator += data;
303
+ while (true) {
304
+ //console.log('ACC(' + obj.socketAccumulator + '): ' + obj.socketAccumulator);
305
+ if (obj.socketParseState == 0) {
306
+ var headersize = obj.socketAccumulator.indexOf("\r\n\r\n");
307
+ if (headersize < 0) return;
308
+ //obj.Debug(obj.socketAccumulator.substring(0, headersize)); // Display received HTTP header
309
+ obj.socketHeader = obj.socketAccumulator.substring(0, headersize).split("\r\n");
310
+ if (obj.amtVersion == null) { for (var i in obj.socketHeader) { if (obj.socketHeader[i].indexOf('Server: Intel(R) Active Management Technology ') == 0) { obj.amtVersion = obj.socketHeader[i].substring(46); } } }
311
+ obj.socketAccumulator = obj.socketAccumulator.substring(headersize + 4);
312
+ obj.socketParseState = 1;
313
+ obj.socketData = '';
314
+ obj.socketXHeader = { Directive: obj.socketHeader[0].split(' ') };
315
+ for (i in obj.socketHeader) {
316
+ if (i != 0) {
317
+ var x2 = obj.socketHeader[i].indexOf(':');
318
+ obj.socketXHeader[obj.socketHeader[i].substring(0, x2).toLowerCase()] = obj.socketHeader[i].substring(x2 + 2);
319
+ }
320
+ }
321
+ }
322
+ if (obj.socketParseState == 1) {
323
+ var csize = -1;
324
+ if ((obj.socketXHeader["connection"] != undefined) && (obj.socketXHeader["connection"].toLowerCase() == 'close') && ((obj.socketXHeader["transfer-encoding"] == undefined) || (obj.socketXHeader["transfer-encoding"].toLowerCase() != 'chunked'))) {
325
+ // The body ends with a close, in this case, we will only process the header
326
+ csize = 0;
327
+ } else if (obj.socketXHeader["content-length"] != undefined) {
328
+ // The body length is specified by the content-length
329
+ csize = parseInt(obj.socketXHeader["content-length"]);
330
+ if (obj.socketAccumulator.length < csize) return;
331
+ var data = obj.socketAccumulator.substring(0, csize);
332
+ obj.socketAccumulator = obj.socketAccumulator.substring(csize);
333
+ obj.socketData = data;
334
+ csize = 0;
335
+ } else {
336
+ // The body is chunked
337
+ var clen = obj.socketAccumulator.indexOf("\r\n");
338
+ if (clen < 0) return; // Chunk length not found, exit now and get more data.
339
+ // Chunk length if found, lets see if we can get the data.
340
+ csize = parseInt(obj.socketAccumulator.substring(0, clen), 16);
341
+ if (obj.socketAccumulator.length < clen + 2 + csize + 2) return;
342
+ // We got a chunk with all of the data, handle the chunck now.
343
+ var data = obj.socketAccumulator.substring(clen + 2, clen + 2 + csize);
344
+ obj.socketAccumulator = obj.socketAccumulator.substring(clen + 2 + csize + 2);
345
+ obj.socketData += data;
346
+ }
347
+ if (csize == 0) {
348
+ //obj.Debug("xxOnSocketData DONE: (" + obj.socketData.length + "): " + obj.socketData);
349
+ obj.xxProcessHttpResponse(obj.socketXHeader, obj.socketData);
350
+ obj.socketParseState = 0;
351
+ obj.socketHeader = null;
352
+ }
353
+ }
354
+ }
355
+ }
356
+
357
+ // NODE.js specific private method
358
+ obj.xxProcessHttpResponse = function (header, data) {
359
+ //obj.Debug("xxProcessHttpResponse: " + header.Directive[1]);
360
+
361
+ var s = parseInt(header.Directive[1]);
362
+ if (isNaN(s)) s = 500;
363
+ if (s == 401 && ++(obj.authcounter) < 3) {
364
+ obj.challengeParams = obj.parseDigest(header['www-authenticate']); // Set the digest parameters, after this, the socket will close and we will auto-retry
365
+ obj.socket.end();
366
+ } else {
367
+ var r = obj.pendingAjaxCall.shift();
368
+ if (r == null || r.length < 1) { console.log("pendingAjaxCall error, " + r); return; }
369
+ //if (s != 200) { obj.Debug("Error, status=" + s + "\r\n\r\nreq=" + r[0] + "\r\n\r\nresp=" + data); } // Debug: Display the request & response if something did not work.
370
+ obj.authcounter = 0;
371
+ obj.ActiveAjaxCount--;
372
+ obj.gotNextMessages(data, 'success', { status: s }, r);
373
+ obj.PerformNextAjax();
374
+ }
375
+ }
376
+
377
+ // NODE.js specific private method
378
+ obj.xxOnSocketClosed = function (data) {
379
+ //obj.Debug("xxOnSocketClosed");
380
+ obj.socketState = 0;
381
+ if (obj.socket != null) { obj.socket.destroy(); obj.socket = null; }
382
+ if (obj.pendingAjaxCall.length > 0) {
383
+ var r = obj.pendingAjaxCall.shift();
384
+ var retry = r[5];
385
+ setTimeout(function () { obj.PerformAjaxExNodeJS2(r[0], r[1], r[2], r[3], r[4], --retry) }, 500); // Wait half a second and try again
386
+ }
387
+ }
388
+
389
+ // NODE.js specific private method
390
+ obj.xxSend = function (x) {
391
+ if (obj.socketState == 2) {
392
+ if (urlvars && urlvars['wsmantrace']) { console.log("WSMAN-SEND(" + x.length + "): " + x); }
393
+ obj.socket.write(new Buffer(x, "binary"));
394
+ }
395
+ }
396
+
397
+ // Cancel all pending queries with given status
398
+ obj.CancelAllQueries = function (s) {
399
+ obj.FailAllError = s;
400
+ while (obj.PendingAjax.length > 0) { var x = obj.PendingAjax.shift(); x[1](null, s, x[2]); }
401
+ if (obj.socket != null) { obj.socket.end(); obj.socket = null; obj.socketState = 0; }
402
+ }
403
+
404
+ // Private method
405
+ obj.gotNextMessages = function (data, status, request, callArgs) {
406
+ if (obj.FailAllError == 999) return;
407
+ if (obj.FailAllError != 0) { try { callArgs[1](null, obj.FailAllError, callArgs[2]); } catch (ex) { console.error(ex); } return; }
408
+ if (request.status != 200) { try { callArgs[1](null, request.status, callArgs[2]); } catch (ex) { console.error(ex); } return; }
409
+ try { callArgs[1](data, 200, callArgs[2]); } catch (ex) { console.error(ex); }
410
+ }
411
+
412
+ // Private method
413
+ obj.gotNextMessagesError = function (request, status, errorThrown, callArgs) {
414
+ if (obj.FailAllError == 999) return;
415
+ if (obj.FailAllError != 0) { try { callArgs[1](null, obj.FailAllError, callArgs[2]); } catch (ex) { console.error(ex); } return; }
416
+ try { callArgs[1](obj, null, { Header: { HttpError: request.status } }, request.status, callArgs[2]); } catch (ex) { console.error(ex); }
417
+ }
418
+
419
+ /*
420
+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
421
+ * Digest Algorithm, as defined in RFC 1321.
422
+ * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
423
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
424
+ * Distributed under the BSD License
425
+ * See http://pajhome.org.uk/crypt/md5 for more info.
426
+ */
427
+
428
+ /*
429
+ * Configurable variables. You may need to tweak these to be compatible with
430
+ * the server-side, but the defaults work in most cases.
431
+ */
432
+ var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
433
+ var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
434
+ var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
435
+
436
+ /*
437
+ * These are the functions you'll usually want to call
438
+ * They take string arguments and return either hex or base-64 encoded strings
439
+ */
440
+ function hex_md5(s) { return binl2hex(core_md5(str2binl(s), s.length * chrsz)); }
441
+ function b64_md5(s) { return binl2b64(core_md5(str2binl(s), s.length * chrsz)); }
442
+ function str_md5(s) { return binl2str(core_md5(str2binl(s), s.length * chrsz)); }
443
+ function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
444
+ function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
445
+ function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
446
+
447
+ /*
448
+ * Perform a simple self-test to see if the VM is working
449
+ */
450
+ function md5_vm_test() {
451
+ return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
452
+ }
453
+
454
+ /*
455
+ * Calculate the MD5 of an array of little-endian words, and a bit length
456
+ */
457
+ function core_md5(x, len) {
458
+ /* append padding */
459
+ x[len >> 5] |= 0x80 << ((len) % 32);
460
+ x[(((len + 64) >>> 9) << 4) + 14] = len;
461
+
462
+ var a = 1732584193;
463
+ var b = -271733879;
464
+ var c = -1732584194;
465
+ var d = 271733878;
466
+
467
+ for (var i = 0; i < x.length; i += 16) {
468
+ var olda = a;
469
+ var oldb = b;
470
+ var oldc = c;
471
+ var oldd = d;
472
+
473
+ a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
474
+ d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
475
+ c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
476
+ b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
477
+ a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
478
+ d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
479
+ c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
480
+ b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
481
+ a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
482
+ d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
483
+ c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
484
+ b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
485
+ a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
486
+ d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
487
+ c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
488
+ b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
489
+
490
+ a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
491
+ d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
492
+ c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
493
+ b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
494
+ a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
495
+ d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
496
+ c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
497
+ b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
498
+ a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
499
+ d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
500
+ c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
501
+ b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
502
+ a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
503
+ d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
504
+ c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
505
+ b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
506
+
507
+ a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
508
+ d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
509
+ c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
510
+ b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
511
+ a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
512
+ d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
513
+ c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
514
+ b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
515
+ a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
516
+ d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
517
+ c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
518
+ b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
519
+ a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
520
+ d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
521
+ c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
522
+ b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
523
+
524
+ a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
525
+ d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
526
+ c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
527
+ b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
528
+ a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
529
+ d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
530
+ c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
531
+ b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
532
+ a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
533
+ d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
534
+ c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
535
+ b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
536
+ a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
537
+ d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
538
+ c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
539
+ b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
540
+
541
+ a = safe_add(a, olda);
542
+ b = safe_add(b, oldb);
543
+ c = safe_add(c, oldc);
544
+ d = safe_add(d, oldd);
545
+ }
546
+ return Array(a, b, c, d);
547
+
548
+ }
549
+
550
+ /*
551
+ * These functions implement the four basic operations the algorithm uses.
552
+ */
553
+ function md5_cmn(q, a, b, x, s, t) {
554
+ return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
555
+ }
556
+ function md5_ff(a, b, c, d, x, s, t) {
557
+ return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
558
+ }
559
+ function md5_gg(a, b, c, d, x, s, t) {
560
+ return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
561
+ }
562
+ function md5_hh(a, b, c, d, x, s, t) {
563
+ return md5_cmn(b ^ c ^ d, a, b, x, s, t);
564
+ }
565
+ function md5_ii(a, b, c, d, x, s, t) {
566
+ return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
567
+ }
568
+
569
+ /*
570
+ * Calculate the HMAC-MD5, of a key and some data
571
+ */
572
+ function core_hmac_md5(key, data) {
573
+ var bkey = str2binl(key);
574
+ if (bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
575
+
576
+ var ipad = Array(16), opad = Array(16);
577
+ for (var i = 0; i < 16; i++) {
578
+ ipad[i] = bkey[i] ^ 0x36363636;
579
+ opad[i] = bkey[i] ^ 0x5C5C5C5C;
580
+ }
581
+
582
+ var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
583
+ return core_md5(opad.concat(hash), 512 + 128);
584
+ }
585
+
586
+ /*
587
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
588
+ * to work around bugs in some JS interpreters.
589
+ */
590
+ function safe_add(x, y) {
591
+ var lsw = (x & 0xFFFF) + (y & 0xFFFF);
592
+ var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
593
+ return (msw << 16) | (lsw & 0xFFFF);
594
+ }
595
+
596
+ /*
597
+ * Bitwise rotate a 32-bit number to the left.
598
+ */
599
+ function bit_rol(num, cnt) {
600
+ return (num << cnt) | (num >>> (32 - cnt));
601
+ }
602
+
603
+ /*
604
+ * Convert a string to an array of little-endian words
605
+ * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
606
+ */
607
+ function str2binl(str) {
608
+ var bin = Array();
609
+ var mask = (1 << chrsz) - 1;
610
+ for (var i = 0; i < str.length * chrsz; i += chrsz)
611
+ bin[i >> 5] |= (str.charCodeAt(i / chrsz) & mask) << (i % 32);
612
+ return bin;
613
+ }
614
+
615
+ /*
616
+ * Convert an array of little-endian words to a string
617
+ */
618
+ function binl2str(bin) {
619
+ var str = "";
620
+ var mask = (1 << chrsz) - 1;
621
+ for (var i = 0; i < bin.length * 32; i += chrsz)
622
+ str += String.fromCharCode((bin[i >> 5] >>> (i % 32)) & mask);
623
+ return str;
624
+ }
625
+
626
+ /*
627
+ * Convert an array of little-endian words to a hex string.
628
+ */
629
+ function binl2hex(binarray) {
630
+ var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
631
+ var str = "";
632
+ for (var i = 0; i < binarray.length * 4; i++) {
633
+ str += hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8 + 4)) & 0xF) +
634
+ hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8)) & 0xF);
635
+ }
636
+ return str;
637
+ }
638
+
639
+ /*
640
+ * Convert an array of little-endian words to a base-64 string
641
+ */
642
+ function binl2b64(binarray) {
643
+ var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
644
+ var str = "";
645
+ for (var i = 0; i < binarray.length * 4; i += 3) {
646
+ var triplet = (((binarray[i >> 2] >> 8 * (i % 4)) & 0xFF) << 16)
647
+ | (((binarray[i + 1 >> 2] >> 8 * ((i + 1) % 4)) & 0xFF) << 8)
648
+ | ((binarray[i + 2 >> 2] >> 8 * ((i + 2) % 4)) & 0xFF);
649
+ for (var j = 0; j < 4; j++) {
650
+ if (i * 8 + j * 6 > binarray.length * 32) str += b64pad;
651
+ else str += tab.charAt((triplet >> 6 * (3 - j)) & 0x3F);
652
+ }
653
+ }
654
+ return str;
655
+ }
656
+ return obj;
657
+}
658
+
659
+module.exports = CreateWsmanComm;
\ No newline at end of file
amt/amt-wsman.js
new
+213
@@ -0,0 +1,213 @@
1
+/*
2
+Copyright 2018 Intel Corporation
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+*/
16
+
17
+/**
18
+* @description Intel(r) AMT WSMAN Stack
19
+* @author Ylian Saint-Hilaire
20
+* @version v0.2.0
21
+*/
22
+
23
+// Construct a MeshServer object
24
+function WsmanStackCreateService(CreateWsmanComm, host, port, user, pass, tls, extra)
25
+{
26
+ var obj = {_ObjectID: 'WSMAN'};
27
+ //obj.onDebugMessage = null; // Set to a function if you want to get debug messages.
28
+ obj.NextMessageId = 1; // Next message number, used to label WSMAN calls.
29
+ obj.Address = '/wsman';
30
+ obj.xmlParser = require('./amt-xml.js');
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) {
41
+ obj.comm = new CreateWsmanComm(host, port, user, pass, tls, extra);
42
+ }
43
+ }
44
+
45
+ obj.PerformAjax = function PerformAjax(postdata, callback, tag, pri, namespaces) {
46
+ if (namespaces == null) namespaces = '';
47
+ 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) {
48
+ if (status != 200) { callback(obj, null, { Header: { HttpError: status } }, status, tag); return; }
49
+ var wsresponse = obj.xmlParser.ParseWsman(data);
50
+ if (!wsresponse || wsresponse == null) { callback(obj, null, { Header: { HttpError: status } }, 601, tag); } else { callback(obj, wsresponse.Header["ResourceURI"], wsresponse, 200, tag); }
51
+ }, tag, pri);
52
+ }
53
+
54
+ // Private method
55
+ //obj.Debug = function (msg) { /*console.log(msg);*/ }
56
+
57
+ // Cancel all pending queries with given status
58
+ obj.CancelAllQueries = function CancelAllQueries(s) { obj.comm.CancelAllQueries(s); }
59
+
60
+ // Get the last element of a URI string
61
+ obj.GetNameFromUrl = function (resuri) {
62
+ var x = resuri.lastIndexOf("/");
63
+ return (x == -1)?resuri:resuri.substring(x + 1);
64
+ }
65
+
66
+ // Perform a WSMAN Subscribe operation
67
+ obj.ExecSubscribe = function ExecSubscribe(resuri, delivery, url, callback, tag, pri, selectors, opaque, user, pass) {
68
+ var digest = "", digest2 = "", opaque = "";
69
+ 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"/>'; }
70
+ if (opaque != null) { opaque = '<a:ReferenceParameters><m:arg>' + opaque + '</m:arg></a:ReferenceParameters>'; }
71
+ if (delivery == 'PushWithAck') { delivery = 'dmtf.org/wbem/wsman/1/wsman/PushWithAck'; } else if (delivery == 'Push') { delivery = 'xmlsoap.org/ws/2004/08/eventing/DeliveryModes/Push'; }
72
+ 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>';
73
+ obj.PerformAjax(data + "</Body></Envelope>", callback, tag, pri, 'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing" xmlns:m="http://x.com"');
74
+ }
75
+
76
+ // Perform a WSMAN UnSubscribe operation
77
+ obj.ExecUnSubscribe = function ExecUnSubscribe(resuri, callback, tag, pri, selectors) {
78
+ 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/>';
79
+ obj.PerformAjax(data + "</Body></Envelope>", callback, tag, pri, 'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing"');
80
+ }
81
+
82
+ // Perform a WSMAN PUT operation
83
+ obj.ExecPut = function ExecPut(resuri, putobj, callback, tag, pri, selectors) {
84
+ 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);
85
+ obj.PerformAjax(data + "</Body></Envelope>", callback, tag, pri);
86
+ }
87
+
88
+ // Perform a WSMAN CREATE operation
89
+ obj.ExecCreate = function ExecCreate(resuri, putobj, callback, tag, pri, selectors) {
90
+ var objname = obj.GetNameFromUrl(resuri);
91
+ 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 + "\">";
92
+ for (var n in putobj) { data += "<g:" + n + ">" + putobj[n] + "</g:" + n + ">" }
93
+ obj.PerformAjax(data + "</g:" + objname + "></Body></Envelope>", callback, tag, pri);
94
+ }
95
+
96
+ // Perform a WSMAN DELETE operation
97
+ obj.ExecDelete = function ExecDelete(resuri, putobj, callback, tag, pri) {
98
+ 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>";
99
+ obj.PerformAjax(data, callback, tag, pri);
100
+ }
101
+
102
+ // Perform a WSMAN GET operation
103
+ obj.ExecGet = function ExecGet(resuri, callback, tag, pri) {
104
+ 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);
105
+ }
106
+
107
+ // Perform a WSMAN method call operation
108
+ obj.ExecMethod = function ExecMethod(resuri, method, args, callback, tag, pri, selectors) {
109
+ var argsxml = "";
110
+ 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 + ">"; } } }
111
+ obj.ExecMethodXml(resuri, method, argsxml, callback, tag, pri, selectors);
112
+ }
113
+
114
+ // Perform a WSMAN method call operation. The arguments are already formatted in XML.
115
+ obj.ExecMethodXml = function ExecMethodXml(resuri, method, argsxml, callback, tag, pri, selectors) {
116
+ 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);
117
+ }
118
+
119
+ // Perform a WSMAN ENUM operation
120
+ obj.ExecEnum = function ExecEnum(resuri, callback, tag, pri) {
121
+ 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);
122
+ }
123
+
124
+ // Perform a WSMAN PULL operation
125
+ obj.ExecPull = function ExecPull(resuri, enumctx, callback, tag, pri) {
126
+ 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);
127
+ }
128
+
129
+ function _PutObjToBodyXml(resuri, putObj) {
130
+ if (!resuri || putObj == null) return '';
131
+ var objname = obj.GetNameFromUrl(resuri);
132
+ var result = '<r:' + objname + ' xmlns:r="' + resuri + '">';
133
+
134
+ for (var prop in putObj) {
135
+ if (!putObj.hasOwnProperty(prop) || prop.indexOf('__') === 0 || prop.indexOf('@') === 0) continue;
136
+ if (putObj[prop] == null || typeof putObj[prop] === 'function') continue;
137
+ if (typeof putObj[prop] === 'object' && putObj[prop]['ReferenceParameters']) {
138
+ result += '<r:' + prop + '><a:Address>' + putObj[prop].Address + '</a:Address><a:ReferenceParameters><w:ResourceURI>' + putObj[prop]['ReferenceParameters']["ResourceURI"] + '</w:ResourceURI><w:SelectorSet>';
139
+ var selectorArray = putObj[prop]['ReferenceParameters']['SelectorSet']['Selector'];
140
+ if (Array.isArray(selectorArray)) {
141
+ for (var i=0; i< selectorArray.length; i++) {
142
+ result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray[i]) + '>' + selectorArray[i]['Value'] + '</w:Selector>';
143
+ }
144
+ }
145
+ else {
146
+ result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray) + '>' + selectorArray['Value'] + '</w:Selector>';
147
+ }
148
+ result += '</w:SelectorSet></a:ReferenceParameters></r:' + prop + '>';
149
+ }
150
+ else {
151
+ if (Array.isArray(putObj[prop])) {
152
+ for (var i = 0; i < putObj[prop].length; i++) {
153
+ result += '<r:' + prop + '>' + putObj[prop][i].toString() + '</r:' + prop + '>';
154
+ }
155
+ } else {
156
+ result += '<r:' + prop + '>' + putObj[prop].toString() + '</r:' + prop + '>';
157
+ }
158
+ }
159
+ }
160
+
161
+ result += '</r:' + objname + '>';
162
+ return result;
163
+ }
164
+
165
+ /*
166
+ convert
167
+ { @Name: 'InstanceID', @AttrName: 'Attribute Value'}
168
+ into
169
+ ' Name="InstanceID" AttrName="Attribute Value" '
170
+ */
171
+ function _ObjectToXmlAttributes(objWithAttributes) {
172
+ if(!objWithAttributes) return '';
173
+ var result = ' ';
174
+ for (var propName in objWithAttributes) {
175
+ if (!objWithAttributes.hasOwnProperty(propName) || propName.indexOf('@') !== 0) continue;
176
+ result += propName.substring(1) + '="' + objWithAttributes[propName] + '" ';
177
+ }
178
+ return result;
179
+ }
180
+
181
+ function _PutObjToSelectorsXml(selectorSet) {
182
+ if (!selectorSet) return '';
183
+ if (typeof selectorSet == 'string') return selectorSet;
184
+ if (selectorSet['InstanceID']) return "<w:SelectorSet><w:Selector Name=\"InstanceID\">" + selectorSet['InstanceID'] + "</w:Selector></w:SelectorSet>";
185
+ var result = '<w:SelectorSet>';
186
+ for(var propName in selectorSet) {
187
+ if (!selectorSet.hasOwnProperty(propName)) continue;
188
+ result += '<w:Selector Name="' + propName + '">';
189
+ if (selectorSet[propName]['ReferenceParameters']) {
190
+ result += '<a:EndpointReference>';
191
+ result += '<a:Address>' + selectorSet[propName]['Address'] + '</a:Address><a:ReferenceParameters><w:ResourceURI>' + selectorSet[propName]['ReferenceParameters']['ResourceURI'] + '</w:ResourceURI><w:SelectorSet>';
192
+ var selectorArray = selectorSet[propName]['ReferenceParameters']['SelectorSet']['Selector'];
193
+ if (Array.isArray(selectorArray)) {
194
+ for (var i = 0; i < selectorArray.length; i++) {
195
+ result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray[i]) + '>' + selectorArray[i]['Value'] + '</w:Selector>';
196
+ }
197
+ } else {
198
+ result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray) + '>' + selectorArray['Value'] + '</w:Selector>';
199
+ }
200
+ result += '</w:SelectorSet></a:ReferenceParameters></a:EndpointReference>';
201
+ } else {
202
+ result += selectorSet[propName];
203
+ }
204
+ result += '</w:Selector>';
205
+ }
206
+ result += '</w:SelectorSet>';
207
+ return result;
208
+ }
209
+
210
+ return obj;
211
+}
212
+
213
+module.exports = WsmanStackCreateService;
\ No newline at end of file
amt/amt-xml.js
new
+189
@@ -0,0 +1,189 @@
1
+/*
2
+Copyright 2018 Intel Corporation
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+*/
16
+
17
+/**
18
+* @description Parse XML
19
+* @author Ylian Saint-Hilaire
20
+* @version v0.2.0
21
+*/
22
+
23
+// Parse XML and return JSON
24
+module.exports.ParseWsman = function (xml) {
25
+ try {
26
+ if (!xml.childNodes) xml = _turnToXml(xml);
27
+ var r = { Header: {} }, header = xml.getElementsByTagName("Header")[0], t;
28
+ if (!header) header = xml.getElementsByTagName("a:Header")[0];
29
+ if (!header) return null;
30
+ for (var i = 0; i < header.childNodes.length; i++) {
31
+ var child = header.childNodes[i];
32
+ r.Header[child.localName] = child.textContent;
33
+ }
34
+ var body = xml.getElementsByTagName("Body")[0];
35
+ if (!body) body = xml.getElementsByTagName("a:Body")[0];
36
+ if (!body) return null;
37
+ if (body.childNodes.length > 0) {
38
+ t = body.childNodes[0].localName;
39
+ if (t.indexOf("_OUTPUT") == t.length - 7) { t = t.substring(0, t.length - 7); }
40
+ r.Header['Method'] = t;
41
+ r.Body = _ParseWsmanRec(body.childNodes[0]);
42
+ }
43
+ return r;
44
+ } catch (e) {
45
+ console.log("Unable to parse XML: " + xml);
46
+ return null;
47
+ }
48
+}
49
+
50
+// Private method
51
+function _ParseWsmanRec(node) {
52
+ var data, r = {};
53
+ for (var i = 0; i < node.childNodes.length; i++) {
54
+ var child = node.childNodes[i];
55
+ if ((child.childElementCount == null) || (child.childElementCount == 0)) { data = child.textContent; } else { data = _ParseWsmanRec(child); }
56
+ if (data == 'true') data = true; // Convert 'true' into true
57
+ if (data == 'false') data = false; // Convert 'false' into false
58
+ if ((parseInt(data) + '') === data) data = parseInt(data); // Convert integers
59
+
60
+ var childObj = data;
61
+ if ((child.attributes != null) && (child.attributes.length > 0)) {
62
+ childObj = { 'Value': data };
63
+ for (var j = 0; j < child.attributes.length; j++) {
64
+ childObj['@' + child.attributes[j].name] = child.attributes[j].value;
65
+ }
66
+ }
67
+
68
+ if (r[child.localName] instanceof Array) { r[child.localName].push(childObj); }
69
+ else if (r[child.localName] == null) { r[child.localName] = childObj; }
70
+ else { r[child.localName] = [r[child.localName], childObj]; }
71
+ }
72
+ return r;
73
+}
74
+
75
+function _PutObjToBodyXml(resuri, putObj) {
76
+ if (!resuri || putObj == null) return '';
77
+ var objname = obj.GetNameFromUrl(resuri);
78
+ var result = '<r:' + objname + ' xmlns:r="' + resuri + '">';
79
+
80
+ for (var prop in putObj) {
81
+ if (!putObj.hasOwnProperty(prop) || prop.indexOf('__') === 0 || prop.indexOf('@') === 0) continue;
82
+ if (putObj[prop] == null || typeof putObj[prop] === 'function') continue;
83
+ if (typeof putObj[prop] === 'object' && putObj[prop]['ReferenceParameters']) {
84
+ result += '<r:' + prop + '><a:Address>' + putObj[prop].Address + '</a:Address><a:ReferenceParameters><w:ResourceURI>' + putObj[prop]['ReferenceParameters']["ResourceURI"] + '</w:ResourceURI><w:SelectorSet>';
85
+ var selectorArray = putObj[prop]['ReferenceParameters']['SelectorSet']['Selector'];
86
+ if (Array.isArray(selectorArray)) {
87
+ for (var i = 0; i < selectorArray.length; i++) {
88
+ result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray[i]) + '>' + selectorArray[i]['Value'] + '</w:Selector>';
89
+ }
90
+ }
91
+ else {
92
+ result += '<w:Selector' + _ObjectToXmlAttributes(selectorArray) + '>' + selectorArray['Value'] + '</w:Selector>';
93
+ }
94
+ result += '</w:SelectorSet></a:ReferenceParameters></r:' + prop + '>';
95
+ }
96
+ else {
97
+ if (Array.isArray(putObj[prop])) {
98
+ for (var i = 0; i < putObj[prop].length; i++) {
99
+ result += '<r:' + prop + '>' + putObj[prop][i].toString() + '</r:' + prop + '>';
100
+ }
101
+ } else {
102
+ result += '<r:' + prop + '>' + putObj[prop].toString() + '</r:' + prop + '>';
103
+ }
104
+ }
105
+ }
106
+
107
+ result += '</r:' + objname + '>';
108
+ return result;
109
+}
110
+
111
+// This is a drop-in replacement to _turnToXml() that works without xml parser dependency.
112
+try { Object.defineProperty(Array.prototype, "peek", { value: function () { return (this.length > 0 ? this[this.length - 1] : null); } }); } catch (ex) { }
113
+function _treeBuilder() {
114
+ this.tree = [];
115
+ this.push = function (element) { this.tree.push(element); };
116
+ 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); };
117
+ this.peek = function () { return (this.tree.peek()); }
118
+ 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; } } } } }
119
+ 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; }
120
+}
121
+function _turnToXml(text) { if (text == null) return null; return ({ childNodes: [_turnToXmlRec(text)], getElementsByTagName: _getElementsByTagName, getChildElementsByTagName: _getChildElementsByTagName, getElementsByTagNameNS: _getElementsByTagNameNS }); }
122
+function _getElementsByTagNameNS(ns, name) { var ret = []; _xmlTraverseAllRec(this.childNodes, function (node) { if (node.localName == name && (node.namespace == ns || ns == '*')) { ret.push(node); } }); return ret; }
123
+function _getElementsByTagName(name) { var ret = []; _xmlTraverseAllRec(this.childNodes, function (node) { if (node.localName == name) { ret.push(node); } }); return ret; }
124
+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); }
125
+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); }
126
+function _xmlTraverseAllRec(nodes, func) { for (var i in nodes) { func(nodes[i]); if (nodes[i].childNodes) { _xmlTraverseAllRec(nodes[i].childNodes, func); } } }
127
+function _turnToXmlRec(text) {
128
+ var elementStack = new _treeBuilder(), lastElement = null, x1 = text.split('<'), ret = [], element = null, currentElementName = null;
129
+ for (var i in x1) {
130
+ var x2 = x1[i].split('>'), x3 = x2[0].split(' '), elementName = x3[0];
131
+ if ((elementName.length > 0) && (elementName[0] != '?')) {
132
+ if (elementName[0] != '/') {
133
+ var attributes = [], localName, localname2 = elementName.split(' ')[0].split(':'), localName = (localname2.length > 1) ? localname2[1] : localname2[0];
134
+ Object.defineProperty(attributes, "get",
135
+ {
136
+ value: function () {
137
+ if (arguments.length == 1) {
138
+ for (var a in this) { if (this[a].name == arguments[0]) { return (this[a]); } }
139
+ }
140
+ else if (arguments.length == 2) {
141
+ for (var a in this) { if (this[a].name == arguments[1] && (arguments[0] == '*' || this[a].namespace == arguments[0])) { return (this[a]); } }
142
+ }
143
+ else {
144
+ throw ('attributes.get(): Invalid number of parameters');
145
+ }
146
+ }
147
+ });
148
+ elementStack.push({ name: elementName, localName: localName, getChildElementsByTagName: _getChildElementsByTagName, getElementsByTagNameNS: _getElementsByTagNameNS, getChildElementsByTagNameNS: _getChildElementsByTagNameNS, attributes: attributes, childNodes: [], nsTable: {} });
149
+ // Parse Attributes
150
+ if (x3.length > 0) {
151
+ var skip = false;
152
+ for (var j in x3) {
153
+ if (x3[j] == '/') {
154
+ // This is an empty Element
155
+ elementStack.peek().namespace = elementStack.peek().name == elementStack.peek().localName ? elementStack.getNamespace('*') : elementStack.getNamespace(elementStack.peek().name.substring(0, elementStack.peek().name.indexOf(':')));
156
+ elementStack.peek().textContent = '';
157
+ lastElement = elementStack.pop();
158
+ skip = true;
159
+ break;
160
+ }
161
+ var k = x3[j].indexOf('=');
162
+ if (k > 0) {
163
+ var attrName = x3[j].substring(0, k);
164
+ var attrValue = x3[j].substring(k + 2, x3[j].length - 1);
165
+ var attrNS = elementStack.getNamespace('*');
166
+
167
+ if (attrName == 'xmlns') {
168
+ elementStack.addNamespace('*', attrValue);
169
+ attrNS = attrValue;
170
+ } else if (attrName.startsWith('xmlns:')) {
171
+ elementStack.addNamespace(attrName.substring(6), attrValue);
172
+ } else {
173
+ var ax = attrName.split(':');
174
+ if (ax.length == 2) { attrName = ax[1]; attrNS = elementStack.getNamespace(ax[0]); }
175
+ }
176
+ var x = { name: attrName, value: attrValue }
177
+ if (attrNS != null) x.namespace = attrNS;
178
+ elementStack.peek().attributes.push(x);
179
+ }
180
+ }
181
+ if (skip) { continue; }
182
+ }
183
+ elementStack.peek().namespace = elementStack.peek().name == elementStack.peek().localName ? elementStack.getNamespace('*') : elementStack.getNamespace(elementStack.peek().name.substring(0, elementStack.peek().name.indexOf(':')));
184
+ if (x2[1]) { elementStack.peek().textContent = x2[1]; }
185
+ } else { lastElement = elementStack.pop(); }
186
+ }
187
+ }
188
+ return lastElement;
189
+}
\ No newline at end of file
amt/amt.js
new
+1020
@@ -0,0 +1,1020 @@
1
+/*
2
+Copyright 2018 Intel Corporation
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+*/
16
+
17
+/**
18
+* @fileoverview Intel(r) AMT Communication StackXX
19
+* @author Ylian Saint-Hilaire
20
+* @version v0.2.0b
21
+*/
22
+
23
+/**
24
+ * Construct a AmtStackCreateService object, this is the main Intel AMT communication stack.
25
+ * @constructor
26
+ */
27
+function AmtStackCreateService(wsmanStack) {
28
+ var obj = new Object();
29
+ obj._ObjectID = 'AMT'
30
+ obj.wsman = wsmanStack;
31
+ obj.pfx = ["http://intel.com/wbem/wscim/1/amt-schema/1/", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/", "http://intel.com/wbem/wscim/1/ips-schema/1/"];
32
+ obj.PendingEnums = [];
33
+ obj.PendingBatchOperations = 0;
34
+ obj.ActiveEnumsCount = 0;
35
+ obj.MaxActiveEnumsCount = 1; // Maximum number of enumerations that can be done at the same time.
36
+ obj.onProcessChanged = null;
37
+ var _MaxProcess = 0;
38
+ var _LastProcess = 0;
39
+
40
+ // Return the number of pending actions
41
+ obj.GetPendingActions = function () { return (obj.PendingEnums.length * 2) + (obj.ActiveEnumsCount) + obj.wsman.comm.PendingAjax.length + obj.wsman.comm.ActiveAjaxCount + obj.PendingBatchOperations; }
42
+
43
+ // Private Method, Update the current processing status, this gives the application an idea of what progress is being done by the WSMAN stack
44
+ function _up() {
45
+ var x = obj.GetPendingActions();
46
+ if (_MaxProcess < x) _MaxProcess = x;
47
+ if (obj.onProcessChanged != null && _LastProcess != x) {
48
+ //console.log("Process Old=" + _LastProcess + ", New=" + x + ", PEnums=" + obj.PendingEnums.length + ", AEnums=" + obj.ActiveEnumsCount + ", PAjax=" + obj.wsman.comm.PendingAjax.length + ", AAjax=" + obj.wsman.comm.ActiveAjaxCount + ", PBatch=" + obj.PendingBatchOperations);
49
+ _LastProcess = x;
50
+ obj.onProcessChanged(x, _MaxProcess);
51
+ }
52
+ if (x == 0) _MaxProcess = 0;
53
+ }
54
+
55
+ // Perform a WSMAN "SUBSCRIBE" operation.
56
+ obj.Subscribe = function Subscribe(name, delivery, url, callback, tag, pri, selectors, opaque, user, pass) { obj.wsman.ExecSubscribe(obj.CompleteName(name), delivery, url, function (ws, resuri, response, xstatus) { _up(); callback.call(obj, obj, name, response, xstatus, tag); }, 0, pri, selectors, opaque, user, pass); _up(); }
57
+
58
+ // Perform a WSMAN "UNSUBSCRIBE" operation.
59
+ obj.UnSubscribe = function UnSubscribe(name, callback, tag, pri, selectors) { obj.wsman.ExecUnSubscribe(obj.CompleteName(name), function (ws, resuri, response, xstatus) { _up(); callback.call(obj, obj, name, response, xstatus, tag); }, 0, pri, selectors); _up(); }
60
+
61
+ // Perform a WSMAN "GET" operation.
62
+ obj.Get = function Get(name, callback, tag, pri) { obj.wsman.ExecGet(obj.CompleteName(name), function (ws, resuri, response, xstatus) { _up(); callback.call(obj, obj, name, response, xstatus, tag); }, 0, pri); _up(); }
63
+
64
+ // Perform a WSMAN "PUT" operation.
65
+ obj.Put = function Put(name, putobj, callback, tag, pri, selectors) { obj.wsman.ExecPut(obj.CompleteName(name), putobj, function (ws, resuri, response, xstatus) { _up(); callback.call(obj, obj, name, response, xstatus, tag); }, 0, pri, selectors); _up(); }
66
+
67
+ // Perform a WSMAN "CREATE" operation.
68
+ obj.Create = function Create(name, putobj, callback, tag, pri) { obj.wsman.ExecCreate(obj.CompleteName(name), putobj, function (ws, resuri, response, xstatus) { _up(); callback.call(obj, obj, name, response, xstatus, tag); }, 0, pri); _up(); }
69
+
70
+ // Perform a WSMAN "DELETE" operation.
71
+ obj.Delete = function Delete(name, putobj, callback, tag, pri) { obj.wsman.ExecDelete(obj.CompleteName(name), putobj, function (ws, resuri, response, xstatus) { _up(); callback.call(obj, obj, name, response, xstatus, tag); }, 0, pri); _up(); }
72
+
73
+ // Perform a WSMAN method call operation.
74
+ obj.Exec = function Exec(name, method, args, callback, tag, pri, selectors) { obj.wsman.ExecMethod(obj.CompleteName(name), method, args, function (ws, resuri, response, xstatus) { _up(); callback.call(obj, obj, name, obj.CompleteExecResponse(response), xstatus, tag); }, 0, pri, selectors); _up(); }
75
+
76
+ // Perform a WSMAN method call operation.
77
+ obj.ExecWithXml = function ExecWithXml(name, method, args, callback, tag, pri, selectors) { obj.wsman.ExecMethodXml(obj.CompleteName(name), method, execArgumentsToXml(args), function (ws, resuri, response, xstatus) { _up(); callback.call(obj, obj, name, obj.CompleteExecResponse(response), xstatus, tag); }, 0, pri, selectors); _up(); }
78
+
79
+ // Perform a WSMAN "ENUMERATE" operation.
80
+ obj.Enum = function Enum(name, callback, tag, pri) {
81
+ if (obj.ActiveEnumsCount < obj.MaxActiveEnumsCount) {
82
+ obj.ActiveEnumsCount++; obj.wsman.ExecEnum(obj.CompleteName(name), function (ws, resuri, response, xstatus, tag0) { _up(); _EnumStartSink(name, response, callback, resuri, xstatus, tag0); }, tag, pri);
83
+ } else {
84
+ obj.PendingEnums.push([name, callback, tag, pri]);
85
+ }
86
+ _up();
87
+ }
88
+
89
+ // Private method
90
+ function _EnumStartSink(name, response, callback, resuri, status, tag, pri) {
91
+ if (status != 200) { callback.call(obj, obj, name, null, status, tag); _EnumDoNext(1); return; }
92
+ if (response == null || response.Header["Method"] != "EnumerateResponse" || !response.Body["EnumerationContext"]) { callback.call(obj, obj, name, null, 603, tag); _EnumDoNext(1); return; }
93
+ var enumctx = response.Body["EnumerationContext"];
94
+ obj.wsman.ExecPull(resuri, enumctx, function (ws, resuri, response, xstatus) { _EnumContinueSink(name, response, callback, resuri, [], xstatus, tag, pri); });
95
+ }
96
+
97
+ // Private method
98
+ function _EnumContinueSink(name, response, callback, resuri, items, status, tag, pri) {
99
+ if (status != 200) { callback.call(obj, obj, name, null, status, tag); _EnumDoNext(1); return; }
100
+ if (response == null || response.Header["Method"] != "PullResponse") { callback.call(obj, obj, name, null, 604, tag); _EnumDoNext(1); return; }
101
+ for (var i in response.Body["Items"]) {
102
+ if (response.Body["Items"][i] instanceof Array) {
103
+ for (var j in response.Body["Items"][i]) { items.push(response.Body["Items"][i][j]); }
104
+ } else {
105
+ items.push(response.Body["Items"][i]);
106
+ }
107
+ }
108
+ if (response.Body["EnumerationContext"]) {
109
+ var enumctx = response.Body["EnumerationContext"];
110
+ obj.wsman.ExecPull(resuri, enumctx, function (ws, resuri, response, xstatus) { _EnumContinueSink(name, response, callback, resuri, items, xstatus, tag, 1); });
111
+ } else {
112
+ _EnumDoNext(1);
113
+ callback.call(obj, obj, name, items, status, tag);
114
+ _up();
115
+ }
116
+ }
117
+
118
+ // Private method
119
+ function _EnumDoNext(dec) {
120
+ obj.ActiveEnumsCount -= dec;
121
+ if (obj.ActiveEnumsCount >= obj.MaxActiveEnumsCount || obj.PendingEnums.length == 0) return;
122
+ var x = obj.PendingEnums.shift();
123
+ obj.Enum(x[0], x[1], x[2]);
124
+ _EnumDoNext(0);
125
+ }
126
+
127
+ // Perform a batch of WSMAN "ENUM" operations.
128
+ obj.BatchEnum = function (batchname, names, callback, tag, continueOnError, pri) {
129
+ obj.PendingBatchOperations += (names.length * 2);
130
+ _BatchNextEnum(batchname, Clone(names), callback, tag, {}, continueOnError, pri); _up();
131
+ }
132
+
133
+ function Clone(v) { return JSON.parse(JSON.stringify(v)); }
134
+
135
+ // Request each enum in the batch, stopping if something does not return status 200
136
+ function _BatchNextEnum(batchname, names, callback, tag, results, continueOnError, pri) {
137
+ obj.PendingBatchOperations -= 2;
138
+ var n = names.shift(), f = obj.Enum;
139
+ if (n[0] == '*') { f = obj.Get; n = n.substring(1); } // If the name starts with a star, do a GET instead of an ENUM. This will reduce round trips.
140
+ //console.log((f == obj.Get?'Get ':'Enum ') + n);
141
+ // Perform a GET/ENUM action
142
+ f(n, function (stack, name, responses, status, tag0) {
143
+ tag0[2][name] = { response: (responses==null?null:responses.Body), responses: responses, status: status };
144
+ if (tag0[1].length == 0 || status == 401 || (continueOnError != true && status != 200 && status != 400)) { obj.PendingBatchOperations -= (names.length * 2); _up(); callback.call(obj, obj, batchname, tag0[2], status, tag); }
145
+ else { _up(); _BatchNextEnum(batchname, names, callback, tag, tag0[2], pri); }
146
+ }, [batchname, names, results], pri);
147
+ _up();
148
+ }
149
+
150
+ // Perform a batch of WSMAN "GET" operations.
151
+ obj.BatchGet = function (batchname, names, callback, tag, pri) {
152
+ _FetchNext({ name: batchname, names: names, callback: callback, current: 0, responses: {}, tag: tag, pri: pri }); _up();
153
+ }
154
+
155
+ // Private method
156
+ function _FetchNext(batch) {
157
+ if (batch.names.length <= batch.current) {
158
+ batch.callback.call(obj, obj, batch.name, batch.responses, 200, batch.tag);
159
+ } else {
160
+ obj.wsman.ExecGet(obj.CompleteName(batch.names[batch.current]), function (ws, resuri, response, xstatus) { _Fetched(batch, response, xstatus); }, batch.pri);
161
+ batch.current++;
162
+ }
163
+ _up();
164
+ }
165
+
166
+ // Private method
167
+ function _Fetched(batch, response, status) {
168
+ if (response == null || status != 200) {
169
+ batch.callback.call(obj, obj, batch.name, null, status, batch.tag);
170
+ } else {
171
+ batch.responses[response.Header["Method"]] = response;
172
+ _FetchNext(batch);
173
+ }
174
+ }
175
+
176
+ // Private method
177
+ obj.CompleteName = function(name) {
178
+ if (name.indexOf("AMT_") == 0) return obj.pfx[0] + name;
179
+ if (name.indexOf("CIM_") == 0) return obj.pfx[1] + name;
180
+ if (name.indexOf("IPS_") == 0) return obj.pfx[2] + name;
181
+ }
182
+
183
+ obj.CompleteExecResponse = function (resp) {
184
+ if (resp && resp != null && resp.Body && (resp.Body["ReturnValue"] != undefined)) { resp.Body.ReturnValueStr = obj.AmtStatusToStr(resp.Body["ReturnValue"]); }
185
+ return resp;
186
+ }
187
+
188
+ obj.RequestPowerStateChange = function (PowerState, callback_func) {
189
+ obj.CIM_PowerManagementService_RequestPowerStateChange(PowerState, "<Address xmlns=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\"><ResourceURI xmlns=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem</ResourceURI><SelectorSet xmlns=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\"><Selector Name=\"CreationClassName\">CIM_ComputerSystem</Selector><Selector Name=\"Name\">ManagedSystem</Selector></SelectorSet></ReferenceParameters>", null, null, callback_func);
190
+ }
191
+
192
+ obj.SetBootConfigRole = function (Role, callback_func) {
193
+ obj.CIM_BootService_SetBootConfigRole("<Address xmlns=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\"><ResourceURI xmlns=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootConfigSetting</ResourceURI><SelectorSet xmlns=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\"><Selector Name=\"InstanceID\">Intel(r) AMT: Boot Configuration 0</Selector></SelectorSet></ReferenceParameters>", Role, callback_func);
194
+ }
195
+
196
+ // Cancel all pending queries with given status
197
+ obj.CancelAllQueries = function (s) {
198
+ obj.wsman.CancelAllQueries(s);
199
+ }
200
+
201
+ // Auto generated methods
202
+ obj.AMT_AgentPresenceWatchdog_RegisterAgent = function (callback_func, tag, pri, selectors) { obj.Exec("AMT_AgentPresenceWatchdog", "RegisterAgent", {}, callback_func, tag, pri, selectors); }
203
+ obj.AMT_AgentPresenceWatchdog_AssertPresence = function (SequenceNumber, callback_func, tag, pri, selectors) { obj.Exec("AMT_AgentPresenceWatchdog", "AssertPresence", { "SequenceNumber": SequenceNumber }, callback_func, tag, pri, selectors); }
204
+ obj.AMT_AgentPresenceWatchdog_AssertShutdown = function (SequenceNumber, callback_func, tag, pri, selectors) { obj.Exec("AMT_AgentPresenceWatchdog", "AssertShutdown", { "SequenceNumber": SequenceNumber }, callback_func, tag, pri, selectors); }
205
+ //obj.AMT_AgentPresenceWatchdog_RegisterAgent = function (callback_func) { obj.Exec("AMT_AgentPresenceWatchdog", "RegisterAgent", {}, callback_func); }
206
+ //obj.AMT_AgentPresenceWatchdog_AssertPresence = function (SequenceNumber, callback_func) { obj.Exec("AMT_AgentPresenceWatchdog", "AssertPresence", { "SequenceNumber": SequenceNumber }, callback_func); }
207
+ //obj.AMT_AgentPresenceWatchdog_AssertShutdown = function (SequenceNumber, callback_func) { obj.Exec("AMT_AgentPresenceWatchdog", "AssertShutdown", { "SequenceNumber": SequenceNumber }, callback_func); }
208
+ obj.AMT_AgentPresenceWatchdog_AddAction = function (OldState, NewState, EventOnTransition, ActionSd, ActionEac, callback_func, tag, pri, selectors) { obj.Exec("AMT_AgentPresenceWatchdog", "AddAction", { "OldState": OldState, "NewState": NewState, "EventOnTransition": EventOnTransition, "ActionSd": ActionSd, "ActionEac": ActionEac }, callback_func, tag, pri, selectors); }
209
+ obj.AMT_AgentPresenceWatchdog_DeleteAllActions = function (callback_func, tag, pri, selectors) { obj.Exec("AMT_AgentPresenceWatchdog", "DeleteAllActions", {}, callback_func, tag, pri, selectors); }
210
+ obj.AMT_AgentPresenceWatchdogAction_GetActionEac = function (callback_func) { obj.Exec("AMT_AgentPresenceWatchdogAction", "GetActionEac", {}, callback_func); }
211
+ obj.AMT_AgentPresenceWatchdogVA_RegisterAgent = function (callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "RegisterAgent", {}, callback_func); }
212
+ obj.AMT_AgentPresenceWatchdogVA_AssertPresence = function (SequenceNumber, callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "AssertPresence", { "SequenceNumber": SequenceNumber }, callback_func); }
213
+ obj.AMT_AgentPresenceWatchdogVA_AssertShutdown = function (SequenceNumber, callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "AssertShutdown", { "SequenceNumber": SequenceNumber }, callback_func); }
214
+ obj.AMT_AgentPresenceWatchdogVA_AddAction = function (OldState, NewState, EventOnTransition, ActionSd, ActionEac, callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "AddAction", { "OldState": OldState, "NewState": NewState, "EventOnTransition": EventOnTransition, "ActionSd": ActionSd, "ActionEac": ActionEac }, callback_func); }
215
+ obj.AMT_AgentPresenceWatchdogVA_DeleteAllActions = function (_method_dummy, callback_func) { obj.Exec("AMT_AgentPresenceWatchdogVA", "DeleteAllActions", { "_method_dummy": _method_dummy }, callback_func); }
216
+ obj.AMT_AlarmClockService_AddAlarm = function AlarmClockService_AddAlarm(alarmInstance, callback_func)
217
+ {
218
+ var id = alarmInstance.InstanceID;
219
+ var nm = alarmInstance.ElementName;
220
+ var start = alarmInstance.StartTime.Datetime;
221
+ var interval = alarmInstance.Interval ? alarmInstance.Interval.Datetime : undefined;
222
+ var doc = alarmInstance.DeleteOnCompletion;
223
+ var tpl = "<d:AlarmTemplate xmlns:d=\"http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AlarmClockService\" xmlns:s=\"http://intel.com/wbem/wscim/1/ips-schema/1/IPS_AlarmClockOccurrence\"><s:InstanceID>" + id + "</s:InstanceID><s:ElementName>" + nm + "</s:ElementName><s:StartTime><p:Datetime xmlns:p=\"http://schemas.dmtf.org/wbem/wscim/1/common\">" + start + "</p:Datetime></s:StartTime>" + ((interval!=undefined)?("<s:Interval><p:Interval xmlns:p=\"http://schemas.dmtf.org/wbem/wscim/1/common\">" + interval + "</p:Interval></s:Interval>"):"") + "<s:DeleteOnCompletion>" + doc + "</s:DeleteOnCompletion></d:AlarmTemplate>"
224
+ obj.wsman.ExecMethodXml(obj.CompleteName("AMT_AlarmClockService"), "AddAlarm", tpl, callback_func);
225
+ };
226
+ obj.AMT_AuditLog_ClearLog = function (callback_func) { obj.Exec("AMT_AuditLog", "ClearLog", {}, callback_func); }
227
+ obj.AMT_AuditLog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_AuditLog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
228
+ obj.AMT_AuditLog_ReadRecords = function (StartIndex, callback_func, tag) { obj.Exec("AMT_AuditLog", "ReadRecords", { "StartIndex": StartIndex }, callback_func, tag); }
229
+ obj.AMT_AuditLog_SetAuditLock = function (LockTimeoutInSeconds, Flag, Handle, callback_func) { obj.Exec("AMT_AuditLog", "SetAuditLock", { "LockTimeoutInSeconds": LockTimeoutInSeconds, "Flag": Flag, "Handle": Handle }, callback_func); }
230
+ obj.AMT_AuditLog_ExportAuditLogSignature = function (SigningMechanism, callback_func) { obj.Exec("AMT_AuditLog", "ExportAuditLogSignature", { "SigningMechanism": SigningMechanism }, callback_func); }
231
+ obj.AMT_AuditLog_SetSigningKeyMaterial = function (SigningMechanismType, SigningKey, LengthOfCertificates, Certificates, callback_func) { obj.Exec("AMT_AuditLog", "SetSigningKeyMaterial", { "SigningMechanismType": SigningMechanismType, "SigningKey": SigningKey, "LengthOfCertificates": LengthOfCertificates, "Certificates": Certificates }, callback_func); }
232
+ obj.AMT_AuditPolicyRule_SetAuditPolicy = function (Enable, AuditedAppID, EventID, PolicyType, callback_func) { obj.Exec("AMT_AuditPolicyRule", "SetAuditPolicy", { "Enable": Enable, "AuditedAppID": AuditedAppID, "EventID": EventID, "PolicyType": PolicyType }, callback_func); }
233
+ obj.AMT_AuditPolicyRule_SetAuditPolicyBulk = function (Enable, AuditedAppID, EventID, PolicyType, callback_func) { obj.Exec("AMT_AuditPolicyRule", "SetAuditPolicyBulk", { "Enable": Enable, "AuditedAppID": AuditedAppID, "EventID": EventID, "PolicyType": PolicyType }, callback_func); }
234
+ obj.AMT_AuthorizationService_AddUserAclEntryEx = function (DigestUsername, DigestPassword, KerberosUserSid, AccessPermission, Realms, callback_func) { obj.Exec("AMT_AuthorizationService", "AddUserAclEntryEx", { "DigestUsername": DigestUsername, "DigestPassword": DigestPassword, "KerberosUserSid": KerberosUserSid, "AccessPermission": AccessPermission, "Realms": Realms }, callback_func); }
235
+ obj.AMT_AuthorizationService_EnumerateUserAclEntries = function (StartIndex, callback_func) { obj.Exec("AMT_AuthorizationService", "EnumerateUserAclEntries", { "StartIndex": StartIndex }, callback_func); }
236
+ obj.AMT_AuthorizationService_GetUserAclEntryEx = function (Handle, callback_func, tag) { obj.Exec("AMT_AuthorizationService", "GetUserAclEntryEx", { "Handle": Handle }, callback_func, tag); }
237
+ obj.AMT_AuthorizationService_UpdateUserAclEntryEx = function (Handle, DigestUsername, DigestPassword, KerberosUserSid, AccessPermission, Realms, callback_func) { obj.Exec("AMT_AuthorizationService", "UpdateUserAclEntryEx", { "Handle": Handle, "DigestUsername": DigestUsername, "DigestPassword": DigestPassword, "KerberosUserSid": KerberosUserSid, "AccessPermission": AccessPermission, "Realms": Realms }, callback_func); }
238
+ obj.AMT_AuthorizationService_RemoveUserAclEntry = function (Handle, callback_func) { obj.Exec("AMT_AuthorizationService", "RemoveUserAclEntry", { "Handle": Handle }, callback_func); }
239
+ obj.AMT_AuthorizationService_SetAdminAclEntryEx = function (Username, DigestPassword, callback_func) { obj.Exec("AMT_AuthorizationService", "SetAdminAclEntryEx", { "Username": Username, "DigestPassword": DigestPassword }, callback_func); }
240
+ obj.AMT_AuthorizationService_GetAdminAclEntry = function (callback_func) { obj.Exec("AMT_AuthorizationService", "GetAdminAclEntry", {}, callback_func); }
241
+ obj.AMT_AuthorizationService_GetAdminAclEntryStatus = function (callback_func) { obj.Exec("AMT_AuthorizationService", "GetAdminAclEntryStatus", {}, callback_func); }
242
+ obj.AMT_AuthorizationService_GetAdminNetAclEntryStatus = function (callback_func) { obj.Exec("AMT_AuthorizationService", "GetAdminNetAclEntryStatus", {}, callback_func); }
243
+ obj.AMT_AuthorizationService_SetAclEnabledState = function (Handle, Enabled, callback_func, tag) { obj.Exec("AMT_AuthorizationService", "SetAclEnabledState", { "Handle": Handle, "Enabled": Enabled }, callback_func, tag); }
244
+ obj.AMT_AuthorizationService_GetAclEnabledState = function (Handle, callback_func, tag) { obj.Exec("AMT_AuthorizationService", "GetAclEnabledState", { "Handle": Handle }, callback_func, tag); }
245
+ obj.AMT_EndpointAccessControlService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
246
+ obj.AMT_EndpointAccessControlService_GetPosture = function (PostureType, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "GetPosture", { "PostureType": PostureType }, callback_func); }
247
+ obj.AMT_EndpointAccessControlService_GetPostureHash = function (PostureType, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "GetPostureHash", { "PostureType": PostureType }, callback_func); }
248
+ obj.AMT_EndpointAccessControlService_UpdatePostureState = function (UpdateType, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "UpdatePostureState", { "UpdateType": UpdateType }, callback_func); }
249
+ obj.AMT_EndpointAccessControlService_GetEacOptions = function (callback_func) { obj.Exec("AMT_EndpointAccessControlService", "GetEacOptions", {}, callback_func); }
250
+ obj.AMT_EndpointAccessControlService_SetEacOptions = function (EacVendors, PostureHashAlgorithm, callback_func) { obj.Exec("AMT_EndpointAccessControlService", "SetEacOptions", { "EacVendors": EacVendors, "PostureHashAlgorithm": PostureHashAlgorithm }, callback_func); }
251
+ obj.AMT_EnvironmentDetectionSettingData_SetSystemDefensePolicy = function (Policy, callback_func) { obj.Exec("AMT_EnvironmentDetectionSettingData", "SetSystemDefensePolicy", { "Policy": Policy }, callback_func); }
252
+ obj.AMT_EnvironmentDetectionSettingData_EnableVpnRouting = function (Enable, callback_func) { obj.Exec("AMT_EnvironmentDetectionSettingData", "EnableVpnRouting", { "Enable": Enable }, callback_func); }
253
+ obj.AMT_EthernetPortSettings_SetLinkPreference = function (LinkPreference, Timeout, callback_func) { obj.Exec("AMT_EthernetPortSettings", "SetLinkPreference", { "LinkPreference": LinkPreference, "Timeout": Timeout }, callback_func); }
254
+ obj.AMT_HeuristicPacketFilterStatistics_ResetSelectedStats = function (SelectedStatistics, callback_func) { obj.Exec("AMT_HeuristicPacketFilterStatistics", "ResetSelectedStats", { "SelectedStatistics": SelectedStatistics }, callback_func); }
255
+ obj.AMT_KerberosSettingData_GetCredentialCacheState = function (callback_func) { obj.Exec("AMT_KerberosSettingData", "GetCredentialCacheState", {}, callback_func); }
256
+ obj.AMT_KerberosSettingData_SetCredentialCacheState = function (Enable, callback_func) { obj.Exec("AMT_KerberosSettingData", "SetCredentialCacheState", { "Enable": Enable }, callback_func); }
257
+ obj.AMT_MessageLog_CancelIteration = function (IterationIdentifier, callback_func) { obj.Exec("AMT_MessageLog", "CancelIteration", { "IterationIdentifier": IterationIdentifier }, callback_func); }
258
+ obj.AMT_MessageLog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_MessageLog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
259
+ obj.AMT_MessageLog_ClearLog = function (callback_func) { obj.Exec("AMT_MessageLog", "ClearLog", { }, callback_func); }
260
+ obj.AMT_MessageLog_GetRecords = function (IterationIdentifier, MaxReadRecords, callback_func, tag) { obj.Exec("AMT_MessageLog", "GetRecords", { "IterationIdentifier": IterationIdentifier, "MaxReadRecords": MaxReadRecords }, callback_func, tag); }
261
+ obj.AMT_MessageLog_GetRecord = function (IterationIdentifier, PositionToNext, callback_func) { obj.Exec("AMT_MessageLog", "GetRecord", { "IterationIdentifier": IterationIdentifier, "PositionToNext": PositionToNext }, callback_func); }
262
+ obj.AMT_MessageLog_PositionAtRecord = function (IterationIdentifier, MoveAbsolute, RecordNumber, callback_func) { obj.Exec("AMT_MessageLog", "PositionAtRecord", { "IterationIdentifier": IterationIdentifier, "MoveAbsolute": MoveAbsolute, "RecordNumber": RecordNumber }, callback_func); }
263
+ obj.AMT_MessageLog_PositionToFirstRecord = function (callback_func, tag) {
264
+ obj.Exec("AMT_MessageLog", "PositionToFirstRecord", {}, callback_func, tag); }
265
+ obj.AMT_MessageLog_FreezeLog = function (Freeze, callback_func) { obj.Exec("AMT_MessageLog", "FreezeLog", { "Freeze": Freeze }, callback_func); }
266
+ obj.AMT_PublicKeyManagementService_AddCRL = function (Url, SerialNumbers, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "AddCRL", { "Url": Url, "SerialNumbers": SerialNumbers }, callback_func); }
267
+ obj.AMT_PublicKeyManagementService_ResetCRLList = function (_method_dummy, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "ResetCRLList", { "_method_dummy": _method_dummy }, callback_func); }
268
+ obj.AMT_PublicKeyManagementService_AddCertificate = function (CertificateBlob, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "AddCertificate", { "CertificateBlob": CertificateBlob }, callback_func); }
269
+ obj.AMT_PublicKeyManagementService_AddTrustedRootCertificate = function (CertificateBlob, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "AddTrustedRootCertificate", { "CertificateBlob": CertificateBlob }, callback_func); }
270
+ obj.AMT_PublicKeyManagementService_AddKey = function (KeyBlob, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "AddKey", { "KeyBlob": KeyBlob }, callback_func); }
271
+ obj.AMT_PublicKeyManagementService_GeneratePKCS10Request = function (KeyPair, DNName, Usage, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "GeneratePKCS10Request", { "KeyPair": KeyPair, "DNName": DNName, "Usage": Usage }, callback_func); }
272
+ obj.AMT_PublicKeyManagementService_GeneratePKCS10RequestEx = function (KeyPair, SigningAlgorithm, NullSignedCertificateRequest, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "GeneratePKCS10RequestEx", { "KeyPair": KeyPair, "SigningAlgorithm": SigningAlgorithm, "NullSignedCertificateRequest": NullSignedCertificateRequest }, callback_func); }
273
+ obj.AMT_PublicKeyManagementService_GenerateKeyPair = function (KeyAlgorithm, KeyLength, callback_func) { obj.Exec("AMT_PublicKeyManagementService", "GenerateKeyPair", { "KeyAlgorithm": KeyAlgorithm, "KeyLength": KeyLength }, callback_func); }
274
+ obj.AMT_RedirectionService_RequestStateChange = function (RequestedState, callback_func) { obj.Exec("AMT_RedirectionService", "RequestStateChange", { "RequestedState": RequestedState }, callback_func); }
275
+ obj.AMT_RedirectionService_TerminateSession = function (SessionType, callback_func) { obj.Exec("AMT_RedirectionService", "TerminateSession", { "SessionType": SessionType }, callback_func); }
276
+ 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); }
277
+ 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); }
278
+ obj.AMT_RemoteAccessService_CloseRemoteAccessConnection = function (_method_dummy, callback_func) { obj.Exec("AMT_RemoteAccessService", "CloseRemoteAccessConnection", { "_method_dummy": _method_dummy }, callback_func); }
279
+ obj.AMT_SetupAndConfigurationService_CommitChanges = function (_method_dummy, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "CommitChanges", { "_method_dummy": _method_dummy }, callback_func); }
280
+ obj.AMT_SetupAndConfigurationService_Unprovision = function (ProvisioningMode, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "Unprovision", { "ProvisioningMode": ProvisioningMode }, callback_func); }
281
+ obj.AMT_SetupAndConfigurationService_PartialUnprovision = function (_method_dummy, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "PartialUnprovision", { "_method_dummy": _method_dummy }, callback_func); }
282
+ obj.AMT_SetupAndConfigurationService_ResetFlashWearOutProtection = function (_method_dummy, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "ResetFlashWearOutProtection", { "_method_dummy": _method_dummy }, callback_func); }
283
+ obj.AMT_SetupAndConfigurationService_ExtendProvisioningPeriod = function (Duration, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "ExtendProvisioningPeriod", { "Duration": Duration }, callback_func); }
284
+ obj.AMT_SetupAndConfigurationService_SetMEBxPassword = function (Password, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "SetMEBxPassword", { "Password": Password }, callback_func); }
285
+ obj.AMT_SetupAndConfigurationService_SetTLSPSK = function (PID, PPS, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "SetTLSPSK", { "PID": PID, "PPS": PPS }, callback_func); }
286
+ obj.AMT_SetupAndConfigurationService_GetProvisioningAuditRecord = function (callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "GetProvisioningAuditRecord", {}, callback_func); }
287
+ obj.AMT_SetupAndConfigurationService_GetUuid = function (callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "GetUuid", {}, callback_func); }
288
+ obj.AMT_SetupAndConfigurationService_GetUnprovisionBlockingComponents = function (callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "GetUnprovisionBlockingComponents", {}, callback_func); }
289
+ obj.AMT_SetupAndConfigurationService_GetProvisioningAuditRecordV2 = function (callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "GetProvisioningAuditRecordV2", {}, callback_func); }
290
+ obj.AMT_SystemDefensePolicy_GetTimeout = function (callback_func) { obj.Exec("AMT_SystemDefensePolicy", "GetTimeout", {}, callback_func); }
291
+ obj.AMT_SystemDefensePolicy_SetTimeout = function (Timeout, callback_func) { obj.Exec("AMT_SystemDefensePolicy", "SetTimeout", { "Timeout": Timeout }, callback_func); }
292
+ 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); }
293
+ obj.AMT_SystemPowerScheme_SetPowerScheme = function (callback_func, schemeInstanceId, tag) { obj.Exec("AMT_SystemPowerScheme", "SetPowerScheme", {}, callback_func, tag, 0, { "InstanceID": schemeInstanceId }); }
294
+ obj.AMT_TimeSynchronizationService_GetLowAccuracyTimeSynch = function (callback_func, tag) { obj.Exec("AMT_TimeSynchronizationService", "GetLowAccuracyTimeSynch", {}, callback_func, tag); }
295
+ 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); }
296
+ obj.AMT_UserInitiatedConnectionService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("AMT_UserInitiatedConnectionService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
297
+ obj.AMT_WebUIService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func, tag) { obj.Exec("AMT_WebUIService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func, tag); }
298
+ 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); }
299
+ 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); }
300
+ obj.AMT_WiFiPortConfigurationService_DeleteAllITProfiles = function (_method_dummy, callback_func) { obj.Exec("AMT_WiFiPortConfigurationService", "DeleteAllITProfiles", { "_method_dummy": _method_dummy }, callback_func); }
301
+ obj.AMT_WiFiPortConfigurationService_DeleteAllUserProfiles = function (_method_dummy, callback_func) { obj.Exec("AMT_WiFiPortConfigurationService", "DeleteAllUserProfiles", { "_method_dummy": _method_dummy }, callback_func); }
302
+ obj.CIM_Account_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_Account", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
303
+ obj.CIM_AccountManagementService_CreateAccount = function (System, AccountTemplate, callback_func) { obj.Exec("CIM_AccountManagementService", "CreateAccount", { "System": System, "AccountTemplate": AccountTemplate }, callback_func); }
304
+ obj.CIM_BootConfigSetting_ChangeBootOrder = function (Source, callback_func) { obj.Exec("CIM_BootConfigSetting", "ChangeBootOrder", { "Source": Source }, callback_func); }
305
+ obj.CIM_BootService_SetBootConfigRole = function (BootConfigSetting, Role, callback_func) { obj.Exec("CIM_BootService", "SetBootConfigRole", { "BootConfigSetting": BootConfigSetting, "Role": Role }, callback_func, 0, 1); }
306
+ obj.CIM_Card_ConnectorPower = function (Connector, PoweredOn, callback_func) { obj.Exec("CIM_Card", "ConnectorPower", { "Connector": Connector, "PoweredOn": PoweredOn }, callback_func); }
307
+ obj.CIM_Card_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_Card", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
308
+ obj.CIM_Chassis_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_Chassis", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
309
+ obj.CIM_Fan_SetSpeed = function (DesiredSpeed, callback_func) { obj.Exec("CIM_Fan", "SetSpeed", { "DesiredSpeed": DesiredSpeed }, callback_func); }
310
+ obj.CIM_KVMRedirectionSAP_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_KVMRedirectionSAP", "RequestStateChange", { "RequestedState": RequestedState/*, "TimeoutPeriod": TimeoutPeriod */}, callback_func); }
311
+ obj.CIM_MediaAccessDevice_LockMedia = function (Lock, callback_func) { obj.Exec("CIM_MediaAccessDevice", "LockMedia", { "Lock": Lock }, callback_func); }
312
+ obj.CIM_MediaAccessDevice_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_MediaAccessDevice", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
313
+ obj.CIM_MediaAccessDevice_Reset = function (callback_func) { obj.Exec("CIM_MediaAccessDevice", "Reset", {}, callback_func); }
314
+ obj.CIM_MediaAccessDevice_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_MediaAccessDevice", "EnableDevice", { "Enabled": Enabled }, callback_func); }
315
+ obj.CIM_MediaAccessDevice_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_MediaAccessDevice", "OnlineDevice", { "Online": Online }, callback_func); }
316
+ obj.CIM_MediaAccessDevice_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_MediaAccessDevice", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
317
+ obj.CIM_MediaAccessDevice_SaveProperties = function (callback_func) { obj.Exec("CIM_MediaAccessDevice", "SaveProperties", {}, callback_func); }
318
+ obj.CIM_MediaAccessDevice_RestoreProperties = function (callback_func) { obj.Exec("CIM_MediaAccessDevice", "RestoreProperties", {}, callback_func); }
319
+ obj.CIM_MediaAccessDevice_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_MediaAccessDevice", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
320
+ obj.CIM_PhysicalFrame_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_PhysicalFrame", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
321
+ obj.CIM_PhysicalPackage_IsCompatible = function (ElementToCheck, callback_func) { obj.Exec("CIM_PhysicalPackage", "IsCompatible", { "ElementToCheck": ElementToCheck }, callback_func); }
322
+ 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); }
323
+ obj.CIM_PowerSupply_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_PowerSupply", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
324
+ obj.CIM_PowerSupply_Reset = function (callback_func) { obj.Exec("CIM_PowerSupply", "Reset", {}, callback_func); }
325
+ obj.CIM_PowerSupply_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_PowerSupply", "EnableDevice", { "Enabled": Enabled }, callback_func); }
326
+ obj.CIM_PowerSupply_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_PowerSupply", "OnlineDevice", { "Online": Online }, callback_func); }
327
+ obj.CIM_PowerSupply_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_PowerSupply", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
328
+ obj.CIM_PowerSupply_SaveProperties = function (callback_func) { obj.Exec("CIM_PowerSupply", "SaveProperties", {}, callback_func); }
329
+ obj.CIM_PowerSupply_RestoreProperties = function (callback_func) { obj.Exec("CIM_PowerSupply", "RestoreProperties", {}, callback_func); }
330
+ obj.CIM_PowerSupply_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_PowerSupply", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
331
+ obj.CIM_Processor_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_Processor", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
332
+ obj.CIM_Processor_Reset = function (callback_func) { obj.Exec("CIM_Processor", "Reset", {}, callback_func); }
333
+ obj.CIM_Processor_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_Processor", "EnableDevice", { "Enabled": Enabled }, callback_func); }
334
+ obj.CIM_Processor_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_Processor", "OnlineDevice", { "Online": Online }, callback_func); }
335
+ obj.CIM_Processor_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_Processor", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
336
+ obj.CIM_Processor_SaveProperties = function (callback_func) { obj.Exec("CIM_Processor", "SaveProperties", {}, callback_func); }
337
+ obj.CIM_Processor_RestoreProperties = function (callback_func) { obj.Exec("CIM_Processor", "RestoreProperties", {}, callback_func); }
338
+ obj.CIM_Processor_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_Processor", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
339
+ obj.CIM_RecordLog_ClearLog = function (callback_func) { obj.Exec("CIM_RecordLog", "ClearLog", {}, callback_func); }
340
+ obj.CIM_RecordLog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_RecordLog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
341
+ obj.CIM_RedirectionService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_RedirectionService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
342
+ obj.CIM_Sensor_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_Sensor", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
343
+ obj.CIM_Sensor_Reset = function (callback_func) { obj.Exec("CIM_Sensor", "Reset", {}, callback_func); }
344
+ obj.CIM_Sensor_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_Sensor", "EnableDevice", { "Enabled": Enabled }, callback_func); }
345
+ obj.CIM_Sensor_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_Sensor", "OnlineDevice", { "Online": Online }, callback_func); }
346
+ obj.CIM_Sensor_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_Sensor", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
347
+ obj.CIM_Sensor_SaveProperties = function (callback_func) { obj.Exec("CIM_Sensor", "SaveProperties", {}, callback_func); }
348
+ obj.CIM_Sensor_RestoreProperties = function (callback_func) { obj.Exec("CIM_Sensor", "RestoreProperties", {}, callback_func); }
349
+ obj.CIM_Sensor_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_Sensor", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
350
+ obj.CIM_StatisticalData_ResetSelectedStats = function (SelectedStatistics, callback_func) { obj.Exec("CIM_StatisticalData", "ResetSelectedStats", { "SelectedStatistics": SelectedStatistics }, callback_func); }
351
+ obj.CIM_Watchdog_KeepAlive = function (callback_func) { obj.Exec("CIM_Watchdog", "KeepAlive", {}, callback_func); }
352
+ obj.CIM_Watchdog_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_Watchdog", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
353
+ obj.CIM_Watchdog_Reset = function (callback_func) { obj.Exec("CIM_Watchdog", "Reset", {}, callback_func); }
354
+ obj.CIM_Watchdog_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_Watchdog", "EnableDevice", { "Enabled": Enabled }, callback_func); }
355
+ obj.CIM_Watchdog_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_Watchdog", "OnlineDevice", { "Online": Online }, callback_func); }
356
+ obj.CIM_Watchdog_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_Watchdog", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
357
+ obj.CIM_Watchdog_SaveProperties = function (callback_func) { obj.Exec("CIM_Watchdog", "SaveProperties", {}, callback_func); }
358
+ obj.CIM_Watchdog_RestoreProperties = function (callback_func) { obj.Exec("CIM_Watchdog", "RestoreProperties", {}, callback_func); }
359
+ obj.CIM_Watchdog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_Watchdog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
360
+ obj.CIM_WiFiPort_SetPowerState = function (PowerState, Time, callback_func) { obj.Exec("CIM_WiFiPort", "SetPowerState", { "PowerState": PowerState, "Time": Time }, callback_func); }
361
+ obj.CIM_WiFiPort_Reset = function (callback_func) { obj.Exec("CIM_WiFiPort", "Reset", {}, callback_func); }
362
+ obj.CIM_WiFiPort_EnableDevice = function (Enabled, callback_func) { obj.Exec("CIM_WiFiPort", "EnableDevice", { "Enabled": Enabled }, callback_func); }
363
+ obj.CIM_WiFiPort_OnlineDevice = function (Online, callback_func) { obj.Exec("CIM_WiFiPort", "OnlineDevice", { "Online": Online }, callback_func); }
364
+ obj.CIM_WiFiPort_QuiesceDevice = function (Quiesce, callback_func) { obj.Exec("CIM_WiFiPort", "QuiesceDevice", { "Quiesce": Quiesce }, callback_func); }
365
+ obj.CIM_WiFiPort_SaveProperties = function (callback_func) { obj.Exec("CIM_WiFiPort", "SaveProperties", {}, callback_func); }
366
+ obj.CIM_WiFiPort_RestoreProperties = function (callback_func) { obj.Exec("CIM_WiFiPort", "RestoreProperties", {}, callback_func); }
367
+ obj.CIM_WiFiPort_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("CIM_WiFiPort", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
368
+ 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); }
369
+ obj.IPS_HostBasedSetupService_AddNextCertInChain = function (NextCertificate, IsLeafCertificate, IsRootCertificate, callback_func) { obj.Exec("IPS_HostBasedSetupService", "AddNextCertInChain", { "NextCertificate": NextCertificate, "IsLeafCertificate": IsLeafCertificate, "IsRootCertificate": IsRootCertificate }, callback_func); }
370
+ 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); }
371
+ obj.IPS_HostBasedSetupService_UpgradeClientToAdmin = function (McNonce, SigningAlgorithm, DigitalSignature, callback_func) { obj.Exec("IPS_HostBasedSetupService", "UpgradeClientToAdmin", { "McNonce": McNonce, "SigningAlgorithm": SigningAlgorithm, "DigitalSignature": DigitalSignature }, callback_func); }
372
+ obj.IPS_HostBasedSetupService_DisableClientControlMode = function (_method_dummy, callback_func) { obj.Exec("IPS_HostBasedSetupService", "DisableClientControlMode", { "_method_dummy": _method_dummy }, callback_func); }
373
+ obj.IPS_KVMRedirectionSettingData_TerminateSession = function (callback_func) { obj.Exec("IPS_KVMRedirectionSettingData", "TerminateSession", {}, callback_func); }
374
+ obj.IPS_KVMRedirectionSettingData_DataChannelRead = function (callback_func) { obj.Exec("IPS_KVMRedirectionSettingData", "DataChannelRead", {}, callback_func); }
375
+ obj.IPS_KVMRedirectionSettingData_DataChannelWrite = function (Data, callback_func) { obj.Exec("IPS_KVMRedirectionSettingData", "DataChannelWrite", { "DataMessage": Data }, callback_func); }
376
+ obj.IPS_OptInService_StartOptIn = function (callback_func) { obj.Exec("IPS_OptInService", "StartOptIn", {}, callback_func); }
377
+ obj.IPS_OptInService_CancelOptIn = function (callback_func) { obj.Exec("IPS_OptInService", "CancelOptIn", {}, callback_func); }
378
+ obj.IPS_OptInService_SendOptInCode = function (OptInCode, callback_func) { obj.Exec("IPS_OptInService", "SendOptInCode", { "OptInCode": OptInCode }, callback_func); }
379
+ obj.IPS_OptInService_StartService = function (callback_func) { obj.Exec("IPS_OptInService", "StartService", {}, callback_func); }
380
+ obj.IPS_OptInService_StopService = function (callback_func) { obj.Exec("IPS_OptInService", "StopService", {}, callback_func); }
381
+ obj.IPS_OptInService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("IPS_OptInService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
382
+ obj.IPS_ProvisioningRecordLog_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("IPS_ProvisioningRecordLog", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
383
+ obj.IPS_ProvisioningRecordLog_ClearLog = function (_method_dummy, callback_func) { obj.Exec("IPS_ProvisioningRecordLog", "ClearLog", { "_method_dummy": _method_dummy }, callback_func); }
384
+ obj.IPS_SecIOService_RequestStateChange = function (RequestedState, TimeoutPeriod, callback_func) { obj.Exec("IPS_SecIOService", "RequestStateChange", { "RequestedState": RequestedState, "TimeoutPeriod": TimeoutPeriod }, callback_func); }
385
+
386
+ obj.AmtStatusToStr = function (code) { if (obj.AmtStatusCodes[code]) return obj.AmtStatusCodes[code]; else return "UNKNOWN_ERROR" }
387
+ obj.AmtStatusCodes = {
388
+ 0x0000: "SUCCESS",
389
+ 0x0001: "INTERNAL_ERROR",
390
+ 0x0002: "NOT_READY",
391
+ 0x0003: "INVALID_PT_MODE",
392
+ 0x0004: "INVALID_MESSAGE_LENGTH",
393
+ 0x0005: "TABLE_FINGERPRINT_NOT_AVAILABLE",
394
+ 0x0006: "INTEGRITY_CHECK_FAILED",
395
+ 0x0007: "UNSUPPORTED_ISVS_VERSION",
396
+ 0x0008: "APPLICATION_NOT_REGISTERED",
397
+ 0x0009: "INVALID_REGISTRATION_DATA",
398
+ 0x000A: "APPLICATION_DOES_NOT_EXIST",
399
+ 0x000B: "NOT_ENOUGH_STORAGE",
400
+ 0x000C: "INVALID_NAME",
401
+ 0x000D: "BLOCK_DOES_NOT_EXIST",
402
+ 0x000E: "INVALID_BYTE_OFFSET",
403
+ 0x000F: "INVALID_BYTE_COUNT",
404
+ 0x0010: "NOT_PERMITTED",
405
+ 0x0011: "NOT_OWNER",
406
+ 0x0012: "BLOCK_LOCKED_BY_OTHER",
407
+ 0x0013: "BLOCK_NOT_LOCKED",
408
+ 0x0014: "INVALID_GROUP_PERMISSIONS",
409
+ 0x0015: "GROUP_DOES_NOT_EXIST",
410
+ 0x0016: "INVALID_MEMBER_COUNT",
411
+ 0x0017: "MAX_LIMIT_REACHED",
412
+ 0x0018: "INVALID_AUTH_TYPE",
413
+ 0x0019: "AUTHENTICATION_FAILED",
414
+ 0x001A: "INVALID_DHCP_MODE",
415
+ 0x001B: "INVALID_IP_ADDRESS",
416
+ 0x001C: "INVALID_DOMAIN_NAME",
417
+ 0x001D: "UNSUPPORTED_VERSION",
418
+ 0x001E: "REQUEST_UNEXPECTED",
419
+ 0x001F: "INVALID_TABLE_TYPE",
420
+ 0x0020: "INVALID_PROVISIONING_STATE",
421
+ 0x0021: "UNSUPPORTED_OBJECT",
422
+ 0x0022: "INVALID_TIME",
423
+ 0x0023: "INVALID_INDEX",
424
+ 0x0024: "INVALID_PARAMETER",
425
+ 0x0025: "INVALID_NETMASK",
426
+ 0x0026: "FLASH_WRITE_LIMIT_EXCEEDED",
427
+ 0x0027: "INVALID_IMAGE_LENGTH",
428
+ 0x0028: "INVALID_IMAGE_SIGNATURE",
429
+ 0x0029: "PROPOSE_ANOTHER_VERSION",
430
+ 0x002A: "INVALID_PID_FORMAT",
431
+ 0x002B: "INVALID_PPS_FORMAT",
432
+ 0x002C: "BIST_COMMAND_BLOCKED",
433
+ 0x002D: "CONNECTION_FAILED",
434
+ 0x002E: "CONNECTION_TOO_MANY",
435
+ 0x002F: "RNG_GENERATION_IN_PROGRESS",
436
+ 0x0030: "RNG_NOT_READY",
437
+ 0x0031: "CERTIFICATE_NOT_READY",
438
+ 0x0400: "DISABLED_BY_POLICY",
439
+ 0x0800: "NETWORK_IF_ERROR_BASE",
440
+ 0x0801: "UNSUPPORTED_OEM_NUMBER",
441
+ 0x0802: "UNSUPPORTED_BOOT_OPTION",
442
+ 0x0803: "INVALID_COMMAND",
443
+ 0x0804: "INVALID_SPECIAL_COMMAND",
444
+ 0x0805: "INVALID_HANDLE",
445
+ 0x0806: "INVALID_PASSWORD",
446
+ 0x0807: "INVALID_REALM",
447
+ 0x0808: "STORAGE_ACL_ENTRY_IN_USE",
448
+ 0x0809: "DATA_MISSING",
449
+ 0x080A: "DUPLICATE",
450
+ 0x080B: "EVENTLOG_FROZEN",
451
+ 0x080C: "PKI_MISSING_KEYS",
452
+ 0x080D: "PKI_GENERATING_KEYS",
453
+ 0x080E: "INVALID_KEY",
454
+ 0x080F: "INVALID_CERT",
455
+ 0x0810: "CERT_KEY_NOT_MATCH",
456
+ 0x0811: "MAX_KERB_DOMAIN_REACHED",
457
+ 0x0812: "UNSUPPORTED",
458
+ 0x0813: "INVALID_PRIORITY",
459
+ 0x0814: "NOT_FOUND",
460
+ 0x0815: "INVALID_CREDENTIALS",
461
+ 0x0816: "INVALID_PASSPHRASE",
462
+ 0x0818: "NO_ASSOCIATION",
463
+ 0x081B: "AUDIT_FAIL",
464
+ 0x081C: "BLOCKING_COMPONENT",
465
+ 0x0821: "USER_CONSENT_REQUIRED",
466
+ 0x1000: "APP_INTERNAL_ERROR",
467
+ 0x1001: "NOT_INITIALIZED",
468
+ 0x1002: "LIB_VERSION_UNSUPPORTED",
469
+ 0x1003: "INVALID_PARAM",
470
+ 0x1004: "RESOURCES",
471
+ 0x1005: "HARDWARE_ACCESS_ERROR",
472
+ 0x1006: "REQUESTOR_NOT_REGISTERED",
473
+ 0x1007: "NETWORK_ERROR",
474
+ 0x1008: "PARAM_BUFFER_TOO_SHORT",
475
+ 0x1009: "COM_NOT_INITIALIZED_IN_THREAD",
476
+ 0x100A: "URL_REQUIRED"
477
+ }
478
+
479
+ //
480
+ // Methods used for getting the event log
481
+ //
482
+
483
+ obj.GetMessageLog = function (func, tag) {
484
+ obj.AMT_MessageLog_PositionToFirstRecord(_GetMessageLog0, [func, tag, []]);
485
+ }
486
+ function _GetMessageLog0(stack, name, responses, status, tag) {
487
+ if (status != 200 || responses.Body["ReturnValue"] != '0') { tag[0](obj, null, tag[2], status); return; }
488
+ obj.AMT_MessageLog_GetRecords(responses.Body["IterationIdentifier"], 390, _GetMessageLog1, tag);
489
+ }
490
+ function _GetMessageLog1(stack, name, responses, status, tag) {
491
+ if (status != 200 || responses.Body["ReturnValue"] != '0') { tag[0](obj, null, tag[2], status); return; }
492
+ var i, j, x, e, AmtMessages = tag[2], t = new Date(), TimeStamp, ra = responses.Body["RecordArray"];
493
+ if (typeof ra === 'string') { responses.Body["RecordArray"] = [responses.Body["RecordArray"]]; }
494
+
495
+ for (i in ra) {
496
+ e = Buffer.from(ra[i], 'base64');
497
+ if (e != null) {
498
+ TimeStamp = ReadIntX(e, 0);
499
+ if ((TimeStamp > 0) && (TimeStamp < 0xFFFFFFFF)) {
500
+ 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) };
501
+ for (j = 13; j < 21; j++) { x['EventData'].push(e[j]); }
502
+ x['EntityStr'] = _SystemEntityTypes[x['Entity']];
503
+ x['Desc'] = _GetEventDetailStr(x['EventSensorType'], x['EventOffset'], x['EventData'], x['Entity']);
504
+ if (!x['EntityStr']) x['EntityStr'] = "Unknown";
505
+ AmtMessages.push(x);
506
+ }
507
+ }
508
+ }
509
+
510
+ if (responses.Body["NoMoreRecords"] != true) {
511
+ obj.AMT_MessageLog_GetRecords(responses.Body["IterationIdentifier"], 390, _GetMessageLog1, [tag[0], AmtMessages, tag[2]]); }
512
+ else { tag[0](obj, AmtMessages, tag[2], status); }
513
+ }
514
+
515
+ 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('|');
516
+ 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('|');
517
+ 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('|');
518
+ 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('|');
519
+ 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('|');
520
+ obj.WatchdogCurrentStates = { 1: 'Not Started', 2: 'Stopped', 4: 'Running', 8: 'Expired', 16: 'Suspended' };
521
+
522
+ function _GetEventDetailStr(eventSensorType, eventOffset, eventDataField, entity) {
523
+
524
+ if (eventSensorType == 15)
525
+ {
526
+ if (eventDataField[0] == 235) return "Invalid Data";
527
+ if (eventOffset == 0) return _SystemFirmwareError[eventDataField[1]];
528
+ return _SystemFirmwareProgress[eventDataField[1]];
529
+ }
530
+
531
+ if (eventSensorType == 18 && eventDataField[0] == 170) // System watchdog event
532
+ {
533
+ 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]];
534
+ }
535
+
536
+ //if (eventSensorType == 5 && eventOffset == 0) // System chassis
537
+ //{
538
+ // return "Case intrusion";
539
+ //}
540
+
541
+ //if (eventSensorType == 192 && eventOffset == 0 && eventDataField[0] == 170 && eventDataField[1] == 48)
542
+ //{
543
+ // if (eventDataField[2] == 0) return "A remote Serial Over LAN session was established.";
544
+ // if (eventDataField[2] == 1) return "Remote Serial Over LAN session finished. User control was restored.";
545
+ // if (eventDataField[2] == 2) return "A remote IDE-Redirection session was established.";
546
+ // if (eventDataField[2] == 3) return "Remote IDE-Redirection session finished. User control was restored.";
547
+ //}
548
+
549
+ //if (eventSensorType == 36)
550
+ //{
551
+ // long handle = ((long)(eventDataField[1]) << 24) + ((long)(eventDataField[2]) << 16) + ((long)(eventDataField[3]) << 8) + (long)(eventDataField[4]);
552
+ // string nic = string.Format("#{0}", eventDataField[0]);
553
+ // if (eventDataField[0] == 0xAA) nic = "wired"; // TODO: Add wireless *****
554
+ // //if (eventDataField[0] == 0xAA) nic = "wireless";
555
+
556
+ // if (handle == 4294967293) { return string.Format("All received packet filter was matched on {0} interface.", nic); }
557
+ // if (handle == 4294967292) { return string.Format("All outbound packet filter was matched on {0} interface.", nic); }
558
+ // if (handle == 4294967290) { return string.Format("Spoofed packet filter was matched on {0} interface.", nic); }
559
+ // return string.Format("Filter {0} was matched on {1} interface.", handle, nic);
560
+ //}
561
+
562
+ //if (eventSensorType == 192)
563
+ //{
564
+ // if (eventDataField[2] == 0) return "Security policy invoked. Some or all network traffic (TX) was stopped.";
565
+ // if (eventDataField[2] == 2) return "Security policy invoked. Some or all network traffic (RX) was stopped.";
566
+ // return "Security policy invoked.";
567
+ //}
568
+
569
+ //if (eventSensorType == 193)
570
+ //{
571
+ // if (eventDataField[0] == 0xAA && eventDataField[1] == 0x30 && eventDataField[2] == 0x00 && eventDataField[3] == 0x00) { return "User request for remote connection."; }
572
+ // 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 }
573
+ // if (eventDataField[0] == 0xAA && eventDataField[1] == 0x20 && eventDataField[2] == 0x04 && eventDataField[3] == 0x00) { return "Certificate revoked. "; }
574
+ //}
575
+
576
+ if (eventSensorType == 6) return "Authentication failed " + (eventDataField[1] + (eventDataField[2] << 8)) + " times. The system may be under attack.";
577
+ if (eventSensorType == 30) return "No bootable media";
578
+ if (eventSensorType == 32) return "Operating system lockup or power interrupt";
579
+ if (eventSensorType == 35) return "System boot failure";
580
+ if (eventSensorType == 37) return "System firmware started (at least one CPU is properly executing).";
581
+ return "Unknown Sensor Type #" + eventSensorType;
582
+ }
583
+
584
+// ###BEGIN###{AuditLog}
585
+
586
+ // Useful link: https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Fsecurityadminevents.htm
587
+
588
+ var _AmtAuditStringTable =
589
+ {
590
+ 16: 'Security Admin',
591
+ 17: 'RCO',
592
+ 18: 'Redirection Manager',
593
+ 19: 'Firmware Update Manager',
594
+ 20: 'Security Audit Log',
595
+ 21: 'Network Time',
596
+ 22: 'Network Administration',
597
+ 23: 'Storage Administration',
598
+ 24: 'Event Manager',
599
+ 25: 'Circuit Breaker Manager',
600
+ 26: 'Agent Presence Manager',
601
+ 27: 'Wireless Configuration',
602
+ 28: 'EAC',
603
+ 29: 'KVM',
604
+ 30: 'User Opt-In Events',
605
+ 32: 'Screen Blanking',
606
+ 33: 'Watchdog Events',
607
+ 1600: 'Provisioning Started',
608
+ 1601: 'Provisioning Completed',
609
+ 1602: 'ACL Entry Added',
610
+ 1603: 'ACL Entry Modified',
611
+ 1604: 'ACL Entry Removed',
612
+ 1605: 'ACL Access with Invalid Credentials',
613
+ 1606: 'ACL Entry State',
614
+ 1607: 'TLS State Changed',
615
+ 1608: 'TLS Server Certificate Set',
616
+ 1609: 'TLS Server Certificate Remove',
617
+ 1610: 'TLS Trusted Root Certificate Added',
618
+ 1611: 'TLS Trusted Root Certificate Removed',
619
+ 1612: 'TLS Preshared Key Set',
620
+ 1613: 'Kerberos Settings Modified',
621
+ 1614: 'Kerberos Master Key Modified',
622
+ 1615: 'Flash Wear out Counters Reset',
623
+ 1616: 'Power Package Modified',
624
+ 1617: 'Set Realm Authentication Mode',
625
+ 1618: 'Upgrade Client to Admin Control Mode',
626
+ 1619: 'Unprovisioning Started',
627
+ 1700: 'Performed Power Up',
628
+ 1701: 'Performed Power Down',
629
+ 1702: 'Performed Power Cycle',
630
+ 1703: 'Performed Reset',
631
+ 1704: 'Set Boot Options',
632
+ 1800: 'IDER Session Opened',
633
+ 1801: 'IDER Session Closed',
634
+ 1802: 'IDER Enabled',
635
+ 1803: 'IDER Disabled',
636
+ 1804: 'SoL Session Opened',
637
+ 1805: 'SoL Session Closed',
638
+ 1806: 'SoL Enabled',
639
+ 1807: 'SoL Disabled',
640
+ 1808: 'KVM Session Started',
641
+ 1809: 'KVM Session Ended',
642
+ 1810: 'KVM Enabled',
643
+ 1811: 'KVM Disabled',
644
+ 1812: 'VNC Password Failed 3 Times',
645
+ 1900: 'Firmware Updated',
646
+ 1901: 'Firmware Update Failed',
647
+ 2000: 'Security Audit Log Cleared',
648
+ 2001: 'Security Audit Policy Modified',
649
+ 2002: 'Security Audit Log Disabled',
650
+ 2003: 'Security Audit Log Enabled',
651
+ 2004: 'Security Audit Log Exported',
652
+ 2005: 'Security Audit Log Recovered',
653
+ 2100: 'Intel(R) ME Time Set',
654
+ 2200: 'TCPIP Parameters Set',
655
+ 2201: 'Host Name Set',
656
+ 2202: 'Domain Name Set',
657
+ 2203: 'VLAN Parameters Set',
658
+ 2204: 'Link Policy Set',
659
+ 2205: 'IPv6 Parameters Set',
660
+ 2300: 'Global Storage Attributes Set',
661
+ 2301: 'Storage EACL Modified',
662
+ 2302: 'Storage FPACL Modified',
663
+ 2303: 'Storage Write Operation',
664
+ 2400: 'Alert Subscribed',
665
+ 2401: 'Alert Unsubscribed',
666
+ 2402: 'Event Log Cleared',
667
+ 2403: 'Event Log Frozen',
668
+ 2500: 'CB Filter Added',
669
+ 2501: 'CB Filter Removed',
670
+ 2502: 'CB Policy Added',
671
+ 2503: 'CB Policy Removed',
672
+ 2504: 'CB Default Policy Set',
673
+ 2505: 'CB Heuristics Option Set',
674
+ 2506: 'CB Heuristics State Cleared',
675
+ 2600: 'Agent Watchdog Added',
676
+ 2601: 'Agent Watchdog Removed',
677
+ 2602: 'Agent Watchdog Action Set',
678
+ 2700: 'Wireless Profile Added',
679
+ 2701: 'Wireless Profile Removed',
680
+ 2702: 'Wireless Profile Updated',
681
+ 2800: 'EAC Posture Signer SET',
682
+ 2801: 'EAC Enabled',
683
+ 2802: 'EAC Disabled',
684
+ 2803: 'EAC Posture State',
685
+ 2804: 'EAC Set Options',
686
+ 2900: 'KVM Opt-in Enabled',
687
+ 2901: 'KVM Opt-in Disabled',
688
+ 2902: 'KVM Password Changed',
689
+ 2903: 'KVM Consent Succeeded',
690
+ 2904: 'KVM Consent Failed',
691
+ 3000: 'Opt-In Policy Change',
692
+ 3001: 'Send Consent Code Event',
693
+ 3002: 'Start Opt-In Blocked Event'
694
+ }
695
+
696
+ // Return human readable extended audit log data
697
+ // TODO: Just put some of them here, but many more still need to be added, helpful link here:
698
+ // https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Fsecurityadminevents.htm
699
+ obj.GetAuditLogExtendedDataStr = function (id, data) {
700
+ if ((id == 1602 || id == 1604) && data[0] == 0) { return data.splice(2, 2 + data[1]).toString(); } // ACL Entry Added/Removed (Digest)
701
+ if (id == 1603) { if (data[1] == 0) { return data.splice(3).toString(); } return null; } // ACL Entry Modified
702
+ if (id == 1605) { return ["Invalid ME access", "Invalid MEBx access"][data[0]]; } // ACL Access with Invalid Credentials
703
+ if (id == 1606) { var r = ["Disabled", "Enabled"][data[0]]; if (data[1] == 0) { r += ", " + data[3]; } return r; } // ACL Entry State
704
+ if (id == 1607) { return "Remote " + ["NoAuth", "ServerAuth", "MutualAuth"][data[0]] + ", Local " + ["NoAuth", "ServerAuth", "MutualAuth"][data[1]]; } // TLS State Changed
705
+ if (id == 1617) { return obj.RealmNames[ReadInt(data, 0)] + ", " + ["NoAuth", "Auth", "Disabled"][data[4]]; } // Set Realm Authentication Mode
706
+ if (id == 1619) { return ["BIOS", "MEBx", "Local MEI", "Local WSMAN", "Remote WSAMN"][data[0]]; } // Intel AMT Unprovisioning Started
707
+ 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
708
+ if (id == 2100) { var t4 = new Date(); t4.setTime(ReadInt(data, 0) * 1000 + (new Date().getTimezoneOffset() * 60000)); return t4.toLocaleString(); } // Intel AMT Time Set
709
+ if (id == 3000) { return "From " + ["None", "KVM", "All"][data[0]] + " to " + ["None", "KVM", "All"][data[1]]; } // Opt-In Policy Change
710
+ if (id == 3001) { return ["Success", "Failed 3 times"][data[0]]; } // Send Consent Code Event
711
+ return null;
712
+ }
713
+
714
+ obj.GetAuditLog = function (func) {
715
+ obj.AMT_AuditLog_ReadRecords(1, _GetAuditLog0, [func, []]);
716
+ }
717
+
718
+ function MakeToArray(v) { if (!v || v == null || typeof v == 'object') return v; return [v]; }
719
+ function ReadShort(v, p) { return (v[p] << 8) + v[p + 1]; }
720
+ 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.
721
+ function ReadIntX(v, p) { return (v[p + 3] * 0x1000000) + (v[p + 2] << 16) + (v[p + 1] << 8) + v[p]; }
722
+ function btoa(x) { return Buffer.from(x).toString('base64'); }
723
+ function atob(x) { var z = null; try { z = Buffer.from(x, 'base64').toString(); } catch (e) { console.log(e); } return z; }
724
+
725
+ function _GetAuditLog0(stack, name, responses, status, tag) {
726
+ if (status != 200) { tag[0](obj, [], status); return; }
727
+ var ptr, i, e, es, x, r = tag[1], t = new Date(), TimeStamp;
728
+
729
+ if (responses.Body['RecordsReturned'] > 0) {
730
+ responses.Body['EventRecords'] = MakeToArray(responses.Body['EventRecords']);
731
+
732
+ for (i in responses.Body['EventRecords']) {
733
+ e = null;
734
+ try {
735
+ es = atob(responses.Body['EventRecords'][i]);
736
+ e = new Buffer(es);
737
+ } catch (ex) {
738
+ console.log(ex + " " + responses.Body['EventRecords'][i])
739
+ }
740
+
741
+ x = { 'AuditAppID': ReadShort(e, 0), 'EventID': ReadShort(e, 2), 'InitiatorType': e[4] };
742
+ x['AuditApp'] = _AmtAuditStringTable[x['AuditAppID']];
743
+ x['Event'] = _AmtAuditStringTable[(x['AuditAppID'] * 100) + x['EventID']];
744
+ if (!x['Event']) x['Event'] = '#' + x['EventID'];
745
+
746
+ // Read and process the initiator
747
+ if (x['InitiatorType'] == 0) {
748
+ // HTTP digest
749
+ var userlen = e[5];
750
+ x['Initiator'] = e.slice(6, 6 + userlen).toString();
751
+ ptr = 6 + userlen;
752
+ }
753
+ if (x['InitiatorType'] == 1) {
754
+ // Kerberos
755
+ x['KerberosUserInDomain'] = ReadInt(e, 5);
756
+ var userlen = e[9];
757
+ x['Initiator'] = GetSidString(e.slice(10, 10 + userlen));
758
+ ptr = 10 + userlen;
759
+ }
760
+ if (x['InitiatorType'] == 2) {
761
+ // Local
762
+ x['Initiator'] = 'Local';
763
+ ptr = 5;
764
+ }
765
+ if (x['InitiatorType'] == 3) {
766
+ // KVM Default Port
767
+ x['Initiator'] = 'KVM Default Port';
768
+ ptr = 5;
769
+ }
770
+
771
+ // Read timestamp
772
+ TimeStamp = ReadInt(e, ptr);
773
+ x['Time'] = new Date((TimeStamp + (t.getTimezoneOffset() * 60)) * 1000);
774
+ ptr += 4;
775
+
776
+ // Read network access
777
+ x['MCLocationType'] = e[ptr++];
778
+ var netlen = e[ptr++];
779
+
780
+ x['NetAddress'] = e.slice(ptr, ptr + netlen).toString();
781
+
782
+ // Read extended data
783
+ ptr += netlen;
784
+ var exlen = e[ptr++];
785
+ x['Ex'] = e.slice(ptr, ptr + exlen);
786
+ x['ExStr'] = obj.GetAuditLogExtendedDataStr((x['AuditAppID'] * 100) + x['EventID'], x['Ex']);
787
+ r.push(x);
788
+ }
789
+ }
790
+ if (responses.Body['TotalRecordCount'] > r.length) {
791
+ obj.AMT_AuditLog_ReadRecords(r.length + 1, _GetAuditLog0, [tag[0], r]);
792
+ } else {
793
+ tag[0](obj, r, status);
794
+ }
795
+ }
796
+
797
+ // ###END###{AuditLog}
798
+
799
+ /*
800
+ // ###BEGIN###{Certificates}
801
+
802
+ // Forge MD5
803
+ function hex_md5(str) { return forge.md.md5.create().update(str).digest().toHex(); }
804
+
805
+ // ###END###{Certificates}
806
+
807
+ // ###BEGIN###{!Certificates}
808
+
809
+ // TinyMD5 from https://github.com/jbt/js-crypto
810
+
811
+ // Perform MD5 setup
812
+ var md5_k = [];
813
+ for (var i = 0; i < 64;) { md5_k[i] = 0 | (Math.abs(Math.sin(++i)) * 4294967296); }
814
+
815
+ // Perform MD5 on raw string and return hex
816
+ function hex_md5(str) {
817
+ var b, c, d, j,
818
+ x = [],
819
+ str2 = unescape(encodeURI(str)),
820
+ a = str2.length,
821
+ h = [b = 1732584193, c = -271733879, ~b, ~c],
822
+ i = 0;
823
+
824
+ for (; i <= a;) x[i >> 2] |= (str2.charCodeAt(i) || 128) << 8 * (i++ % 4);
825
+
826
+ x[str = (a + 8 >> 6) * 16 + 14] = a * 8;
827
+ i = 0;
828
+
829
+ for (; i < str; i += 16) {
830
+ a = h; j = 0;
831
+ for (; j < 64;) {
832
+ a = [
833
+ d = a[3],
834
+ ((b = a[1] | 0) +
835
+ ((d = (
836
+ (a[0] +
837
+ [
838
+ b & (c = a[2]) | ~b & d,
839
+ d & b | ~d & c,
840
+ b ^ c ^ d,
841
+ c ^ (b | ~d)
842
+ ][a = j >> 4]
843
+ ) +
844
+ (md5_k[j] +
845
+ (x[[
846
+ j,
847
+ 5 * j + 1,
848
+ 3 * j + 5,
849
+ 7 * j
850
+ ][a] % 16 + i] | 0)
851
+ )
852
+ )) << (a = [
853
+ 7, 12, 17, 22,
854
+ 5, 9, 14, 20,
855
+ 4, 11, 16, 23,
856
+ 6, 10, 15, 21
857
+ ][4 * a + j++ % 4]) | d >>> 32 - a)
858
+ ),
859
+ b,
860
+ c
861
+ ];
862
+ }
863
+ for (j = 4; j;) h[--j] = h[j] + a[j];
864
+ }
865
+
866
+ str = '';
867
+ for (; j < 32;) str += ((h[j >> 3] >> ((1 ^ j++ & 7) * 4)) & 15).toString(16);
868
+ return str;
869
+ }
870
+
871
+ // ###END###{!Certificates}
872
+
873
+ // Perform MD5 on raw string and return raw string result
874
+ function rstr_md5(str) { return hex2rstr(hex_md5(str)); }
875
+ */
876
+ /*
877
+ Convert arguments into selector set and body XML. Used by AMT_WiFiPortConfigurationService_UpdateWiFiSettings.
878
+ args = {
879
+ "WiFiEndpoint": {
880
+ __parameterType: 'reference',
881
+ __resourceUri: 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpoint',
882
+ Name: 'WiFi Endpoint 0'
883
+ },
884
+ "WiFiEndpointSettingsInput":
885
+ {
886
+ __parameterType: 'instance',
887
+ __namespace: 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointSettings',
888
+ ElementName: document.querySelector('#editProfile-profileName').value,
889
+ InstanceID: 'Intel(r) AMT:WiFi Endpoint Settings ' + document.querySelector('#editProfile-profileName').value,
890
+ AuthenticationMethod: document.querySelector('#editProfile-networkAuthentication').value,
891
+ //BSSType: 3, // Intel(r) AMT supports only infrastructure networks
892
+ EncryptionMethod: document.querySelector('#editProfile-encryption').value,
893
+ SSID: document.querySelector('#editProfile-networkName').value,
894
+ Priority: 100,
895
+ PSKPassPhrase: document.querySelector('#editProfile-passPhrase').value
896
+ },
897
+ "IEEE8021xSettingsInput": null,
898
+ "ClientCredential": null,
899
+ "CACredential": null
900
+ },
901
+ */
902
+ function execArgumentsToXml(args) {
903
+ if (args === undefined || args === null) return null;
904
+
905
+ var result = '';
906
+ for (var argName in args) {
907
+ var arg = args[argName];
908
+ if (!arg) continue;
909
+ if (arg['__parameterType'] === 'reference') result += referenceToXml(argName, arg);
910
+ else result += instanceToXml(argName, arg);
911
+ //if(arg['__isInstance']) result += instanceToXml(argName, arg);
912
+ }
913
+ return result;
914
+ }
915
+
916
+ /**
917
+ * Convert JavaScript object into XML
918
+
919
+ <r:WiFiEndpointSettingsInput xmlns:q="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointSettings">
920
+ <q:ElementName>Wireless-Profile-Admin</q:ElementName>
921
+ <q:InstanceID>Intel(r) AMT:WiFi Endpoint Settings Wireless-Profile-Admin</q:InstanceID>
922
+ <q:AuthenticationMethod>6</q:AuthenticationMethod>
923
+ <q:EncryptionMethod>4</q:EncryptionMethod>
924
+ <q:Priority>100</q:Priority>
925
+ <q:PSKPassPhrase>P@ssw0rd</q:PSKPassPhrase>
926
+ </r:WiFiEndpointSettingsInput>
927
+ */
928
+ function instanceToXml(instanceName, inInstance) {
929
+ if (inInstance === undefined || inInstance === null) return null;
930
+
931
+ var hasNamespace = !!inInstance['__namespace'];
932
+ var startTag = hasNamespace ? '<q:' : '<';
933
+ var endTag = hasNamespace ? '</q:' : '</';
934
+ var namespaceDef = hasNamespace ? (' xmlns:q="' + inInstance['__namespace'] + '"') : '';
935
+ var result = '<r:' + instanceName + namespaceDef + '>';
936
+ for (var prop in inInstance) {
937
+ if (!inInstance.hasOwnProperty(prop) || prop.indexOf('__') === 0) continue;
938
+
939
+ if (typeof inInstance[prop] === 'function' || Array.isArray(inInstance[prop])) continue;
940
+
941
+ if (typeof inInstance[prop] === 'object') {
942
+ //result += startTag + prop +'>' + instanceToXml('prop', inInstance[prop]) + endTag + prop +'>';
943
+ console.error('only convert one level down...');
944
+ }
945
+ else {
946
+ result += startTag + prop + '>' + inInstance[prop].toString() + endTag + prop + '>';
947
+ }
948
+ }
949
+ result += '</r:' + instanceName + '>';
950
+ return result;
951
+ }
952
+
953
+
954
+ /**
955
+ * Convert a selector set into XML. Expect no nesting.
956
+ * {
957
+ * selectorName : selectorValue,
958
+ * selectorName : selectorValue,
959
+ * ... ...
960
+ * }
961
+
962
+ <r:WiFiEndpoint>
963
+ <a:Address>http://192.168.1.103:16992/wsman</a:Address>
964
+ <a:ReferenceParameters>
965
+ <w:ResourceURI>http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpoint</w:ResourceURI>
966
+ <w:SelectorSet>
967
+ <w:Selector Name="Name">WiFi Endpoint 0</w:Selector>
968
+ </w:SelectorSet>
969
+ </a:ReferenceParameters>
970
+ </r:WiFiEndpoint>
971
+
972
+ */
973
+ function referenceToXml(referenceName, inReference) {
974
+ if (inReference === undefined || inReference === null) return null;
975
+
976
+ var result = '<r:' + referenceName + '><a:Address>/wsman</a:Address><a:ReferenceParameters><w:ResourceURI>' + inReference['__resourceUri'] + '</w:ResourceURI><w:SelectorSet>';
977
+ for (var selectorName in inReference) {
978
+ if (!inReference.hasOwnProperty(selectorName) || selectorName.indexOf('__') === 0) continue;
979
+
980
+ if (typeof inReference[selectorName] === 'function' ||
981
+ typeof inReference[selectorName] === 'object' ||
982
+ Array.isArray(inReference[selectorName]))
983
+ continue;
984
+
985
+ result += '<w:Selector Name="' + selectorName + '">' + inReference[selectorName].toString() + '</w:Selector>';
986
+ }
987
+
988
+ result += '</w:SelectorSet></a:ReferenceParameters></r:' + referenceName + '>';
989
+ return result;
990
+ }
991
+
992
+ // Convert a byte array of SID into string
993
+ function GetSidString(sid) {
994
+ var r = "S-" + sid.charCodeAt(0) + "-" + sid.charCodeAt(7);
995
+ for (var i = 2; i < (sid.length / 4) ; i++) r += "-" + ReadIntX(sid, i * 4);
996
+ return r;
997
+ }
998
+
999
+ // Convert a SID readable string into bytes
1000
+ function GetSidByteArray(sidString) {
1001
+ if (!sidString || sidString == null) return null;
1002
+ var sidParts = sidString.split('-');
1003
+
1004
+ // Make sure the SID has at least 4 parts and starts with 'S'
1005
+ if (sidParts.length < 4 || (sidParts[0] != 's' && sidParts[0] != 'S')) return null;
1006
+
1007
+ // Check that each part of the SID is really an integer
1008
+ for (var i = 1; i < sidParts.length; i++) { var y = parseInt(sidParts[i]); if (y != sidParts[i]) return null; sidParts[i] = y; }
1009
+
1010
+ // 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.
1011
+ var r = String.fromCharCode(sidParts[1]) + String.fromCharCode(sidParts.length - 3) + ShortToStr(Math.floor(sidParts[2] / Math.pow(2, 32))) + IntToStr((sidParts[2]) & 0xFFFF);
1012
+
1013
+ // the rest are in 32 bit in little endian
1014
+ for (var i = 3; i < sidParts.length; i++) r += IntToStrX(sidParts[i]);
1015
+ return r;
1016
+ }
1017
+
1018
+ return obj;
1019
+}
1020
+module.exports = AmtStackCreateService;
\ No newline at end of file
apfserver.js
+1
-1
@@ -140,7 +140,7 @@ module.exports.CreateApfServer = function (parent, db, args) {
140
parent.debug('apf',"WS Extensions:"+socket.extensions);
141
parent.debug('apf',"WS Binary type:"+socket.binaryType);
142
143
- socket._socket.on('data', function(chunk) { console.log(chunk.toString('hex'))});
143
+ //socket._socket.on('data', function(chunk) { console.log(chunk.toString('hex'))});
144
145
// Setup the APF keep alive timer
146
// Websocket does not have timout