Skip to content

Commit 44fb059

Browse files
author
james
committed
Add error checking to mssql_clr_payload
Additional error checking had been added to exploits/windows/mssql/mssql_clr_payload If an error is encountered when changing the trustworthy or clr setting, the exploit fails with a message.
1 parent 6051a1a commit 44fb059

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

modules/exploits/windows/mssql/mssql_clr_payload.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ def get_exploit_version(sql_version_string)
9696
end
9797

9898
def set_trustworthy(on)
99-
mssql_query("ALTER DATABASE [#{datastore['DATABASE']}] SET TRUSTWORTHY #{on ? 'ON' : 'OFF'}", false)
99+
result = mssql_query("ALTER DATABASE [#{datastore['DATABASE']}] SET TRUSTWORTHY #{on ? 'ON' : 'OFF'}", false)
100+
unless result[:errors].empty?
101+
fail_with(Failure::Unknown, "Failed to change Trustworthy setting")
102+
end
100103
end
101104

102105
def is_trustworthy
@@ -112,7 +115,10 @@ def enable_clr(enable)
112115
EXEC sp_configure 'clr enabled', #{enable ? 1 : 0};
113116
RECONFIGURE;
114117
^
115-
mssql_query(query, false)
118+
result = mssql_query(query, false)
119+
unless result[:errors].empty?
120+
fail_with(Failure::Unknown, "Failed to change CLR setting")
121+
end
116122
end
117123

118124
def is_clr_enabled

0 commit comments

Comments
 (0)