From 7d20f14525fd56ce6ca4321267f882138887aeaf Mon Sep 17 00:00:00 2001 From: j0hn__f Date: Tue, 26 Jun 2012 12:40:34 +0100 Subject: [PATCH] exec SQL from file --- modules/auxiliary/admin/mssql/mssql_sqlfile.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/auxiliary/admin/mssql/mssql_sqlfile.rb b/modules/auxiliary/admin/mssql/mssql_sqlfile.rb index 05e7041649..5c6a4e5667 100644 --- a/modules/auxiliary/admin/mssql/mssql_sqlfile.rb +++ b/modules/auxiliary/admin/mssql/mssql_sqlfile.rb @@ -22,7 +22,7 @@ class Metasploit3 < Msf::Auxiliary This module will allow for multiple SQL queries contained within a specified file to be executed against a MSSQL instance given the appropiate credentials. }, - 'Author' => [ 'j0hn__f : ' ], + 'Author' => [ 'j0hn__f : ' ], 'License' => MSF_LICENSE, 'Version' => '$Revision: 1 $' )) @@ -38,17 +38,20 @@ class Metasploit3 < Msf::Auxiliary def run - print_status "> loaded the following SQL:" queries = File.readlines(datastore['SQL_FILE']) - print_status queries.to_s prefix = datastore['QUERY_PREFIX'] suffix = datastore['QUERY_SUFFIX'] - queries.each do |sql_query| - mssql_query(prefix+sql_query.chomp+suffix,true) if mssql_login_datastore + begin + queries.each do |sql_query| + mssql_query(prefix+sql_query.chomp+suffix,true) if mssql_login_datastore + end + rescue Rex::ConnectionRefused, Rex::ConnectionTimeout + print_error "Error connecting to server: #{$!}" + ensure + disconnect end - disconnect end end