Module: Msf::Exploit::Remote::HTTP::ApacheSolr
- Defined in:
- lib/msf/core/exploit/remote/http/apache_solr.rb
Overview
This module provides a way of logging into Apache Solr
Instance Method Summary collapse
- #solr_check_auth ⇒ Object
-
#solr_get(opts = {}) ⇒ Object
make sending requests easier.
- #solr_post(opts = {}) ⇒ Object
Instance Method Details
#solr_check_auth ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/msf/core/exploit/remote/http/apache_solr.rb', line 58 def solr_check_auth # see if authentication is required for the specified Solr instance auth_check = solr_get( 'uri' => normalize_uri(target_uri.path, '/admin/info/system'), 'vars_get' => { 'wt' => 'json' } ) # successfully connected? unless auth_check print_bad('Connection failed!') return nil end # if response code is not 200, then the Solr instance definitely requires authentication unless auth_check.code == 200 # if authentication is required and creds are not provided, we cannot reliably check exploitability if datastore['USERNAME'] == '' && datastore['PASSWORD'] == '' print_bad('Credentials not provided, skipping credentialed check...') return nil end # otherwise, try the given creds auth_string = basic_auth(datastore['USERNAME'], datastore['PASSWORD']) attempt_auth = solr_get( 'uri' => normalize_uri(target_uri.path, '/admin/info/system'), 'vars_get' => { 'wt' => 'json' }, 'auth' => auth_string ) # successfully connected? unless attempt_auth print_bad('Connection failed!') return nil end # if the return code is not 200, then authentication definitely failed unless attempt_auth.code == 200 print_bad('Invalid credentials!') return nil end store_valid_credential( user: datastore['USERNAME'], private: datastore['PASSWORD'], private_type: :password, proof: attempt_auth.to_s ) @auth_string = auth_string # return the response for use in check/exploit return attempt_auth end print_status("#{peer}: Authentication not required") # return the response for use in check/exploit auth_check end |
#solr_get(opts = {}) ⇒ Object
make sending requests easier
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/msf/core/exploit/remote/http/apache_solr.rb', line 11 def solr_get(opts = {}) send_request_cgi_opts = { 'method' => 'GET', 'connection' => 'Keep-Alive', 'uri' => opts['uri'] }.merge(opts) # @auth_string defaults to "" if no authentication is necessary # otherwise, authentication is required if opts['auth'] != '' send_request_cgi_opts.store('authorization', opts['auth']) end # a bit unrefined, but should suffice in this case if opts['vars_get'] send_request_cgi_opts.store('vars_get', opts['vars_get']) end send_request_cgi(send_request_cgi_opts) end |
#solr_post(opts = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/msf/core/exploit/remote/http/apache_solr.rb', line 32 def solr_post(opts = {}) send_request_cgi_opts = { 'method' => 'POST', 'connection' => 'Keep-Alive', 'uri' => opts['uri'] }.merge(opts) # @auth_string defaults to "" if no authentication is necessary # otherwise, authentication is required if opts['auth'] != '' send_request_cgi_opts.store('authorization', opts['auth']) end # a bit unrefined, but should suffice in this case if opts['vars_get'] send_request_cgi_opts.store('vars_get', opts['vars_get']) end if opts['vars_post'] send_request_cgi_opts.store('vars_get', opts['vars_post']) end send_request_cgi(send_request_cgi_opts) end |