Skip to content

Commit 79f220d

Browse files
committed
Adds command nessus_db_scan_workspace that allows user to choose
which workspace will be scanned.
1 parent 963437d commit 79f220d

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

plugins/nessus.rb

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ def commands
7272
"nessus_index" => "Manually generates a search index for exploits",
7373
"nessus_template_list" => "List all the templates on the server",
7474
"nessus_db_scan" => "Create a scan of all IP addresses in db_hosts",
75+
"nessus_db_scan_workspace" => "Create a scan of all IP addresses in db_hosts for a given workspace",
7576
"nessus_db_import" => "Import Nessus scan to the Metasploit connected database",
7677
"nessus_save" => "Save credentials of the logged in user to nessus.yml",
7778
"nessus_folder_list" => "List folders configured on the Nessus server",
78-
"nessus_scanner_list" => "List the configured scanners on the Nessus server",
7979
"nessus_family_list" => "List all the plugin families along with their corresponding family IDs and plugin count"
8080
}
8181
end
@@ -253,6 +253,7 @@ def cmd_nessus_help(*args)
253253
tbl << [ "Nessus Database Commands", "" ]
254254
tbl << [ "-----------------", "-----------------" ]
255255
tbl << [ "nessus_db_scan", "Create a scan of all IP addresses in db_hosts" ]
256+
tbl << [ "nessus_db_scan_workspace", "Create a scan of all IP addresses in db_hosts for a given workspace" ]
256257
tbl << [ "nessus_db_import", "Import Nessus scan to the Metasploit connected database" ]
257258
tbl << [ "", ""]
258259
tbl << [ "Reports Commands", "" ]
@@ -1075,6 +1076,59 @@ def cmd_nessus_db_scan(*args)
10751076
end
10761077
end
10771078

1079+
def cmd_nessus_db_scan_workspace(*args)
1080+
if args[0] == "-h"
1081+
print_status("nessus_db_scan_workspace <policy ID> <scan name> <scan description> <workspace>")
1082+
print_status("Creates a scan based on all the hosts listed in db_hosts for a given workspace.")
1083+
print_status("Use nessus_policy_list to list all available policies with their corresponding policy IDs")
1084+
return
1085+
end
1086+
if !nessus_verify_db
1087+
return
1088+
end
1089+
if !nessus_verify_token
1090+
return
1091+
end
1092+
case args.length
1093+
when 4
1094+
policy_id = args[0]
1095+
name = args[1]
1096+
desc = args[2]
1097+
new_workspace = framework.db.find_workspace(args[3])
1098+
else
1099+
print_status("Usage: ")
1100+
print_status("nessus_db_scan <policy ID> <scan name> <scan description> <workspace>")
1101+
print_status("Use nessus_policy_list to list all available policies with their corresponding policy IDs")
1102+
return
1103+
end
1104+
if !valid_policy(policy_id)
1105+
print_error("That policy does not exist.")
1106+
return
1107+
end
1108+
if new_workspace.nil?
1109+
print_error("That workspace does not exist.")
1110+
return
1111+
end
1112+
framework.db.workspace = new_workspace
1113+
print_status("Switched workspace: #{framework.db.workspace.name}")
1114+
targets = ""
1115+
framework.db.hosts.each do |host|
1116+
targets << host.address
1117+
targets << ","
1118+
print_status("Targets: #{targets}")
1119+
end
1120+
targets.chop!
1121+
print_status("Creating scan from policy #{policy_id}, called \"#{name}\" and scanning all hosts in #{framework.db.workspace.name}")
1122+
scan = @n.scan_create(policy_id, name, desc, targets)
1123+
if !scan["error"]
1124+
scan = scan["scan"]
1125+
print_status("Scan ID #{scan['id']} successfully created")
1126+
print_status("Run nessus_scan_launch #{scan['id']} to launch the scan")
1127+
else
1128+
print_error(JSON.pretty_generate(scan))
1129+
end
1130+
end
1131+
10781132
def cmd_nessus_db_import(*args)
10791133
if args[0] == "-h"
10801134
print_status("nessus_db_import <scan ID>")
@@ -1786,4 +1840,4 @@ def cleanup
17861840
remove_console_dispatcher('Nessus')
17871841
end
17881842
end
1789-
end
1843+
end

0 commit comments

Comments
 (0)