redirectUser($location); // any other error requires no special handling and will be caught outside break; case 'popup' == $_REQUEST['module']: require_once 'inc/popup.php'; require_once 'inc/init.php'; renderPopupHTML(); break; case 'upgrade' == $_REQUEST['module']: require_once 'inc/config.php'; // for CODE_VERSION require_once 'inc/dictionary.php'; require_once 'inc/functions.php'; // for ip translation functions require_once 'inc/upgrade.php'; renderUpgraderHTML(); break; case 'installer' == $_REQUEST['module']: require_once 'inc/dictionary.php'; require_once 'inc/config.php'; require_once 'inc/install.php'; renderInstallerHTML(); break; default: throw new InvalidRequestArgException('module', $_REQUEST['module']); } ob_end_flush(); } catch (Exception $e) { ob_end_clean(); printException($e); }
/** * Override the global exception handler with more useful behavior. * * If `$debug` is true, then unhandled exceptions will cause the script to * print a stack trace and then exit. If `$debug` is false, then the script * will exit silently. * * @param bool $debug Whether to display stack traces. */ function overrideExceptionHandler($debug = true) { if ($debug) { set_exception_handler(function ($e) { printException($e); exit(1); }); } else { set_exception_handler(function () { exit(1); }); } }
function origdetails() { global $uroles, $user, $sid, $query_risk, $border, $report_id, $scantime, $scantype, $fp, $nfp, $filterip, $enableFP, $enableNotes, $enableException, $output, $sortby, $dbconn, $arruser; global $treport, $ipl, $query_byuser, $ips_inrange; $enableException = 0; $colors = array("Serious" => "#FFCDFF", "High" => "#FFDBDB", "Medium" => "#FFF283", "Low" => "#FFFFC0", "Info" => "#FFFFE3"); $images = array("Serious" => "./images/risk7.gif", "High" => "./images/risk6.gif", "Medium" => "./images/risk3.gif", "Low" => "./images/risk2.gif", "Info" => "./images/risk1.gif"); $levels = array("Serious" => "1", "High" => "2", "Medium" => "3", "Low" => "6", "Info" => "7"); $query_host = ""; if ($filterip) { $query_host = " AND hostip='{$filterip}'"; } echo "<center>"; echo "<form>"; echo "<table width=\"900\" class=\"noborder\" style=\"background:transparent;\">"; echo "<tr><td style=\"text-align:left;\" class=\"nobborder\">"; echo "<input id=\"checkboxFP\" type=\"checkbox\" onclick=\"showFalsePositives()\"> <span style=\"color:black\">" . _("View false positives") . "</span>"; echo "</td><td class=\"nobborder\" style=\"text-align:center;\">"; // print the icon legend if ($enableFP) { echo "<img alt='True' src='images/true.gif' border=0 align='absmiddle'> - " . _("True result") . " "; echo "<img alt='False' src='images/false.png' border=0 align='absmiddle'> - " . _("False positive result") . " "; } if ($enableNotes) { echo "<img alt='Note' src='images/note.png' border=0 align='absmiddle'> - " . _("Add a custom note") . " "; } echo "<img alt='Info' src='images/info.png' border=0 align='absmiddle'> - " . _("Additional information is available"); echo "</td></tr></table>"; echo "</form>"; echo "<br>"; //$query ="select distinct hostip, hostname from vuln_nessus_results where report_id='$report_id' $query_host order by INET_ATON(hostip) ASC"; if ($ipl == "all") { $query = "SELECT distinct t1.hostip, t2.hostname\n FROM vuln_nessus_latest_results t1\n LEFT JOIN host t2 on t1.hostip = t2.ip " . (in_array("admin", $arruser) ? "" : "WHERE username in ('{$user}') ") . "ORDER BY hostip ASC"; } else { $query = "SELECT distinct t1.hostip, t2.hostname\n FROM " . ($treport == "latest" || $ipl != "" ? "vuln_nessus_latest_results" : "vuln_nessus_results") . " t1\n LEFT JOIN host t2 on t1.hostip = t2.ip\n WHERE report_id in ({$report_id}) " . ($treport == "latest" || $ip != "" ? " and sid in ({$sid})" : " ") . " {$query_host}" . (!in_array("admin", $arruser) && ($treport == "latest" || $ipl != "") ? " AND username in ('{$user}') " : " ") . "ORDER BY INET_ATON(hostip) ASC"; } $resultp = $dbconn->execute($query); $host_range = array_keys($ips_inrange); while (list($hostip, $hostname) = $resultp->fields) { if ($hostname == "") { $hostname = "unknown"; } if (in_array($hostip, $host_range)) { if ($output == "min") { echo "<h3>" . _("Details for Serious, High, Medium and Medium/Low severity risks only") . ".</h3>"; } echo "<div class='hostip'>"; echo <<<EOT <br><font color="red"><b><a name="{$hostip}">{$hostip} - {$hostname}</a></b></font> EOT; echo "<table summary=\"{$hostip} - " . _("Reported Ports") . "\">"; echo "<tr><th colspan=2>" . _("Reported Ports") . "</th></tr>"; // get the "open ports" this replaced an approroacj requiring risk 7 and an empty msg cell if ($ipl == "all") { $query = "SELECT DISTINCT `port` , `protocol` FROM vuln_nessus_latest_results \n \t\tWHERE hostip='{$hostip}' {$query_byuser} AND port > '0' ORDER BY port ASC"; } else { $query = "SELECT DISTINCT `port` , `protocol` FROM `" . ($treport == "latest" || $ipl != "" ? "vuln_nessus_latest_results" : "vuln_nessus_results") . "` \n \t\tWHERE report_id in ({$report_id})" . ($treport == "latest" || $ipl != "" ? " and sid in ({$sid})" : " ") . ($scantime != "" ? " AND scantime={$scantime}" : "") . (!in_array("admin", $arruser) && ($treport == "latest" || $ipl != "") ? " AND username in ('{$user}') " : " ") . " AND hostip='{$hostip}' AND port > '0' ORDER BY port ASC"; } $result1 = $dbconn->execute($query); //$arrResults=""; $k = 1; $pos = ""; if (!$result1->fields) { print "<tr><td>" . _("No reported ports found") . "</td></tr>"; } else { while (list($port, $proto) = $result1->fields) { if ($k % 2) { echo "<tr><td>{$port}/{$proto}</td>"; $pos = "open"; } else { echo "<td>{$port}/{$proto}</td></tr>"; $pos = "closed"; } $k++; $result1->MoveNext(); } // end while // close up the table if ($pos != "closed") { echo "<td> </td></tr>"; } } echo "</table><p></p>"; echo <<<EOT <table width="900" summary="{$hostip} - risks"> <tr> EOT; echo "<th>" . _("Vuln Name") . "</th>"; echo "<th>" . _("VulnID") . "</th>"; echo "<th>" . _("Service") . "</th>"; echo "<th>" . _("Severity") . "</th>"; echo "</tr>"; if ($ipl == "all") { $query = "select distinct 0, r.service, r.risk, r.falsepositive, r.scriptid, v.name, r.msg\n FROM vuln_nessus_latest_results as r\n LEFT JOIN vuln_nessus_plugins as v ON v.id=r.scriptid\n WHERE hostip='{$hostip}' {$query_byuser} and msg<>''"; /* $query_msg = "select r.msg from vuln_nessus_latest_results as r LEFT JOIN vuln_nessus_plugins as v ON v.id=r.scriptid WHERE hostip='$hostip' $query_byuser and msg<>'' ORDER BY r.scantime DESC LIMIT 0,1";*/ } else { if ($treport == "latest" || $ipl != "") { $query = "select distinct 0, r.service, r.risk, r.falsepositive, r.scriptid, v.name, r.msg\n FROM vuln_nessus_latest_results as r\n LEFT JOIN vuln_nessus_plugins as v ON v.id=r.scriptid\n WHERE report_id in ({$report_id}) and sid in ({$sid}) and hostip='{$hostip}' and msg<>''" . ($scantime != "" && $ipl == "" ? " AND scantime={$scantime}" : "") . (!in_array("admin", $arruser) && ($treport == "latest" || $ipl != "") ? " AND username in ('{$user}') " : ""); /* $query_msg = "select r.msg from vuln_nessus_latest_results as r LEFT JOIN vuln_nessus_plugins as v ON v.id=r.scriptid WHERE report_id in ($report_id) and sid in ($sid) and hostip='$hostip' and msg<>''". (($scantime!="" && $ipl=="")? " AND scantime=$scantime":""). ((!in_array("admin", $arruser) && ($treport=="latest" || $ipl!=""))? " AND username in ('$user') " : " ")."ORDER BY r.scantime DESC LIMIT 0,1";*/ } else { $query = "select distinct 0, t1.service, t1.risk, t1.falsepositive, t1.scriptid, v.name, t1.msg\n FROM vuln_nessus_results t1\n LEFT JOIN vuln_nessus_plugins as v ON v.id=t1.scriptid\n WHERE report_id in ({$report_id}) and hostip='{$hostip}' and msg<>''" . ($scantime != "" && $ipl == "" ? " AND scantime={$scantime}" : "") . (!in_array("admin", $arruser) && ($treport == "latest" || $ipl != "") ? " AND username in ('{$user}') " : ""); /* $query_msg = "select t1.msg from vuln_nessus_results t1 LEFT JOIN vuln_nessus_plugins as v ON v.id=t1.scriptid WHERE report_id in ($report_id) and hostip='$hostip' and msg<>''". (($scantime!="" && $ipl=="")? " AND scantime=$scantime":""). ((!in_array("admin", $arruser) && ($treport=="latest" || $ipl!=""))? " AND username in ('$user') " : " ")."ORDER BY t1.scantime DESC LIMIT 0,1";*/ } } //echo $scantime; //echo "bucle:$query"; // for minimized output, don't include risk=[5|6|7] if ($output == "min") { $query .= " and risk NOT IN( '7', '6', '5')"; } $query .= " order by risk"; $result1 = $dbconn->execute($query); $arrResults = ""; while (list($result_id, $service, $risk, $falsepositive, $scriptid, $pname, $msg) = $result1->fields) { //$msg = get_msg($dbconn,$query_msg); // to avoid same messages $tmpport1 = preg_split("/\\(|\\)/", $service); if (sizeof($tmpport1) == 1) { $tmpport1[1] = $tmpport1[0]; } #echo "$tmpport1[0] $tmpport1[1]<BR>"; $tmpport2 = preg_split("/\\//", $tmpport1[1]); #echo "$tmpport2[0] $tmpport2[1]<BR>"; $service_num = $tmpport2[0]; $service_proto = $tmpport2[1]; $arrResults[] = array($service_num, $service_proto, $service, $risk, $falsepositive, $result_id, $msg, $scriptid, $pname); $result1->MoveNext(); } if (!empty($arrResults)) { //uasort ($arrResults, 'arrScanResultsCompare'); } else { // empty, print out message echo "<td colspan='4'>" . _("No vulnerability results matching this reports \n filtering criteria were found") . ".</td></tr>"; } foreach ($arrResults as $key => $value) { list($service_num, $service_proto, $service, $risk, $falsepositive, $resid, $msg, $scriptid, $pname) = $value; // No need to do this anymore as the HTML entities are converted when // importing the results // $msg=htmlspecialchars($msg); // Print Notes associated with this result (resid) // modified to remove username filter - will tag the note with the // username which we now get in the results if ($enableNotes) { $query = "select note, username FROM nessus_notes WHERE pid={$scriptid} and resid = {$resid}"; $result_note = $dbconn->execute($query); //and username='******'"); //The next line breaks for upgrade installs //$notes=$result_note->GetArray(); if (!empty($result_note)) { $msg .= '<p><FONT COLOR="#0044FF"><B>' . _("Custom Notes") . ':</B>'; foreach ($result_note as $note_num => $customnote) { //list($customnote)=$result_note->fields; $note_num++; // do this as the index starts at 0 $msg .= "\n{$note_num}. [{$customnote['username']}] - {$customnote['note']}"; //$note_num++; //$result_note->MoveNext(); } $msg .= "</FONT></p>"; } } // end Print Notes $msg = preg_replace("/^[ \t]*/", "", $msg); $msg = preg_replace("/\n/", "<br>", $msg); // $tr = array("\\n" => "<br>"); // $msg=strtr($msg,$tr); //$msg=wordwrap(preg_replace("/\n/","<br>",$msg),100,"<br>",1); $msg = wordwrap($msg, 100, "<br>", 1); // Add Exceptions //if ($enableException && $risk <= 6) { if ($enableException) { $msg .= "<p><FONT COLOR='#0044FF'><b>" . _("Exceptions") . ":</b><br>"; if ($uroles['eview'] || $uroles['esubmit'] || $uroles['eapprove']) { $msg .= printException($hostip, $scriptid, $dbconn, FALSE, $hostname, $service_num, $sid); } //if ($esubmit) { // $msg .= addException($hostip,$resid,$scriptid,$schedid,$hostname); //} } // end Exceptions $tmprisk = getrisk($risk); $msg = preg_replace("/^\\<br\\>/i", "", str_replace("\\r", "", $msg)); $msg = preg_replace("/(Solution|Overview|Synopsis|Description|See also|Plugin output|References|Vulnerability Insight|Impact|Impact Level|Affected Software\\/OS|Fix|Information about this scan)\\s*:/", "<b>\\1:</b>", $msg); // output the table cells $ancla = $hostip . "_" . $levels[$tmprisk]; echo "<tr " . ($falsepositive == 'Y' ? "class=\"trsk risk{$risk} fp\"" : "class=\"trsk risk{$risk}\"") . "style=\"background-color:" . $colors[$tmprisk] . ($falsepositive == 'Y' ? ";display:none;" : "") . "\">"; //echo "<tr>"; echo "<td width=\"50%\" style=\"padding:3px 0px 3px 0px;\"><b>" . ($pname != "" ? $pname : _("No name")) . "</b></td>"; echo "<td style=\"padding:3px 0px 3px 0px;\">{$scriptid}</td>"; ?> <td style="padding:3px;" width="180"><?php echo $service; ?> </td> <td style="text-align:center;"> <?php echo $tmprisk; ?> <img align="absmiddle" src="<?php echo $images[$tmprisk]; ?> " style="border: 1px solid ; width: 25px; height: 10px;"> </td> </tr> <?php echo "<tr " . ($falsepositive == 'Y' ? "class=\"trsk risk{$risk} fp\"" : "class=\"trsk risk{$risk}\"") . "style=\"background-color:" . $colors[$tmprisk] . ($falsepositive == 'Y' ? ";display:none;" : "") . "\">"; ?> <td style="padding:3px 0px 3px 6px;text-align:left;"> <A class="msg" NAME="<?php echo $resid; ?> "></a><a name="<?php echo $ancla; ?> "></a> <?php echo $msg; ?> <font size="1"> <br><br> </font> <?php // Add info from osvdb echo " <a title=\"" . _("Info from OSVDB for vuln id ") . "{$scriptid}\" class=\"greybox\" href=\"osvdb_info.php?scriptid={$scriptid}\"><img src=\"images/osvdb.png\" border=\"0\"></a> "; // Add link to popup with Script Info echo <<<EOT <a href="javascript:;" lid="{$scriptid}" style="text-decoration:none;" class="scriptinfo"><img alt="Info" src="images/info.png" border=0></a> EOT; // Add Custom Notes icon // don't filter on username - any user can add a note to any result //if ($sql_uid==$user) { if ($enableNotes) { if ($output == "min") { echo <<<EOT <a href="notes.php?op=add&pid={$scriptid}&scantime={$scantime}&scantype={$scantype}&sortby={$sortby}&resid={$resid}&httpfrom=resmin" onClick="popup('notes.php?op=add&pid={$scriptid}&scantime={$scantime}&scantype={$scantype}&sortby={$sortby}&resid={$resid}&httpfrom=resmin','Notes'); return false;"><img alt="Note" src="images/note.png" title="Add note" border=0></a> EOT; } else { echo <<<EOT <a href="notes.php?op=add&pid={$scriptid}&scantime={$scantime}&scantype={$scantype}&sortby={$sortby}&resid={$resid}&httpfrom=results" onClick="popup('notes.php?op=add&pid={$scriptid}&scantime={$scantime}&scantype={$scantype}&sortby={$sortby}&resid={$resid}&httpfrom=results','Notes'); return false;"><img alt="Note" src="images/note.png" title="Add note" border=0></a> EOT; } } //} // Add False Positive Indicator/link if ($enableFP && ($sql_uid == $user || $uroles['admin'])) { /*if($ipl=="all"){ $query = "select result_id from vuln_nessus_latest_results WHERE hostip='$hostip' and service='$service' and risk=".$levels[$tmprisk]." and scriptid=$scriptid $query_byuser"; }*/ if ($ipl == "") { $list_result_ids = array(); $query = "select result_id from " . ($treport == "latest" || $ipl != "" ? "vuln_nessus_latest_results" : "vuln_nessus_results") . " \n WHERE report_id in ({$report_id})" . ($treport == "latest" || $ipl != "" ? " and sid in ({$sid})" : " ") . " and hostip='{$hostip}'\n and service='{$service}' and risk=" . $levels[$tmprisk] . " and scriptid={$scriptid}" . (!in_array("admin", $arruser) && ($treport == "latest" || $ipl != "") ? " AND username in ('{$user}') " : ""); $result = $dbconn->execute($query); while (!$result->EOF) { $list_result_ids[] = $result->fields["result_id"]; $result->MoveNext(); } $resid = base64_encode(implode(",", $list_result_ids)); } else { $resid = base64_encode("{$report_id};{$hostip};{$service};" . $levels[$tmprisk] . ";{$scriptid}"); } //print_r ($query); $tmpu = array(); $url = ""; foreach ($_GET as $kget => $vget) { if ($kget != "pluginid" && $kget != "nfp" && $kget != "fp") { $tmpu[] = "{$kget}={$vget}"; } } $url = implode("&", $tmpu); if ($falsepositive == "Y") { /* echo <<<EOT <a href="reshtml.php?$url&nfp=$resid&pluginid=$scriptid"> EOT;*/ echo <<<EOT <a href="reshtml.php?{$url}&nfp={$resid}"> EOT; echo "<img alt=\"" . _("Clear false positive") . "\" src=\"images/false.png\" title=\"" . _("Clear false positive") . "\" border=0></a>"; } else { /* echo <<<EOT <a href="reshtml.php?$url&fp=$resid&pluginid=$scriptid"> EOT;*/ echo <<<EOT <a href="reshtml.php?{$url}&fp={$resid}"> EOT; echo "<img alt=\"" . _("Mark as false positive") . "\" src=\"images/true.gif\" title=\"" . _("Mark as false positive") . "\" border=0></a>"; } } $pticket = "ref=Vulnerability&ip={$hostip}&port={$service_num}&nessus_id={$scriptid}&risk={$tmprisk}&type=Nessus Vulnerability"; echo " <a title=\"" . _("New ticket") . "\" class=\"greybox\" href=\"new_vuln_ticket.php?{$pticket}\"><img style=\"padding-bottom:2px;\" src=\"../pixmaps/incident.png\" border=\"0\" alt=\"i\" width=\"12\"></a> "; ?> </td> <?php $plugin_info = $dbconn->execute("SELECT t2.name, t3.name, t1.copyright, t1.summary, t1.version \n FROM vuln_nessus_plugins t1\n LEFT JOIN vuln_nessus_family t2 on t1.family=t2.id\n LEFT JOIN vuln_nessus_category t3 on t1.category=t3.id\n WHERE t1.id='{$scriptid}'"); list($pfamily, $pcategory, $pcopyright, $psummary, $pversion) = $plugin_info->fields; ?> <td colspan="3" valign="top" style="text-align:left;padding:3px;"> <?php $plugindetails = ""; if ($pfamily != "") { $plugindetails .= '<b>Family name:</b> ' . $pfamily . '<br><br>'; } if ($pcategory != "") { $plugindetails .= '<b>Category:</b> ' . $pcategory . '<br><br>'; } if ($pcopyright != "") { $plugindetails .= '<b>Copyright:</b> ' . $pcopyright . '<br><br>'; } if ($psummary != "") { $plugindetails .= '<b>Summary:</b> ' . $psummary . '<br><br>'; } if ($pversion != "") { $plugindetails .= '<b>Version:</b> ' . $pversion . '<br><br>'; } echo $plugindetails; ?> </td> </tr> <?php $result1->MoveNext(); } echo "</table>"; echo "</div>"; } $resultp->MoveNext(); } echo "</center>"; }