CyberSlave

Live the life you love.

Nessus API

Nessus API cli

So I recently needed to add multiple scans to nessus and export the results for splunk, being new to python and loving it. I decided to look for some examples and work from there, I found “https://github.com/averagesecurityguy/Nessus6/blob/master/nessus6_scan_demo.py” grabbed a copy and started to modify it to what I needed.

Warning this is not the best code but does what I currenlty need it to do.

The source can be found here https://github.com/ryanoberto/nessus-api-cli.

Firstly start off by editing all the required fields

1
2
3
4
5
url = 'https://<HOST>:8834'
username = '<USERNAME>'
password = '<PASSWORD>'
email = '<EMAIL>'
filename = '/<PATH>/nessus_{0}_{1}.nessus'.format(sid, fid)

Usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
./nessus-cli.py -h

##################################
#        Nessus api client       #
##################################
Add Desktop Scan
        ./nessus.py add_desktop_scan name description target

Add Server Scan
        ./nessus.py add_server_scan name description target

List Scans
        ./nessus.py list_scans

List Subnets
        ./nessus.py list_subnets

List running scans
        ./nessus.py list_running_scans

List completed scans
        ./nessus.py list_completed_scans

Export Scan
        ./nessus.py export_scan id

Export scans that have not been completed
        ./nessus.py export_scans


Start Scan
        ./nessus.py launch_scan  id

##################################