From 7ce91df66ea025bc1864cafa7edcd9522ebe4a12 Mon Sep 17 00:00:00 2001 From: Zach Goldman Date: Wed, 14 Feb 2024 08:42:45 -0600 Subject: [PATCH] clean up code duplication --- .../exploits/windows/mssql/mssql_payload.rb | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/modules/exploits/windows/mssql/mssql_payload.rb b/modules/exploits/windows/mssql/mssql_payload.rb index 36ace61e6fe8..952ea7dae127 100644 --- a/modules/exploits/windows/mssql/mssql_payload.rb +++ b/modules/exploits/windows/mssql/mssql_payload.rb @@ -70,15 +70,6 @@ def initialize(info = {}) end def check - if session - set_session(session.client) - end - - unless session || mssql_login_datastore - vprint_status("Invalid SQL Server credentials") - return Exploit::CheckCode::Detected - end - if session set_session(session.client) else @@ -105,14 +96,13 @@ def execute_command(cmd, opts) end def exploit - if session set_session(session.client) - end - - unless session || mssql_login_datastore - print_status("Invalid SQL Server credentials") - return + else + unless mssql_login_datastore + print_status("Invalid SQL Server credentials") + return + end end method = datastore['METHOD'].downcase