From ee51814650befb752e3de2d3617f9668218ce8b8 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 13 May 2020 17:02:07 +0200 Subject: [PATCH] fixes --- pandora_server/lib/PandoraFMS/DiscoveryServer.pm | 11 ++++++++--- pandora_server/lib/PandoraFMS/Recon/Base.pm | 13 ++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index ef08977ffb..cfaf91b69a 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -551,7 +551,12 @@ sub PandoraFMS::Recon::Base::test_module($$) { # Remote command. return 0 unless $self->rcmd_responds($addr); - my $target_os = pandora_get_os($self->{'dbh'}, $test->{'custom_string_2'}); + my $target_os; + if ($test->{'custom_string_2'} =~ /inherited/i) { + $target_os = $self->{'os_cache'}{$test->{'ip_target'}}; + } else { + $target_os = $test->{'custom_string_2'}; + } $value = enterprise_hook( 'remote_execution_module', @@ -566,8 +571,8 @@ sub PandoraFMS::Recon::Base::test_module($$) { $target_os, # ip_target, $test->{'ip_target'}, - # tcp_port - $test->{'tcp_port'} + # tcp_send + $test->{'tcp_send'} ] ); diff --git a/pandora_server/lib/PandoraFMS/Recon/Base.pm b/pandora_server/lib/PandoraFMS/Recon/Base.pm index a1b17ce383..2e54650f7c 100644 --- a/pandora_server/lib/PandoraFMS/Recon/Base.pm +++ b/pandora_server/lib/PandoraFMS/Recon/Base.pm @@ -2324,9 +2324,12 @@ sub rcmd_credentials_calculation { return undef; } - my $id_os = $self->call('guess_os', $target, 1); + my $os = $self->{'os_cache'}{$target}; + $os = $self->call('guess_os', $target, 1) if is_empty($os); $rcmd->set_host($target); - $rcmd->set_os($id_os); + $rcmd->set_os($os); + + $self->{'os_cache'}{$target} = $os; # Test all credentials selected. foreach my $key_index (@{$self->{'auth_strings_array'}}) { @@ -2363,10 +2366,10 @@ sub rcmd_credentials_calculation { chomp($result); my $out = ''; $out = $result if !is_empty($result); - $self->call('message', "Trying [".$key_index."] in [". $target."] [".$id_os."]: [$out]", 10); + $self->call('message', "Trying [".$key_index."] in [". $target."] [".$os."]: [$out]", 10); }; if ($@) { - $self->call('message', "Failed while trying [".$key_index."] in [". $target."] [".$id_os."]:" . @_, 10); + $self->call('message', "Failed while trying [".$key_index."] in [". $target."] [".$os."]:" . @_, 10); } if (!is_empty($result) && $result == "1") { @@ -2377,7 +2380,7 @@ sub rcmd_credentials_calculation { $self->call('message', "RCMD available for $target", 10); return 1; } else { - $self->call('message', "Last error ($target|$id_os|$result) was [".$rcmd->get_last_error()."]", 10); + $self->call('message', "Last error ($target|$os|$result) was [".$rcmd->get_last_error()."]", 10); } }