more wmic replacements
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
parent
0ec8b061c8
commit
b39235643e
|
@ -3885,7 +3885,7 @@ function processConsoleCommand(cmd, args, rights, sessionid) {
|
||||||
if (bcdOK()) { availcommands += ',safemode'; }
|
if (bcdOK()) { availcommands += ',safemode'; }
|
||||||
if (require('notifybar-desktop').DefaultPinned != null) { availcommands += ',privacybar'; }
|
if (require('notifybar-desktop').DefaultPinned != null) { availcommands += ',privacybar'; }
|
||||||
try { require('win-utils'); availcommands += ',taskbar'; } catch (ex) { }
|
try { require('win-utils'); availcommands += ',taskbar'; } catch (ex) { }
|
||||||
try { require('win-info'); availcommands += ',installedapps'; } catch (ex) { }
|
try { require('win-info'); availcommands += ',installedapps,qfe'; } catch (ex) { }
|
||||||
}
|
}
|
||||||
if (amt != null) { availcommands += ',amt,amtconfig,amtevents'; }
|
if (amt != null) { availcommands += ',amt,amtconfig,amtevents'; }
|
||||||
if (process.platform != 'freebsd') { availcommands += ',vm'; }
|
if (process.platform != 'freebsd') { availcommands += ',vm'; }
|
||||||
|
@ -5329,6 +5329,13 @@ function processConsoleCommand(cmd, args, rights, sessionid) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'qfe': {
|
||||||
|
if(process.platform == 'win32'){
|
||||||
|
var qfe = require('win-info').qfe();
|
||||||
|
sendConsoleText(JSON.stringify(qfe,null,1));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: { // This is an unknown command, return an error message
|
default: { // This is an unknown command, return an error message
|
||||||
response = "Unknown command \"" + cmd + "\", type \"help\" for list of available commands.";
|
response = "Unknown command \"" + cmd + "\", type \"help\" for list of available commands.";
|
||||||
break;
|
break;
|
||||||
|
@ -5597,8 +5604,8 @@ function windows_execve(name, agentfilename, sessionid) {
|
||||||
var cmd = require('_GenericMarshal').CreateVariable(process.env['windir'] + '\\system32\\cmd.exe', { wide: true });
|
var cmd = require('_GenericMarshal').CreateVariable(process.env['windir'] + '\\system32\\cmd.exe', { wide: true });
|
||||||
var args = require('_GenericMarshal').CreateVariable(3 * require('_GenericMarshal').PointerSize);
|
var args = require('_GenericMarshal').CreateVariable(3 * require('_GenericMarshal').PointerSize);
|
||||||
var arg1 = require('_GenericMarshal').CreateVariable('cmd.exe', { wide: true });
|
var arg1 = require('_GenericMarshal').CreateVariable('cmd.exe', { wide: true });
|
||||||
var arg2 = require('_GenericMarshal').CreateVariable('/C wmic service "' + name + '" call stopservice & "' + process.cwd() + agentfilename + '.update.exe" -b64exec ' + 'dHJ5CnsKICAgIHZhciBzZXJ2aWNlTG9jYXRpb24gPSBwcm9jZXNzLmFyZ3YucG9wKCkudG9Mb3dlckNhc2UoKTsKICAgIHJlcXVpcmUoJ3Byb2Nlc3MtbWFuYWdlcicpLmVudW1lcmF0ZVByb2Nlc3NlcygpLnRoZW4oZnVuY3Rpb24gKHByb2MpCiAgICB7CiAgICAgICAgZm9yICh2YXIgcCBpbiBwcm9jKQogICAgICAgIHsKICAgICAgICAgICAgaWYgKHByb2NbcF0ucGF0aCAmJiAocHJvY1twXS5wYXRoLnRvTG93ZXJDYXNlKCkgPT0gc2VydmljZUxvY2F0aW9uKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgcHJvY2Vzcy5raWxsKHByb2NbcF0ucGlkKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBwcm9jZXNzLmV4aXQoKTsKICAgIH0pOwp9CmNhdGNoIChlKQp7CiAgICBwcm9jZXNzLmV4aXQoKTsKfQ==' +
|
var arg2 = require('_GenericMarshal').CreateVariable('/C net stop "' + name + '" & "' + process.cwd() + agentfilename + '.update.exe" -b64exec ' + 'dHJ5CnsKICAgIHZhciBzZXJ2aWNlTG9jYXRpb24gPSBwcm9jZXNzLmFyZ3YucG9wKCkudG9Mb3dlckNhc2UoKTsKICAgIHJlcXVpcmUoJ3Byb2Nlc3MtbWFuYWdlcicpLmVudW1lcmF0ZVByb2Nlc3NlcygpLnRoZW4oZnVuY3Rpb24gKHByb2MpCiAgICB7CiAgICAgICAgZm9yICh2YXIgcCBpbiBwcm9jKQogICAgICAgIHsKICAgICAgICAgICAgaWYgKHByb2NbcF0ucGF0aCAmJiAocHJvY1twXS5wYXRoLnRvTG93ZXJDYXNlKCkgPT0gc2VydmljZUxvY2F0aW9uKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgcHJvY2Vzcy5raWxsKHByb2NbcF0ucGlkKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBwcm9jZXNzLmV4aXQoKTsKICAgIH0pOwp9CmNhdGNoIChlKQp7CiAgICBwcm9jZXNzLmV4aXQoKTsKfQ==' +
|
||||||
' "' + process.execPath + '" & copy "' + process.cwd() + agentfilename + '.update.exe" "' + process.execPath + '" & wmic service "' + name + '" call startservice & erase "' + process.cwd() + agentfilename + '.update.exe"', { wide: true });
|
' "' + process.execPath + '" & copy "' + process.cwd() + agentfilename + '.update.exe" "' + process.execPath + '" & net start "' + name + '" & erase "' + process.cwd() + agentfilename + '.update.exe"', { wide: true });
|
||||||
|
|
||||||
arg1.pointerBuffer().copy(args.toBuffer());
|
arg1.pointerBuffer().copy(args.toBuffer());
|
||||||
arg2.pointerBuffer().copy(args.toBuffer(), require('_GenericMarshal').PointerSize);
|
arg2.pointerBuffer().copy(args.toBuffer(), require('_GenericMarshal').PointerSize);
|
||||||
|
|
|
@ -225,19 +225,14 @@ function macos_memUtilization()
|
||||||
function windows_thermals()
|
function windows_thermals()
|
||||||
{
|
{
|
||||||
var ret = [];
|
var ret = [];
|
||||||
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', '/namespace:\\\\root\\wmi', 'PATH', 'MSAcpi_ThermalZoneTemperature', 'get', 'CurrentTemperature']);
|
try {
|
||||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
ret = require('win-wmi').query('ROOT\\WMI', 'SELECT CurrentTemperature,InstanceName FROM MSAcpi_ThermalZoneTemperature',['CurrentTemperature','InstanceName']);
|
||||||
child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
|
if (ret[0]) {
|
||||||
child.waitExit();
|
for (var i = 0; i < ret.length; ++i) {
|
||||||
|
ret[i]['CurrentTemperature'] = ((parseFloat(ret[i]['CurrentTemperature']) / 10) - 273.15).toFixed(2);
|
||||||
if(child.stdout.str.trim!='')
|
}
|
||||||
{
|
|
||||||
var lines = child.stdout.str.trim().split('\r\n');
|
|
||||||
for (var i = 1; i < lines.length; ++i)
|
|
||||||
{
|
|
||||||
if (lines[i].trim() != '') { ret.push(((parseFloat(lines[i]) / 10) - 273.15).toFixed(2)); }
|
|
||||||
}
|
}
|
||||||
}
|
} catch (ex) { }
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -800,32 +800,35 @@ function hexToAscii(hexString) {
|
||||||
|
|
||||||
function win_chassisType()
|
function win_chassisType()
|
||||||
{
|
{
|
||||||
var child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'SystemEnclosure', 'get', 'ChassisTypes']);
|
// needs to be replaced with win-wmi but due to bug in win-wmi it doesnt handle arrays correctly
|
||||||
|
var child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-'], {});
|
||||||
|
if (child == null) { return ([]); }
|
||||||
|
child.descriptorMetadata = 'process-manager';
|
||||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||||
child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
|
child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
|
||||||
|
child.stdin.write('Get-CimInstance Win32_SystemEnclosure| Select-Object -ExpandProperty ChassisTypes\r\n');
|
||||||
|
child.stdin.write('exit\r\n');
|
||||||
child.waitExit();
|
child.waitExit();
|
||||||
|
try {
|
||||||
try
|
return (parseInt(child.stdout.str));
|
||||||
{
|
} catch (e) {
|
||||||
var tok = child.stdout.str.split('{')[1].split('}')[0];
|
|
||||||
var val = tok.split(',')[0];
|
|
||||||
return (parseInt(val));
|
|
||||||
}
|
|
||||||
catch (e)
|
|
||||||
{
|
|
||||||
return (2); // unknown
|
return (2); // unknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function win_systemType()
|
function win_systemType()
|
||||||
{
|
{
|
||||||
var CSV = '/FORMAT:"' + require('util-language').wmicXslPath + 'csv"';
|
try {
|
||||||
var child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'ComputerSystem', 'get', 'PCSystemType', CSV]);
|
var tokens = require('win-wmi').query('ROOT\\CIMV2', 'SELECT PCSystemType FROM Win32_ComputerSystem', ['PCSystemType']);
|
||||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
if (tokens[0]) {
|
||||||
child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
|
return (parseInt(tokens[0]['PCSystemType']));
|
||||||
child.waitExit();
|
} else {
|
||||||
|
return (parseInt(1)); // default is desktop
|
||||||
|
}
|
||||||
|
} catch (ex) {
|
||||||
|
return (parseInt(1)); // default is desktop
|
||||||
|
}
|
||||||
|
|
||||||
return (parseInt(child.stdout.str.trim().split(',').pop()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function win_formFactor(chassistype)
|
function win_formFactor(chassistype)
|
||||||
|
|
|
@ -229,25 +229,14 @@ function macos_memUtilization()
|
||||||
function windows_thermals()
|
function windows_thermals()
|
||||||
{
|
{
|
||||||
var ret = [];
|
var ret = [];
|
||||||
child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', '/namespace:\\\\root\\wmi', 'PATH', 'MSAcpi_ThermalZoneTemperature', 'get', 'CurrentTemperature,InstanceName', '/FORMAT:CSV']);
|
try {
|
||||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
ret = require('win-wmi').query('ROOT\\WMI', 'SELECT CurrentTemperature,InstanceName FROM MSAcpi_ThermalZoneTemperature',['CurrentTemperature','InstanceName']);
|
||||||
child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
|
if (ret[0]) {
|
||||||
child.waitExit();
|
for (var i = 0; i < ret.length; ++i) {
|
||||||
if(child.stdout.str.trim()!='')
|
ret[i]['CurrentTemperature'] = ((parseFloat(ret[i]['CurrentTemperature']) / 10) - 273.15).toFixed(2);
|
||||||
{
|
|
||||||
var lines = child.stdout.str.trim().split('\r\n');
|
|
||||||
var keys = lines[0].trim().split(',');
|
|
||||||
for (var i = 1; i < lines.length; ++i)
|
|
||||||
{
|
|
||||||
var obj = {};
|
|
||||||
var tokens = lines[i].trim().split(',');
|
|
||||||
for (var key = 0; key < keys.length; ++key)
|
|
||||||
{
|
|
||||||
if (tokens[key]) { obj[keys[key]] = key==1 ? ((parseFloat(tokens[key]) / 10) - 273.15).toFixed(2) : tokens[key]; }
|
|
||||||
}
|
}
|
||||||
ret.push(obj);
|
|
||||||
}
|
}
|
||||||
}
|
} catch (ex) { }
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,28 +18,21 @@ var promise = require('promise');
|
||||||
|
|
||||||
function qfe()
|
function qfe()
|
||||||
{
|
{
|
||||||
var child = require('child_process').execFile(process.env['windir'] + '\\System32\\wbem\\wmic.exe', ['wmic', 'qfe', 'list', 'full', '/FORMAT:CSV']);
|
try {
|
||||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
var tokens = require('win-wmi').query('ROOT\\CIMV2', 'SELECT * FROM Win32_QuickFixEngineering');
|
||||||
child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
|
if (tokens[0]){
|
||||||
child.waitExit();
|
for (var index = 0; index < tokens.length; index++) {
|
||||||
|
for (var key in tokens[index]) {
|
||||||
var lines = child.stdout.str.trim().split('\r\n');
|
if (key.startsWith('__')) delete tokens[index][key];
|
||||||
var keys = lines[0].split(',');
|
}
|
||||||
var i, key;
|
}
|
||||||
var tokens;
|
return (tokens);
|
||||||
var result = [];
|
} else {
|
||||||
|
return ([]);
|
||||||
for (i = 1; i < lines.length; ++i)
|
|
||||||
{
|
|
||||||
var obj = {};
|
|
||||||
tokens = lines[i].split(',');
|
|
||||||
for (key = 0; key < keys.length; ++key)
|
|
||||||
{
|
|
||||||
if (tokens[key]) { obj[keys[key]] = tokens[key]; }
|
|
||||||
}
|
}
|
||||||
result.push(obj);
|
} catch (ex) {
|
||||||
|
return ([]);
|
||||||
}
|
}
|
||||||
return (result);
|
|
||||||
}
|
}
|
||||||
function av()
|
function av()
|
||||||
{
|
{
|
||||||
|
|
|
@ -485,8 +485,8 @@ function windows_execve(name, agentfilename, sessionid) {
|
||||||
var cmd = require('_GenericMarshal').CreateVariable(process.env['windir'] + '\\system32\\cmd.exe', { wide: true });
|
var cmd = require('_GenericMarshal').CreateVariable(process.env['windir'] + '\\system32\\cmd.exe', { wide: true });
|
||||||
var args = require('_GenericMarshal').CreateVariable(3 * require('_GenericMarshal').PointerSize);
|
var args = require('_GenericMarshal').CreateVariable(3 * require('_GenericMarshal').PointerSize);
|
||||||
var arg1 = require('_GenericMarshal').CreateVariable('cmd.exe', { wide: true });
|
var arg1 = require('_GenericMarshal').CreateVariable('cmd.exe', { wide: true });
|
||||||
var arg2 = require('_GenericMarshal').CreateVariable('/C wmic service "' + name + '" call stopservice & "' + cwd + agentfilename + '.update.exe" -b64exec ' + 'dHJ5CnsKICAgIHZhciBzZXJ2aWNlTG9jYXRpb24gPSBwcm9jZXNzLmFyZ3YucG9wKCkudG9Mb3dlckNhc2UoKTsKICAgIHJlcXVpcmUoJ3Byb2Nlc3MtbWFuYWdlcicpLmVudW1lcmF0ZVByb2Nlc3NlcygpLnRoZW4oZnVuY3Rpb24gKHByb2MpCiAgICB7CiAgICAgICAgZm9yICh2YXIgcCBpbiBwcm9jKQogICAgICAgIHsKICAgICAgICAgICAgaWYgKHByb2NbcF0ucGF0aCAmJiAocHJvY1twXS5wYXRoLnRvTG93ZXJDYXNlKCkgPT0gc2VydmljZUxvY2F0aW9uKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgcHJvY2Vzcy5raWxsKHByb2NbcF0ucGlkKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBwcm9jZXNzLmV4aXQoKTsKICAgIH0pOwp9CmNhdGNoIChlKQp7CiAgICBwcm9jZXNzLmV4aXQoKTsKfQ==' +
|
var arg2 = require('_GenericMarshal').CreateVariable('/C net stop "' + name + '" & "' + cwd + agentfilename + '.update.exe" -b64exec ' + 'dHJ5CnsKICAgIHZhciBzZXJ2aWNlTG9jYXRpb24gPSBwcm9jZXNzLmFyZ3YucG9wKCkudG9Mb3dlckNhc2UoKTsKICAgIHJlcXVpcmUoJ3Byb2Nlc3MtbWFuYWdlcicpLmVudW1lcmF0ZVByb2Nlc3NlcygpLnRoZW4oZnVuY3Rpb24gKHByb2MpCiAgICB7CiAgICAgICAgZm9yICh2YXIgcCBpbiBwcm9jKQogICAgICAgIHsKICAgICAgICAgICAgaWYgKHByb2NbcF0ucGF0aCAmJiAocHJvY1twXS5wYXRoLnRvTG93ZXJDYXNlKCkgPT0gc2VydmljZUxvY2F0aW9uKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgcHJvY2Vzcy5raWxsKHByb2NbcF0ucGlkKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBwcm9jZXNzLmV4aXQoKTsKICAgIH0pOwp9CmNhdGNoIChlKQp7CiAgICBwcm9jZXNzLmV4aXQoKTsKfQ==' +
|
||||||
' "' + process.execPath + '" & copy "' + cwd + agentfilename + '.update.exe" "' + process.execPath + '" & wmic service "' + name + '" call startservice & erase "' + cwd + agentfilename + '.update.exe"', { wide: true });
|
' "' + process.execPath + '" & copy "' + cwd + agentfilename + '.update.exe" "' + process.execPath + '" & net start "' + name + '" & erase "' + cwd + agentfilename + '.update.exe"', { wide: true });
|
||||||
|
|
||||||
if (name == null)
|
if (name == null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue