Module: PWN::Plugins::OpenVAS
- Defined in:
- lib/pwn/plugins/openvas.rb
Overview
This plugin is used for interacting w/ OpenVAS using OMP (OpenVAS Management Protocol).
Class Method Summary collapse
-
.authors ⇒ Object
- Author(s)
-
0day Inc.
-
.get_report_types(opts = {}) ⇒ Object
- Supported Method Parameters
-
report_types = PWN::Plugins::OpenVAS.get_report_types( username: ‘required username’, password: ‘optional password (will prompt if nil)’ ).
-
.get_task_id(opts = {}) ⇒ Object
- Supported Method Parameters
-
task_xml_resp = PWN::Plugins::OpenVAS.get_task_id( task_name: ‘required task name to start’, username: ‘required username’, password: ‘optional password (will prompt if nil)’ ).
-
.get_task_status(opts = {}) ⇒ Object
- Supported Method Parameters
-
task_status = PWN::Plugins::OpenVAS.get_task_status( task_name: ‘required task name to start’, username: ‘required username’, password: ‘optional password (will prompt if nil)’ ).
-
.help ⇒ Object
Display Usage for this Module.
-
.last_report_id(opts = {}) ⇒ Object
- Supported Method Parameters
-
last_report_id = PWN::Plugins::OpenVAS.last_report_id( task_name: ‘required task name to start’, username: ‘required username’, password: ‘optional password (will prompt if nil)’ ).
-
.save_report(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::OpenVAS.save_report( report_type: ‘required report type (csv|itg|pdf|txt|xml)’, report_id: ‘required report id to save’, report_dir: ‘required directory to save report’, username: ‘required username’, password: ‘optional password (will prompt if nil)’, report_filter: ‘optional - results filter (Default: “apply_overrides=0 levels=hml rows=1000 min_qod=70 first=1 sort-reverse=severity”) ).
-
.start_task(opts = {}) ⇒ Object
- Supported Method Parameters
-
start_task_xml_resp = PWN::Plugins::OpenVAS.start_task( task_name: ‘required task name to start’, username: ‘required username’, password: ‘optional password (will prompt if nil)’ ).
Class Method Details
.authors ⇒ Object
- Author(s)
-
0day Inc. <[email protected]>
261 262 263 264 265 |
# File 'lib/pwn/plugins/openvas.rb', line 261 public_class_method def self. "AUTHOR(S): 0day Inc. <[email protected]> " end |
.get_report_types(opts = {}) ⇒ Object
- Supported Method Parameters
-
report_types = PWN::Plugins::OpenVAS.get_report_types(
username: 'required username', password: 'optional password (will prompt if nil)'
)
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/pwn/plugins/openvas.rb', line 239 public_class_method def self.get_report_types(opts = {}) username = opts[:username].to_s.scrub password = if opts[:password].nil? PWN::Plugins::AuthenticationHelper.mask_password else opts[:password].to_s.scrub end report_types = %i[ csv itg pdf txt xml ] rescue StandardError => e raise e end |
.get_task_id(opts = {}) ⇒ Object
- Supported Method Parameters
-
task_xml_resp = PWN::Plugins::OpenVAS.get_task_id(
task_name: 'required task name to start', username: 'required username', password: 'optional password (will prompt if nil)'
)
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pwn/plugins/openvas.rb', line 18 public_class_method def self.get_task_id(opts = {}) task_name = opts[:task_name].to_s.scrub username = opts[:username].to_s.scrub password = if opts[:password].nil? PWN::Plugins::AuthenticationHelper.mask_password else opts[:password].to_s.scrub end get_tasks_xml_resp = Nokogiri::XML( `sudo runuser -u _gvm -- /usr/bin/gvm-cli \ --gmp-username '#{username}' \ --gmp-password '#{password}' \ socket \ --xml="<get_tasks/>" ` ) get_tasks_xml_resp.xpath( "/get_tasks_response/task[name/text()='#{task_name}']" ) rescue StandardError => e raise e end |
.get_task_status(opts = {}) ⇒ Object
- Supported Method Parameters
-
task_status = PWN::Plugins::OpenVAS.get_task_status(
task_name: 'required task name to start', username: 'required username', password: 'optional password (will prompt if nil)'
)
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/pwn/plugins/openvas.rb', line 86 public_class_method def self.get_task_status(opts = {}) task_name = opts[:task_name].to_s.scrub username = opts[:username].to_s.scrub password = if opts[:password].nil? PWN::Plugins::AuthenticationHelper.mask_password else opts[:password].to_s.scrub end get_task_id( task_name: task_name, username: username, password: password ).xpath('status').text rescue StandardError => e raise e end |
.help ⇒ Object
Display Usage for this Module
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/pwn/plugins/openvas.rb', line 269 public_class_method def self.help puts "USAGE: task_xml_resp = #{self}.get_task_id( task_name: 'required task name to start', username: 'required username', password: 'optional password (will prompt if nil)' ) start_task_xml_resp = #{self}.start_task( task_name: 'required task name to start', username: 'required username', password: 'optional password (will prompt if nil)' ) task_status = #{self}.get_task_status( task_name: 'required task name to start', username: 'required username', password: 'optional password (will prompt if nil)' ) last_report_id = #{self}.last_report_id( task_name: 'required task name to start', username: 'required username', password: 'optional password (will prompt if nil)' ) #{self}.save_report( report_type: 'required report type (csv|itg|pdf|txt|xml)', report_id: 'required report id to save', report_dir: 'required directory to save report', username: 'required username', password: 'optional password (will prompt if nil)', report_filter: 'optional - results filter (Default: \"apply_overrides=0 levels=hml rows=1000 min_qod=70 first=1 sort-reverse=severity\") ) report_types = #{self}.get_report_types( username: 'required username', password: 'optional password (will prompt if nil)' ) #{self}.authors " end |
.last_report_id(opts = {}) ⇒ Object
- Supported Method Parameters
-
last_report_id = PWN::Plugins::OpenVAS.last_report_id(
task_name: 'required task name to start', username: 'required username', password: 'optional password (will prompt if nil)'
)
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/pwn/plugins/openvas.rb', line 112 public_class_method def self.last_report_id(opts = {}) task_name = opts[:task_name].to_s.scrub username = opts[:username].to_s.scrub password = if opts[:password].nil? PWN::Plugins::AuthenticationHelper.mask_password else opts[:password].to_s.scrub end task_id = get_task_id( task_name: task_name, username: username, password: password ).xpath('@id').text report_xml_resp = Nokogiri::XML( `sudo runuser -u _gvm -- /usr/bin/gvm-cli \ --gmp-username '#{username}' \ --gmp-password '#{password}' \ socket \ --xml="<get_reports/>" ` ) report_xml_resp.xpath( "/get_reports_response/report/task[@id='#{task_id}']" ).last.parent.xpath( '@id' ).text rescue StandardError => e raise e end |
.save_report(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::OpenVAS.save_report(
report_type: 'required report type (csv|itg|pdf|txt|xml)', report_id: 'required report id to save', report_dir: 'required directory to save report', username: 'required username', password: 'optional password (will prompt if nil)', report_filter: 'optional - results filter (Default: "apply_overrides=0 levels=hml rows=1000 min_qod=70 first=1 sort-reverse=severity")
)
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/pwn/plugins/openvas.rb', line 156 public_class_method def self.save_report(opts = {}) report_type = opts[:report_type].to_s.scrub report_id = opts[:report_id].to_s.scrub report_dir = opts[:report_dir].to_s.scrub raise "#{report_dir} Does Not Exist." unless Dir.exist?( report_dir ) username = opts[:username].to_s.scrub password = if opts[:password].nil? PWN::Plugins::AuthenticationHelper.mask_password else opts[:password].to_s.scrub end report_filter = opts[:report_filter] report_filter ||= 'apply_overrides=0 levels=hml rows=1000 min_qod=70 first=1 sort-reverse=severity' case report_type.to_sym when :csv report_type_name = 'CSV Results' when :itg report_type_name = 'ITG' when :pdf report_type_name = 'PDF' when :txt report_type_name = 'TXT' when :xml report_type_name = 'XML' else raise "Report Type: \"#{report_type}\" not supported." end report_formats_xml_resp = Nokogiri::XML( `sudo runuser -u _gvm -- /usr/bin/gvm-cli \ --gmp-username '#{username}' \ --gmp-password '#{password}' \ socket \ --xml="<get_report_formats/>" ` ) rpt_fmt_xml_resp_by_name = report_formats_xml_resp.xpath( "/get_report_formats_response/report_format[name/text()='#{report_type_name}']" ) format_id = rpt_fmt_xml_resp_by_name.xpath('@id').text # Generate Report report_xml_resp = Nokogiri::XML( `sudo runuser -u _gvm -- /usr/bin/gvm-cli \ --gmp-username '#{username}' \ --gmp-password '#{password}' \ socket \ --xml="<get_reports report_id='#{report_id}' format_id='#{format_id}' filter='#{report_filter}' details='1' />" ` ) # timestamp = Time.parse( # report_xml_resp.xpath('//modification_time') # ).localtime.strftime( # '%Y-%m-%d-%H-%M-%S%z' # ) base64_report = report_xml_resp.xpath( '//report/text()' ).text # File.open("#{report_dir}/openvas_results-#{timestamp}.#{report_type}", 'w') do |f| File.open("#{report_dir}/openvas_results.#{report_type}", 'w') do |f| f.puts Base64.strict_decode64(base64_report) end rescue StandardError => e raise e end |
.start_task(opts = {}) ⇒ Object
- Supported Method Parameters
-
start_task_xml_resp = PWN::Plugins::OpenVAS.start_task(
task_name: 'required task name to start', username: 'required username', password: 'optional password (will prompt if nil)'
)
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/pwn/plugins/openvas.rb', line 51 public_class_method def self.start_task(opts = {}) task_name = opts[:task_name].to_s.scrub username = opts[:username].to_s.scrub password = if opts[:password].nil? PWN::Plugins::AuthenticationHelper.mask_password else opts[:password].to_s.scrub end task_id = get_task_id( task_name: task_name, username: username, password: password ).xpath('@id').text Nokogiri::XML( `sudo runuser -u _gvm -- /usr/bin/gvm-cli \ --gmp-username '#{username}' \ --gmp-password '#{password}' \ socket \ --xml="<start_task task_id='#{task_id}'/>" ` ) rescue StandardError => e raise e end |