Revert "swap powershell write to command instead" to fix win7/server2008r2
Signed-off-by: si458 <simonsmith5521@gmail.com>
si458 committed
Nov 30, 2024 at 00:21 UTC
ef4d764ab4a7cc2344889e51b57203f9c70110cd
4 files changed
+13
-13
agents/meshcore.js
+1
-1
@@ -249,7 +249,7 @@ function lockDesktop(uid) {
249
case 'win32':
250
{
251
var options = { type: 1, uid: uid };
252
- var child = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ['cmd', '/c', 'RunDll32.exe user32.dll,LockWorkStation'], options);
252
+ var child = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ['/c', 'RunDll32.exe user32.dll,LockWorkStation'], options);
253
child.waitExit();
254
}
255
break;
agents/modules_meshcore/computer-identifiers.js
+8
-9
@@ -431,12 +431,11 @@ function windows_volumes()
431
p1._p2 = p2;
432
p2._p1 = p1;
433
434
- var cmd = '"Get-Volume | Select-Object -Property DriveLetter,FileSystemLabel,FileSystemType,Size,SizeRemaining,DriveType | ConvertTo-Csv -NoTypeInformation"';
435
- var child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', cmd]);
434
+ var child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-']);
435
p1.child = child;
436
child.promise = p1;
437
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
439
- child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
438
+ child.stdin.write('Get-Volume | Select-Object -Property DriveLetter,FileSystemLabel,FileSystemType,Size,SizeRemaining,DriveType | ConvertTo-Csv -NoTypeInformation\r\nexit\r\n');
439
child.on('exit', function (c)
440
{
441
var a, i, tokens, key;
@@ -467,13 +466,12 @@ function windows_volumes()
466
var ret = j.r;
467
var tokens = j.t;
468
470
- var cmd = '"Get-BitLockerVolume | Select-Object -Property MountPoint,VolumeStatus,ProtectionStatus | ConvertTo-Csv -NoTypeInformation"';
471
- var child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', cmd]);
469
+ var child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-']);
470
p2.child = child;
471
child.promise = p2;
472
child.tokens = tokens;
473
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
476
- child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
474
+ child.stdin.write('Get-BitLockerVolume | Select-Object -Property MountPoint,VolumeStatus,ProtectionStatus | ConvertTo-Csv -NoTypeInformation\r\nexit\r\n');
475
child.on('exit', function ()
476
{
477
var i;
@@ -488,7 +486,7 @@ function windows_volumes()
486
ret[key].protectionStatus = tokens[2].split('"')[1];
487
try {
488
var foundIDMarkedLine = false, foundMarkedLine = false, identifier = '', password = '';
491
- var keychild = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ['cmd', '/c', 'manage-bde -protectors -get ', tokens[0].split('"')[1], ' -Type recoverypassword'], {});
489
+ var keychild = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ['/c', 'manage-bde -protectors -get ', tokens[0].split('"')[1], ' -Type recoverypassword'], {});
490
keychild.stdout.str = ''; keychild.stdout.on('data', function (c) { this.str += c.toString(); });
491
keychild.waitExit();
492
var lines = keychild.stdout.str.trim().split('\r\n');
@@ -803,12 +801,13 @@ function hexToAscii(hexString) {
801
function win_chassisType()
802
{
803
// needs to be replaced with win-wmi but due to bug in win-wmi it doesnt handle arrays correctly
806
- var cmd = '"Get-CimInstance Win32_SystemEnclosure | Select-Object -ExpandProperty ChassisTypes"';
807
- var child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', cmd], {});
804
+ var child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-'], {});
805
if (child == null) { return ([]); }
806
child.descriptorMetadata = 'process-manager';
807
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
808
child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
809
+ child.stdin.write('Get-CimInstance Win32_SystemEnclosure| Select-Object -ExpandProperty ChassisTypes\r\n');
810
+ child.stdin.write('exit\r\n');
811
child.waitExit();
812
try {
813
return (parseInt(child.stdout.str));
agents/modules_meshcore/win-info.js
+3
-2
@@ -243,11 +243,12 @@ function installedApps()
243
function defender(){
244
var promise = require('promise');
245
var ret = new promise(function (a, r) { this._resolve = a; this._reject = r; });
246
- var cmd = '"Get-MpComputerStatus | Select-Object RealTimeProtectionEnabled,IsTamperProtected | ConvertTo-JSON"';
247
- ret.child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', cmd], {});
246
+ ret.child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-'], {});
247
ret.child.promise = ret;
248
ret.child.stdout.str = ''; ret.child.stdout.on('data', function (c) { this.str += c.toString(); });
249
ret.child.stderr.str = ''; ret.child.stderr.on('data', function (c) { this.str += c.toString(); });
250
+ ret.child.stdin.write('Get-MpComputerStatus | Select-Object RealTimeProtectionEnabled,IsTamperProtected | ConvertTo-JSON\r\n');
251
+ ret.child.stdin.write('exit\r\n');
252
ret.child.on('exit', function (c) {
253
if (this.stdout.str == '') { this.promise._resolve({}); return; }
254
var abc = JSON.parse(this.stdout.str.trim())
agents/recoverycore.js
+1
-1
@@ -870,7 +870,7 @@ function onTunnelControlData(data, ws) {
870
if (process.platform == 'win32') {
871
MeshServerLog("Locking remote user out of desktop", ws.httprequest);
872
var child = require('child_process');
873
- child.execFile(process.env['windir'] + '\\system32\\cmd.exe', ['cmd', '/c', 'RunDll32.exe user32.dll,LockWorkStation'], { type: 1 });
873
+ child.execFile(process.env['windir'] + '\\system32\\cmd.exe', ['/c', 'RunDll32.exe user32.dll,LockWorkStation'], { type: 1 });
874
}
875
} catch (e) { }
876
break;