Nebula level 04

Share it!

En este nivel se nos presenta el siguiente binario compilado cuyo source code es el siguiente :

#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <stdio.h>
#include <fcntl.h>
int main(int argc, char **argv, char **envp)

{

char buf[1024];

int fd, rc;

if(argc == 1) {

printf("%s [file to read]\n", argv[0]);

exit(EXIT_FAILURE);

}

if(strstr(argv[1], "token") != NULL) {

printf("You may not access '%s'\n", argv[1]);

exit(EXIT_FAILURE);

}

fd = open(argv[1], O_RDONLY);

if(fd == -1) {

err(EXIT_FAILURE, "Unable to open %s", argv[1]);

}

rc = read(fd, buf, sizeof(buf));

if(rc == -1) {

err(EXIT_FAILURE, "Unable to read fd %d", fd);

}

write(1, buf, rc);

}

En este nivel lo que tenemos que hacer es averiguar qué contiene el token para pasar de nivel, pero si tiene el nombre token, fallará, por tanto ¿ Cómo hacemos entonces si no podemos cambiar el nombre del fichero al no tener privilegios? Muy fácil, haciendo lo siguiente:

 

Si preparamos un enlace simbólico en algún sitio donde podamos escribir ( como viene siendo tónica de estos niveles ), y enlazamos el fichero token original, con otro fichero que difiera de ese nombre y lo ejecutamos.. here we go!

Podemos usar ese token como pass para el flag04 user y escalar privilegios, muy facil este !

 

Saludos

Share it!
Esta entrada fue publicada en Privilege Escalation. Guarda el enlace permanente.

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos necesarios están marcados *

*

Puedes usar las siguientes etiquetas y atributos HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>