Skip to content

Commit

Permalink
Catch a couple of potential issues on Windows when Apache user not se…
Browse files Browse the repository at this point in the history
…t correctly.
  • Loading branch information
mark-unwin committed Dec 12, 2023
1 parent 0ea8337 commit 3d9a76b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/Helpers/discoveries_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ function all_ip_list($discovery = null)
}
}
} else {
if (php_uname('s') === 'Windows NT' and empty($output)) {
log_message('error', 'No response from Nmap. Is the Apache Service running as a normal user?');
}
$discoveryLogModel->create($log);
return false;
}
Expand Down Expand Up @@ -101,6 +104,9 @@ function responding_ip_list($discovery = null)
}
}
} else {
if (php_uname('s') === 'Windows NT' and empty($output)) {
log_message('error', 'No response from Nmap. Is the Apache Service running as a normal user?');
}
$log->command_output = json_encode($output);
$discoveryLogModel->create($log);
return false;
Expand Down Expand Up @@ -144,6 +150,9 @@ function responding_ip_list($discovery = null)
*/
function update_non_responding($discovery_id = 0, $all_ip_list = array(), $responding_ip_list = array())
{
if (!is_array($all_ip_list)) {
return;
}
$discoveryLogModel = new \App\Models\DiscoveryLogModel();
$instance = & get_instance();
$db = db_connect();
Expand Down Expand Up @@ -191,7 +200,9 @@ function queue_responding($discovery_id = 0, $responding_ip_list = array())
$log->file = 'discoveries_helper';
$log->function = 'update_responding';
$log->command_status = 'notice';

if (!is_array($responding_ip_list)) {
return;
}
foreach ($responding_ip_list as $key => $ip) {
$item = new \StdClass();
$item->ip = $ip;
Expand Down Expand Up @@ -281,7 +292,7 @@ function discover_subnet($queue_item = null)
$discoveryLogModel->create($log);
} else {
$all_ip_list = all_ip_list($discovery);
$count = @count($all_ip_list);
$count = (!empty($all_ip_list)) ? count($all_ip_list) : 0;
$log->command_status = 'notice';
if ($discovery->scan_options->ping === 'n') {
$log->message = 'Ping response not required, assuming all ' . $count . ' IP addresses are up.';
Expand Down

0 comments on commit 3d9a76b

Please sign in to comment.