@@ -75,6 +75,39 @@ def initialize(framework_module, framework, rhost, rport = 1433, proxies = nil,
7575 @current_database = ''
7676 end
7777
78+ def connect ( global = true , opts = { } )
79+ dossl = false
80+ if ( opts . has_key? ( 'SSL' ) )
81+ dossl = opts [ 'SSL' ]
82+ else
83+ dossl = ssl
84+ end
85+
86+ @mstds_channel = Rex ::Proto ::MsTds ::Channel . new (
87+ 'PeerHost' => opts [ 'RHOST' ] || rhost ,
88+ 'PeerHostname' => opts [ 'SSLServerNameIndication' ] || opts [ 'RHOSTNAME' ] ,
89+ 'PeerPort' => ( opts [ 'RPORT' ] || rport ) . to_i ,
90+ 'LocalHost' => opts [ 'CHOST' ] || chost || "0.0.0.0" ,
91+ 'LocalPort' => ( opts [ 'CPORT' ] || cport || 0 ) . to_i ,
92+ 'SSL' => dossl ,
93+ 'SSLVersion' => opts [ 'SSLVersion' ] || ssl_version ,
94+ 'SSLVerifyMode' => opts [ 'SSLVerifyMode' ] || ssl_verify_mode ,
95+ 'SSLKeyLogFile' => opts [ 'SSLKeyLogFile' ] || sslkeylogfile ,
96+ 'SSLCipher' => opts [ 'SSLCipher' ] || ssl_cipher ,
97+ 'Proxies' => proxies ,
98+ 'Timeout' => ( opts [ 'ConnectTimeout' ] || connection_timeout || 10 ) . to_i ,
99+ 'Context' => { 'Msf' => framework , 'MsfExploit' => framework_module }
100+ )
101+ nsock = @mstds_channel . lsock
102+ # enable evasions on this socket
103+ set_tcp_evasions ( nsock )
104+
105+ # Set this socket to the global socket as necessary
106+ self . sock = nsock if ( global )
107+
108+ return nsock
109+ end
110+
78111 # MS SQL Server only supports Windows and Linux
79112 def map_compile_os_to_platform ( server_info )
80113 return '' if server_info . blank?
@@ -340,12 +373,12 @@ def mssql_login(user='sa', pass='', db='', domain_name='')
340373 # upon receiving the ntlm_negociate request it send an ntlm_challenge but the status flag of the tds packet header
341374 # is set to STATUS_NORMAL and not STATUS_END_OF_MESSAGE, then internally it waits for the ntlm_authentification
342375 if tdsencryption == true
343- proxy = TDSSSLProxy . new ( sock , sslkeylogfile : sslkeylogfile )
344- proxy . setup_ssl
345- resp = proxy . send_recv ( pkt )
346- else
347- resp = mssql_send_recv ( pkt , 15 , false )
376+ #proxy = TDSSSLProxy.new(sock, sslkeylogfile: sslkeylogfile)
377+ #proxy.setup_ssl
378+ #resp = proxy.send_recv(pkt)
379+ @mstds_channel . starttls
348380 end
381+ resp = mssql_send_recv ( pkt , 15 , false )
349382
350383 # Strip the TDS header
351384 resp = resp [ 3 ..-1 ]
@@ -369,13 +402,7 @@ def mssql_login(user='sa', pass='', db='', domain_name='')
369402
370403 pkt = pkt_hdr . pack ( "CCnnCC" ) + type3_blob
371404
372- if self . tdsencryption == true
373- resp = mssql_ssl_send_recv ( pkt , proxy )
374- proxy . cleanup
375- proxy = nil
376- else
377- resp = mssql_send_recv ( pkt )
378- end
405+ resp = mssql_send_recv ( pkt )
379406
380407 #SQL Server Authentication
381408 else
0 commit comments