@@ -71,6 +71,7 @@ def commands
71
71
"nessus_index" => "Manually generates a search index for exploits" ,
72
72
"nessus_template_list" => "List all the templates on the server" ,
73
73
"nessus_db_scan" => "Create a scan of all IP addresses in db_hosts" ,
74
+ "nessus_db_scan_workspace" => "Create a scan of all IP addresses in db_hosts for a given workspace" ,
74
75
"nessus_db_import" => "Import Nessus scan to the Metasploit connected database" ,
75
76
"nessus_save" => "Save credentials of the logged in user to nessus.yml" ,
76
77
"nessus_folder_list" => "List folders configured on the Nessus server" ,
@@ -256,6 +257,7 @@ def cmd_nessus_help(*args)
256
257
tbl << [ "Nessus Database Commands" , "" ]
257
258
tbl << [ "-----------------" , "-----------------" ]
258
259
tbl << [ "nessus_db_scan" , "Create a scan of all IP addresses in db_hosts" ]
260
+ tbl << [ "nessus_db_scan_workspace" , "Create a scan of all IP addresses in db_hosts for a given workspace" ]
259
261
tbl << [ "nessus_db_import" , "Import Nessus scan to the Metasploit connected database" ]
260
262
tbl << [ "" , "" ]
261
263
tbl << [ "Reports Commands" , "" ]
@@ -1091,6 +1093,59 @@ def cmd_nessus_db_scan(*args)
1091
1093
end
1092
1094
end
1093
1095
1096
+ def cmd_nessus_db_scan_workspace ( *args )
1097
+ if args [ 0 ] == "-h"
1098
+ print_status ( "nessus_db_scan_workspace <policy ID> <scan name> <scan description> <workspace>" )
1099
+ print_status ( "Creates a scan based on all the hosts listed in db_hosts for a given workspace." )
1100
+ print_status ( "Use nessus_policy_list to list all available policies with their corresponding policy IDs" )
1101
+ return
1102
+ end
1103
+ if !nessus_verify_db
1104
+ return
1105
+ end
1106
+ if !nessus_verify_token
1107
+ return
1108
+ end
1109
+ case args . length
1110
+ when 4
1111
+ policy_id = args [ 0 ]
1112
+ name = args [ 1 ]
1113
+ desc = args [ 2 ]
1114
+ new_workspace = framework . db . find_workspace ( args [ 3 ] )
1115
+ else
1116
+ print_status ( "Usage: " )
1117
+ print_status ( "nessus_db_scan_workspace <policy ID> <scan name> <scan description> <workspace>" )
1118
+ print_status ( "Use nessus_policy_list to list all available policies with their corresponding policy IDs" )
1119
+ return
1120
+ end
1121
+ if !valid_policy ( policy_id )
1122
+ print_error ( "That policy does not exist." )
1123
+ return
1124
+ end
1125
+ if new_workspace . nil?
1126
+ print_error ( "That workspace does not exist." )
1127
+ return
1128
+ end
1129
+ framework . db . workspace = new_workspace
1130
+ print_status ( "Switched workspace: #{ framework . db . workspace . name } " )
1131
+ targets = ""
1132
+ framework . db . hosts . each do |host |
1133
+ targets << host . address
1134
+ targets << ","
1135
+ print_status ( "Targets: #{ targets } " )
1136
+ end
1137
+ targets . chop!
1138
+ print_status ( "Creating scan from policy #{ policy_id } , called \" #{ name } \" and scanning all hosts in #{ framework . db . workspace . name } " )
1139
+ scan = @n . scan_create ( policy_id , name , desc , targets )
1140
+ if !scan [ "error" ]
1141
+ scan = scan [ "scan" ]
1142
+ print_status ( "Scan ID #{ scan [ 'id' ] } successfully created" )
1143
+ print_status ( "Run nessus_scan_launch #{ scan [ 'id' ] } to launch the scan" )
1144
+ else
1145
+ print_error ( JSON . pretty_generate ( scan ) )
1146
+ end
1147
+ end
1148
+
1094
1149
def cmd_nessus_db_import ( *args )
1095
1150
if args [ 0 ] == "-h"
1096
1151
print_status ( "nessus_db_import <scan ID>" )
0 commit comments