Class: Ronin::Vulns::CLI::WebVulnCommand Private
- Includes:
 - Importable, Printing
 
- Defined in:
 - lib/ronin/vulns/cli/web_vuln_command.rb
 
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Base class for all web vulnerability commands.
Direct Known Subclasses
Commands::CommandInjection, Commands::Lfi, Commands::OpenRedirect, Commands::ReflectedXss, Commands::Rfi, Commands::Scan, Commands::Sqli, Commands::Ssti
Constant Summary
Constants included from Printing
Instance Attribute Summary collapse
- 
  
    
      #scan_kwargs  ⇒ Hash{Symbol => Object} 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  private
  
    
Keywrod arguments that will be used in #scan_url and #test_url to call WebVuln.scan or WebVuln.test.
 - 
  
    
      #scan_mode  ⇒ :first, :all 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  private
  
    
The scan mode.
 
Instance Method Summary collapse
- 
  
    
      #cookie  ⇒ Ronin::Support::Network::HTTP::Cookie 
    
    
  
  
  
  
  
  
  
  private
  
    
The optional
Cookieheader to send. - 
  
    
      #form_data  ⇒ Hash{String => String}? 
    
    
  
  
  
  
  
  
  
  private
  
    
Additional form params.
 - 
  
    
      #headers  ⇒ Hash{String => String} 
    
    
  
  
  
  
  
  
  
  private
  
    
Additional headers.
 - 
  
    
      #initialize(**kwargs)  ⇒ WebVulnCommand 
    
    
  
  
  
    constructor
  
  
  
  
  
  private
  
    
Initializes the command.
 - 
  
    
      #print_vuln(vuln, print_curl: , print_http: )  ⇒ Object 
    
    
  
  
  
  
  
  
  
  private
  
    
Prints detailed information about a discovered web vulnerability.
 - 
  
    
      #print_vulns(vulns, print_curl: , print_http: )  ⇒ Object 
    
    
  
  
  
  
  
  
  
  private
  
    
Print a summary of all web vulnerabilities found.
 - 
  
    
      #process_url(url) {|vuln| ... } ⇒ Object 
    
    
  
  
  
  
  
  
  
  private
  
    
Processes a URL.
 - 
  
    
      #process_vuln(vuln)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  private
  
    
Logs and optioanlly imports a new discovered web vulnerability.
 - 
  
    
      #referer  ⇒ String? 
    
    
  
  
  
  
  
  
  
  private
  
    
The optional HTTP
Refererheader to send. - 
  
    
      #referer=(new_referer)  ⇒ String? 
    
    
  
  
  
  
  
  
  
  private
  
    
Sets the HTTP
Refererheader to send. - 
  
    
      #request_method  ⇒ :copy, ... 
    
    
  
  
  
  
  
  
  
  private
  
    
The HTTP request method to use.
 - 
  
    
      #request_method=(new_request_method)  ⇒ :copy, ... 
    
    
  
  
  
  
  
  
  
  private
  
    
Sets the HTTP request method to use.
 - 
  
    
      #run(*urls)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  private
  
    
Runs the command.
 - 
  
    
      #scan_url(url) {|vuln| ... } ⇒ Object 
    
    
  
  
  
  
  
  abstract
  
  private
  
    
Scans a URL for web vulnerabilities.
 - 
  
    
      #test_cookie_params  ⇒ Set<String>, true 
    
    
  
  
  
  
  
  
  
  private
  
    
The HTTP Cookie to test.
 - 
  
    
      #test_cookie_params=(new_cookie_params)  ⇒ Set<String>, true 
    
    
  
  
  
  
  
  
  
  private
  
    
Sets the HTTP Cookie to test.
 - 
  
    
      #test_form_params  ⇒ Set<String>? 
    
    
  
  
  
  
  
  
  
  private
  
    
The form params to test.
 - 
  
    
      #test_form_params=(new_form_params)  ⇒ Set<String>, true 
    
    
  
  
  
  
  
  
  
  private
  
    
Sets the form params to test.
 - 
  
    
      #test_header_names  ⇒ Set<String> 
    
    
  
  
  
  
  
  
  
  private
  
    
The HTTP Header names to test.
 - 
  
    
      #test_query_params  ⇒ Set<String>, true 
    
    
  
  
  
  
  
  
  
  private
  
    
The URL query params to test.
 - 
  
    
      #test_query_params=(new_query_params)  ⇒ Set<String>, true 
    
    
  
  
  
  
  
  
  
  private
  
    
Sets the URL query params to test.
 - 
  
    
      #test_url(url)  ⇒ WebVuln? 
    
    
  
  
  
  
  
  abstract
  
  private
  
    
Tests a URL for web vulnerabilities.
 - 
  
    
      #user_agent  ⇒ String, ... 
    
    
  
  
  
  
  
  
  
  private
  
    
The optional HTTP
User-Agentheader to send. - 
  
    
      #user_agent=(new_user_agent)  ⇒ String, ... 
    
    
  
  
  
  
  
  
  
  private
  
    
Sets the HTTP
User-Agentheader. 
Methods included from Importable
Methods included from Printing
#log_vuln, #vuln_param_name, #vuln_param_type, #vuln_type
Constructor Details
#initialize(**kwargs) ⇒ WebVulnCommand
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the command.
      236 237 238 239 240 241  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 236 def initialize(**kwargs) super(**kwargs) @scan_mode = :first @scan_kwargs = {} end  | 
  
Instance Attribute Details
#scan_kwargs ⇒ Hash{Symbol => Object} (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Keywrod arguments that will be used in #scan_url and #test_url to call WebVuln.scan or WebVuln.test.
      228 229 230  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 228 def scan_kwargs @scan_kwargs end  | 
  
