<?php include '../vendor/autoload.php'; // Prepare the connection to the API $nessus = new Nessus\Client('username', 'password', '192.168.56.101'); // Get the Server properties // GET /server/properties $server_properties = $nessus->server()->properties()->via('get'); print '[+] Server Version: ' . $server_properties->server_version . PHP_EOL; print '[+] Feed: ' . $server_properties->feed . PHP_EOL; foreach ($server_properties->notifications as $notification) { print '[+] Notification Type: ' . $notification->type . ' : ' . $notification->message . PHP_EOL; } // Get the server status // GET /server/status $server_status = $nessus->server()->status()->via('get'); print '[+] Server Progress: ' . $server_status->progress . PHP_EOL; print '[+] Server Status: ' . $server_status->status . PHP_EOL; // Sample output // λ git n6* → php server.php // [+] Server Version: 6.0.0 // [+] Feed: ProFeed // [+] Notification Type: warning : Your plugin feed subscription will expire in 26 day(s). // [+] Server Progress: // [+] Server Status: ready
<?php include '../vendor/autoload.php'; // Prepare the connection to the API $nessus = new Nessus\Client('username', 'password', '192.168.56.101'); // Get the configured users... // GET /users $users = $nessus->users()->via('get')->users; // ... and print some information foreach ($users as $user) { print '[+] id:' . $user->id . " - " . $user->type . ' user ' . $user->username . ' last login: '******'username' => 'apiuser', 'password' => 'apiuser', 'permissions' => 128, 'name' => 'API User', 'email' => '*****@*****.**', 'type' => 'local'))->via('post'); print '[+] Created new user ' . $new_user->name . ' with id ' . $new_user->id . PHP_EOL; // Edit the user // PUT /users/{user_id} //This API call appears to be broken? $user_edit = $nessus->users($new_user->id)->setFields(array('permissions' => 128, 'name' => 'Edited API Name', 'email' => '*****@*****.**'))->via('put'); print '[+] Edited user ' . $new_user->id . PHP_EOL; // Delete the user // DELETE /users/{user_id} $deleted_user = $nessus->users($new_user->id)->via('delete'); print '[+] Deleted user ' . $new_user->id . PHP_EOL; // λ git n6* → php users.php // [+] id:3 - local user test last login: 1413804979 // [+] id:4 - local user username last login: 1413876143 // [+] Created new user apiuser with id 27 // [+] Edited user 27 // [+] Deleted user 27
<?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