@@ -72,10 +72,10 @@ def commands
72
72
"nessus_index" => "Manually generates a search index for exploits" ,
73
73
"nessus_template_list" => "List all the templates on the server" ,
74
74
"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" ,
75
76
"nessus_db_import" => "Import Nessus scan to the Metasploit connected database" ,
76
77
"nessus_save" => "Save credentials of the logged in user to nessus.yml" ,
77
78
"nessus_folder_list" => "List folders configured on the Nessus server" ,
78
- "nessus_scanner_list" => "List the configured scanners on the Nessus server" ,
79
79
"nessus_family_list" => "List all the plugin families along with their corresponding family IDs and plugin count"
80
80
}
81
81
end
@@ -253,6 +253,7 @@ def cmd_nessus_help(*args)
253
253
tbl << [ "Nessus Database Commands" , "" ]
254
254
tbl << [ "-----------------" , "-----------------" ]
255
255
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" ]
256
257
tbl << [ "nessus_db_import" , "Import Nessus scan to the Metasploit connected database" ]
257
258
tbl << [ "" , "" ]
258
259
tbl << [ "Reports Commands" , "" ]
@@ -1075,6 +1076,59 @@ def cmd_nessus_db_scan(*args)
1075
1076
end
1076
1077
end
1077
1078
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
+
1078
1132
def cmd_nessus_db_import ( *args )
1079
1133
if args [ 0 ] == "-h"
1080
1134
print_status ( "nessus_db_import <scan ID>" )
@@ -1786,4 +1840,4 @@ def cleanup
1786
1840
remove_console_dispatcher ( 'Nessus' )
1787
1841
end
1788
1842
end
1789
- end
1843
+ end
0 commit comments