Module: Ronin::Exploits::Mixins::HTTP
- Included in:
- Web
- Defined in:
- lib/ronin/exploits/mixins/http.rb
Overview
Adds HTTP helper methods for communicating with a web server.
Constant Summary collapse
- HTTP_USER_AGENT_ALIASES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Possible values for the
user_agent
param. [ :random, :chrome, :firefox, :safari, :linux, :macos, :windows, :iphone, :ipad, :android ] + Support::Network::HTTP::UserAgents::ALIASES.keys
Class Method Summary collapse
-
.included(exploit) ⇒ Object
private
Adds the required
base_url
params to the exploit class.
Instance Method Summary collapse
-
#http ⇒ Ronin::Support::Network::HTTP
A persistent HTTP connection to the target host and port.
-
#http_allowed_methods(path, **kwargs) {|response| ... } ⇒ Array<Symbol>
Performs a
OPTIONS
HTTP request for the given URI and parses theAllow
response header. -
#http_cookie ⇒ String?
private
The
Cookie
to use for HTTP requests. -
#http_copy(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
COPY
request for the given URI. -
#http_delete(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
DELETE
request for the given URI. -
#http_get(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
GET
request for the given URI. -
#http_get_body(path, **kwargs) ⇒ String
Performs a
GET
request for the given URI and returns the response body. -
#http_get_cookies(path, **kwargs) ⇒ Array<Ronin::Support::Network::HTTPSetCookie>?
Sends an HTTP request and returns the parsed
Set-Cookie
header(s). -
#http_get_headers(path, **kwargs) ⇒ Hash{String => String}
Performs a
GET
request for the given URI and returns the response headers. -
#http_head(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
HEAD
request for the given URI. -
#http_headers ⇒ Hash{Symbol,String => String,Array}
private
Additional default headers to send with every HTTP request.
-
#http_lock(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
LOCK
request for the given URI. -
#http_mkcol(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
MKCOL
request for the given URI. -
#http_move(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
MOVE
request for the given URI. -
#http_ok?(method = :head, path, **kwargs) ⇒ Boolean
Sends a HTTP request and determines if the response status was 200.
-
#http_options(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
OPTIONS
request for the given URI. -
#http_password ⇒ String?
private
The HTTP
Basic-Auth
password to use for all HTTP requests. -
#http_patch(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
PATCH
request for the given URI. -
#http_post(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
POST
request for the given URI. -
#http_post_body(path, **kwargs) ⇒ String
Performs a
POST
request for the given URI and returns the response body. -
#http_post_headers(path, **kwargs) ⇒ Hash{String => String}
Performs a
POST
request on the given URI and returns the response headers. -
#http_powered_by_header(path, method: :head, **kwargs) ⇒ String?
Sends an HTTP request and returns the
X-Powered-By
header. -
#http_propfind(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
(also: #http_prop_find)
Performs a
PROPFIND
request for the given URI. -
#http_proppatch(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
(also: #http_prop_patch)
Performs a
PROPPATCH
request for the given URI. -
#http_proxy ⇒ String?
private
The HTTP proxy to use for all HTTP requests.
-
#http_put(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
PUT
request for the given URI. -
#http_request(method, path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs and arbitrary HTTP request.
-
#http_response_body(method = :get, path, **kwargs) ⇒ String
Sends an arbitrary HTTP request and returns the response body.
-
#http_response_headers(method = :head, path, **kwargs) ⇒ Hash{String => String}
Sends an arbitrary HTTP request and returns the response headers.
-
#http_response_status(method = :head, path, **kwargs) ⇒ Integer
Sends an arbitrary HTTP request and returns the response status.
-
#http_server_header(path, method: :head, **kwargs) ⇒ String?
Sends an HTTP request and returns the
Server
header. -
#http_trace(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
TRACE
request for the given URI. -
#http_unlock(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a
UNLOCK
request for the given URI. -
#http_user ⇒ String?
private
The HTTP
Basic-Auth
user to use for all HTTP requests. -
#http_user_agent ⇒ String, ...
private
The
User-Agent
to use for HTTP requests.
Class Method Details
.included(exploit) ⇒ 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.
Adds the required base_url
params to the exploit class.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ronin/exploits/mixins/http.rb', line 61 def self.included(exploit) exploit.include Params::BaseURL exploit.param :http_proxy, desc: 'The HTTP proxy to use' exploit.param :http_user, desc: 'The HTTP Basic-Auth user' exploit.param :http_password, desc: 'The HTTP Basic-Auth password' exploit.param :user_agent, Core::Params::Types::Enum.new(HTTP_USER_AGENT_ALIASES), desc: 'The HTTP User-Agent to select' exploit.param :user_agent_string, desc: 'The raw HTTP User-Agent string to use' exploit.param :http_cookie, desc: 'The raw HTTP Cookie to use' end |
Instance Method Details
#http ⇒ Ronin::Support::Network::HTTP
This method will lazily initialize the HTTP connection on the first time this method is called and memoize the HTTP object.
A persistent HTTP connection to the target host and port.
178 179 180 181 182 183 184 185 186 187 |
# File 'lib/ronin/exploits/mixins/http.rb', line 178 def http @http ||= Support::Network::HTTP.connect_uri( params[:base_url], proxy: http_proxy, headers: http_headers, user_agent: http_user_agent, cookie: , user: http_user, password: http_password ) end |
#http_allowed_methods(path, **kwargs) {|response| ... } ⇒ Array<Symbol>
Performs a OPTIONS
HTTP request for the given URI and parses the
Allow
response header.
635 636 637 638 639 640 641 |
# File 'lib/ronin/exploits/mixins/http.rb', line 635 def http_allowed_methods(path,**kwargs,&block) if debug? print_debug "Checking allowed HTTP methods for #{url_for(path)} ..." end http.allowed_methods(path,**kwargs) end |
#http_cookie ⇒ 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 Cookie
to use for HTTP requests.
140 141 142 |
# File 'lib/ronin/exploits/mixins/http.rb', line 140 def params[:http_cookie] end |
#http_copy(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a COPY
request for the given URI.
374 375 376 377 378 379 380 |
# File 'lib/ronin/exploits/mixins/http.rb', line 374 def http_copy(path,**kwargs) if debug? print_debug "Requesting COPY #{url_for(path)} ..." end http.copy(path,**kwargs) end |
#http_delete(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a DELETE
request for the given URI.
399 400 401 402 403 404 405 |
# File 'lib/ronin/exploits/mixins/http.rb', line 399 def http_delete(path,**kwargs,&block) if debug? print_debug "Requesting DELETE #{url_for(path)} ..." end http.delete(path,**kwargs) end |
#http_get(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a GET
request for the given URI.
424 425 426 427 428 429 430 |
# File 'lib/ronin/exploits/mixins/http.rb', line 424 def http_get(path,**kwargs,&block) if debug? print_debug "Requesting GET #{url_for(path)} ..." end http.get(path,**kwargs) end |
#http_get_body(path, **kwargs) ⇒ String
Performs a GET
request for the given URI and returns the response
body.
484 485 486 487 488 489 490 |
# File 'lib/ronin/exploits/mixins/http.rb', line 484 def http_get_body(path,**kwargs) if debug? print_debug "Requesting body for GET #{url_for(path)} ..." end http.get_body(path,**kwargs) end |
#http_get_cookies(path, **kwargs) ⇒ Array<Ronin::Support::Network::HTTPSetCookie>?
Sends an HTTP request and returns the parsed Set-Cookie
header(s).
464 465 466 467 468 469 470 |
# File 'lib/ronin/exploits/mixins/http.rb', line 464 def (path,**kwargs) if debug? print_debug "Getting cookies for #{url_for(path)} ..." end http.(path,**kwargs) end |
#http_get_headers(path, **kwargs) ⇒ Hash{String => String}
Performs a GET
request for the given URI and returns the response
headers.
444 445 446 447 448 449 450 |
# File 'lib/ronin/exploits/mixins/http.rb', line 444 def http_get_headers(path,**kwargs) if debug? print_debug "Requesting headers for GET #{url_for(path)} ..." end http.get_headers(path,**kwargs) end |
#http_head(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a HEAD
request for the given URI.
509 510 511 512 513 514 515 |
# File 'lib/ronin/exploits/mixins/http.rb', line 509 def http_head(path,**kwargs,&block) if debug? print_debug "Requesting HEAD #{url_for(path)} ..." end http.head(path,**kwargs,&block) end |
#http_headers ⇒ Hash{Symbol,String => String,Array}
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 default headers to send with every HTTP request.
117 118 119 |
# File 'lib/ronin/exploits/mixins/http.rb', line 117 def http_headers {} end |
#http_lock(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a LOCK
request for the given URI.
534 535 536 537 538 539 540 |
# File 'lib/ronin/exploits/mixins/http.rb', line 534 def http_lock(path,**kwargs,&block) if debug? print_debug "Requesting LOCK #{url_for(path)} ..." end http.lock(path,**kwargs,&block) end |
#http_mkcol(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a MKCOL
request for the given URI.
559 560 561 562 563 564 565 |
# File 'lib/ronin/exploits/mixins/http.rb', line 559 def http_mkcol(path,**kwargs,&block) if debug? print_debug "Requesting MKCOL #{url_for(path)} ..." end http.mkcol(path,**kwargs,&block) end |
#http_move(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a MOVE
request for the given URI.
584 585 586 587 588 589 590 |
# File 'lib/ronin/exploits/mixins/http.rb', line 584 def http_move(path,**kwargs,&block) if debug? print_debug "Requesting MOVE #{url_for(path)} ..." end http.move(path,**kwargs,&block) end |
#http_ok?(method = :head, path, **kwargs) ⇒ Boolean
Sends a HTTP request and determines if the response status was 200.
257 258 259 260 261 262 263 |
# File 'lib/ronin/exploits/mixins/http.rb', line 257 def http_ok?(method=:head,path,**kwargs) if debug? print_debug "Checking if response status for #{method.upcase} #{url_for(path)} is 200 ..." end http.ok?(method,path,**kwargs) end |
#http_options(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a OPTIONS
request for the given URI.
609 610 611 612 613 614 615 |
# File 'lib/ronin/exploits/mixins/http.rb', line 609 def (path,**kwargs,&block) if debug? print_debug "Requesting OPTIONS #{url_for(path)} ..." end http.(path,**kwargs,&block) end |
#http_password ⇒ 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 Basic-Auth
password to use for all HTTP requests.
106 107 108 |
# File 'lib/ronin/exploits/mixins/http.rb', line 106 def http_password params[:http_password] end |
#http_patch(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a PATCH
request for the given URI.
662 663 664 665 666 667 668 |
# File 'lib/ronin/exploits/mixins/http.rb', line 662 def http_patch(path,**kwargs,&block) if debug? print_debug "Requesting PATCH #{url_for(path)} ..." end http.patch(path,**kwargs,&block) end |
#http_post(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a POST
request for the given URI.
687 688 689 690 691 692 693 |
# File 'lib/ronin/exploits/mixins/http.rb', line 687 def http_post(path,**kwargs,&block) if debug? print_debug "Requesting POST #{url_for(path)} ..." end http.post(path,**kwargs,&block) end |
#http_post_body(path, **kwargs) ⇒ String
Performs a POST
request for the given URI and returns the
response body.
727 728 729 730 731 732 733 |
# File 'lib/ronin/exploits/mixins/http.rb', line 727 def http_post_body(path,**kwargs) if debug? print_debug "Requesting response body for POST #{url_for(path)} ..." end http.post_body(path,**kwargs) end |
#http_post_headers(path, **kwargs) ⇒ Hash{String => String}
Performs a POST
request on the given URI and returns the response
headers.
707 708 709 710 711 712 713 |
# File 'lib/ronin/exploits/mixins/http.rb', line 707 def http_post_headers(path,**kwargs) if debug? print_debug "Requesting response headers for POST #{url_for(path)} ..." end http.post_headers(path,**kwargs) end |
#http_powered_by_header(path, method: :head, **kwargs) ⇒ String?
Sends an HTTP request and returns the X-Powered-By
header.
The HTTP method to use for the request.
327 328 329 330 331 332 333 |
# File 'lib/ronin/exploits/mixins/http.rb', line 327 def http_powered_by_header(path, method: :head, **kwargs) if debug? print_debug "Requesting the 'X-Powered-By' header for #{method.upcase} #{url_for(path)} ..." end http.powered_by_header(path, method: method, **kwargs) end |
#http_propfind(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse Also known as: http_prop_find
Performs a PROPFIND
request for the given URI.
752 753 754 755 756 757 758 |
# File 'lib/ronin/exploits/mixins/http.rb', line 752 def http_propfind(path,**kwargs,&block) if debug? print_debug "Requesting PROPFIND #{url_for(path)} ..." end http.propfind(path,**kwargs,&block) end |
#http_proppatch(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse Also known as: http_prop_patch
Performs a PROPPATCH
request for the given URI.
779 780 781 782 783 784 785 |
# File 'lib/ronin/exploits/mixins/http.rb', line 779 def http_proppatch(path,**kwargs,&block) if debug? print_debug "Requesting PROPPATCH #{url_for(path)} ..." end http.proppatch(path,**kwargs,&block) end |
#http_proxy ⇒ 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 proxy to use for all HTTP requests.
84 85 86 |
# File 'lib/ronin/exploits/mixins/http.rb', line 84 def http_proxy params[:http_proxy] end |
#http_put(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a PUT
request for the given URI.
806 807 808 809 810 811 812 |
# File 'lib/ronin/exploits/mixins/http.rb', line 806 def http_put(path,**kwargs,&block) if debug? print_debug "Requesting PUT #{url_for(path)} ..." end http.put(path,**kwargs,&block) end |
#http_request(method, path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs and arbitrary HTTP request.
213 214 215 216 217 218 219 |
# File 'lib/ronin/exploits/mixins/http.rb', line 213 def http_request(method,path,**kwargs,&block) if debug? print_debug "Sending #{method.upcase} request to #{url_for(path)} ..." end http.request(method,path,**kwargs,&block) end |
#http_response_body(method = :get, path, **kwargs) ⇒ String
Sends an arbitrary HTTP request and returns the response body.
349 350 351 352 353 354 355 |
# File 'lib/ronin/exploits/mixins/http.rb', line 349 def http_response_body(method=:get, path,**kwargs) if debug? print_debug "Requesting response body for #{method.upcase} #{url_for(path)} ..." end http.response_body(method, path,**kwargs) end |
#http_response_headers(method = :head, path, **kwargs) ⇒ Hash{String => String}
Sends an arbitrary HTTP request and returns the response headers.
279 280 281 282 283 284 285 |
# File 'lib/ronin/exploits/mixins/http.rb', line 279 def http_response_headers(method=:head,path,**kwargs) if debug? print_debug "Requesting response headers for #{method.upcase} #{url_for(path)} ..." end http.response_headers(method,path,**kwargs) end |
#http_response_status(method = :head, path, **kwargs) ⇒ Integer
Sends an arbitrary HTTP request and returns the response status.
235 236 237 238 239 240 241 |
# File 'lib/ronin/exploits/mixins/http.rb', line 235 def http_response_status(method=:head,path,**kwargs) if debug? print_debug "Checking response status for #{method.upcase} #{url_for(path)} ..." end http.response_status(method,path,**kwargs) end |
#http_server_header(path, method: :head, **kwargs) ⇒ String?
Sends an HTTP request and returns the Server
header.
The HTTP method to use for the request.
303 304 305 306 307 308 309 |
# File 'lib/ronin/exploits/mixins/http.rb', line 303 def http_server_header(path, method: :head, **kwargs) if debug? print_debug "Requesting the 'Server' header for #{method.upcase} #{url_for(path)} ..." end http.server_header(path, method: method, **kwargs) end |
#http_trace(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a TRACE
request for the given URI.
831 832 833 834 835 836 837 |
# File 'lib/ronin/exploits/mixins/http.rb', line 831 def http_trace(path,**kwargs,&block) if debug? print_debug "Requesting TRACE #{url_for(path)} ..." end http.trace(path,**kwargs,&block) end |
#http_unlock(path, **kwargs) {|response| ... } ⇒ Net::HTTPResponse
Performs a UNLOCK
request for the given URI.
856 857 858 859 860 861 862 |
# File 'lib/ronin/exploits/mixins/http.rb', line 856 def http_unlock(path,**kwargs,&block) if debug? print_debug "Requesting UNLOCK #{url_for(path)} ..." end http.unlock(path,**kwargs,&block) end |
#http_user ⇒ 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 Basic-Auth
user to use for all HTTP requests.
95 96 97 |
# File 'lib/ronin/exploits/mixins/http.rb', line 95 def http_user params[:http_user] end |
#http_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 User-Agent
to use for HTTP requests.
129 130 131 |
# File 'lib/ronin/exploits/mixins/http.rb', line 129 def http_user_agent params[:user_agent_string] || params[:user_agent] end |