Skip to content

Commit dfff20a

Browse files
committed
Landing rapid7#1692 - Handles OSQL banners and responses
[Close rapid7#1692]
2 parents b10b2c6 + cd4a410 commit dfff20a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

modules/post/windows/manage/mssql_local_auth_bypass.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,9 @@ def get_sql_client
181181
services_array1 = running_services1.split("\n")
182182

183183
# Check for osql
184-
services_array1.each do |service1|
185-
if service1 =~ /SQL Server Command Line Tool/ then
186-
print_good("OSQL client was found")
187-
return "osql"
188-
end
184+
if services_array1.join =~ /(SQL Server Command Line Tool)|(usage: osql)/
185+
print_good("OSQL client was found")
186+
return "osql"
189187
end
190188

191189
# Get Data - sqlcmd
@@ -251,11 +249,11 @@ def add_sql_login(sqlclient,dbuser,dbpass,instance,service_instance,verbose)
251249
end
252250

253251
# check for success/fail
254-
if add_login_result == ""
252+
if add_login_result.empty? or add_login_result =~ /New login created./
255253
print_good("Successfully added login \"#{dbuser}\" with password \"#{dbpass}\"")
256254
return 1
257255
else
258-
print_error("Unabled to add login #{dbuser}")
256+
print_error("Unable to add login #{dbuser}")
259257
print_error("Database Error:\n #{add_login_result}")
260258
return 0
261259
end

0 commit comments

Comments
 (0)