// CAAS is distibuted in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with CAAS. If not, see <http://www.gnu.org/licenses/>. define("__INCLUDED__", 1); require_once "./inc/base.php"; /////////////////////////////////////////// // DOWNLOAD OPERATIONS /////////////////////////////////////////// // download json report if (isset($_GET["download_json"])) { $aid = $_GET["download_json"]; $aid_s = secure_display($aid); $mode = "usermode"; if (isset($_GET["k"])) { $mode = "kernelmode"; } $req = get_analysis_info($aid); $line = $req->fetchArray(); if ($line) { $md5_hash = $line["md5"]; $path = $results_path . $md5_hash . "." . $line["analysis_id"] . ".json"; if (file_exists($path)) { header("Content-disposition: attachment; filename=" . $md5_hash . "." . $line["analysis_id"] . ".json"); header("Content-type: text/json"); readfile($path); exit(0); }
function display_tasks() { global $tasks_header, $tasks_footer; echo $tasks_header; $start = 0; $count = 10; $start_s = 0; $count_s = 10; if (isset($_GET["st"]) && isset($_GET["nb"])) { $start = $_GET["st"]; $count = $_GET["nb"]; $start_s = intval($_GET["st"]); $count_s = intval($_GET["nb"]); } $task_count = get_tasks_count(); $nb_pages = $task_count / $count_s; $req = get_tasks($start, $count); // security checks done in db.php :] echo ' <div class="container100"> <table class="std"> <tr><th class="std">#</th><th class="std">MD5</th><th class="std">ANALYSES :: SCORE</th><th class="std">SOURCES</th><th class="std">VIEW TASK</th></tr>'; while ($res = $req->fetchArray()) { $alerts_msg = ""; $alerts = get_task_alerts($res["task_id"]); while ($alert = $alerts->fetchArray()) { $criticity = 'green'; if ($alert['criticity'] == 2) { $criticity = 'orange'; } elseif ($alert['criticity'] == 1) { $criticity = 'red'; } $alerts_msg .= '<br /><span style="color:' . $criticity . '">' . secure_display($alert['label']) . ': ' . secure_display($alert['description']) . '</span>'; } $submitions = get_task_submitions($res["task_id"]); $counts = array(); $signs = array(); while ($sub = $submitions->fetchArray()) { $source_info = get_source_info($sub["source_type"], $sub["source_id"], TRUE); if (in_array($source_info, $signs)) { $counts[array_search($source_info, $signs)]++; } else { $counts[] = 1; $signs[] = $source_info; } } $source_data = ''; for ($i = 0; $i < count($counts); $i++) { if ($signs[$i] != 'MANUAL' && $counts[$i] != 1) { $counts[$i]--; } $source_data .= $signs[$i] . ' (' . $counts[$i] . ')<br />'; } echo ' <tr onclick="document.location.href=\'' . $_SERVER['PHP_SELF'] . '?display_task=' . $res["task_id"] . '\'"><td>' . $res['task_id'] . '</td><td>' . $res['md5'] . $alerts_msg . '</td><td>'; display_task_analyses_short($res["task_id"]); echo '</td><td>' . $source_data . '</td><td><a href="' . $_SERVER['PHP_SELF'] . '?display_task=' . $res["task_id"] . '" style="color:blue;">display info</a></td></tr>'; } echo ' </table> <a href="' . $_SERVER['PHP_SELF'] . '?display_tasks&st=' . ($start_s - $count_s) . '&nb=' . $count_s . '"><--</a> <a href="' . $_SERVER['PHP_SELF'] . '?display_tasks&st=' . ($start_s + $count_s) . '&nb=' . $count_s . '">>--</a> <br /> <form action="' . $_SERVER['PHP_SELF'] . '" method="GET"> <input type="hidden" name="display_tasks" /> PAGE <select name="st" />'; for ($i = 0; $i < $nb_pages; $i++) { $sel = ''; if ($i * $count_s == $start_s) { $sel = " selected "; } echo '<option value="' . $i * $count_s . '"' . $sel . '>' . ($i + 1) . '</option>'; } echo '</select><input type="submit" value="OK" /> Display <select name="nb">'; if ($count_s != 10) { echo ' <option value="' . $count_s . '">' . $count_s . '</option>'; } echo ' <option value="10">10</option> <option value="20">20</option> <option value="50">50</option> <option value="100">100</option> </select> results. </form> </div>'; echo $tasks_footer; }