#scan_mode ⇒ :first, :all (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The scan mode.
      222 223 224  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 222 def scan_mode @scan_mode end  | 
  
Instance Method Details
#cookie ⇒ Ronin::Support::Network::HTTP::Cookie
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The optional Cookie header to send.
      451 452 453  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 451 def @scan_kwargs[:cookie] ||= Support::Network::HTTP::Cookie.new end  | 
  
#form_data ⇒ Hash{String => String}?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Additional form params.
      481 482 483  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 481 def form_data @scan_kwargs[:form_data] ||= {} end  | 
  
#headers ⇒ Hash{String => String}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Additional headers.
      399 400 401  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 399 def headers @scan_kwargs[:headers] ||= {} end  | 
  
#print_vuln(vuln, print_curl: , print_http: ) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Prints detailed information about a discovered web vulnerability.
      313 314 315 316 317  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 313 def print_vuln(vuln, print_curl: [:print_curl], print_http: [:print_http]) super(vuln, print_curl: print_curl, print_http: print_http) end  | 
  
#print_vulns(vulns, print_curl: , print_http: ) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Print a summary of all web vulnerabilities found.
      293 294 295 296 297  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 293 def print_vulns(vulns, print_curl: [:print_curl], print_http: [:print_http]) super(vulns, print_curl: print_curl, print_http: print_http) end  | 
  
#process_url(url) {|vuln| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Processes a URL.
      332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 332 def process_url(url) unless url.start_with?('http://') || url.start_with?('https://') print_error("URL must start with http:// or https://: #{url.inspect}") exit(-1) end if @scan_mode == :first if (first_vuln = test_url(url)) process_vuln(first_vuln) yield first_vuln end else scan_url(url) do |vuln| process_vuln(vuln) yield vuln end end end  | 
  
#process_vuln(vuln) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Logs and optioanlly imports a new discovered web vulnerability.
      359 360 361 362  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 359 def process_vuln(vuln) log_vuln(vuln) import_vuln(vuln) if [:import] end  | 
  
#referer ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The optional HTTP Referer header to send.
      460 461 462  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 460 def referer @scan_kwargs[:referer] end  | 
  
#referer=(new_referer) ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Sets the HTTP Referer header to send.
      472 473 474  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 472 def referer=(new_referer) @scan_kwargs[:referer] = new_referer end  | 
  
#request_method ⇒ :copy, ...
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The HTTP request method to use.
      373 374 375  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 373 def request_method @scan_kwargs[:request_method] end  | 
  
#request_method=(new_request_method) ⇒ :copy, ...
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Sets the HTTP request method to use.
      390 391 392  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 390 def request_method=(new_request_method) @scan_kwargs[:request_method] = new_request_method end  | 
  
#run(*urls) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Runs the command.
      249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 249 def run(*urls) unless ([:input] || !urls.empty?) print_error "must specify URL(s) or --input" exit(-1) end db_connect if [:import] vulns = [] if [:input] File.open([:input]) do |file| file.each_line(chomp: true) do |url| process_url(url) do |vuln| vulns << vuln end end end elsif !urls.empty? urls.each do |url| process_url(url) do |vuln| vulns << vuln end end end puts unless vulns.empty? print_vulns(vulns) end  | 
  
#scan_url(url) {|vuln| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Scans a URL for web vulnerabilities.
      571 572 573  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 571 def scan_url(url,&block) raise(NotImplementedError,"#{self.class}#scan_url was not defined") end  | 
  
#test_cookie_params ⇒ Set<String>, true
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The HTTP Cookie to test.
      520 521 522  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 520 def @scan_kwargs[:cookie_params] ||= Set.new end  | 
  
#test_cookie_params=(new_cookie_params) ⇒ Set<String>, true
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Sets the HTTP Cookie to test.
      532 533 534  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 532 def () @scan_kwargs[:cookie_params] = end  | 
  
#test_form_params ⇒ Set<String>?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The form params to test.
      541 542 543  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 541 def test_form_params @scan_kwargs[:form_params] ||= Set.new end  | 
  
#test_form_params=(new_form_params) ⇒ Set<String>, true
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Sets the form params to test.
      553 554 555  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 553 def test_form_params=(new_form_params) @scan_kwargs[:form_params] = new_form_params end  | 
  
#test_header_names ⇒ Set<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The HTTP Header names to test.
      511 512 513  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 511 def test_header_names @scan_kwargs[:header_names] ||= Set.new end  | 
  
#test_query_params ⇒ Set<String>, true
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The URL query params to test.
      490 491 492  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 490 def test_query_params @scan_kwargs[:query_params] ||= Set.new end  | 
  
#test_query_params=(new_query_params) ⇒ Set<String>, true
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Sets the URL query params to test.
      502 503 504  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 502 def test_query_params=(new_query_params) @scan_kwargs[:query_params] = new_query_params end  | 
  
#test_url(url) ⇒ WebVuln?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Tests a URL for web vulnerabilities.
      586 587 588  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 586 def test_url(url) raise(NotImplementedError,"#{self.class}#test_url was not defined") end  | 
  
#user_agent ⇒ String, ...
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The optional HTTP User-Agent header to send.
      416 417 418  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 416 def user_agent @scan_kwargs[:user_agent] end  | 
  
#user_agent=(new_user_agent) ⇒ String, ...
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Sets the HTTP User-Agent header.
The new User-Agent value to send.
      442 443 444  | 
    
      # File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 442 def user_agent=(new_user_agent) @scan_kwargs[:user_agent] = new_user_agent end  |