Updated to next generation MeshAgent.
Ylian Saint-Hilaire committed
Nov 28, 2019 at 12:27 UTC
4f4ca2c8bb83d22416f979cb4ff6dc4bcfc25691
16 files changed
+275
-68
MeshCentralServer.njsproj
+2
-2
@@ -34,9 +34,9 @@
34
<Compile Include="agents\modules_meshcmd\amt-wsman.js" />
35
<Compile Include="agents\modules_meshcmd\amt-xml.js" />
36
<Compile Include="agents\modules_meshcmd\amt.js" />
37
- <Compile Include="agents\modules_meshcmd\service-host.js" />
38
- <Compile Include="agents\modules_meshcmd\service-manager.js" />
37
+ <Compile Include="agents\modules_meshcmd\identifiers.js" />
38
<Compile Include="agents\modules_meshcmd\smbios.js" />
39
+ <Compile Include="agents\modules_meshcmd\sysinfo.js" />
40
<Compile Include="agents\modules_meshcmd\user-sessions.js" />
41
<Compile Include="agents\modules_meshcmd_min\amt-ider.min.js" />
42
<Compile Include="agents\modules_meshcmd_min\amt-lme.min.js" />
agents/MeshCmd-signed.exe
Binary files a/agents/MeshCmd-signed.exe and b/agents/MeshCmd-signed.exe differ
agents/MeshCmd64-signed.exe
Binary files a/agents/MeshCmd64-signed.exe and b/agents/MeshCmd64-signed.exe differ
agents/MeshService-signed.exe
Binary files a/agents/MeshService-signed.exe and b/agents/MeshService-signed.exe differ
agents/MeshService.exe
Binary files a/agents/MeshService.exe and b/agents/MeshService.exe differ
agents/MeshService64-signed.exe
Binary files a/agents/MeshService64-signed.exe and b/agents/MeshService64-signed.exe differ
agents/MeshService64.exe
Binary files a/agents/MeshService64.exe and b/agents/MeshService64.exe differ
agents/meshcore.js
+39
-25
@@ -361,9 +361,9 @@ function createMeshCore(agent) {
361
if (data != null) {
362
SMBiosTablesRaw = data;
363
SMBiosTables = require('smbios').parse(data)
364
- if (mesh.isControlChannelConnected) { mesh.SendCommand({ "action": "smbios", "value": SMBiosTablesRaw }); }
364
+ if (mesh.isControlChannelConnected) { mesh.SendCommand({ 'action': 'smbios', 'value': SMBiosTablesRaw }); }
365
366
- // If SMBios tables say that AMT is present, try to connect MEI
366
+ // If SMBios tables say that Intel AMT is present, try to connect MEI
367
if (SMBiosTables.amtInfo && (SMBiosTables.amtInfo.AMT == true)) {
368
var amtmodule = require('amt-manage');
369
amt = new amtmodule(mesh, db, true);
@@ -696,6 +696,30 @@ function createMeshCore(agent) {
696
} catch (e) { }
697
break;
698
}
699
+ case 'deskBackground': {
700
+ // Toggle desktop background
701
+ try {
702
+ if (process.platform == 'win32') {
703
+ var id = require('user-sessions').getProcessOwnerName(process.pid).tsid == 0 ? 1 : 0;
704
+ var child = require('child_process').execFile(process.execPath, [process.execPath.split('\\').pop(), '-b64exec', 'dmFyIFNQSV9HRVRERVNLV0FMTFBBUEVSID0gMHgwMDczOwp2YXIgU1BJX1NFVERFU0tXQUxMUEFQRVIgPSAweDAwMTQ7CnZhciBHTSA9IHJlcXVpcmUoJ19HZW5lcmljTWFyc2hhbCcpOwp2YXIgdXNlcjMyID0gR00uQ3JlYXRlTmF0aXZlUHJveHkoJ3VzZXIzMi5kbGwnKTsKdXNlcjMyLkNyZWF0ZU1ldGhvZCgnU3lzdGVtUGFyYW1ldGVyc0luZm9BJyk7CgppZiAocHJvY2Vzcy5hcmd2Lmxlbmd0aCA9PSAzKQp7CiAgICB2YXIgdiA9IEdNLkNyZWF0ZVZhcmlhYmxlKDEwMjQpOwogICAgdXNlcjMyLlN5c3RlbVBhcmFtZXRlcnNJbmZvQShTUElfR0VUREVTS1dBTExQQVBFUiwgdi5fc2l6ZSwgdiwgMCk7CiAgICBjb25zb2xlLmxvZyh2LlN0cmluZyk7CiAgICBwcm9jZXNzLmV4aXQoKTsKfQplbHNlCnsKICAgIHZhciBuYiA9IEdNLkNyZWF0ZVZhcmlhYmxlKHByb2Nlc3MuYXJndlszXSk7CiAgICB1c2VyMzIuU3lzdGVtUGFyYW1ldGVyc0luZm9BKFNQSV9TRVRERVNLV0FMTFBBUEVSLCBuYi5fc2l6ZSwgbmIsIDApOwogICAgcHJvY2Vzcy5leGl0KCk7Cn0='], { type: id });
705
+ child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
706
+ child.stderr.on('data', function () { });
707
+ child.waitExit();
708
+ var current = child.stdout.str.trim();
709
+ if (current != '') { require('MeshAgent')._wallpaper = current; }
710
+ child = require('child_process').execFile(process.execPath, [process.execPath.split('\\').pop(), '-b64exec', 'dmFyIFNQSV9HRVRERVNLV0FMTFBBUEVSID0gMHgwMDczOwp2YXIgU1BJX1NFVERFU0tXQUxMUEFQRVIgPSAweDAwMTQ7CnZhciBHTSA9IHJlcXVpcmUoJ19HZW5lcmljTWFyc2hhbCcpOwp2YXIgdXNlcjMyID0gR00uQ3JlYXRlTmF0aXZlUHJveHkoJ3VzZXIzMi5kbGwnKTsKdXNlcjMyLkNyZWF0ZU1ldGhvZCgnU3lzdGVtUGFyYW1ldGVyc0luZm9BJyk7CgppZiAocHJvY2Vzcy5hcmd2Lmxlbmd0aCA9PSAzKQp7CiAgICB2YXIgdiA9IEdNLkNyZWF0ZVZhcmlhYmxlKDEwMjQpOwogICAgdXNlcjMyLlN5c3RlbVBhcmFtZXRlcnNJbmZvQShTUElfR0VUREVTS1dBTExQQVBFUiwgdi5fc2l6ZSwgdiwgMCk7CiAgICBjb25zb2xlLmxvZyh2LlN0cmluZyk7CiAgICBwcm9jZXNzLmV4aXQoKTsKfQplbHNlCnsKICAgIHZhciBuYiA9IEdNLkNyZWF0ZVZhcmlhYmxlKHByb2Nlc3MuYXJndlszXSk7CiAgICB1c2VyMzIuU3lzdGVtUGFyYW1ldGVyc0luZm9BKFNQSV9TRVRERVNLV0FMTFBBUEVSLCBuYi5fc2l6ZSwgbmIsIDApOwogICAgcHJvY2Vzcy5leGl0KCk7Cn0=', current != '' ? '""' : require('MeshAgent')._wallpaper], { type: id });
711
+ child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
712
+ child.stderr.on('data', function () { });
713
+ child.waitExit();
714
+ } else {
715
+ var id = require('user-sessions').consoleUid();
716
+ var current = require('linux-gnome-helpers').getDesktopWallpaper(id);
717
+ if (current != '/dev/null') { require('MeshAgent')._wallpaper = current; }
718
+ require('linux-gnome-helpers').setDesktopWallpaper(id, current != '/dev/null' ? undefined : require('MeshAgent')._wallpaper);
719
+ }
720
+ } catch (e) { }
721
+ break;
722
+ }
723
case 'openUrl': {
724
// Open a local web browser and return success/fail
725
MeshServerLog('Opening: ' + data.url, data);
@@ -1087,19 +1111,18 @@ function createMeshCore(agent) {
1111
{
1112
if (((this.httprequest.protocol == 6) || (this.httprequest.protocol == 8)) && (require('win-terminal').PowerShellCapable() == true)) {
1113
//if (require('win-virtual-terminal').supported) {
1090
- //this.httprequest._term = require('win-virtual-terminal').StartPowerShell(80, 25);
1114
+ //this.httprequest._term = require('win-virtual-terminal').StartPowerShell(80, 25); // TODO: Start as logged in used when protocol is 8
1115
//} else {
1116
this.httprequest._term = require('win-terminal').StartPowerShell(80, 25); // TODO: Start as logged in used when protocol is 8
1117
//}
1118
} else {
1119
//if (require('win-virtual-terminal').supported) {
1096
- //this.httprequest._term = require('win-virtual-terminal').Start(80, 25);
1120
+ //this.httprequest._term = require('win-virtual-terminal').Start(80, 25); // TODO: Start as logged in used when protocol is 8
1121
//} else {
1098
- this.httprequest._term = require('win-terminal').Start(80, 25); // TODO: Start as logged in used when protocol is 7
1122
+ this.httprequest._term = require('win-terminal').Start(80, 25); // TODO: Start as logged in used when protocol is 8
1123
//}
1124
}
1101
- } catch (e)
1102
- {
1125
+ } catch (e) {
1126
MeshServerLog('Failed to start remote terminal session, ' + e.toString() + ' (' + this.httprequest.remoteaddr + ')', this.httprequest);
1127
this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString() }));
1128
this.end();
@@ -1123,8 +1146,7 @@ function createMeshCore(agent) {
1146
this.httprequest.process = childProcess.execFile('/bin/sh', ['sh'], { type: childProcess.SpawnTypes.TERM, uid: (this.httprequest.protocol == 8)?require('user-sessions').consoleUid():null }); // Start as active user
1147
if (process.platform == 'linux') { this.httprequest.process.stdin.write("stty erase ^H\nalias ls='ls --color=auto'\nPS1='\\u@\\h:\\w\\$ '\nclear\n"); }
1148
}
1126
- } catch (e)
1127
- {
1149
+ } catch (e) {
1150
MeshServerLog("Failed to start remote terminal session, " + e.toString() + ' (' + this.httprequest.remoteaddr + ')', this.httprequest);
1151
this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString() }));
1152
this.end();
@@ -1802,7 +1824,7 @@ function createMeshCore(agent) {
1824
var response = null;
1825
switch (cmd) {
1826
case 'help': { // Displays available commands
1805
- var fin = '', f = '', availcommands = 'help,info,osinfo,args,print,type,dbkeys,dbget,dbset,dbcompact,eval,parseuri,httpget,nwslist,plugin,wsconnect,wssend,wsclose,notify,ls,ps,kill,amt,netinfo,location,power,wakeonlan,setdebug,smbios,rawsmbios,toast,lock,users,sendcaps,openurl,amtreset,amtccm,amtacm,amtdeactivate,amtpolicy,getscript,getclip,setclip,log,av,cpuinfo,sysinfo,apf,scanwifi,scanamt';
1827
+ var fin = '', f = '', availcommands = 'help,info,osinfo,args,print,type,dbkeys,dbget,dbset,dbcompact,eval,parseuri,httpget,nwslist,plugin,wsconnect,wssend,wsclose,notify,ls,ps,kill,amt,netinfo,location,power,wakeonlan,setdebug,smbios,rawsmbios,toast,lock,users,sendcaps,openurl,amtreset,amtccm,amtacm,amtdeactivate,amtpolicy,getscript,getclip,setclip,log,av,cpuinfo,sysinfo,apf,scanwifi,scanamt,safemode,wallpaper';
1828
availcommands = availcommands.split(',').sort();
1829
while (availcommands.length > 0) {
1830
if (f.length > 100) { fin += (f + ',\r\n'); f = ''; }
@@ -1840,18 +1862,14 @@ function createMeshCore(agent) {
1862
child.stderr.on('data', function () { });
1863
child.waitExit();
1864
var current = child.stdout.str.trim();
1843
- if (args['_'][0].toUpperCase() == 'GET')
1844
- {
1865
+ if (args['_'][0].toUpperCase() == 'GET') {
1866
response = current;
1867
break;
1868
}
1848
- if (current != '')
1849
- {
1869
+ if (current != '') {
1870
require('MeshAgent')._wallpaper = current;
1871
response = 'Wallpaper cleared';
1852
- }
1853
- else
1854
- {
1872
+ } else {
1873
response = 'Wallpaper restored';
1874
}
1875
child = require('child_process').execFile(process.execPath, [process.execPath.split('\\').pop(), '-b64exec', 'dmFyIFNQSV9HRVRERVNLV0FMTFBBUEVSID0gMHgwMDczOwp2YXIgU1BJX1NFVERFU0tXQUxMUEFQRVIgPSAweDAwMTQ7CnZhciBHTSA9IHJlcXVpcmUoJ19HZW5lcmljTWFyc2hhbCcpOwp2YXIgdXNlcjMyID0gR00uQ3JlYXRlTmF0aXZlUHJveHkoJ3VzZXIzMi5kbGwnKTsKdXNlcjMyLkNyZWF0ZU1ldGhvZCgnU3lzdGVtUGFyYW1ldGVyc0luZm9BJyk7CgppZiAocHJvY2Vzcy5hcmd2Lmxlbmd0aCA9PSAzKQp7CiAgICB2YXIgdiA9IEdNLkNyZWF0ZVZhcmlhYmxlKDEwMjQpOwogICAgdXNlcjMyLlN5c3RlbVBhcmFtZXRlcnNJbmZvQShTUElfR0VUREVTS1dBTExQQVBFUiwgdi5fc2l6ZSwgdiwgMCk7CiAgICBjb25zb2xlLmxvZyh2LlN0cmluZyk7CiAgICBwcm9jZXNzLmV4aXQoKTsKfQplbHNlCnsKICAgIHZhciBuYiA9IEdNLkNyZWF0ZVZhcmlhYmxlKHByb2Nlc3MuYXJndlszXSk7CiAgICB1c2VyMzIuU3lzdGVtUGFyYW1ldGVyc0luZm9BKFNQSV9TRVRERVNLV0FMTFBBUEVSLCBuYi5fc2l6ZSwgbmIsIDApOwogICAgcHJvY2Vzcy5leGl0KCk7Cn0=', current != '' ? '""' : require('MeshAgent')._wallpaper], { type: id });
@@ -1863,18 +1881,14 @@ function createMeshCore(agent) {
1881
{
1882
var id = require('user-sessions').consoleUid();
1883
var current = require('linux-gnome-helpers').getDesktopWallpaper(id);
1866
- if (args['_'][0].toUpperCase() == 'GET')
1867
- {
1884
+ if (args['_'][0].toUpperCase() == 'GET') {
1885
response = current;
1886
break;
1887
}
1871
- if (current != '/dev/null')
1872
- {
1888
+ if (current != '/dev/null') {
1889
require('MeshAgent')._wallpaper = current;
1890
response = 'Wallpaper cleared';
1875
- }
1876
- else
1877
- {
1891
+ } else {
1892
response = 'Wallpaper restored';
1893
}
1894
require('linux-gnome-helpers').setDesktopWallpaper(id, current != '/dev/null' ? undefined : require('MeshAgent')._wallpaper);
@@ -1924,7 +1938,7 @@ function createMeshCore(agent) {
1938
break;
1939
}
1940
}
1927
- response = 'Current: ' + require('win-bcd').bootMode + ' , NextBoot: ' + (nextboot ? nextboot : 'NORMAL');
1941
+ response = 'Current: ' + require('win-bcd').bootMode + ', NextBoot: ' + (nextboot ? nextboot : 'NORMAL');
1942
break;
1943
}
1944
}
agents/meshcore.min.js
+39
-25
@@ -361,9 +361,9 @@ function createMeshCore(agent) {
361
if (data != null) {
362
SMBiosTablesRaw = data;
363
SMBiosTables = require('smbios').parse(data)
364
- if (mesh.isControlChannelConnected) { mesh.SendCommand({ "action": "smbios", "value": SMBiosTablesRaw }); }
364
+ if (mesh.isControlChannelConnected) { mesh.SendCommand({ 'action': 'smbios', 'value': SMBiosTablesRaw }); }
365
366
- // If SMBios tables say that AMT is present, try to connect MEI
366
+ // If SMBios tables say that Intel AMT is present, try to connect MEI
367
if (SMBiosTables.amtInfo && (SMBiosTables.amtInfo.AMT == true)) {
368
var amtmodule = require('amt-manage');
369
amt = new amtmodule(mesh, db, true);
@@ -696,6 +696,30 @@ function createMeshCore(agent) {
696
} catch (e) { }
697
break;
698
}
699
+ case 'deskBackground': {
700
+ // Toggle desktop background
701
+ try {
702
+ if (process.platform == 'win32') {
703
+ var id = require('user-sessions').getProcessOwnerName(process.pid).tsid == 0 ? 1 : 0;
704
+ var child = require('child_process').execFile(process.execPath, [process.execPath.split('\\').pop(), '-b64exec', 'dmFyIFNQSV9HRVRERVNLV0FMTFBBUEVSID0gMHgwMDczOwp2YXIgU1BJX1NFVERFU0tXQUxMUEFQRVIgPSAweDAwMTQ7CnZhciBHTSA9IHJlcXVpcmUoJ19HZW5lcmljTWFyc2hhbCcpOwp2YXIgdXNlcjMyID0gR00uQ3JlYXRlTmF0aXZlUHJveHkoJ3VzZXIzMi5kbGwnKTsKdXNlcjMyLkNyZWF0ZU1ldGhvZCgnU3lzdGVtUGFyYW1ldGVyc0luZm9BJyk7CgppZiAocHJvY2Vzcy5hcmd2Lmxlbmd0aCA9PSAzKQp7CiAgICB2YXIgdiA9IEdNLkNyZWF0ZVZhcmlhYmxlKDEwMjQpOwogICAgdXNlcjMyLlN5c3RlbVBhcmFtZXRlcnNJbmZvQShTUElfR0VUREVTS1dBTExQQVBFUiwgdi5fc2l6ZSwgdiwgMCk7CiAgICBjb25zb2xlLmxvZyh2LlN0cmluZyk7CiAgICBwcm9jZXNzLmV4aXQoKTsKfQplbHNlCnsKICAgIHZhciBuYiA9IEdNLkNyZWF0ZVZhcmlhYmxlKHByb2Nlc3MuYXJndlszXSk7CiAgICB1c2VyMzIuU3lzdGVtUGFyYW1ldGVyc0luZm9BKFNQSV9TRVRERVNLV0FMTFBBUEVSLCBuYi5fc2l6ZSwgbmIsIDApOwogICAgcHJvY2Vzcy5leGl0KCk7Cn0='], { type: id });
705
+ child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
706
+ child.stderr.on('data', function () { });
707
+ child.waitExit();
708
+ var current = child.stdout.str.trim();
709
+ if (current != '') { require('MeshAgent')._wallpaper = current; }
710
+ child = require('child_process').execFile(process.execPath, [process.execPath.split('\\').pop(), '-b64exec', 'dmFyIFNQSV9HRVRERVNLV0FMTFBBUEVSID0gMHgwMDczOwp2YXIgU1BJX1NFVERFU0tXQUxMUEFQRVIgPSAweDAwMTQ7CnZhciBHTSA9IHJlcXVpcmUoJ19HZW5lcmljTWFyc2hhbCcpOwp2YXIgdXNlcjMyID0gR00uQ3JlYXRlTmF0aXZlUHJveHkoJ3VzZXIzMi5kbGwnKTsKdXNlcjMyLkNyZWF0ZU1ldGhvZCgnU3lzdGVtUGFyYW1ldGVyc0luZm9BJyk7CgppZiAocHJvY2Vzcy5hcmd2Lmxlbmd0aCA9PSAzKQp7CiAgICB2YXIgdiA9IEdNLkNyZWF0ZVZhcmlhYmxlKDEwMjQpOwogICAgdXNlcjMyLlN5c3RlbVBhcmFtZXRlcnNJbmZvQShTUElfR0VUREVTS1dBTExQQVBFUiwgdi5fc2l6ZSwgdiwgMCk7CiAgICBjb25zb2xlLmxvZyh2LlN0cmluZyk7CiAgICBwcm9jZXNzLmV4aXQoKTsKfQplbHNlCnsKICAgIHZhciBuYiA9IEdNLkNyZWF0ZVZhcmlhYmxlKHByb2Nlc3MuYXJndlszXSk7CiAgICB1c2VyMzIuU3lzdGVtUGFyYW1ldGVyc0luZm9BKFNQSV9TRVRERVNLV0FMTFBBUEVSLCBuYi5fc2l6ZSwgbmIsIDApOwogICAgcHJvY2Vzcy5leGl0KCk7Cn0=', current != '' ? '""' : require('MeshAgent')._wallpaper], { type: id });
711
+ child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
712
+ child.stderr.on('data', function () { });
713
+ child.waitExit();
714
+ } else {
715
+ var id = require('user-sessions').consoleUid();
716
+ var current = require('linux-gnome-helpers').getDesktopWallpaper(id);
717
+ if (current != '/dev/null') { require('MeshAgent')._wallpaper = current; }
718
+ require('linux-gnome-helpers').setDesktopWallpaper(id, current != '/dev/null' ? undefined : require('MeshAgent')._wallpaper);
719
+ }
720
+ } catch (e) { }
721
+ break;
722
+ }
723
case 'openUrl': {
724
// Open a local web browser and return success/fail
725
MeshServerLog('Opening: ' + data.url, data);
@@ -1087,19 +1111,18 @@ function createMeshCore(agent) {
1111
{
1112
if (((this.httprequest.protocol == 6) || (this.httprequest.protocol == 8)) && (require('win-terminal').PowerShellCapable() == true)) {
1113
//if (require('win-virtual-terminal').supported) {
1090
- //this.httprequest._term = require('win-virtual-terminal').StartPowerShell(80, 25);
1114
+ //this.httprequest._term = require('win-virtual-terminal').StartPowerShell(80, 25); // TODO: Start as logged in used when protocol is 8
1115
//} else {
1116
this.httprequest._term = require('win-terminal').StartPowerShell(80, 25); // TODO: Start as logged in used when protocol is 8
1117
//}
1118
} else {
1119
//if (require('win-virtual-terminal').supported) {
1096
- //this.httprequest._term = require('win-virtual-terminal').Start(80, 25);
1120
+ //this.httprequest._term = require('win-virtual-terminal').Start(80, 25); // TODO: Start as logged in used when protocol is 8
1121
//} else {
1098
- this.httprequest._term = require('win-terminal').Start(80, 25); // TODO: Start as logged in used when protocol is 7
1122
+ this.httprequest._term = require('win-terminal').Start(80, 25); // TODO: Start as logged in used when protocol is 8
1123
//}
1124
}
1101
- } catch (e)
1102
- {
1125
+ } catch (e) {
1126
MeshServerLog('Failed to start remote terminal session, ' + e.toString() + ' (' + this.httprequest.remoteaddr + ')', this.httprequest);
1127
this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString() }));
1128
this.end();
@@ -1123,8 +1146,7 @@ function createMeshCore(agent) {
1146
this.httprequest.process = childProcess.execFile('/bin/sh', ['sh'], { type: childProcess.SpawnTypes.TERM, uid: (this.httprequest.protocol == 8)?require('user-sessions').consoleUid():null }); // Start as active user
1147
if (process.platform == 'linux') { this.httprequest.process.stdin.write("stty erase ^H\nalias ls='ls --color=auto'\nPS1='\\u@\\h:\\w\\$ '\nclear\n"); }
1148
}
1126
- } catch (e)
1127
- {
1149
+ } catch (e) {
1150
MeshServerLog("Failed to start remote terminal session, " + e.toString() + ' (' + this.httprequest.remoteaddr + ')', this.httprequest);
1151
this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString() }));
1152
this.end();
@@ -1802,7 +1824,7 @@ function createMeshCore(agent) {
1824
var response = null;
1825
switch (cmd) {
1826
case 'help': { // Displays available commands
1805
- var fin = '', f = '', availcommands = 'help,info,osinfo,args,print,type,dbkeys,dbget,dbset,dbcompact,eval,parseuri,httpget,nwslist,plugin,wsconnect,wssend,wsclose,notify,ls,ps,kill,amt,netinfo,location,power,wakeonlan,setdebug,smbios,rawsmbios,toast,lock,users,sendcaps,openurl,amtreset,amtccm,amtacm,amtdeactivate,amtpolicy,getscript,getclip,setclip,log,av,cpuinfo,sysinfo,apf,scanwifi,scanamt';
1827
+ var fin = '', f = '', availcommands = 'help,info,osinfo,args,print,type,dbkeys,dbget,dbset,dbcompact,eval,parseuri,httpget,nwslist,plugin,wsconnect,wssend,wsclose,notify,ls,ps,kill,amt,netinfo,location,power,wakeonlan,setdebug,smbios,rawsmbios,toast,lock,users,sendcaps,openurl,amtreset,amtccm,amtacm,amtdeactivate,amtpolicy,getscript,getclip,setclip,log,av,cpuinfo,sysinfo,apf,scanwifi,scanamt,safemode,wallpaper';
1828
availcommands = availcommands.split(',').sort();
1829
while (availcommands.length > 0) {
1830
if (f.length > 100) { fin += (f + ',\r\n'); f = ''; }
@@ -1840,18 +1862,14 @@ function createMeshCore(agent) {
1862
child.stderr.on('data', function () { });
1863
child.waitExit();
1864
var current = child.stdout.str.trim();
1843
- if (args['_'][0].toUpperCase() == 'GET')
1844
- {
1865
+ if (args['_'][0].toUpperCase() == 'GET') {
1866
response = current;
1867
break;
1868
}
1848
- if (current != '')
1849
- {
1869
+ if (current != '') {
1870
require('MeshAgent')._wallpaper = current;
1871
response = 'Wallpaper cleared';
1852
- }
1853
- else
1854
- {
1872
+ } else {
1873
response = 'Wallpaper restored';
1874
}
1875
child = require('child_process').execFile(process.execPath, [process.execPath.split('\\').pop(), '-b64exec', 'dmFyIFNQSV9HRVRERVNLV0FMTFBBUEVSID0gMHgwMDczOwp2YXIgU1BJX1NFVERFU0tXQUxMUEFQRVIgPSAweDAwMTQ7CnZhciBHTSA9IHJlcXVpcmUoJ19HZW5lcmljTWFyc2hhbCcpOwp2YXIgdXNlcjMyID0gR00uQ3JlYXRlTmF0aXZlUHJveHkoJ3VzZXIzMi5kbGwnKTsKdXNlcjMyLkNyZWF0ZU1ldGhvZCgnU3lzdGVtUGFyYW1ldGVyc0luZm9BJyk7CgppZiAocHJvY2Vzcy5hcmd2Lmxlbmd0aCA9PSAzKQp7CiAgICB2YXIgdiA9IEdNLkNyZWF0ZVZhcmlhYmxlKDEwMjQpOwogICAgdXNlcjMyLlN5c3RlbVBhcmFtZXRlcnNJbmZvQShTUElfR0VUREVTS1dBTExQQVBFUiwgdi5fc2l6ZSwgdiwgMCk7CiAgICBjb25zb2xlLmxvZyh2LlN0cmluZyk7CiAgICBwcm9jZXNzLmV4aXQoKTsKfQplbHNlCnsKICAgIHZhciBuYiA9IEdNLkNyZWF0ZVZhcmlhYmxlKHByb2Nlc3MuYXJndlszXSk7CiAgICB1c2VyMzIuU3lzdGVtUGFyYW1ldGVyc0luZm9BKFNQSV9TRVRERVNLV0FMTFBBUEVSLCBuYi5fc2l6ZSwgbmIsIDApOwogICAgcHJvY2Vzcy5leGl0KCk7Cn0=', current != '' ? '""' : require('MeshAgent')._wallpaper], { type: id });
@@ -1863,18 +1881,14 @@ function createMeshCore(agent) {
1881
{
1882
var id = require('user-sessions').consoleUid();
1883
var current = require('linux-gnome-helpers').getDesktopWallpaper(id);
1866
- if (args['_'][0].toUpperCase() == 'GET')
1867
- {
1884
+ if (args['_'][0].toUpperCase() == 'GET') {
1885
response = current;
1886
break;
1887
}
1871
- if (current != '/dev/null')
1872
- {
1888
+ if (current != '/dev/null') {
1889
require('MeshAgent')._wallpaper = current;
1890
response = 'Wallpaper cleared';
1875
- }
1876
- else
1877
- {
1891
+ } else {
1892
response = 'Wallpaper restored';
1893
}
1894
require('linux-gnome-helpers').setDesktopWallpaper(id, current != '/dev/null' ? undefined : require('MeshAgent')._wallpaper);
@@ -1924,7 +1938,7 @@ function createMeshCore(agent) {
1938
break;
1939
}
1940
}
1927
- response = 'Current: ' + require('win-bcd').bootMode + ' , NextBoot: ' + (nextboot ? nextboot : 'NORMAL');
1941
+ response = 'Current: ' + require('win-bcd').bootMode + ', NextBoot: ' + (nextboot ? nextboot : 'NORMAL');
1942
break;
1943
}
1944
}
agents/modules_meshcore/amt-manage.js
+7
-8
@@ -25,7 +25,7 @@ limitations under the License.
25
* @constructor
26
*/
27
function AmtManager(agent, db, isdebug) {
28
- var sendConsole = function (msg) { agent.SendCommand({ "action": "msg", "type": "console", "value": msg }); }
28
+ var sendConsole = function (msg) { agent.SendCommand({ 'action': 'msg', 'type': 'console', 'value': msg }); }
29
var debug = function (msg) { if (isdebug) { sendConsole('amt-manager: ' + msg + '<br />'); } }
30
var amtMei = null, amtMeiState = 0;
31
var amtLms = null, amtLmsState = 0;
@@ -75,7 +75,7 @@ function AmtManager(agent, db, isdebug) {
75
obj.lmsreset();
76
}
77
});
78
- } catch (ex) { debug('MEI exception: ' + ex); amtMei = null; amtMeiState = -1; obj.state = -1; }
78
+ } catch (ex) { debug("MEI exception: " + ex); amtMei = null; amtMeiState = -1; obj.state = -1; }
79
}
80
81
// Get Intel AMT information using MEI
@@ -104,27 +104,26 @@ function AmtManager(agent, db, isdebug) {
104
var amtMessage = notifyMsg.Body.MessageID, amtMessageArg = notifyMsg.Body.MessageArguments[0], notify = null;
105
106
switch (amtMessage) {
107
- case 'iAMT0050': { if (amtMessageArg == '48') { notify = 'Intel® AMT Serial-over-LAN connected'; } else if (amtMessageArg == '49') { notify = 'Intel® AMT Serial-over-LAN disconnected'; } break; } // SOL
108
- case 'iAMT0052': { if (amtMessageArg == '1') { notify = 'Intel® AMT KVM connected'; } else if (amtMessageArg == '2') { notify = 'Intel® AMT KVM disconnected'; } break; } // KVM
107
+ case 'iAMT0050': { if (amtMessageArg == '48') { notify = "Intel® AMT Serial-over-LAN connected"; } else if (amtMessageArg == '49') { notify = "Intel® AMT Serial-over-LAN disconnected"; } break; } // SOL
108
+ case 'iAMT0052': { if (amtMessageArg == '1') { notify = "Intel® AMT KVM connected"; } else if (amtMessageArg == '2') { notify = "Intel® AMT KVM disconnected"; } break; } // KVM
109
default: { break; }
110
}
111
112
// Sent to the entire group, no sessionid or userid specified.
113
- if (notify != null) { agent.SendCommand({ "action": "msg", "type": "notify", "value": notify, "tag": "general", "amtMessage": amtMessage }); }
113
+ if (notify != null) { agent.SendCommand({ 'action': 'msg', 'type': 'notify', 'value': notify, 'tag': 'general', 'amtMessage': amtMessage }); }
114
}
115
116
// Launch LMS
117
obj.lmsreset = function () {
118
//debug('Binding to LMS');
119
- var amtLms = null, amtLmsState = 0;
119
obj.lmsstate = 0;
120
try {
121
var lme_heci = require('amt-lme');
122
amtLmsState = 1;
123
obj.lmsstate = 1;
124
amtLms = new lme_heci();
126
- amtLms.on('error', function (e) { amtLmsState = 0; obj.lmsstate = 0; amtLms = null; debug('LMS error'); setupMeiOsAdmin(1); });
127
- amtLms.on('connect', function () { amtLmsState = 2; obj.lmsstate = 2; debug('LMS connected'); setupMeiOsAdmin(2); });
125
+ amtLms.on('error', function (e) { amtLmsState = 0; obj.lmsstate = 0; amtLms = null; debug("LMS error: " + e); setupMeiOsAdmin(1); });
126
+ amtLms.on('connect', function () { amtLmsState = 2; obj.lmsstate = 2; debug("LMS connected"); setupMeiOsAdmin(2); });
127
//amtLms.on('bind', function (map) { });
128
amtLms.on('notify', function (data, options, str, code) {
129
//debug('LMS notify');
agents/modules_meshcore/win-virtual-terminal.js
new
+172
@@ -0,0 +1,172 @@
1
+/*
2
+Copyright 2019 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
+var PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE = 0x00020016;
18
+var EXTENDED_STARTUPINFO_PRESENT = 0x00080000;
19
+var HEAP_ZERO_MEMORY = 0x00000008;
20
+
21
+var duplex = require('stream').Duplex;
22
+
23
+function vt()
24
+{
25
+ this._ObjectID = 'win-virtual-terminal';
26
+ Object.defineProperty(this, 'supported', {
27
+ value: (function ()
28
+ {
29
+ var gm = require('_GenericMarshal');
30
+ var k32 = gm.CreateNativeProxy('kernel32.dll');
31
+ try
32
+ {
33
+ k32.CreateMethod('CreatePseudoConsole');
34
+ }
35
+ catch(e)
36
+ {
37
+ return (false);
38
+ }
39
+ return (true);
40
+ })()
41
+ });
42
+ this.Create = function Create(path, width, height)
43
+ {
44
+ if (!this.supported) { throw ('This build of Windows does not have support for PseudoConsoles'); }
45
+ if (!width) { width = 80; }
46
+ if (!height) { height = 25; }
47
+
48
+ var GM = require('_GenericMarshal');
49
+ var k32 = GM.CreateNativeProxy('kernel32.dll');
50
+ k32.CreateMethod('CreatePipe');
51
+ k32.CreateMethod('CreateProcessW');
52
+ k32.CreateMethod('CreatePseudoConsole');
53
+ k32.CreateMethod('GetProcessHeap');
54
+ k32.CreateMethod('HeapAlloc');
55
+ k32.CreateMethod('InitializeProcThreadAttributeList');
56
+ k32.CreateMethod('UpdateProcThreadAttribute');
57
+ k32.CreateMethod('WriteFile');
58
+ k32.CreateMethod('ReadFile');
59
+ k32.CreateMethod('TerminateProcess');
60
+
61
+ var ret = { _h: GM.CreatePointer(), _consoleInput: GM.CreatePointer(), _consoleOutput: GM.CreatePointer(), _input: GM.CreatePointer(), _output: GM.CreatePointer(), k32: k32 };
62
+ var attrSize = GM.CreateVariable(8);
63
+ var attrList;
64
+ var pi = GM.CreateVariable(GM.PointerSize == 4 ? 16 : 24);
65
+
66
+ // Create the necessary pipes
67
+ if (k32.CreatePipe(ret._consoleInput, ret._input, 0, 0).Val == 0) { console.log('PIPE/FAIL'); }
68
+ if (k32.CreatePipe(ret._output, ret._consoleOutput, 0, 0).Val == 0) { console.log('PIPE/FAIL'); }
69
+
70
+
71
+ if (k32.CreatePseudoConsole((height << 16) | width, ret._consoleInput.Deref(), ret._consoleOutput.Deref(), 0, ret._h).Val != 0)
72
+ {
73
+ throw ('Error calling CreatePseudoConsole()');
74
+ }
75
+
76
+ k32.InitializeProcThreadAttributeList(0, 1, 0, attrSize);
77
+ attrList = GM.CreateVariable(attrSize.toBuffer().readUInt32LE());
78
+ var startupinfoex = GM.CreateVariable(GM.PointerSize == 8 ? 112 : 72);
79
+ startupinfoex.toBuffer().writeUInt32LE(GM.PointerSize == 8 ? 112 : 72, 0);
80
+ attrList.pointerBuffer().copy(startupinfoex.Deref(GM.PointerSize == 8 ? 104 : 68, GM.PointerSize).toBuffer());
81
+
82
+ if (k32.InitializeProcThreadAttributeList(attrList, 1, 0, attrSize).Val != 0)
83
+ {
84
+ if (k32.UpdateProcThreadAttribute(attrList, 0, PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE, ret._h.Deref(), GM.PointerSize, 0, 0).Val != 0)
85
+ {
86
+ if (k32.CreateProcessW(0, GM.CreateVariable(path, { wide: true }), 0, 0, 1, EXTENDED_STARTUPINFO_PRESENT, 0, 0, startupinfoex, pi).Val != 0)
87
+ {
88
+ ret._startupinfoex = startupinfoex;
89
+ ret._process = pi.Deref(0);
90
+ ret._pid = pi.Deref(GM.PointerSize == 4 ? 8 : 16, 4).toBuffer().readUInt32LE();
91
+ var ds = new duplex(
92
+ {
93
+ 'write': function (chunk, flush)
94
+ {
95
+ var written = require('_GenericMarshal').CreateVariable(4);
96
+ this.terminal.k32.WriteFile(this.terminal._input.Deref(), require('_GenericMarshal').CreateVariable(chunk), chunk.length, written, 0);
97
+ flush();
98
+ return (true);
99
+ },
100
+ 'final': function (flush)
101
+ {
102
+ if (this.terminal._process)
103
+ {
104
+ this.terminal.k32.TerminateProcess(this.terminal._process, 0);
105
+ this.terminal._process = null;
106
+ this.terminal.k32.ReadFile.async.abort();
107
+ }
108
+ flush();
109
+ }
110
+ });
111
+ ret._waiter = require('DescriptorEvents').addDescriptor(pi.Deref(0));
112
+ ret._waiter.ds = ds;
113
+ ret._waiter.on('signaled', function () { this.ds.push(null); });
114
+
115
+ ds.terminal = ret;
116
+ ds._rpbuf = GM.CreateVariable(4096);
117
+ ds._rpbufRead = GM.CreateVariable(4);
118
+ ds._read = function _read()
119
+ {
120
+ this._rp = this.terminal.k32.ReadFile.async(this.terminal._output.Deref(), this._rpbuf, this._rpbuf._size, this._rpbufRead, 0);
121
+ this._rp.then(function ()
122
+ {
123
+ var len = this.parent._rpbufRead.toBuffer().readUInt32LE();
124
+ this.parent.push(this.parent._rpbuf.toBuffer().slice(0, len));
125
+ this.parent._read();
126
+ });
127
+ this._rp.parent = this;
128
+ };
129
+ ds._read();
130
+ return (ds);
131
+ }
132
+ else
133
+ {
134
+ console.log('FAILED!');
135
+ }
136
+ }
137
+
138
+ }
139
+ throw ('Internal Error');
140
+ }
141
+ this.PowerShellCapable = function ()
142
+ {
143
+ if (require('os').arch() == 'x64')
144
+ {
145
+ return (require('fs').existsSync(process.env['windir'] + '\\SysWow64\\WindowsPowerShell\\v1.0\\powershell.exe'));
146
+ }
147
+ else
148
+ {
149
+ return (require('fs').existsSync(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe'));
150
+ }
151
+ }
152
+ this.Start = function Start(CONSOLE_SCREEN_WIDTH, CONSOLE_SCREEN_HEIGHT)
153
+ {
154
+ return (this.Create(process.env['windir'] + '\\System32\\cmd.exe', CONSOLE_SCREEN_WIDTH, CONSOLE_SCREEN_HEIGHT));
155
+ }
156
+ this.StartPowerShell = function StartPowerShell(CONSOLE_SCREEN_WIDTH, CONSOLE_SCREEN_HEIGHT)
157
+ {
158
+ if (require('os').arch() == 'x64')
159
+ {
160
+ return (this.Create(process.env['windir'] + '\\SysWow64\\WindowsPowerShell\\v1.0\\powershell.exe', CONSOLE_SCREEN_WIDTH, CONSOLE_SCREEN_HEIGHT));
161
+ }
162
+ else
163
+ {
164
+ return (this.Create(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', CONSOLE_SCREEN_WIDTH, CONSOLE_SCREEN_HEIGHT));
165
+ }
166
+ }
167
+}
168
+
169
+if (process.platform == 'win32')
170
+{
171
+ module.exports = new vt();
172
+}
\ No newline at end of file
agents/modules_meshcore_min/amt-manage.min.js
+1
-1
@@ -1 +1 @@
1
-function AmtManager(d,q,v){var M=function(T){d.SendCommand({action:"msg",type:"console",value:T})};var r=function(T){if(v){M("amt-manager: "+T+"<br />")}};var h=null,i=0;var f=null,g=0;var e=null;var H=null;var G=null;var k=null;var F=this;var E;var O=null;F.state=0;F.lmsstate=0;F.onStateChange=null;F.setDebug=function(T){v=T};F.setPolicy=function(U,T){if(T||(JSON.stringify(k)!=JSON.stringify(U))){k=U;if(m==null){m=setTimeout(F.applyPolicy,8000)}}};var L=0;F.reset=function(){++L;h=null,i=0,f=null,g=0,F.state=0,F.lmsstate=0;try{var T=require("amt-mei");h=new T();h.on("error",function(V){r("MEI error");h=null;i=-1;F.state=-1;if(F.onStateChange!=null){F.onStateChange(i)}});h.getVersion(function(V){if(V==null){i=-1;F.state=-1;if(F.onStateChange!=null){F.onStateChange(i)}if(L<10){setTimeout(F.reset,10000)}}else{e=V;i=2;F.state=2;L=0;if(F.onStateChange!=null){F.onStateChange(i)}F.lmsreset()}})}catch(U){r("MEI exception: "+U);h=null;i=-1;F.state=-1}};var j=null;F.getAmtInfo=function(U){if((h==null)||(i<2)){if(U!=null){U(null)}return}try{j={Flags:0};h.getProtocolVersion(function(V){if(V!=null){j.MeiVersion=V}});h.getVersion(function(V){if(V){j.Versions={};for(var W in V.Versions){j.Versions[V.Versions[W].Description]=V.Versions[W].Version}}});h.getProvisioningMode(function(V){if(V){j.ProvisioningMode=V.mode}});h.getProvisioningState(function(V){if(V){j.ProvisioningState=V.state}});h.getEHBCState(function(V){if((V!=null)&&(V.EHBC==true)){j.Flags+=1}});h.getControlMode(function(V){if(V!=null){if(V.controlMode==1){j.Flags+=2}if(V.controlMode==2){j.Flags+=4}}});h.getLanInterfaceSettings(0,function(V){if(V){j.net0=V}});h.getLanInterfaceSettings(1,function(V){if(V){j.net1=V}});h.getUuid(function(V){if((V!=null)&&(V.uuid!=null)){j.UUID=V.uuid}});h.getDnsSuffix(function(V){if(V!=null){j.DNS=V}if(U!=null){U(j)}})}catch(T){if(U!=null){U(null)}return}};var t=function(W){if((W==null)||(W.Body==null)||(W.Body.MessageID==null)||(W.Body.MessageArguments==null)){return null}var T=W.Body.MessageID,U=W.Body.MessageArguments[0],V=null;switch(T){case"iAMT0050":if(U=="48"){V="Intel® AMT Serial-over-LAN connected"}else{if(U=="49"){V="Intel® AMT Serial-over-LAN disconnected"}}break;case"iAMT0052":if(U=="1"){V="Intel® AMT KVM connected"}else{if(U=="2"){V="Intel® AMT KVM disconnected"}}break;default:break}if(V!=null){d.SendCommand({action:"msg",type:"notify",value:V,tag:"general",amtMessage:T})}};F.lmsreset=function(){var T=null,U=0;F.lmsstate=0;try{var W=require("amt-lme");U=1;F.lmsstate=1;T=new W();T.on("error",function(X){U=0;F.lmsstate=0;T=null;r("LMS error");N(1)});T.on("connect",function(){U=2;F.lmsstate=2;r("LMS connected");N(2)});T.on("notify",function(Y,Z,aa,X){if(X=="iAMT0052-3"){y()}else{t(Y)}})}catch(V){U=-1;F.lmsstate=-1;T=null}};var N=function(T){if((h==null)||(i<2)||(e==null)){return}h.getLocalSystemAccount(function(aa){if(aa==null){return}var Y=require("amt-wsman-duk");var Z=require("amt-wsman");var U=require("amt");H=new Z(Y,"127.0.0.1",16992,aa.user,aa.pass,false);G=new U(H);i=3;F.state=3;if(F.onStateChange!=null){F.onStateChange(i)}if(m==null){F.applyPolicy()}var V=null;try{for(var X in e.Versions){if(e.Versions[X].Description=="AMT"){V=parseInt(e.Versions[X].Version.split(".")[0])}}}catch(W){}if((V!=null)&&(V>=12)){y("skip");F.kvmTempTimer=setInterval(function(){y()},2000);A(JSON.stringify({action:"restart",ver:1}))}})};var y=function(T){G.IPS_KVMRedirectionSettingData_DataChannelRead(F.kvmDataGetResponse,T)};var x=function(W,U,V,X,Y){if((Y!="skip")&&(X==200)&&(V.Body.ReturnValue==0)){var Z=null;try{Z=Buffer.from(V.Body.DataMessage,"base64").toString()}catch(T){return}if(Z!=null){F.kvmProcessData(V.Body.RealmsBitmap,V.Body.MessageId,Z)}}};var Q=null;var z=function(W,V,Y){var T=null;try{T=JSON.parse(Y)}catch(U){}if((T!=null)&&(T.action)){if(T.action=="present"){A(JSON.stringify({action:"present",ver:1,platform:process.platform}))}if(T.action=="offer"){Q={};var X=require("ILibWebRTC");Q.webrtc=X.createConnection();Q.webrtc.on("connected",function(){});Q.webrtc.on("disconnected",function(){F.webRtcCleanUp()});Q.webrtc.on("dataChannel",function(Z){Q.rtcchannel=Z;Q.kvm=mesh.getRemoteDesktopStream();Q.kvm.pipe(Q.rtcchannel,{dataTypeSkip:1,end:false});Q.rtcchannel.on("end",function(){F.webRtcCleanUp()});Q.rtcchannel.on("data",function(aa){F.kvmCtrlData(this,aa)});Q.rtcchannel.pipe(Q.kvm,{dataTypeSkip:1,end:false})});A(JSON.stringify({action:"answer",ver:1,sdp:Q.webrtc.setOffer(T.sdp)}))}}};var w=function(U,W){if(W.length>0&&W.charCodeAt(0)!=123){if(F.fileupload!=null){W=Buffer.from(W,"base64");var ac=W.readUInt32BE(0);if((ac==16777216)||(ac==16777217)){fs.writeSync(F.fileupload.fp,W.slice(4));U.write({action:"upload",sub:"ack",reqid:F.fileupload.reqid});if(ac==16777217){fs.closeSync(F.fileupload.fp);F.fileupload=null}}}return}r("KVM Ctrl Data: "+W);try{W=JSON.parse(W)}catch(Z){r("Invalid JSON: "+W);return}if((W.path!=null)&&(process.platform!="win32")&&(W.path[0]!="/")){W.path="/"+W.path}switch(W.action){case"ping":U.write({action:"pong"});break;case"lock":if(process.platform=="win32"){var V=require("child_process");V.execFile(process.env.windir+"\\system32\\cmd.exe",["/c","RunDll32.exe user32.dll,LockWorkStation"],{type:1})}break;case"ls":var af=getDirectoryInfo(W.path);if(W.reqid!=undefined){af.reqid=W.reqid}U.write(af);break;case"mkdir":fs.mkdirSync(W.path);break;case"rm":for(var ad in W.delfiles){var ab=I.join(W.path,W.delfiles[ad]);try{fs.unlinkSync(ab)}catch(Y){r(Y)}}break;case"rename":try{fs.renameSync(I.join(W.path,W.oldname),I.join(W.path,W.newname))}catch(Y){r(Y)}break;case"download":var ah=0;if(W.sub=="start"){if(F.filedownload!=null){U.write({action:"download",sub:"cancel",id:F.filedownload.id});delete F.filedownload}F.filedownload={id:W.id,path:W.path,ptr:0};try{F.filedownload.f=fs.openSync(F.filedownload.path,"rbN")}catch(Y){U.write({action:"download",sub:"cancel",id:F.filedownload.id});delete F.filedownload}if(F.filedownload){U.write({action:"download",sub:"start",id:W.id})}}else{if((F.filedownload!=null)&&(W.id==F.filedownload.id)){if(W.sub=="startack"){ah=8}else{if(W.sub=="stop"){delete F.filedownload}else{if(W.sub=="ack"){ah=1}}}}}while(ah>0){ah--;var T=Buffer.alloc(4096);var ae=fs.readSync(F.filedownload.f,T,4,4092,null);F.filedownload.ptr+=ae;if(ae<4092){T.writeInt32BE(16777217,0);fs.closeSync(F.filedownload.f);delete F.filedownload;ah=0}else{T.writeInt32BE(16777216,0)}U.write(T.slice(0,ae+4).toString("base64"))}break;case"upload":if(W.sub=="start"){if(F.fileupload!=null){fs.closeSync(F.fileupload.fp)}if(!W.path||!W.name){break}F.fileupload={reqid:W.reqid};var aa=I.join(W.path,W.name);try{F.fileupload.fp=fs.openSync(aa,"wbN")}catch(Y){}if(F.fileupload.fp){U.write({action:"upload",sub:"start",reqid:F.fileupload.reqid})}else{F.fileupload=null;U.write({action:"upload",sub:"error",reqid:F.fileupload.reqid})}}else{if(W.sub=="cancel"){if(F.fileupload!=null){fs.closeSync(F.fileupload.fp);F.fileupload=null}}}break;case"copy":for(var ad in W.names){var ag=I.join(W.scpath,W.names[ad]),X=I.join(W.dspath,W.names[ad]);if(ag!=X){try{fs.copyFileSync(ag,X)}catch(Y){}}}break;case"move":for(var ad in W.names){var ag=I.join(W.scpath,W.names[ad]),X=I.join(W.dspath,W.names[ad]);if(ag!=X){try{fs.copyFileSync(ag,X);fs.unlinkSync(ag)}catch(Y){}}}break;default:r("Invalid KVM command: "+W);break}};var P=function(){r("webRtcCleanUp");if(Q==null){return}if(Q.rtcchannel){try{Q.rtcchannel.close()}catch(T){}try{Q.rtcchannel.removeAllListeners("data")}catch(T){}try{Q.rtcchannel.removeAllListeners("end")}catch(T){}delete Q.rtcchannel}if(Q.webrtc){try{Q.webrtc.close()}catch(T){}try{Q.webrtc.removeAllListeners("connected")}catch(T){}try{Q.webrtc.removeAllListeners("disconnected")}catch(T){}try{Q.webrtc.removeAllListeners("dataChannel")}catch(T){}delete Q.webrtc}if(Q.kvm){try{Q.kvm.end()}catch(T){}delete Q.kvm}Q=null};var A=function(T){G.IPS_KVMRedirectionSettingData_DataChannelWrite(Buffer.from(T).toString("base64"),function(){})};var s=function(T,U){if(fs.existsSync(T)){if(U==true){fs.readdirSync(F.path.join(T,"*")).forEach(function(W,X){var V=F.path.join(T,W);if(fs.statSync(V).isDirectory()){s(V,true)}else{fs.unlinkSync(V)}})}fs.unlinkSync(T)}};var I={join:function(){var V=[];for(var T in arguments){var U=arguments[T];if(U!=null){while(U.endsWith("/")||U.endsWith("\\")){U=U.substring(0,U.length-1)}if(T!=0){while(U.startsWith("/")||U.startsWith("\\")){U=U.substring(1)}}V.push(U)}}if(V.length==0){return"/"}return V.join("/")}};function D(T){return require("MD5Stream").create().syncHash(T).toString("hex")}F.deactivateCCM=function(){h.unprovision(1,function(T){if(T==0){r("Success deactivating Intel AMT CCM.");d.SendCommand({action:"coreinfo",intelamt:{state:0,flags:0}});m=setTimeout(F.applyPolicy,8000)}else{r("Intel AMT CCM deactivation error: "+T)}})};F.getTrustedHashes=function(T,U){if(O!=null){T(U)}O=[];h.getHashHandles(function(W){var V=W.length;for(var X=0;X<W.length;++X){this.getCertHashEntry(W[X],function(Y){if(Y.isActive==1){O.push(Y.certificateHash.toLowerCase())}if(--V==0){T(U)}})}})};F.activeToACM=function(Y){if((Y.ProvisioningState!=0)||(k==null)||(k.match==null)){return}var Z=null;if((Y.net0==null)&&(Y.net0.enabled!=0)){return}if(Y.DNS){Z=Y.DNS}else{var V=require("os").networkInterfaces();for(var U in V){for(var W in V[U]){if((V[U][W].mac==Y.net0.mac)&&(V[U][W].fqdn!=null)&&(V[U][W].fqdn!="")){Z=V[U][W].fqdn.toLowerCase()}}}}if(Z==null){return}var T=null;for(var U in k.match){var X=k.match[U];if(X.cn==Z){for(var W in O){if((O[W]==X.sha256)||(O[W]==X.sha1)){T=O[W]}}}}if(T==null){return}if(G!=null){G.BatchEnum(null,["*AMT_GeneralSettings","*IPS_HostBasedSetupService"],a,{fqdn:Z,hash:T,uuid:Y.UUID})}else{h.getLocalSystemAccount(function(ad){if((ad!=null)&&ad.user&&ad.pass){var ab=require("amt-wsman-duk");var ac=require("amt-wsman");var aa=require("amt");H=new ac(ab,"127.0.0.1",16992,ad.user,ad.pass,false);G=new aa(H);G.BatchEnum(null,["*AMT_GeneralSettings","*IPS_HostBasedSetupService"],a,{fqdn:Z,hash:T,uuid:Y.UUID})}})}};function a(X,V,W,Y,Z){if(Y!=200){return}var U=W.IPS_HostBasedSetupService.response.ConfigurationNonce;var T=W.AMT_GeneralSettings.response.DigestRealm;d.SendCommand({action:"acmactivate",nonce:U,realm:T,fqdn:Z.fqdn,hash:Z.hash,uuid:Z.uuid})}F.setAcmResponse=function(T){T.index=0;J(T)};function J(T){var U=(T.index==0),V=(T.index==(T.certs.length-1));if((T.index<T.certs.length)&&(T.certs[T.index]!=null)){G.IPS_HostBasedSetupService_AddNextCertInChain(T.certs[T.index],U,V,function(Y,W,X,Z){if(Z!==200){r("AddNextCertInChain status="+Z);return}else{if(X.Body["ReturnValue"]!==0){r("AddNextCertInChain error="+X.Body["ReturnValue"]);return}else{T.index++;J(T)}}})}else{G.IPS_HostBasedSetupService_AdminSetup(2,T.password,T.nonce,2,T.signature,function(Y,W,X,Z){if((Z==200)&&(X.Body["ReturnValue"]==0)){if(F.onStateChange!=null){F.onStateChange(2)}}})}}function B(U){var W="",V="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(var T=0;T<U;T++){W+=V.charAt(Math.floor(Math.random()*V.length))}return W}F.activeToCCM=function(T){if((T==null)||(T=="")){T="P@0s"+B(23)}u=T;if(G!=null){G.BatchEnum(null,["*AMT_GeneralSettings","*IPS_HostBasedSetupService"],b,T)}else{h.getLocalSystemAccount(function(X){if((X!=null)&&X.user&&X.pass){var V=require("amt-wsman-duk");var W=require("amt-wsman");var U=require("amt");H=new W(V,"127.0.0.1",16992,X.user,X.pass,false);G=new U(H);G.BatchEnum(null,["*AMT_GeneralSettings","*IPS_HostBasedSetupService"],b,T)}else{}})}};var b=function(W,U,V,X,T){if(X!=200){r("Failed to fetch activation information, status "+X)}else{if(V.IPS_HostBasedSetupService.response.AllowedControlModes.length!=2){r("Client control mode activation not allowed")}else{W.IPS_HostBasedSetupService_Setup(2,D("admin:"+V.AMT_GeneralSettings.response.DigestRealm+":"+T).substring(0,32),null,null,null,null,c)}}};var c=function(V,T,U,W){if(W!=200){r("Failed to activate, status "+W)}else{if(U.Body.ReturnValue!=0){r("Client control mode activation failed: "+U.Body.ReturnValueStr)}else{r("Intel AMT CCM activation success.");q.Put("amtCCMPass",u);d.SendCommand({action:"coreinfo",intelamt:{state:2,flags:2,user:"admin",pass:u}})}}m=setTimeout(F.applyPolicy,8000)};F.start=function(){var T=null;try{T=JSON.parse(q.Get("amtPolicy"))}catch(U){r("Exception loading amtPolicy")}try{u=q.Get("amtCCMPass")}catch(U){}if(typeof u!="string"){u=null}F.reset()};var u,S,l,m,K=0;F.applyPolicy=function(){m=null;if((i!=3)||(k==null)||(typeof k!="object")||(typeof k.type!="number")||(k.type==0)){return}if((k.password!=null)&&(k.password!="")){u=k.password}F.getAmtInfo(function(V){if((k.type==1)&&(V.ProvisioningState==2)&&((V.Flags&2)!=0)){S=l=null;F.deactivateCCM()}else{if((k.type==2)&&(V.ProvisioningState==0)){S=l=null;if((k.password==null)||(k.password=="")){u=null}F.activeToCCM(u)}else{if((k.type==2)&&(V.ProvisioningState==2)&&(u!=null)&&((V.Flags&2)!=0)){var W=require("amt-wsman-duk");var X=require("amt-wsman");var T=require("amt");S=new X(W,"127.0.0.1",16992,"admin",u,false);l=new T(S);var Y=["*AMT_GeneralSettings","*IPS_HostBasedSetupService","*AMT_RedirectionService","*CIM_KVMRedirectionSAP","AMT_PublicKeyCertificate","*AMT_EnvironmentDetectionSettingData"];if(k.cirasetup==2){Y.push("AMT_ManagementPresenceRemoteSAP","AMT_RemoteAccessCredentialContext","AMT_RemoteAccessPolicyAppliesToMPS","AMT_RemoteAccessPolicyRule","*AMT_UserInitiatedConnectionService","AMT_MPSUsernamePassword")}try{l.BatchEnum(null,Y,R)}catch(U){r(U)}}else{if((k.type==3)&&(V.ProvisioningState==0)&&(d.isControlChannelConnected)){F.getTrustedHashes(F.activeToACM,V)}else{}}}}})};function R(ab,V,X,ac){if(ac!=200){if(ac==401){if(k.badpass==1){F.deactivateCCM()}}else{if(++K<20){if(K==10){r("WSMAN fault, MEI Reset");F.reset()}var ad=["*AMT_GeneralSettings","*IPS_HostBasedSetupService","*AMT_RedirectionService","*CIM_KVMRedirectionSAP","AMT_PublicKeyCertificate","*AMT_EnvironmentDetectionSettingData"];if(k.cirasetup==2){ad.push("AMT_ManagementPresenceRemoteSAP","AMT_RemoteAccessCredentialContext","AMT_RemoteAccessPolicyAppliesToMPS","AMT_RemoteAccessPolicyRule","*AMT_UserInitiatedConnectionService","AMT_MPSUsernamePassword")}try{l.BatchEnum(null,ad,R)}catch(T){r(T)}}else{r("WSMAN fault, status="+ac);K=0}}}else{K=0;var Z={};Z.redir=(X.AMT_RedirectionService.response.ListenerEnabled==true);Z.sol=((X.AMT_RedirectionService.response.EnabledState&2)!=0);Z.ider=((X.AMT_RedirectionService.response.EnabledState&1)!=0);Z.kvm=(X.CIM_KVMRedirectionSAP!=null)&&((X.CIM_KVMRedirectionSAP.response.EnabledState==6&&X.CIM_KVMRedirectionSAP.response.RequestedState==2)||X.CIM_KVMRedirectionSAP.response.EnabledState==2||X.CIM_KVMRedirectionSAP.response.EnabledState==6);if((X.AMT_GeneralSettings.response.PingResponseEnabled!=true)||(X.AMT_GeneralSettings.response.RmcpPingResponseEnabled!=true)){X.AMT_GeneralSettings.response.PingResponseEnabled=true;X.AMT_GeneralSettings.response.RmcpPingResponseEnabled=true;l.Put("AMT_GeneralSettings",X.AMT_GeneralSettings.response,function(ai,ag,ah,aj){if(aj!=200){r("Enable PING PUT Error "+aj)}},0,1)}if((Z.redir==false)||(Z.sol==false)||(Z.ider==false)){var W=X.AMT_RedirectionService.response;W.ListenerEnabled=true;W.EnabledState=32768+1+2;l.AMT_RedirectionService_RequestStateChange(W.EnabledState,function(ai,ag,ah,aj){if(aj!=200){r("Enable Redirection EXEC Error "+aj)}})}if((X.CIM_KVMRedirectionSAP!=null)&&(Z.kvm==false)){l.CIM_KVMRedirectionSAP_RequestStateChange(2,0,function(ai,ag,ah,aj){if(aj!=200){messagebox("Error","KVMRedirectionSAP, RequestStateChange Error "+aj);return}l.Put("AMT_RedirectionService",W,function(am,ak,al,an){if(an!=200){r("Enable KVM PUT Error "+an)}},0,1)})}if(typeof k.rootcert=="string"){var Y=false,ae=X.AMT_PublicKeyCertificate.responses;for(var U in ae){if((ae[U]["X509Certificate"]==k.rootcert)&&(ae[U]["TrustedRootCertficate"]==true)){Y=true}}if(Y==false){l.AMT_PublicKeyManagementService_AddTrustedRootCertificate(k.rootcert,function(ai,ag,ah,aj){if(aj!=200){r("Add root cert EXEC Error "+aj)}})}}if((k.cirasetup==2)&&(k.ciraserver!=null)){var aa=false,af=X.AMT_ManagementPresenceRemoteSAP.responses;for(var U in af){if((af[U].AccessInfo==k.ciraserver.name)&&(af[U].Port==k.ciraserver.port)){aa=af[U].Name}}if(aa==false){l.AMT_RemoteAccessService_AddMpServer(k.ciraserver.name,201,k.ciraserver.port,2,null,k.ciraserver.user,k.ciraserver.pass,null,function(aj,ah,ai,ak){if(ak!=200){r("Add MPS server EXEC Error "+ak)}else{aa=false;var al=ai.Body.MpServer.ReferenceParameters.SelectorSet.Selector;for(var ag in al){if(al[ag]["@Name"]=="Name"){aa=al[ag]["Value"]}}if(aa!=false){n(X,aa)}}})}else{n(X,aa)}}else{if(k.cirasetup==1){o(X)}}}}function n(T,V){var U='<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="Name">'+V+"</Selector></SelectorSet></ReferenceParameters>";l.AMT_RemoteAccessService_AddRemoteAccessPolicyRule(2,0,"AAAAAAAAAAo=",[U],null,function(Y,W,X,Z){if(Z!=200){r("Add AddRemoteAccessPolicyRule Error "+Z)}else{o(T)}})}function o(T){var V=[];if((k.ciraserver!=null)&&(k.ciraserver.home!=null)){V=k.ciraserver.home}var U=T.AMT_EnvironmentDetectionSettingData.response;U.DetectionStrings=C(U.DetectionStrings);if(p(U.DetectionStrings,V)==false){U.DetectionStrings=V;l.Put("AMT_EnvironmentDetectionSettingData",U,function(Y,W,X,Z){if(Z!=200){r("Put AMT_EnvironmentDetectionSettingData Error "+Z)}},0,1)}}function p(T,U){if(T==U){return true}if(T==null){T=[]}if(U==null){U=[]}if(T.length!=U.length){return false}for(var V in T){if(U.indexOf(T[V])==-1){return false}}return true}function C(T){if(!T||T==null||typeof T=="object"){return T}return[T]}}module.exports=AmtManager;
\ No newline at end of file
1
+function AmtManager(d,q,v){var M=function(T){d.SendCommand({action:"msg",type:"console",value:T})};var r=function(T){if(v){M("amt-manager: "+T+"<br />")}};var h=null,i=0;var f=null,g=0;var e=null;var H=null;var G=null;var k=null;var F=this;var E;var O=null;F.state=0;F.lmsstate=0;F.onStateChange=null;F.setDebug=function(T){v=T};F.setPolicy=function(U,T){if(T||(JSON.stringify(k)!=JSON.stringify(U))){k=U;if(m==null){m=setTimeout(F.applyPolicy,8000)}}};var L=0;F.reset=function(){++L;h=null,i=0,f=null,g=0,F.state=0,F.lmsstate=0;try{var T=require("amt-mei");h=new T();h.on("error",function(V){r("MEI error");h=null;i=-1;F.state=-1;if(F.onStateChange!=null){F.onStateChange(i)}});h.getVersion(function(V){if(V==null){i=-1;F.state=-1;if(F.onStateChange!=null){F.onStateChange(i)}if(L<10){setTimeout(F.reset,10000)}}else{e=V;i=2;F.state=2;L=0;if(F.onStateChange!=null){F.onStateChange(i)}F.lmsreset()}})}catch(U){r("MEI exception: "+U);h=null;i=-1;F.state=-1}};var j=null;F.getAmtInfo=function(U){if((h==null)||(i<2)){if(U!=null){U(null)}return}try{j={Flags:0};h.getProtocolVersion(function(V){if(V!=null){j.MeiVersion=V}});h.getVersion(function(V){if(V){j.Versions={};for(var W in V.Versions){j.Versions[V.Versions[W].Description]=V.Versions[W].Version}}});h.getProvisioningMode(function(V){if(V){j.ProvisioningMode=V.mode}});h.getProvisioningState(function(V){if(V){j.ProvisioningState=V.state}});h.getEHBCState(function(V){if((V!=null)&&(V.EHBC==true)){j.Flags+=1}});h.getControlMode(function(V){if(V!=null){if(V.controlMode==1){j.Flags+=2}if(V.controlMode==2){j.Flags+=4}}});h.getLanInterfaceSettings(0,function(V){if(V){j.net0=V}});h.getLanInterfaceSettings(1,function(V){if(V){j.net1=V}});h.getUuid(function(V){if((V!=null)&&(V.uuid!=null)){j.UUID=V.uuid}});h.getDnsSuffix(function(V){if(V!=null){j.DNS=V}if(U!=null){U(j)}})}catch(T){if(U!=null){U(null)}return}};var t=function(W){if((W==null)||(W.Body==null)||(W.Body.MessageID==null)||(W.Body.MessageArguments==null)){return null}var T=W.Body.MessageID,U=W.Body.MessageArguments[0],V=null;switch(T){case"iAMT0050":if(U=="48"){V="Intel® AMT Serial-over-LAN connected"}else{if(U=="49"){V="Intel® AMT Serial-over-LAN disconnected"}}break;case"iAMT0052":if(U=="1"){V="Intel® AMT KVM connected"}else{if(U=="2"){V="Intel® AMT KVM disconnected"}}break;default:break}if(V!=null){d.SendCommand({action:"msg",type:"notify",value:V,tag:"general",amtMessage:T})}};F.lmsreset=function(){F.lmsstate=0;try{var U=require("amt-lme");g=1;F.lmsstate=1;f=new U();f.on("error",function(V){g=0;F.lmsstate=0;f=null;r("LMS error: "+V);N(1)});f.on("connect",function(){g=2;F.lmsstate=2;r("LMS connected");N(2)});f.on("notify",function(W,X,Y,V){if(V=="iAMT0052-3"){y()}else{t(W)}})}catch(T){g=-1;F.lmsstate=-1;f=null}};var N=function(T){if((h==null)||(i<2)||(e==null)){return}h.getLocalSystemAccount(function(aa){if(aa==null){return}var Y=require("amt-wsman-duk");var Z=require("amt-wsman");var U=require("amt");H=new Z(Y,"127.0.0.1",16992,aa.user,aa.pass,false);G=new U(H);i=3;F.state=3;if(F.onStateChange!=null){F.onStateChange(i)}if(m==null){F.applyPolicy()}var V=null;try{for(var X in e.Versions){if(e.Versions[X].Description=="AMT"){V=parseInt(e.Versions[X].Version.split(".")[0])}}}catch(W){}if((V!=null)&&(V>=12)){y("skip");F.kvmTempTimer=setInterval(function(){y()},2000);A(JSON.stringify({action:"restart",ver:1}))}})};var y=function(T){G.IPS_KVMRedirectionSettingData_DataChannelRead(F.kvmDataGetResponse,T)};var x=function(W,U,V,X,Y){if((Y!="skip")&&(X==200)&&(V.Body.ReturnValue==0)){var Z=null;try{Z=Buffer.from(V.Body.DataMessage,"base64").toString()}catch(T){return}if(Z!=null){F.kvmProcessData(V.Body.RealmsBitmap,V.Body.MessageId,Z)}}};var Q=null;var z=function(W,V,Y){var T=null;try{T=JSON.parse(Y)}catch(U){}if((T!=null)&&(T.action)){if(T.action=="present"){A(JSON.stringify({action:"present",ver:1,platform:process.platform}))}if(T.action=="offer"){Q={};var X=require("ILibWebRTC");Q.webrtc=X.createConnection();Q.webrtc.on("connected",function(){});Q.webrtc.on("disconnected",function(){F.webRtcCleanUp()});Q.webrtc.on("dataChannel",function(Z){Q.rtcchannel=Z;Q.kvm=mesh.getRemoteDesktopStream();Q.kvm.pipe(Q.rtcchannel,{dataTypeSkip:1,end:false});Q.rtcchannel.on("end",function(){F.webRtcCleanUp()});Q.rtcchannel.on("data",function(aa){F.kvmCtrlData(this,aa)});Q.rtcchannel.pipe(Q.kvm,{dataTypeSkip:1,end:false})});A(JSON.stringify({action:"answer",ver:1,sdp:Q.webrtc.setOffer(T.sdp)}))}}};var w=function(U,W){if(W.length>0&&W.charCodeAt(0)!=123){if(F.fileupload!=null){W=Buffer.from(W,"base64");var ac=W.readUInt32BE(0);if((ac==16777216)||(ac==16777217)){fs.writeSync(F.fileupload.fp,W.slice(4));U.write({action:"upload",sub:"ack",reqid:F.fileupload.reqid});if(ac==16777217){fs.closeSync(F.fileupload.fp);F.fileupload=null}}}return}r("KVM Ctrl Data: "+W);try{W=JSON.parse(W)}catch(Z){r("Invalid JSON: "+W);return}if((W.path!=null)&&(process.platform!="win32")&&(W.path[0]!="/")){W.path="/"+W.path}switch(W.action){case"ping":U.write({action:"pong"});break;case"lock":if(process.platform=="win32"){var V=require("child_process");V.execFile(process.env.windir+"\\system32\\cmd.exe",["/c","RunDll32.exe user32.dll,LockWorkStation"],{type:1})}break;case"ls":var af=getDirectoryInfo(W.path);if(W.reqid!=undefined){af.reqid=W.reqid}U.write(af);break;case"mkdir":fs.mkdirSync(W.path);break;case"rm":for(var ad in W.delfiles){var ab=I.join(W.path,W.delfiles[ad]);try{fs.unlinkSync(ab)}catch(Y){r(Y)}}break;case"rename":try{fs.renameSync(I.join(W.path,W.oldname),I.join(W.path,W.newname))}catch(Y){r(Y)}break;case"download":var ah=0;if(W.sub=="start"){if(F.filedownload!=null){U.write({action:"download",sub:"cancel",id:F.filedownload.id});delete F.filedownload}F.filedownload={id:W.id,path:W.path,ptr:0};try{F.filedownload.f=fs.openSync(F.filedownload.path,"rbN")}catch(Y){U.write({action:"download",sub:"cancel",id:F.filedownload.id});delete F.filedownload}if(F.filedownload){U.write({action:"download",sub:"start",id:W.id})}}else{if((F.filedownload!=null)&&(W.id==F.filedownload.id)){if(W.sub=="startack"){ah=8}else{if(W.sub=="stop"){delete F.filedownload}else{if(W.sub=="ack"){ah=1}}}}}while(ah>0){ah--;var T=Buffer.alloc(4096);var ae=fs.readSync(F.filedownload.f,T,4,4092,null);F.filedownload.ptr+=ae;if(ae<4092){T.writeInt32BE(16777217,0);fs.closeSync(F.filedownload.f);delete F.filedownload;ah=0}else{T.writeInt32BE(16777216,0)}U.write(T.slice(0,ae+4).toString("base64"))}break;case"upload":if(W.sub=="start"){if(F.fileupload!=null){fs.closeSync(F.fileupload.fp)}if(!W.path||!W.name){break}F.fileupload={reqid:W.reqid};var aa=I.join(W.path,W.name);try{F.fileupload.fp=fs.openSync(aa,"wbN")}catch(Y){}if(F.fileupload.fp){U.write({action:"upload",sub:"start",reqid:F.fileupload.reqid})}else{F.fileupload=null;U.write({action:"upload",sub:"error",reqid:F.fileupload.reqid})}}else{if(W.sub=="cancel"){if(F.fileupload!=null){fs.closeSync(F.fileupload.fp);F.fileupload=null}}}break;case"copy":for(var ad in W.names){var ag=I.join(W.scpath,W.names[ad]),X=I.join(W.dspath,W.names[ad]);if(ag!=X){try{fs.copyFileSync(ag,X)}catch(Y){}}}break;case"move":for(var ad in W.names){var ag=I.join(W.scpath,W.names[ad]),X=I.join(W.dspath,W.names[ad]);if(ag!=X){try{fs.copyFileSync(ag,X);fs.unlinkSync(ag)}catch(Y){}}}break;default:r("Invalid KVM command: "+W);break}};var P=function(){r("webRtcCleanUp");if(Q==null){return}if(Q.rtcchannel){try{Q.rtcchannel.close()}catch(T){}try{Q.rtcchannel.removeAllListeners("data")}catch(T){}try{Q.rtcchannel.removeAllListeners("end")}catch(T){}delete Q.rtcchannel}if(Q.webrtc){try{Q.webrtc.close()}catch(T){}try{Q.webrtc.removeAllListeners("connected")}catch(T){}try{Q.webrtc.removeAllListeners("disconnected")}catch(T){}try{Q.webrtc.removeAllListeners("dataChannel")}catch(T){}delete Q.webrtc}if(Q.kvm){try{Q.kvm.end()}catch(T){}delete Q.kvm}Q=null};var A=function(T){G.IPS_KVMRedirectionSettingData_DataChannelWrite(Buffer.from(T).toString("base64"),function(){})};var s=function(T,U){if(fs.existsSync(T)){if(U==true){fs.readdirSync(F.path.join(T,"*")).forEach(function(W,X){var V=F.path.join(T,W);if(fs.statSync(V).isDirectory()){s(V,true)}else{fs.unlinkSync(V)}})}fs.unlinkSync(T)}};var I={join:function(){var V=[];for(var T in arguments){var U=arguments[T];if(U!=null){while(U.endsWith("/")||U.endsWith("\\")){U=U.substring(0,U.length-1)}if(T!=0){while(U.startsWith("/")||U.startsWith("\\")){U=U.substring(1)}}V.push(U)}}if(V.length==0){return"/"}return V.join("/")}};function D(T){return require("MD5Stream").create().syncHash(T).toString("hex")}F.deactivateCCM=function(){h.unprovision(1,function(T){if(T==0){r("Success deactivating Intel AMT CCM.");d.SendCommand({action:"coreinfo",intelamt:{state:0,flags:0}});m=setTimeout(F.applyPolicy,8000)}else{r("Intel AMT CCM deactivation error: "+T)}})};F.getTrustedHashes=function(T,U){if(O!=null){T(U)}O=[];h.getHashHandles(function(W){var V=W.length;for(var X=0;X<W.length;++X){this.getCertHashEntry(W[X],function(Y){if(Y.isActive==1){O.push(Y.certificateHash.toLowerCase())}if(--V==0){T(U)}})}})};F.activeToACM=function(Y){if((Y.ProvisioningState!=0)||(k==null)||(k.match==null)){return}var Z=null;if((Y.net0==null)&&(Y.net0.enabled!=0)){return}if(Y.DNS){Z=Y.DNS}else{var V=require("os").networkInterfaces();for(var U in V){for(var W in V[U]){if((V[U][W].mac==Y.net0.mac)&&(V[U][W].fqdn!=null)&&(V[U][W].fqdn!="")){Z=V[U][W].fqdn.toLowerCase()}}}}if(Z==null){return}var T=null;for(var U in k.match){var X=k.match[U];if(X.cn==Z){for(var W in O){if((O[W]==X.sha256)||(O[W]==X.sha1)){T=O[W]}}}}if(T==null){return}if(G!=null){G.BatchEnum(null,["*AMT_GeneralSettings","*IPS_HostBasedSetupService"],a,{fqdn:Z,hash:T,uuid:Y.UUID})}else{h.getLocalSystemAccount(function(ad){if((ad!=null)&&ad.user&&ad.pass){var ab=require("amt-wsman-duk");var ac=require("amt-wsman");var aa=require("amt");H=new ac(ab,"127.0.0.1",16992,ad.user,ad.pass,false);G=new aa(H);G.BatchEnum(null,["*AMT_GeneralSettings","*IPS_HostBasedSetupService"],a,{fqdn:Z,hash:T,uuid:Y.UUID})}})}};function a(X,V,W,Y,Z){if(Y!=200){return}var U=W.IPS_HostBasedSetupService.response.ConfigurationNonce;var T=W.AMT_GeneralSettings.response.DigestRealm;d.SendCommand({action:"acmactivate",nonce:U,realm:T,fqdn:Z.fqdn,hash:Z.hash,uuid:Z.uuid})}F.setAcmResponse=function(T){T.index=0;J(T)};function J(T){var U=(T.index==0),V=(T.index==(T.certs.length-1));if((T.index<T.certs.length)&&(T.certs[T.index]!=null)){G.IPS_HostBasedSetupService_AddNextCertInChain(T.certs[T.index],U,V,function(Y,W,X,Z){if(Z!==200){r("AddNextCertInChain status="+Z);return}else{if(X.Body["ReturnValue"]!==0){r("AddNextCertInChain error="+X.Body["ReturnValue"]);return}else{T.index++;J(T)}}})}else{G.IPS_HostBasedSetupService_AdminSetup(2,T.password,T.nonce,2,T.signature,function(Y,W,X,Z){if((Z==200)&&(X.Body["ReturnValue"]==0)){if(F.onStateChange!=null){F.onStateChange(2)}}})}}function B(U){var W="",V="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(var T=0;T<U;T++){W+=V.charAt(Math.floor(Math.random()*V.length))}return W}F.activeToCCM=function(T){if((T==null)||(T=="")){T="P@0s"+B(23)}u=T;if(G!=null){G.BatchEnum(null,["*AMT_GeneralSettings","*IPS_HostBasedSetupService"],b,T)}else{h.getLocalSystemAccount(function(X){if((X!=null)&&X.user&&X.pass){var V=require("amt-wsman-duk");var W=require("amt-wsman");var U=require("amt");H=new W(V,"127.0.0.1",16992,X.user,X.pass,false);G=new U(H);G.BatchEnum(null,["*AMT_GeneralSettings","*IPS_HostBasedSetupService"],b,T)}else{}})}};var b=function(W,U,V,X,T){if(X!=200){r("Failed to fetch activation information, status "+X)}else{if(V.IPS_HostBasedSetupService.response.AllowedControlModes.length!=2){r("Client control mode activation not allowed")}else{W.IPS_HostBasedSetupService_Setup(2,D("admin:"+V.AMT_GeneralSettings.response.DigestRealm+":"+T).substring(0,32),null,null,null,null,c)}}};var c=function(V,T,U,W){if(W!=200){r("Failed to activate, status "+W)}else{if(U.Body.ReturnValue!=0){r("Client control mode activation failed: "+U.Body.ReturnValueStr)}else{r("Intel AMT CCM activation success.");q.Put("amtCCMPass",u);d.SendCommand({action:"coreinfo",intelamt:{state:2,flags:2,user:"admin",pass:u}})}}m=setTimeout(F.applyPolicy,8000)};F.start=function(){var T=null;try{T=JSON.parse(q.Get("amtPolicy"))}catch(U){r("Exception loading amtPolicy")}try{u=q.Get("amtCCMPass")}catch(U){}if(typeof u!="string"){u=null}F.reset()};var u,S,l,m,K=0;F.applyPolicy=function(){m=null;if((i!=3)||(k==null)||(typeof k!="object")||(typeof k.type!="number")||(k.type==0)){return}if((k.password!=null)&&(k.password!="")){u=k.password}F.getAmtInfo(function(V){if((k.type==1)&&(V.ProvisioningState==2)&&((V.Flags&2)!=0)){S=l=null;F.deactivateCCM()}else{if((k.type==2)&&(V.ProvisioningState==0)){S=l=null;if((k.password==null)||(k.password=="")){u=null}F.activeToCCM(u)}else{if((k.type==2)&&(V.ProvisioningState==2)&&(u!=null)&&((V.Flags&2)!=0)){var W=require("amt-wsman-duk");var X=require("amt-wsman");var T=require("amt");S=new X(W,"127.0.0.1",16992,"admin",u,false);l=new T(S);var Y=["*AMT_GeneralSettings","*IPS_HostBasedSetupService","*AMT_RedirectionService","*CIM_KVMRedirectionSAP","AMT_PublicKeyCertificate","*AMT_EnvironmentDetectionSettingData"];if(k.cirasetup==2){Y.push("AMT_ManagementPresenceRemoteSAP","AMT_RemoteAccessCredentialContext","AMT_RemoteAccessPolicyAppliesToMPS","AMT_RemoteAccessPolicyRule","*AMT_UserInitiatedConnectionService","AMT_MPSUsernamePassword")}try{l.BatchEnum(null,Y,R)}catch(U){r(U)}}else{if((k.type==3)&&(V.ProvisioningState==0)&&(d.isControlChannelConnected)){F.getTrustedHashes(F.activeToACM,V)}else{}}}}})};function R(ab,V,X,ac){if(ac!=200){if(ac==401){if(k.badpass==1){F.deactivateCCM()}}else{if(++K<20){if(K==10){r("WSMAN fault, MEI Reset");F.reset()}var ad=["*AMT_GeneralSettings","*IPS_HostBasedSetupService","*AMT_RedirectionService","*CIM_KVMRedirectionSAP","AMT_PublicKeyCertificate","*AMT_EnvironmentDetectionSettingData"];if(k.cirasetup==2){ad.push("AMT_ManagementPresenceRemoteSAP","AMT_RemoteAccessCredentialContext","AMT_RemoteAccessPolicyAppliesToMPS","AMT_RemoteAccessPolicyRule","*AMT_UserInitiatedConnectionService","AMT_MPSUsernamePassword")}try{l.BatchEnum(null,ad,R)}catch(T){r(T)}}else{r("WSMAN fault, status="+ac);K=0}}}else{K=0;var Z={};Z.redir=(X.AMT_RedirectionService.response.ListenerEnabled==true);Z.sol=((X.AMT_RedirectionService.response.EnabledState&2)!=0);Z.ider=((X.AMT_RedirectionService.response.EnabledState&1)!=0);Z.kvm=(X.CIM_KVMRedirectionSAP!=null)&&((X.CIM_KVMRedirectionSAP.response.EnabledState==6&&X.CIM_KVMRedirectionSAP.response.RequestedState==2)||X.CIM_KVMRedirectionSAP.response.EnabledState==2||X.CIM_KVMRedirectionSAP.response.EnabledState==6);if((X.AMT_GeneralSettings.response.PingResponseEnabled!=true)||(X.AMT_GeneralSettings.response.RmcpPingResponseEnabled!=true)){X.AMT_GeneralSettings.response.PingResponseEnabled=true;X.AMT_GeneralSettings.response.RmcpPingResponseEnabled=true;l.Put("AMT_GeneralSettings",X.AMT_GeneralSettings.response,function(ai,ag,ah,aj){if(aj!=200){r("Enable PING PUT Error "+aj)}},0,1)}if((Z.redir==false)||(Z.sol==false)||(Z.ider==false)){var W=X.AMT_RedirectionService.response;W.ListenerEnabled=true;W.EnabledState=32768+1+2;l.AMT_RedirectionService_RequestStateChange(W.EnabledState,function(ai,ag,ah,aj){if(aj!=200){r("Enable Redirection EXEC Error "+aj)}})}if((X.CIM_KVMRedirectionSAP!=null)&&(Z.kvm==false)){l.CIM_KVMRedirectionSAP_RequestStateChange(2,0,function(ai,ag,ah,aj){if(aj!=200){messagebox("Error","KVMRedirectionSAP, RequestStateChange Error "+aj);return}l.Put("AMT_RedirectionService",W,function(am,ak,al,an){if(an!=200){r("Enable KVM PUT Error "+an)}},0,1)})}if(typeof k.rootcert=="string"){var Y=false,ae=X.AMT_PublicKeyCertificate.responses;for(var U in ae){if((ae[U]["X509Certificate"]==k.rootcert)&&(ae[U]["TrustedRootCertficate"]==true)){Y=true}}if(Y==false){l.AMT_PublicKeyManagementService_AddTrustedRootCertificate(k.rootcert,function(ai,ag,ah,aj){if(aj!=200){r("Add root cert EXEC Error "+aj)}})}}if((k.cirasetup==2)&&(k.ciraserver!=null)){var aa=false,af=X.AMT_ManagementPresenceRemoteSAP.responses;for(var U in af){if((af[U].AccessInfo==k.ciraserver.name)&&(af[U].Port==k.ciraserver.port)){aa=af[U].Name}}if(aa==false){l.AMT_RemoteAccessService_AddMpServer(k.ciraserver.name,201,k.ciraserver.port,2,null,k.ciraserver.user,k.ciraserver.pass,null,function(aj,ah,ai,ak){if(ak!=200){r("Add MPS server EXEC Error "+ak)}else{aa=false;var al=ai.Body.MpServer.ReferenceParameters.SelectorSet.Selector;for(var ag in al){if(al[ag]["@Name"]=="Name"){aa=al[ag]["Value"]}}if(aa!=false){n(X,aa)}}})}else{n(X,aa)}}else{if(k.cirasetup==1){o(X)}}}}function n(T,V){var U='<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="Name">'+V+"</Selector></SelectorSet></ReferenceParameters>";l.AMT_RemoteAccessService_AddRemoteAccessPolicyRule(2,0,"AAAAAAAAAAo=",[U],null,function(Y,W,X,Z){if(Z!=200){r("Add AddRemoteAccessPolicyRule Error "+Z)}else{o(T)}})}function o(T){var V=[];if((k.ciraserver!=null)&&(k.ciraserver.home!=null)){V=k.ciraserver.home}var U=T.AMT_EnvironmentDetectionSettingData.response;U.DetectionStrings=C(U.DetectionStrings);if(p(U.DetectionStrings,V)==false){U.DetectionStrings=V;l.Put("AMT_EnvironmentDetectionSettingData",U,function(Y,W,X,Z){if(Z!=200){r("Put AMT_EnvironmentDetectionSettingData Error "+Z)}},0,1)}}function p(T,U){if(T==U){return true}if(T==null){T=[]}if(U==null){U=[]}if(T.length!=U.length){return false}for(var V in T){if(U.indexOf(T[V])==-1){return false}}return true}function C(T){if(!T||T==null||typeof T=="object"){return T}return[T]}}module.exports=AmtManager;
\ No newline at end of file
agents/modules_meshcore_min/win-virtual-terminal.min.js
new
+1
@@ -0,0 +1 @@
1
+var PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE=131094;var EXTENDED_STARTUPINFO_PRESENT=524288;var HEAP_ZERO_MEMORY=8;var duplex=require("stream").Duplex;function vt(){this._ObjectID="win-virtual-terminal";Object.defineProperty(this,"supported",{value:(function(){var f=require("_GenericMarshal");var g=f.CreateNativeProxy("kernel32.dll");try{g.CreateMethod("CreatePseudoConsole")}catch(d){return(false)}return(true)})()});this.Create=function a(k,o,i){if(!this.supported){throw ("This build of Windows does not have support for PseudoConsoles")}if(!o){o=80}if(!i){i=25}var h=require("_GenericMarshal");var j=h.CreateNativeProxy("kernel32.dll");j.CreateMethod("CreatePipe");j.CreateMethod("CreateProcessW");j.CreateMethod("CreatePseudoConsole");j.CreateMethod("GetProcessHeap");j.CreateMethod("HeapAlloc");j.CreateMethod("InitializeProcThreadAttributeList");j.CreateMethod("UpdateProcThreadAttribute");j.CreateMethod("WriteFile");j.CreateMethod("ReadFile");j.CreateMethod("TerminateProcess");var m={_h:h.CreatePointer(),_consoleInput:h.CreatePointer(),_consoleOutput:h.CreatePointer(),_input:h.CreatePointer(),_output:h.CreatePointer(),k32:j};var f=h.CreateVariable(8);var e;var l=h.CreateVariable(h.PointerSize==4?16:24);if(j.CreatePipe(m._consoleInput,m._input,0,0).Val==0){console.log("PIPE/FAIL")}if(j.CreatePipe(m._output,m._consoleOutput,0,0).Val==0){console.log("PIPE/FAIL")}if(j.CreatePseudoConsole((i<<16)|o,m._consoleInput.Deref(),m._consoleOutput.Deref(),0,m._h).Val!=0){throw ("Error calling CreatePseudoConsole()")}j.InitializeProcThreadAttributeList(0,1,0,f);e=h.CreateVariable(f.toBuffer().readUInt32LE());var n=h.CreateVariable(h.PointerSize==8?112:72);n.toBuffer().writeUInt32LE(h.PointerSize==8?112:72,0);e.pointerBuffer().copy(n.Deref(h.PointerSize==8?104:68,h.PointerSize).toBuffer());if(j.InitializeProcThreadAttributeList(e,1,0,f).Val!=0){if(j.UpdateProcThreadAttribute(e,0,PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE,m._h.Deref(),h.PointerSize,0,0).Val!=0){if(j.CreateProcessW(0,h.CreateVariable(k,{wide:true}),0,0,1,EXTENDED_STARTUPINFO_PRESENT,0,0,n,l).Val!=0){m._startupinfoex=n;m._process=l.Deref(0);m._pid=l.Deref(h.PointerSize==4?8:16,4).toBuffer().readUInt32LE();var g=new duplex({write:function(p,q){var r=require("_GenericMarshal").CreateVariable(4);this.terminal.k32.WriteFile(this.terminal._input.Deref(),require("_GenericMarshal").CreateVariable(p),p.length,r,0);q();return(true)},"final":function(p){if(this.terminal._process){this.terminal.k32.TerminateProcess(this.terminal._process,0);this.terminal._process=null;this.terminal.k32.ReadFile.async.abort()}p()}});m._waiter=require("DescriptorEvents").addDescriptor(l.Deref(0));m._waiter.ds=g;m._waiter.on("signaled",function(){this.ds.push(null)});g.terminal=m;g._rpbuf=h.CreateVariable(4096);g._rpbufRead=h.CreateVariable(4);g._read=function d(){this._rp=this.terminal.k32.ReadFile.async(this.terminal._output.Deref(),this._rpbuf,this._rpbuf._size,this._rpbufRead,0);this._rp.then(function(){var p=this.parent._rpbufRead.toBuffer().readUInt32LE();this.parent.push(this.parent._rpbuf.toBuffer().slice(0,p));this.parent._read()});this._rp.parent=this};g._read();return(g)}else{console.log("FAILED!")}}}throw ("Internal Error")};this.PowerShellCapable=function(){if(require("os").arch()=="x64"){return(require("fs").existsSync(process.env.windir+"\\SysWow64\\WindowsPowerShell\\v1.0\\powershell.exe"))}else{return(require("fs").existsSync(process.env.windir+"\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"))}};this.Start=function b(e,d){return(this.Create(process.env.windir+"\\System32\\cmd.exe",e,d))};this.StartPowerShell=function c(e,d){if(require("os").arch()=="x64"){return(this.Create(process.env.windir+"\\SysWow64\\WindowsPowerShell\\v1.0\\powershell.exe",e,d))}else{return(this.Create(process.env.windir+"\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",e,d))}}}if(process.platform=="win32"){module.exports=new vt()};
\ No newline at end of file
public/images/icon-background.png
Binary files /dev/null and b/public/images/icon-background.png differ
public/styles/style.css
+1
-1
@@ -2181,7 +2181,7 @@ a {
2181
-ms-grid-row: 4;
2182
}
2183
2184
-#DeskChatButton, #DeskNotifyButton, #DeskOpenWebButton {
2184
+#DeskChatButton, #DeskNotifyButton, #DeskOpenWebButton, #DeskBackgroundButton {
2185
float: right;
2186
margin-top: 1px;
2187
margin-right: 4px;
views/default.handlebars
+13
-6
@@ -518,7 +518,8 @@
518
<input id=DeskToolsButton type=button value=Tools title="Toggle tools view" onkeypress="return false" onkeydown="return false" onclick="toggleDeskTools()" />
519
<span id=DeskChatButton class="deskarea" title="Open chat window to this computer"><img src='images/icon-chat.png' onclick=deviceChat(event) height=16 width=16 style=padding-top:2px /></span>
520
<span id=DeskNotifyButton title="Display a notification on the remote computer"><img src='images/icon-notify.png' onclick=deviceToastFunction() height=16 width=16 style=padding-top:2px /></span>
521
- <span id=DeskOpenWebButton title="Open a web address on remote computer"><img src='images/icon-url2.png' onclick=deviceUrlFunction() height=16 width=16 style=padding-top:2px /></span>
521
+ <span id=DeskOpenWebButton title="Open a web address on the remote computer"><img src='images/icon-url2.png' onclick=deviceUrlFunction() height=16 width=16 style=padding-top:2px /></span>
522
+ <span id=DeskBackgroundButton title="Toggle remote desktop background"><img src='images/icon-background.png' onclick=deviceToggleBackground(event) height=16 width=16 style=padding-top:2px /></span>
523
</div>
524
<div>
525
<select id="deskkeys">
@@ -4625,6 +4626,11 @@
4626
meshserver.send({ action: 'meshmessenger', nodeid: decodeURIComponent(currentNode._id) });
4627
}
4628
4629
+ function deviceToggleBackground() {
4630
+ if (xxdialogMode) return;
4631
+ meshserver.send({ action: 'msg', type: 'deskBackground', nodeid: currentNode._id, op: 1 }); // Toggle desktop background image
4632
+ }
4633
+
4634
function deviceUrlFunction() {
4635
if (xxdialogMode) return;
4636
setDialogMode(2, "Open Page on Device", 3, deviceUrlFunctionEx, '<input id=d2devurl placeholder="http://server.com" style=width:100%;overflow-y:scroll></input>');
@@ -5125,6 +5131,7 @@
5131
5132
QV('DeskToolsButton', (inputAllowed) && (mesh.mtype == 2) && online);
5133
QV('DeskOpenWebButton', (browserfullscreen == false) && (inputAllowed) && (mesh.mtype == 2) && online);
5134
+ QV('DeskBackgroundButton', (debugmode == 1) && (deskState == 3) && (desktop.contype == 1) && (mesh.mtype == 2) && (currentNode.agent.id != 11) && (currentNode.agent.id != 16) && online);
5135
QV('DeskControlSpan', inputAllowed)
5136
QV('deskActionsBtn', (browserfullscreen == false));
5137
QV('deskActionsSettings', (browserfullscreen == false));
@@ -7312,7 +7319,7 @@
7319
if (meshNotify & 2) { meshNotifyStr.push("Connect"); }
7320
if (meshNotify & 4) { meshNotifyStr.push("Disconnect"); }
7321
if (meshNotify & 8) { meshNotifyStr.push("Intel® AMT"); }
7315
- if (meshNotifyStr.length == 0) { meshNotifyStr.push("None"); }
7322
+ if (meshNotifyStr.length == 0) { meshNotifyStr.push('<i>' + "None" + '</i>'); }
7323
x += addHtmlValue("Notifications", addLink(meshNotifyStr.join(', '), 'p20editMeshNotify()'));
7324
7325
// Intel AMT setup
@@ -7497,7 +7504,7 @@
7504
x += '<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px"><b>' + "Desktop" + '</b></div>';
7505
x += '<div><label><input type=checkbox id=d20flag1 ' + ((consent & 0x0001) ? 'checked' : '') + '>' + "Notify user" + '</label></div>';
7506
x += '<div><label><input type=checkbox id=d20flag2 ' + ((consent & 0x0008) ? 'checked' : '') + '>' + "Prompt for user consent" + '</label></div>';
7500
- if (debugmode) { x += '<div><label><input type=checkbox id=d20flag7 ' + ((consent & 0x0040) ? 'checked' : '') + '>' + "Show connection toolbar" + '</label></div>'; }
7507
+ if (debugmode == 1) { x += '<div><label><input type=checkbox id=d20flag7 ' + ((consent & 0x0040) ? 'checked' : '') + '>' + "Show connection toolbar" + '</label></div>'; }
7508
x += '<div style="width:100%;border-bottom:1px solid gray;margin-bottom:5px;margin-top:8px"><b>' + "Terminal" + '</b></div>';
7509
x += '<div><label><input type=checkbox id=d20flag3 ' + ((consent & 0x0002) ? 'checked' : '') + '>' + "Notify user" + '</label></div>';
7510
x += '<div><label><input type=checkbox id=d20flag4 ' + ((consent & 0x0010) ? 'checked' : '') + '>' + "Prompt for user consent" + '</label></div>';
@@ -7512,14 +7519,14 @@
7519
if (serverinfo.consent & 0x0010) { Q('d20flag4').checked = true; }
7520
if (serverinfo.consent & 0x0004) { Q('d20flag5').checked = true; }
7521
if (serverinfo.consent & 0x0020) { Q('d20flag6').checked = true; }
7515
- if (debugmode) { if (serverinfo.consent & 0x0040) { Q('d20flag7').checked = true; } }
7522
+ if (debugmode == 1) { if (serverinfo.consent & 0x0040) { Q('d20flag7').checked = true; } }
7523
QE('d20flag1', !(serverinfo.consent & 0x0001));
7524
QE('d20flag2', !(serverinfo.consent & 0x0008));
7525
QE('d20flag3', !(serverinfo.consent & 0x0002));
7526
QE('d20flag4', !(serverinfo.consent & 0x0010));
7527
QE('d20flag5', !(serverinfo.consent & 0x0004));
7528
QE('d20flag6', !(serverinfo.consent & 0x0020));
7522
- if (debugmode) { QE('d20flag7', !(serverinfo.consent & 0x0040)); }
7529
+ if (debugmode == 1) { QE('d20flag7', !(serverinfo.consent & 0x0040)); }
7530
}
7531
}
7532
@@ -7531,7 +7538,7 @@
7538
if (Q('d20flag4').checked) { consent += 0x0010; }
7539
if (Q('d20flag5').checked) { consent += 0x0004; }
7540
if (Q('d20flag6').checked) { consent += 0x0020; }
7534
- if (debugmode) { if (Q('d20flag7').checked) { consent += 0x0040; } }
7541
+ if (debugmode == 1) { if (Q('d20flag7').checked) { consent += 0x0040; } }
7542
meshserver.send({ action: 'editmesh', meshid: currentMesh._id, consent: consent });
7543
}
7544