Nessus
Vulnerability scanner for auditors and security analysts by Tenable Network Security.
Vulnerability Management · Nessus
Details
| ID | Nessus |
|---|---|
| Provider | Tenable |
| Category | Vulnerability Management |
| From Version | 5.0.0 |
| Supported Modules | Agentix XSIAM |
README
nessus-list-scans
Returns the scan list
Base Command
nessus-list-scans
Input
| Argument Name | Description | Required |
|---|---|---|
| foldersHeaders | The table’s headers to be shown by order. | Optional |
| scansHeaders | The table’s headers to be shown by order. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| NessusScan.UUID | unknown | The uuid for the scan. |
| NessusScan.Name | unknown | The name of the scan. |
| NessusScan.Status | unknown | The status of the scan. |
| NessusScan.FolderID | unknown | The unique id of the folder housing the scan. |
| NessusScan.ID | unknown | The unique id of the scan. |
| NessusScan.UserPermissions | unknown | The sharing permissions for the scan. |
| NessusScan.CreationDate | unknown | The creation date for the scan in unixtime. |
| NessusScan.LastModificationDate | unknown | The last modification date for the scan in unixtime. |
| NessusScan.Type | unknown | The type of scan (local, remote, or agent). |
| NessusScan.Policy | unknown | The policy if the scan. |
| NessusFolder.UnreadCount | unknown | The number of unread scans in the folder. |
| NessusFolder.Custom | unknown | The custom status of the folder (1 or 0). |
| NessusFolder.DefaultTag | unknown | Whether or not the folder is the default (1 or 0). |
| NessusFolder.Type | unknown | The type of the folder (main, trash, custom). |
| NessusFolder.Name | unknown | The name of the folder. |
| NessusFolder.ID | unknown | The unique id of the folder. |
nessus-launch-scan
Launches a new vulnerability scan
Base Command
nessus-launch-scan
Input
| Argument Name | Description | Required |
|---|---|---|
| scanId | The Scan ID (use command list-scans to get possible scan ID’s). | Required |
| targets | If specified, these targets will be scanned instead of the default. Value can be single host or of comma separated targets. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| ScanUUID | unknown | The uuid of the launched scan. |
nessus-scan-details
Returns details for the given scan
Base Command
nessus-scan-details
Input
| Argument Name | Description | Required |
|---|---|---|
| scanId | The Scan ID (use command list-scans to get possible scan ID’s). | Required |
| historyId | The history_id of the historical data that should be returned. | Optional |
| tables | The tables to be shown by order. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| NessusScan.UUID | unknown | The uuid for the scan. |
| NessusScan.Name | unknown | The name of the scan. |
| NessusScan.Status | unknown | The status of the scan. |
| NessusScan.FolderID | unknown | The unique id of the folder housing the scan. |
| NessusScan.ID | unknown | The unique id of the scan. |
| NessusScan.UserPermissions | unknown | The sharing permissions for the scan. |
| NessusScan.CreationDate | unknown | The creation date for the scan in unixtime. |
| NessusScan.LastModificationDate | unknown | The last modification date for the scan in unixtime. |
| NessusScan.Type | unknown | The type of scan (local, remote, or agent). |
| NessusScan.Policy | unknown | The policy if the scan. |
| NessusScan.Endpoint.ID | unknown | The unique id of the host. |
| NessusScan.Endpoint.Index | unknown | The index for the host. |
| NessusScan.Endpoint.Hostname | unknown | The overall severity rating of the host. |
| NessusScan.Endpoint.Progress | unknown | The scan progress of the host. |
| NessusScan.Endpoint.Critical | unknown | The percentage of critical findings on the host. |
| NessusScan.Endpoint.High | unknown | The percentage of high findings on the host. |
| NessusScan.Endpoint.Medium | unknown | The percentage of medium findings on the host. |
| NessusScan.Endpoint.Low | unknown | The percentage of low findings on the host. |
| NessusScan.Endpoint.Info | unknown | The percentage of info findings on the host. |
| NessusScan.Endpoint.TotalChecksConsidered | unknown | The total number of checks considered on the host. |
| NessusScan.Endpoint.NumChecksConsidered | unknown | The number of checks considered on the host. |
| NessusScan.Endpoint.ScanProgressTotal | unknown | The total scan progress for the host. |
| NessusScan.Endpoint.ScanProgressCurrent | unknown | The current scan progress for the host. |
| NessusScan.Endpoint.Score | unknown | The overall score for the host. |
| NessusScan.Vulnerability.PluginID | unknown | The unique id of the vulnerability plugin. |
| NessusScan.Vulnerability.PluginName | unknown | The name of the vulnerability plugin. |
| NessusScan.Vulnerability.PluginFamily | unknown | The parent family of the vulnerability plugin. |
| NessusScan.Vulnerability.Count | unknown | The number of vulnerabilities found. |
| NessusScan.Vulnerability.VulnerabilityIndex | unknown | The index of the vulnerability plugin. |
| NessusScan.Vulnerability.SeverityIndex | unknown | The severity index order of the plugin. |
| NessusScan.Note.Title | unknown | The title of the note. |
| NessusScan.Note.Message | unknown | The specific message of the note. |
| NessusScan.Note.Sevirity | unknown | The severity of the note. |
| NessusScan.Filter.Name | unknown | The short name of the filter. |
| NessusScan.Filter.ReadableName | unknown | The long name of the filter. |
| NessusScan.Filter.Operators | unknown | The comparison options for the filter. |
| NessusScan.Filter.Type | unknown | The input type for the filter. |
| NessusScan.Filter.ReadableRegest | unknown | The input placeholder for the filter. |
| NessusScan.Filter.Regex | unknown | The input regex values for the filter. |
| NessusScan.Filter.Options | unknown | Other input options for the filter. |
| NessusScan.History.ID | unknown | The unique id of the historical data. |
| NessusScan.History.UUID | unknown | The uuid of the historical data. |
| NessusScan.History.OwnerID | unknown | The unique id of the owner of the scan. |
| NessusScan.History.Status | unknown | The status of the historical data. |
| NessusScan.History.CreationDate | unknown | The creation date for the historical data in unixtime. |
| NessusScan.History.LastModification_date | unknown | The last modification date for the historical data in unixtime. |
| NessusScan.Remediations.Remediations | unknown | Remedy to vulnerabilites found during the scan. |
| NessusScan.Remediations.NumHosts | unknown | Number of hosts of Remediations |
| NessusScan.Remediations.NumCVEs | unknown | Number of CVE’s |
| NessusScan.Remediations.NumImpactedHosts | unknown | Number of impacted hosts |
| NessusScan.Remediations.NumRemediatedCVEs | unknown | Number of Remediated CVE’s |
nessus-scan-host-details
Returns details for the given host.
Base Command
nessus-scan-host-details
Input
| Argument Name | Description | Required |
|---|---|---|
| scanId | The Scan ID (use command list-scans to get possible scan ID’s). | Required |
| historyId | The history_id of the historical data that should be returned. | Optional |
| hostId | The id of the host to retrieve. | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| Endpoint.ID | unknown | The unique id of the host. |
| Endpoint.Index | unknown | The index for the host. |
| Endpoint.Hostname | unknown | The overall severity rating of the host. |
| Endpoint.Progress | unknown | The scan progress of the host. |
| Endpoint.Critical | unknown | The percentage of critical findings on the host. |
| Endpoint.High | unknown | The percentage of high findings on the host. |
| Endpoint.Medium | unknown | The percentage of medium findings on the host. |
| Endpoint.Low | unknown | The percentage of low findings on the host. |
| Endpoint.Info | unknown | The percentage of info findings on the host. |
| Endpoint.TotalChecksConsidered | unknown | The total number of checks considered on the host. |
| Endpoint.NumChecksConsidered | unknown | The number of checks considered on the host. |
| Endpoint.ScanProgressTotal | unknown | The total scan progress for the host. |
| Endpoint.ScanProgressCurrent | unknown | The current scan progress for the host. |
| Endpoint.Score | unknown | The overall score for the host. |
nessus-scan-export
Export the given scan (Nessus, HTML, PDF, CSV, or DB format)
Base Command
nessus-scan-export
Input
| Argument Name | Description | Required |
|---|---|---|
| scanId | The Scan ID (use command list-scans to get possible scan ID’s). | Required |
| historyId | The history_id of the historical data that should be returned. | Optional |
| format | scan report file format (nessus, csv, html, db, pdf). | Required |
| password | The password used to encrypt database exports (*Required when exporting as DB). | Optional |
| chapters | The chapters to include in the export (expecting a semi-colon delimited string comprised of some combination of the following options: vuln_hosts_summary, vuln_by_host, compliance_exec, remediations, vuln_by_plugin, compliance). | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| ScanReportID | unknown | ID of the scan report. |
nessus-scan-report-download
Download an exported scan
Base Command
nessus-scan-report-download
Input
| Argument Name | Description | Required |
|---|---|---|
| scanId | The Scan ID (use command list-scans to get possible scan ID’s). | Required |
| fileId | The id of the file to download (result from command export-scan). | Required |
Context Output
There is no context output for this command.
nessus-scan-create
Creates a new scan
Base Command
nessus-scan-create
Input
| Argument Name | Description | Required |
|---|---|---|
| editor | The uuid for the editor template to use. | Required |
| name | The name of the scan. | Required |
| description | The description of the scan. | Optional |
| policyId | The unique id of the policy to use(number). | Optional |
| folderId | The unique id of the destination folder for the scan(number). | Optional |
| scannerId | The unique id of the scanner to use(number). | Optional |
| schedule | If true, the schedule for the scan is enabled(true/false). | Required |
| launch | When to launch the scan. (i.e. ON_DEMAND, DAILY, WEEKLY, MONTHLY, YEARLY). | Optional |
| startTime | The starting time and date for the scan (i.e. YYYYMMDDTHHMMSS). | Optional |
| rules | Expects a semi-colon delimited string comprised of three values. The frequency (FREQ=ONCE or DAILY or WEEKLY or MONTHLY or YEARLY), the interval (INTERVAL=1 or 2 or 3 … x), and the days of the week (BYDAY=SU,MO,TU,WE,TH,FR,SA). To create a scan that runs every three weeks on Monday Wednesday and Friday the string would be ‘FREQ=WEEKLY;INTERVAL=3;BYDAY=MO,WE,FR’. | Optional |
| timeZone | The timezone for the scan schedule. | Optional |
| targets | The list of targets to scan, Value can be single host or of comma separated targets. | Required |
| emails | A comma separated list of accounts who will recieve the email summary report. | Optional |
| acls | An array containing permissions to apply to the scan. | Optional |
| fileTargets | The name of a file containing the list of targets to scan. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| NessusScan.UUID | unknown | The uuid for the scan. |
| NessusScan.Name | unknown | The name of the scan. |
| NessusScan.Status | unknown | The status of the scan. |
| NessusScan.FolderID | unknown | The unique id of the folder housing the scan. |
| NessusScan.ID | unknown | The unique id of the scan. |
| NessusScan.UserPermissions | unknown | The sharing permissions for the scan. |
| NessusScan.CreationDate | unknown | The creation date for the scan in unixtime. |
| NessusScan.LastModificationDate | unknown | The last modification date for the scan in unixtime. |
| NessusScan.Type | unknown | The type of scan (local, remote, or agent). |
| NessusScan.Policy | unknown | The policy if the scan. |
nessus-get-scans-editors
Returns all scan editors template list
Base Command
nessus-get-scans-editors
Input
| Argument Name | Description | Required |
| — | — | — |
Context Output
There is no context output for this command.
nessus-scan-export-status
Check the file status of an exported scan
Base Command
nessus-scan-export-status
Input
| Argument Name | Description | Required |
|---|---|---|
| scanId | The Scan ID (use command list-scans to get possible scan ID’s). | Required |
| fileId | The id of the file to download (result from command export-scan). | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| NessusScan.ScanReportStatus | unknown | The status of the scan report. |
nessus-scan-status
Get scan status by scan id
Base Command
nessus-scan-status
Input
| Argument Name | Description | Required |
|---|---|---|
| scanId | The Scan ID (use command list-scans to get possible scan ID’s). | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| NessusScan.Status | unknown | The status of the scan report. |
Configuration parameters
url— Server Url (format : https://127.0.0.1:8834) (required)username— Usernamepassword— Passwordcredentials— Usernameinsecure— Trust any certificate (not secure)proxy— Use system proxy settings
Commands (18)
-
nessus-get-scans-editorsReturns all scan editors template list.
-
nessus-launch-scanLaunches a new vulnerability scan
-
nessus-list-scansReturns the scan list
-
nessus-scan-createCreates a new scan.
-
nessus-scan-detailsReturns details for the given scan.
-
nessus-scan-exportExport the given scan (Nessus, HTML, PDF, CSV, or DB format).
-
nessus-scan-export-statusCheck the file status of an exported scan.
-
nessus-scan-host-detailsReturns details for the given host.
-
nessus-scan-report-downloadDownload an exported scan.
-
nessus-scan-statusGet scan status by scan id.
-
scan-createDeprecatedCreates a new scan.
-
scan-detailsDeprecatedReturns details for the given scan.
-
scan-exportDeprecatedExport the given scan (Nessus, HTML, PDF, CSV, or DB format).
-
scan-export-statusDeprecatedCheck the file status of an exported scan.
-
scan-host-detailsDeprecatedReturns details for the given host.
-
scan-launchDeprecatedLaunches a new vulnerability scan
-
scan-report-downloadDeprecatedDownload an exported scan.
-
scans-listDeprecatedReturns the scan list
var getReadyURL = function() { u = params.url; if (u && u[u.length - 1] !== '/') { u = u +'/'; } return u; }; var resToMD = function(body, title) { return tblToMd(title, body, Object.keys(body)); }; var entities = { NessusScan: { uuid: 'UUID', name: 'Name' , status: 'Status', folder_id: 'FolderID', id: 'ID', type: 'Type', policy: 'Policy', user_permissions: 'UserPermissions', creation_date: 'CreationDate' , last_modification_date: 'LastModificationDate' }, NessusFolder: { unread_count: 'UnreadCount', custom: 'Custom', default_tag: 'DefaultTag', type: 'Type', name: 'Name', id: 'ID' }, Endpoint : { host_id: 'ID', host_index: 'Index', hostname: 'Hostname', progress: 'Progress', critical: 'Critical', high: 'High', medium: 'Medium', low: 'Low', info: 'Info', totalchecksconsidered: 'TotalChecksConsidered', numchecksconsidered: 'NumChecksConsidered', scanprogresstotal: 'ScanProgressTotal', scanprogresscurrent: 'ScanProgressCurrent', score: 'Score' }, Vulnerability : { plugin_id: 'PluginID' , plugin_name: 'PluginName', plugin_family: 'PluginFamily', count: 'Count' , vuln_index: 'VulnerabilityIndex', severity_index: 'SeverityIndex' }, Note : { title: 'Title', message: 'Message', severity: 'Sevirity' }, Filter:{ name: 'Name', readable_name: 'ReadableName', operators: 'Operators', 'control.type': 'Type', 'control.readable_regest':'ReadableRegest', 'control.regex': 'Regex', 'control.options': 'Options' }, History:{ history_id: 'ID', uuid: 'UUID', owner_id: 'OwnerID', status: 'Status', creation_date: 'CreationDate', last_modification_date: 'LastModification_date' }, Remediations:{ remediations: 'Remediations', num_hosts: 'NumHosts', num_cves: 'NumCVEs', num_impacted_hosts: 'NumImpactedHosts', num_remediated_cves: 'NumRemediatedCVEs' } }; //returns single object withing entity (i.e. File[0]) var jsonToEntityObject = function(origObj, newKeys){ var ret = {}; for(var key in newKeys){ if(newKeys[key]){ ret[newKeys[key]] = dq(origObj, key); } } return ret; }; //returns entire entity array (i.e. File) var jsonToEntity = function(origObj, newKeys){ var j; if(!Array.isArray(origObj)){ return [jsonToEntityObject(origObj, newKeys)]; } else if(origObj.length > 0){ //makes sure no empty arrays are pushed var ret = []; for(j=0; j<origObj.length; j++){ ret.push(jsonToEntityObject(origObj[j], newKeys)); } return ret; } }; var login = function() { let username = params.credentials ? params.credentials.identifier : params.username; let password = params.credentials ? params.credentials.password : params.password; if (!(username&&password)){ throw 'Username and Password must be provided'; } var result = http( getReadyURL()+'session', { Headers: {'Content-Type': ['application/json']}, Method: 'POST', Body: JSON.stringify({'username':username,'password':password}), }, params.insecure, params.proxy ); if (result.StatusCode !== 200 && result.StatusCode !== 201) { throw 'Failed to login, request status code: ' + result.StatusCode + ', check that username/password are correct'; } return JSON.parse(result.Body).token; }; var logout = function(token) { var result = http( getReadyURL()+'session', { Headers: {'Content-Type': ['application/json'], 'X-Cookie': ['token='+token]}, Method: 'DELETE', }, params.insecure, params.proxy ); if (result.StatusCode !== 200 && result.StatusCode !== 401) { throw 'Failed to logout session, request status code: ' + result.StatusCode + ', body='+result.Body; } return 'deleted'; }; var listScans = function(token) { var result = http( getReadyURL()+'scans', { Headers: {'Content-Type': ['application/json'], 'X-Cookie': ['token='+token]}, Method: 'GET', }, params.insecure, params.proxy ); if (result.StatusCode !== 200 ) { throw 'Failed to get scans list, request status code: ' + result.StatusCode + ', body='+result.Body; } logout(token); var res = JSON.parse(result.Body); var md = ''; if(res.folders && res.folders.length > 0){ md += tblToMd('Folders', res.folders, args.foldersHeaders? args.foldersHeaders : Object.keys(res.folders[0])); } if(res.scans && res.scans.length > 0){ md += tblToMd('Scans', res.scans, args.scansHeaders? args.scansHeaders : Object.keys(res.scans[0])); } var context = { NessusFolder : jsonToEntity(res.folders, entities.NessusFolder), NessusScan : jsonToEntity(res.scans, entities.NessusScan) }; return { Type: entryTypes.note, Contents: JSON.parse(result.Body), ContentsFormat: formats.json, HumanReadable: md, EntryContext: context }; }; var scanLaunch = function(token,scanId, targets) { var body = ""; if (targets && targets.length > 0 ) { var targetsArr = [ targets ]; body = JSON.stringify({'alt_targets': targetsArr}); } var result = http( getReadyURL()+'scans/'+scanId+'/launch', { Headers: {'Content-Type': ['application/json'], 'X-Cookie': ['token='+token]}, Method: 'POST', Body: body, }, params.insecure, params.proxy ); if (result.StatusCode !== 200 ) { throw 'Failed to launch scans list, request status code: ' + result.StatusCode + ', body='+result.Body; } logout(token); var res = JSON.parse(result.Body); setContext('ScanUUID', res.scan_uuid); var md = 'scan uuid: ' + res.scan_uuid; return { Type: entryTypes.note, Contents: res, ContentsFormat: formats.json, HumanReadable: md }; }; var scanDetails = function(token,scanId,historyId) { var url = getReadyURL()+'scans/'+scanId; if (historyId && historyId.length > 0 ){ url = url + '?history_id='+historyId; } var result = http( url, { Headers: {'Content-Type': ['application/json'], 'X-Cookie': ['token='+token]}, Method: 'GET', }, params.insecure, params.proxy ); if (result.StatusCode !== 200 ) { throw 'Failed to get scan Details, request status code: ' + result.StatusCode + ', body='+result.Body; } logout(token); var res = JSON.parse(result.Body); var tbToEntity = {'hosts':'Endpoint','comphosts':'Endpoint','vulnerabilities':'Vulnerability',/*'compliance':'Vulnerability',*/'notes':'Note','filters':'Filter','history':'History','remediations':'Remediations'}; var tables = Object.keys(tbToEntity); if(args.tables) tables = args.tables.split(/([ ,\,])/); var md = ''; var cur, i, j; for(i=0; i<tables.length; i++){ cur = res[tables[i]]; if(cur){ if(!Array.isArray(cur)){ md+=tblToMd('Scan '+args.scanId+' '+tables[i], cur, Object.keys(cur)); } else if(cur.length > 0){ md+=tblToMd('Scan '+args.scanId+' '+tables[i], cur, Object.keys(cur[0])); } else{ md+='### '+'Scan '+args.scanId+' '+tables[i]+'\n' + 'No data returned\n'; } } } var context = { NessusScan : jsonToEntity(res.info, entities.NessusScan)}; var curField; context.NessusScan.ID = args.scanId; for(i=0; i<tables.length; i++){ cur = res[tables[i]]; if(Array.isArray(cur) ? cur.length!=0 : !!cur){ curField = context.NessusScan[0][tbToEntity[tables[i]]]; if(curField){ context.NessusScan[0][tbToEntity[tables[i]]]=curField.concat(jsonToEntity(cur, entities[tbToEntity[tables[i]]])); } else{ context.NessusScan[0][tbToEntity[tables[i]]] = jsonToEntity(cur, entities[tbToEntity[tables[i]]]); } } } var ec = {}; ec['NessusScan(val.ID && val.ID == '+scanId+' || val.UUID && val.UUID == '+context.NessusScan.UUID+')'] = context.NessusScan; return { Type: entryTypes.note, Contents: result.Body, ContentsFormat: formats.json, HumanReadable: md, EntryContext: ec }; }; var scanStatus = function(token,scanId){ var url = getReadyURL()+'scans/'+scanId; var result = http( url, { Headers: {'Content-Type': ['application/json'], 'X-Cookie': ['token='+token]}, Method: 'GET', }, params.insecure, params.proxy ); if (result.StatusCode !== 200 ) { throw 'Failed to get scan Details, request status code: ' + result.StatusCode + ', body='+result.Body; } logout(token); var res = JSON.parse(result.Body); //setContext('ScanStatus',res.info.status); var context = {}; context['NessusScan(val.ID && val.ID == ' + scanId +').Status'] = res.info.status; //log(JSON.stringify(context)); return { Type: entryTypes.note, Contents: result.Body, ContentsFormat: formats.json, HumanReadable: 'Scan status: '+ res.info.status, EntryContext: context }; }; var scanHostDetails = function(token,scanId,historyId,hostId) { var url = getReadyURL()+'scans/'+scanId + '/hosts/' + hostId; if (historyId && historyId.length > 0 ){ url = url + '?history_id='+historyId; } var result = http( url, { Headers: {'Content-Type': ['application/json'], 'X-Cookie': ['token='+token]}, Method: 'GET', }, params.insecure, params.proxy ); if (result.StatusCode !== 200 ) { throw 'Failed to get scan Details, request status code: ' + result.StatusCode + ', body='+result.Body; } logout(token); return JSON.parse(result.Body); }; var scanExport = function(token, scanId, historyId, format, password, chapters) { var url = getReadyURL()+'scans/'+scanId + '/export'; if (historyId && historyId.length > 0 ){ url = url + '?history_id='+historyId; } var body = {'format':format}; if (password && password.length > 0){ body.password = password; } if (chapters && chapters.length > 0){ body.chapters = chapters; } var result = http( url, { Headers: {'Content-Type': ['application/json'], 'X-Cookie': ['token='+token]}, Method: 'POST', Body: JSON.stringify(body), }, params.insecure, params.proxy ); if (result.StatusCode !== 200 ) { throw 'Failed to launch scans list, request status code: ' + result.StatusCode + ', body='+result.Body; } logout(token); var context = {}; context['NessusScan(val.ID && val.ID == ' + scanId +').ScanReportID'] = JSON.parse(result.Body).file; return { Type: entryTypes.note, Contents: result.Body, ContentsFormat: formats.json, HumanReadable: 'Report file id: ' + JSON.parse(result.Body).file, EntryContext: context }; }; var getReport = function(token, scanId, fileId) { var res = http( getReadyURL()+'scans/'+ scanId + '/export/' + fileId + '/download', { Headers: {'Content-Type': ['application/json'], 'X-Cookie': ['token='+token]}, Method: 'GET', }, params.insecure, params.proxy ); if (res.StatusCode !== 200) { return 'Failed to execute request:' + res.StatusCode + ', body: ' + res.Body; } var savedFile = saveFile(res.Body); logout(token); return savedFile; }; var scanCreate = function(token, editorUuid, name, description, policy,folder, scannerId, schedule, launchTime, startTime, rules, timeZone, targets,fileTargets, emails, acls) { var body = {}; body.uuid = editorUuid; body.settings = {}; body.settings.name = name; if (description && description.length > 0){ body.settings.description = description; } if (policy && policy.length > 0){ body.settings.policy_id = parseInt(policy); } if (folder && folder.length > 0){ body.settings.folder_id = parseInt(folder); } if (scannerId && scannerId.length > 0){ body.settings.scanner_id = parseInt(scannerId); } if (schedule && schedule.length > 0){ body.settings.enabled = (schedule == 'true'); } if (launchTime && launchTime.length > 0){ body.settings.launch = launchTime; } if (startTime && startTime.length > 0){ body.settings.starttime = startTime; } if (rules && rules.length > 0){ body.settings.rrules = rules; } if (timeZone && timeZone.length > 0){ body.settings.timezone = timeZone; } if (targets && targets.length > 0 ) { body.settings.text_targets = targets; } if (fileTargets && fileTargets.length > 0 ) { body.settings.file_targets = fileTargets; } if (emails && emails.length > 0 ) { body.settings.emails = emails; } if (acls && acls.length > 0 ) { body.settings.acls = acls; } var result = http( getReadyURL()+'scans', { Headers: {'Content-Type': ['application/json'], 'X-Cookie': ['token='+token]}, Method: 'POST', Body: JSON.stringify(body), }, params.insecure, params.proxy ); if (result.StatusCode !== 200 ) { throw 'Failed to launch scans list, request status code: ' + result.StatusCode + ', body='+result.Body; } logout(token); var res = JSON.parse(result.Body); var md = tblToMd('Created Scan Details', res.scan, Object.keys(res.scan)); var context = {NessusScan: jsonToEntity(res.scan, entities.NessusScan)}; return { Type: entryTypes.note, Contents: JSON.parse(result.Body), ContentsFormat: formats.json, HumanReadable: md, EntryContext: context }; }; var getEditors = function(token) { var url = getReadyURL()+'editor/scan/templates'; var result = http( url, { Headers: {'Content-Type': ['application/json'], 'X-Cookie': ['token='+token]}, Method: 'GET', }, params.insecure, params.proxy ); if (result.StatusCode !== 200 ) { throw 'Failed to get scan editors, request status code: ' + result.StatusCode + ', body='+result.Body; } logout(token); var res = JSON.parse(result.Body).templates; var md = tblToMd('Nessus Scans Editors',res, ['title','name','desc','uuid','cloud_only','subscription_only','is_agent','more_info','manager_only','unsupported']); return { Type: entryTypes.note, Contents: result.Body, ContentsFormat: formats.json, HumanReadable: md }; }; var getStatus = function(token,scanId,fileId) { var url = getReadyURL()+'scans/'+scanId+'/export/'+fileId+'/status'; var result = http( url, { Headers: {'Content-Type': ['application/json'], 'X-Cookie': ['token='+token]}, Method: 'GET', }, params.insecure, params.proxy ); if (result.StatusCode !== 200 ) { throw 'Failed to get export status, request status code: ' + result.StatusCode + ', body='+result.Body; } logout(token); var context = {}; context['NessusScan(val.ID && val.ID == '+scanId+').ScanReportStatus'] = JSON.parse(result.Body).status; return { Type: entryTypes.note, Contents: result.Body, ContentsFormat: formats.json, HumanReadable: 'Report file status: ' + JSON.parse(result.Body).status, EntryContext: context }; }; switch (command) { case 'test-module': token = login(); logout(token); return (token && token.length >0); case 'scans-list': //deprecated case 'nessus-list-scans': return listScans(login()); case 'scan-launch': //deprecated case 'nessus-launch-scan': return scanLaunch(login(),args.scanId,args.targets); case 'scan-details': //deprecated case 'nessus-scan-details': return scanDetails(login(),args.scanId,args.historyId); case 'scan-export': //deprecated case 'nessus-scan-export': return scanExport(login(),args.scanId,args.historyId,args.format,args.password,args.chapters); case 'scan-report-download': //deprecated case 'nessus-scan-report-download': return {Type: 3, FileID: getReport(login(),args.scanId,args.fileId),File: args.fileId+'', Contents: 'we must have contents for an entry'}; case 'scan-export-status': //deprecated case 'nessus-scan-export-status': return getStatus(login(),args.scanId,args.fileId); case 'scan-create': //deprecated case 'nessus-scan-create': return scanCreate(login(),args.editor,args.name, args.description, args.policyId, args.folderId, args.scannerId, args.schedule, args.launch, args.startTime, args.rules, args.timeZone, args.targets,args.fileTargets, args.emails, args.acls); case 'nessus-get-scans-editors': return getEditors(login()); case 'nessus-scan-status': return scanStatus(login(),args.scanId); case 'nessus-scan-host-details': case 'scan-host-details': //deprecated return scanHostDetails(login(),args.scanId,args.historyId,args.hostId); }