Skip to content

Commit 63822f6

Browse files
committed
Land #16651, [SQLi library] Ensure the encoder is always used in the #test_vulnerable methods
2 parents 9e3b1ca + 88036a7 commit 63822f6

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

lib/msf/core/exploit/sqli/mssqli/common.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,11 @@ def dump_table_fields(table, columns, condition = '', num_limit = 0)
182182
def test_vulnerable
183183
random_string_len = @truncation_length ? [rand(2..10), @truncation_length].min : rand(2..10)
184184
random_string = Rex::Text.rand_text_alphanumeric(random_string_len)
185-
run_sql("select '#{random_string}'") == random_string
185+
query_string = "'#{random_string}'"
186+
query_string = @encoder[:encode].sub(/\^DATA\^/, query_string) if @encoder
187+
output = run_sql("select #{query_string}")
188+
return false if output.nil?
189+
(@encoder ? @encoder[:decode].call(output) : output) == random_string
186190
end
187191

188192
#

lib/msf/core/exploit/sqli/mysqli/common.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,11 @@ def dump_table_fields(table, columns, condition = '', num_limit = 0)
197197
def test_vulnerable
198198
random_string_len = @truncation_length ? [rand(2..10), @truncation_length].min : rand(2..10)
199199
random_string = Rex::Text.rand_text_alphanumeric(random_string_len)
200-
run_sql("select '#{random_string}'") == random_string
200+
query_string = "'#{random_string}'"
201+
query_string = @encoder[:encode].sub(/\^DATA\^/, query_string) if @encoder
202+
output = run_sql("select #{query_string}")
203+
return false if output.nil?
204+
(@encoder ? @encoder[:decode].call(output) : output) == random_string
201205
end
202206

203207
#

lib/msf/core/exploit/sqli/postgresqli/common.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,11 @@ def dump_table_fields(table, columns, condition = '', num_limit = 0)
189189
def test_vulnerable
190190
random_string_len = @truncation_length ? [rand(2..10), @truncation_length].min : rand(2..10)
191191
random_string = Rex::Text.rand_text_alphanumeric(random_string_len)
192-
run_sql("select '#{random_string}'") == random_string
192+
query_string = "'#{random_string}'"
193+
query_string = @encoder[:encode].sub(/\^DATA\^/, query_string) if @encoder
194+
output = run_sql("select #{query_string}")
195+
return false if output.nil?
196+
(@encoder ? @encoder[:decode].call(output) : output) == random_string
193197
end
194198

195199
#

lib/msf/core/exploit/sqli/sqlitei/common.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def test_vulnerable
146146
query_string = "'#{random_string}'"
147147
query_string = @encoder[:encode].sub(/\^DATA\^/, query_string) if @encoder
148148
output = run_sql("select #{query_string}")
149+
return false if output.nil?
149150
(@encoder ? @encoder[:decode].call(output) : output) == random_string
150151
end
151152

0 commit comments

Comments
 (0)