Exemplo n.º 1
0
<?php

include '../vendor/autoload.php';
// Prepare the connection to the API
$nessus = new Nessus\Client('username', 'password', '192.168.56.101');
// Configure a proxy to use
$nessus->configureProxy('127.0.0.1', 8081)->useProxy();
// Get the Server properties
// GET /scans
$scans = $nessus->scans()->via('get');
print '[+] Scans Timestamp: ' . $scans->timestamp . PHP_EOL;
// Loop over the scans printing some information
foreach ($scans->scans as $scan) {
    print '[+] Scan ' . $scan->id . ': (' . $scan->name . ') status: ' . $scan->status . PHP_EOL;
}
// Prepare a scan for download. To do this we need to first
// schedule a export job. Once this is done, we can download the
// report in the requested format.
// Lets take the first scan from the previous request
$scan_id = $scans->scans[0]->id;
print '[+] Using scan_id: ' . $scan_id . ' for export.' . PHP_EOL;
// Schedule the export in .nessus format, taking note of
// the returned file_id
// POST /scans/{scan_id}/export
$file_id = $nessus->scans($scan_id)->export()->setFields(array('format' => 'nessus'))->via('post')->file;
print '[+] Got file_id: ' . $file_id . ' for export job.' . PHP_EOL;
// We now have to wait for the export to complete. We are
// just going to check the status of our export every 1 second
$export_status = 'waiting';
while ($export_status != 'ready') {
    // Poll for a status update