Class: Ronin::Vulns::CLI::WebVulnCommand Private
- Includes:
- Logging
- 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::Lfi, Commands::OpenRedirect, Commands::ReflectedXss, Commands::Rfi, Commands::Scan, Commands::Sqli, Commands::Ssti
Constant Summary
Constants included from Logging
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
Cookie
header 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.
-
#process_url(url) ⇒ Boolean
private
Processes a URL.
-
#referer ⇒ String?
private
The optional HTTP
Referer
header to send. -
#referer=(new_referer) ⇒ String?
private
Sets the HTTP
Referer
header to send. -
#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_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.
Methods included from Logging
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.
181 182 183 184 185 186 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 181 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.
173 174 175 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 173 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.
167 168 169 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 167 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.
267 268 269 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 267 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.
297 298 299 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 297 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.
258 259 260 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 258 def headers @scan_kwargs[:headers] ||= {} end |
#process_url(url) ⇒ Boolean
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.
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 228 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 vuln_discovered = false if @scan_mode == :first if (first_vuln = test_url(url)) log_vuln(first_vuln) vuln_discovered = true end else scan_url(url) do |vuln| log_vuln(vuln) vuln_discovered = true end end return vuln_discovered 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.
276 277 278 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 276 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.
288 289 290 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 288 def referer=(new_referer) @scan_kwargs[:referer] = new_referer 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.
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 194 def run(*urls) unless ([:input] || !urls.empty?) print_error "must specify URL(s) or --input" exit(-1) end vulns_discovered = false if [:input] File.open([:input]) do |file| file.each_line(chomp: true) do |url| vulns_discovered ||= process_url(url) end end elsif !urls.empty? urls.each do |url| vulns_discovered ||= process_url(url) end end unless vulns_discovered puts colors.green("No vulnerabilities found") end 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.
375 376 377 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 375 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.
336 337 338 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 336 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.
348 349 350 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 348 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.
357 358 359 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 357 def test_form_params @scan_kwargs[:form_params] ||= Set.new 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.
327 328 329 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 327 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.
306 307 308 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 306 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.
318 319 320 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 318 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.
390 391 392 |
# File 'lib/ronin/vulns/cli/web_vuln_command.rb', line 390 def test_url(url) raise(NotImplementedError,"#{self.class}#test_url was not defined") end |