**/ 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'));
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']; $scantypestoget = $vdb_config['scan_types_to_get'];