Added control for WMI binary

This commit is contained in:
José González 2022-05-12 18:31:24 +02:00
parent 8dd959c306
commit 4589a7c298
4 changed files with 34 additions and 8 deletions

View File

@ -661,6 +661,16 @@ $tip = ui_print_help_tip(
true
);
$table_other->data[$i][0] = __('WMI binary');
$table_other->data[$i++][1] = html_print_input_text(
'wmiBinary',
$config['wmiBinary'],
'',
50,
10,
true
);
if (enterprise_installed() === true) {
$table_other->data[$i][0] = __('PhantomJS cache cleanup ').$tip;
$table_other->data[$i++][1] = html_print_input(

View File

@ -278,6 +278,13 @@ class AgentWizard extends HTML
*/
private $extraArguments = '';
/**
* Binary of wmic.
*
* @var string
*/
private $wmiBinary = '';
/**
* Constructor
@ -291,7 +298,7 @@ class AgentWizard extends HTML
// Check access.
check_login();
if (!check_acl($config['id_user'], 0, 'AR')) {
if ((bool) check_acl($config['id_user'], 0, 'AR') === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access event viewer'
@ -311,6 +318,7 @@ class AgentWizard extends HTML
$this->idAgent = get_parameter('id_agente', '');
$this->idPolicy = get_parameter('id', '');
$this->targetIp = get_parameter('targetIp', '');
$this->wmiBinary = $config['wmiBinary'];
if (empty($this->idAgent) === false) {
$array_aux = db_get_all_rows_sql(
@ -1044,7 +1052,7 @@ class AgentWizard extends HTML
$oidExplore = '.1.3.6.1.2.1.1.2.0';
}
// Explore general or interfaces
// Explore general or interfaces.
$receivedOid = $this->snmpWalkValues(
$oidExplore,
false,
@ -1080,7 +1088,7 @@ class AgentWizard extends HTML
// Capture the parameters.
// Call WMI Explorer function.
$this->wmiCommand = wmi_compose_query(
'wmic',
$this->wmiBinary,
$this->usernameWMI,
$this->passwordWMI,
$this->targetIp,
@ -5717,7 +5725,7 @@ class AgentWizard extends HTML
$(this).removeClass('hidden');
return;
}
if (this.id.match(regex)) {
$(this).removeClass('hidden');
} else {
@ -5729,7 +5737,7 @@ class AgentWizard extends HTML
$(this).addClass('hidden');
}
}
if (filter_up == true) {
if ($(this).attr('operstatus') != 1) {
$(this).addClass('hidden');

View File

@ -928,6 +928,10 @@ function config_update_config()
$error_update[] = __('SNMP walk binary path (fallback for v1)');
}
if (config_update_value('wmiBinary', get_parameter('wmiBinary'), true) === false) {
$error_update[] = __('Default WMI Binary');
}
$pjs = get_parameter('phantomjs_cache_interval');
switch ($pjs) {
case $config['phantomjs_cache_interval']:
@ -2088,6 +2092,10 @@ function config_process_config()
config_update_value('snmpwalk_fallback', 'snmpwalk');
}
if (isset($config['wmiBinary']) === false) {
config_update_value('wmiBinary', 'pandorawmic');
}
if (!isset($config['event_purge'])) {
config_update_value('event_purge', 15);
}

View File

@ -32,13 +32,13 @@ function wmi_compose_query($wmi_client, $user, $password, $host, $namespace='')
{
$wmi_command = '';
if (!empty($password)) {
$wmi_command = $wmi_client.' -U "'.$user.'"%"'.$password.'"';
if (empty($password) === false) {
$wmi_command = $wmi_client.' -U \''.$user.'\'%\''.$password.'\'';
} else {
$wmi_command = $wmi_client.' -U "'.$user.'"';
}
if (!empty($namespace)) {
if (empty($namespace) === false) {
$namespace = str_replace('"', "'", $namespace);
$wmi_command .= ' --namespace="'.$namespace.'"';
}