|
1 | 1 | require 'metasploit/framework/tcp/client' |
2 | | -require 'metasploit/framework/mssql/tdssslproxy' |
3 | 2 | require 'rex/proto/mssql/client_mixin' |
4 | 3 | require 'rex/text' |
5 | 4 | require 'msf/core/exploit' |
@@ -242,10 +241,6 @@ def mssql_prelogin(enc_error=false) |
242 | 241 | data |
243 | 242 | end |
244 | 243 |
|
245 | | - def mssql_ssl_send_recv(req, tdsproxy, timeout=15, check_status=true) |
246 | | - tdsproxy.send_recv(req) |
247 | | - end |
248 | | - |
249 | 244 | def query(sqla, doprint=false, opts={}) |
250 | 245 | info = { :sql => sqla } |
251 | 246 | opts[:timeout] ||= 15 |
@@ -415,6 +410,10 @@ def login_kerberos(user, pass, db, domain_name) |
415 | 410 | pkt_hdr.packet_length += pkt_body.num_bytes |
416 | 411 | pkt = pkt_hdr.to_binary_s + pkt_body.to_binary_s |
417 | 412 |
|
| 413 | + if tdsencryption == true |
| 414 | + @mstds_channel.starttls |
| 415 | + end |
| 416 | + |
418 | 417 | # Rem : One have to set check_status to false here because sql server sp0 (and maybe above) |
419 | 418 | # has a strange behavior that differs from the specifications |
420 | 419 | # upon receiving the ntlm_negociate request it send an ntlm_challenge but the status flag of the tds packet header |
@@ -467,12 +466,11 @@ def login_ntlm(user, pass, db, domain_name) |
467 | 466 | # upon receiving the ntlm_negotiate request it send an ntlm_challenge but the status flag of the tds packet header |
468 | 467 | # is set to STATUS_NORMAL and not STATUS_END_OF_MESSAGE, then internally it waits for the ntlm_authentification |
469 | 468 | if tdsencryption == true |
470 | | - #proxy = TDSSSLProxy.new(sock, sslkeylogfile: sslkeylogfile) |
471 | | - #proxy.setup_ssl |
472 | | - #resp = proxy.send_recv(pkt) |
473 | 469 | @mstds_channel.starttls |
474 | 470 | end |
475 | 471 |
|
| 472 | + resp = mssql_send_recv(pkt) |
| 473 | + |
476 | 474 | # Strip the TDS header |
477 | 475 | resp = resp[3..-1] |
478 | 476 | type3 = ntlm_client.init_context([resp].pack('m')) |
@@ -516,15 +514,12 @@ def login_sql(user, pass, db, _domain_name) |
516 | 514 | pkt_hdr.packet_length += pkt_body.num_bytes |
517 | 515 | pkt = pkt_hdr.to_binary_s + pkt_body.to_binary_s |
518 | 516 |
|
519 | | - if self.tdsencryption == true |
520 | | - proxy = TDSSSLProxy.new(sock, sslkeylogfile: sslkeylogfile) |
521 | | - proxy.setup_ssl |
522 | | - resp = mssql_ssl_send_recv(pkt, proxy) |
523 | | - proxy.cleanup |
524 | | - else |
525 | | - resp = mssql_send_recv(pkt) |
| 517 | + if tdsencryption == true |
| 518 | + @mstds_channel.starttls |
526 | 519 | end |
527 | 520 |
|
| 521 | + resp = mssql_send_recv(pkt) |
| 522 | + |
528 | 523 | info = {:errors => []} |
529 | 524 | info = mssql_parse_reply(resp, info) |
530 | 525 | self.initial_connection_info = info |
|
0 commit comments