exit(1); } require $init_file; $insert_model = Model::factory('vulndb_insert'); $vulndb = Model::factory('vulndb_main'); $vdb_config = Config::load('vulndb'); Logger::msg('info', array('message' => 'Starting the asset data report updater')); $accounts = $vulndb->getaccounts(); foreach ($accounts as $account) { $now = date('c'); $account_name = $account['account']; $username = $account['username']; $password = CryptAES::decrypt($account['password']); $url1 = 'https://' . $account['api_url'] . '/msp/'; $url2 = 'https://' . $account['api_url'] . '/api/2.0/fo/'; $api1 = new QualysAPI_v1(); Logger::msg("info", array("message" => "fetching report list", 'account' => $account_name, 'api_call' => 'report_template_list', 'api_version' => 1)); $report_template_xml = $api1->report_template_list($url1, $username, $password); // Check that we got valid XML if (!$vulndb->is_xml($report_template_xml)) { Logger::msg("error", array('message' => 'what I got back from the API call was not XML')); Logger::msg("info", array('report_template_xml' => $report_template_xml)); exit; } // Delete the current report templates in the table for this account $delete_templates = DB::query(Database::DELETE, "DELETE FROM " . REPORT_TEMPLATE_TABLE . " WHERE ACCOUNT = :account")->bind(":account", $account_name)->execute(); Logger::msg("info", array("message" => "deleted report templates", "table" => REPORT_TEMPLATE_TABLE, "account" => $account_name, "rows_deleted" => $delete_templates)); // Put the report template list in the DB $insert = $insert_model->report_templates($report_template_xml, $account_name); Logger::msg("info", array("message" => "report templates inserted for account", "table" => REPORT_TEMPLATE_TABLE, "account" => $account_name, "rows_inserted" => $insert)); // Now lets download our reports defined in config/vulndb.php
**/ if (!is_file($init_file = realpath(dirname(__FILE__)) . "/../init.php")) { echo "Could not find init.php, this file is requied for vulnDB to operate\n"; exit(1); } require $init_file; $insert_model = Model::factory('vulndb_insert'); $vulndb = Model::factory('vulndb_main'); $vdb_config = Config::load('vulndb'); $accounts = $vulndb->getaccounts(); Logger::msg('info', array('message' => 'running scans updater complete')); foreach ($accounts as $account) { $now = date('c'); $account_name = $account['account']; $username = $account['username']; $password = CryptAES::decrypt($account['password']); $url1 = 'https://' . $account['api_url'] . '/msp/'; $url2 = 'https://' . $account['api_url'] . '/api/2.0/fo/'; $api1 = new QualysAPI_v1(); $api2 = new QualysAPI_v2($url2, $username, $password); Logger::msg('info', array('message' => 'polling scans', 'account' => $account_name)); $scanlist_v2 = $api2->pollscans(date('Y-m-d', strtotime('-15 day')), array('state' => 'Running')); $scanlist_v1 = $api1->scan_running_list($url1, $username, $password); // It appears Qualys isnt returning XML when there are no scans anymore :( if (!$scanlist_v1) { continue; } $insert = $insert_model->running_scans($scanlist_v1, $scanlist_v2, $account_name); Logger::msg('info', array('message' => "running scans updated", 'account' => $account_name)); } Logger::msg('info', array('message' => 'running scans updater complete'));
exit(1); } ini_set('memory_limit', '512M'); require $init_file; Logger::msg("info", array('message' => "KB updater starting")); $vdb_config = Config::load('vulndb'); // Name of the account we will use to pull back in the KB // Define it config/vulndb $kb_account = $vdb_config['kb_account']; $vulndb = Model::factory('vulndb_main'); $insert = Model::factory('vulndb_insert'); $account_info = $vulndb->getaccountinfo($kb_account); $username = $account_info['username']; $password = CryptAES::decrypt($account_info['password']); $url1 = $account_info['url1']; $api1 = new QualysAPI_v1(); Logger::msg('info', array('message' => "Qualys KB download beginning", 'api_call' => 'get_qualys_kb', 'api_version' => '1', 'kb_account' => $kb_account, 'account_username' => $username)); $KB_XML = $api1->get_qualys_kb($url1, $username, $password); Logger::msg('info', array('message' => "Qualys KB download complete", 'api_call' => 'get_qualys_kb', 'api_version' => '1')); // check the XML if (!$vulndb->is_xml($KB_XML)) { Logger::msg("error", array('message' => 'what I got back from the API call was not XML')); Logger::msg("info", array('kb_xml' => $KB_XML)); exit; } // If we got good XML back, go ahead an truncate the current KB $truncate = DB::query(Database::DELETE, "TRUNCATE " . MAIN_QUALYS_KB_TABLE)->execute(); Logger::msg("info", array('message' => "Qualys KB table, " . MAIN_QUALYS_KB_TABLE . " truncated")); Logger::msg("info", array('message' => "KB insert beginning")); $go = $insert->kb($KB_XML); Logger::msg("info", array('message' => "KB insert complete", "rows_inserted" => $go));
* * This script will get a list of upcoming scheduled scans and place them in the scheduled_scans table * * It can be useful to run this script in a CRON job for say every hour so upcoming scans can be seen * * * **/ if (!is_file($init_file = realpath(dirname(__FILE__)) . "/../init.php")) { echo "Could not find init.php, this file is requied for vulnDB to operate\n"; exit(1); } require $init_file; $insert_model = Model::factory('vulndb_insert'); $vulndb = Model::factory('vulndb_main'); $vdb_config = Config::load('vulndb'); $accounts = $vulndb->getaccounts(); DB::query(Database::DELETE, "TRUNCATE " . SCAN_SCHEDULES_TABLE)->execute(); foreach ($accounts as $account) { $now = date('c'); $account_name = $account['account']; $username = $account['username']; $password = CryptAES::decrypt($account['password']); $url1 = 'https://' . $account['api_url'] . '/msp/'; $url2 = 'https://' . $account['api_url'] . '/api/2.0/fo/'; $api1 = new QualysAPI_v1(); $api2 = new QualysAPI_v2($url2, $username, $password); // Get a list of upcomming scans $upcoming = $api1->scheduled_scans($url1, $username, $password, array("active" => "yes", "type" => "scan")); $insert = $insert_model->scheduled_scans($upcoming, $account_name); }
} require $init_file; $vdb_config = Config::load('vulndb'); $timeframe = date('Y-m-d', strtotime($vdb_config['scan_timeframe'])); $insert_model = Model::factory('vulndb_insert'); $vulndb = Model::factory('vulndb_main'); Logger::msg('info', array('message' => 'Starting the vulnDB updater')); $accounts = $vulndb->getaccounts(); foreach ($accounts as $account) { $now = date('c'); $account_name = $account['account']; $username = $account['username']; $password = CryptAES::decrypt($account['password']); $url1 = 'https://' . $account['api_url'] . '/msp/'; $url2 = 'https://' . $account['api_url'] . '/api/2.0/fo/'; $api1 = new QualysAPI_v1(); $api2 = new QualysAPI_v2($url2, $username, $password); Logger::msg('info', array('account' => $account_name, 'message' => "starting with account {$account_name}")); Logger::msg('info', array('account' => $account_name, 'message' => "polling scan list", 'timeframe' => $timeframe, 'api_call' => 'pollscans', 'api_version' => 2)); $scanlist_xml = $api2->pollscans($timeframe); $scanlist = parse::scanlist($scanlist_xml); $scans_in_vulndb = $vulndb->getscans($account_name); // Filter out the scans we already have vulnDB and move onto scans we need to get $scans_to_get = $vulndb->prunescanlist($scanlist, $account_name); // Lets get those scans if (count($scans_to_get)) { foreach ($scans_to_get as $scan_to_get) { $scanstatus = $scan_to_get['SCAN_STATUS']; $scanid = (string) $scan_to_get['SCAN_ID']; $scantitle = (string) $scan_to_get['SCAN_TITLE']; $scandate = (string) $scan_to_get['SCAN_DATE'];