13
Introduction to Software Security The 3 rd Homework (3번째 과제) Computer Security & OS Lab Dept. of Software Science, DKU Cho, Seong-je (조성제) Spring, 2020

Introduction to Software Securitysecuresw.dankook.ac.kr/ISS20-1/ISS_2020 HW_3.pdf · 2020-05-04 · Introduction to Software Security The 3rd Homework (3번째과제) Computer Security

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction to Software Securitysecuresw.dankook.ac.kr/ISS20-1/ISS_2020 HW_3.pdf · 2020-05-04 · Introduction to Software Security The 3rd Homework (3번째과제) Computer Security

Introduction to Software Security

The 3rd Homework (3번째과제)

Computer Security & OS LabDept. of Software Science, DKU

Cho, Seong-je (조성제)

Spring, 2020

Page 2: Introduction to Software Securitysecuresw.dankook.ac.kr/ISS20-1/ISS_2020 HW_3.pdf · 2020-05-04 · Introduction to Software Security The 3rd Homework (3번째과제) Computer Security

524660, S’20

- 2 -

3번째과제목적및개요

3번째과제목적

수업중에익힌중요내용을실습을통해심층이해한다.

소프트웨어버그(취약점)를이해하고방어하는능력을갖추는것이다.

Quiz 내용을복습한다.

3번째과제개요

3번슬라이드부터 7번슬라이드의질문에대해답하시오.

각슬라이드마다각각문제가있음 (즉, 5개의문제가있음). 각문제마다 sub-question이 있음.

3번째과제수행기간

5월 4일부터 5월 18일까지 (마감일: 5월 18일)

Computer Security & OS Lab., DKU

Page 3: Introduction to Software Securitysecuresw.dankook.ac.kr/ISS20-1/ISS_2020 HW_3.pdf · 2020-05-04 · Introduction to Software Security The 3rd Homework (3번째과제) Computer Security

524660, S’20

- 3 -

Answer the following questions (1번문제)

1. Write and execute the C program on you computer or Linux server computer.

Explain the results of the program in detail. That is, answer the following two sub-questions.

Computer Security & OS Lab., DKU

(1) Show the output of the program.(우측의 C 프로그램의출력을보이시오.)

$ gcc –o ex2 ex2.c $ ./ex2

(2) Why? Explain the reason why the three printfstatements shows the results.(3개의 printf 문장이해당결과를출력하는이유

를설명하시오. 즉, 왜그렇게출력되는지를설명하면 됩니다.)

#include <stdio.h> /* ex2.c – loss of precision */int main (void) {

int m;short s;char c;

m = 0xcafe7abe;s = m;c = m;

printf("m = 0x%x (%d), (%lu bytes)\n", m,m, sizeof(m));printf("s = 0x%x (%d), (%lu bytes)\n", s,s, sizeof(s));printf("c = 0x%x (%d), (%lu bytes)\n", c,c, sizeof(c));return 0;

}

Page 4: Introduction to Software Securitysecuresw.dankook.ac.kr/ISS20-1/ISS_2020 HW_3.pdf · 2020-05-04 · Introduction to Software Security The 3rd Homework (3번째과제) Computer Security

524660, S’20

- 4 -

Answer the following questions (2번 문제)

Computer Security & OS Lab, DKU

2. 실습환경으로 제공해준 Linux (Ubuntu) 서버에서

cmu.c를 작성하고, 다음과 같이 컴파일하시오.

$ vim cmu.c

$ gcc –o cmu64_1 cmu.c

$ gcc -fno-stack-protector -o cmu64_0 cmu.c

$ gcc –m32 –o cmu32_1 cmu.c

$ gcc –m32 -fno-stack-protector -o cmu32_0 cmu.c

$ ls

cmu32_0 cmu32_1 cmu64_0 cmu64_1 cmu.c

컴파일한 후에, 다음과 같이 실행하시오.

실행하여 나온 출력 결과를 보이고, 설명하시오.

$ ./cmu64_1

$ ./cmu64_0

$ ./cmu32_1

$ ./cmu32_0

#include <stdio.h> /* cmu.c */

typedef int zip_dig[5];

int main() {

int snu[8] = {0, 1, 2, 3, 4, 5, 6, 7};

zip_dig cmu = {10, 11, 12, 13, 14};

int dku[8] = {20, 21, 22, 23, 24, 25, 26, 27};

zip_dig mit = {30, 31, 32, 33, 34};

zip_dig ucb = {40, 41, 42, 43, 44};

short *ptr = (short *)dku;

printf("0x%x\n", snu);

printf("0x%x\n", cmu);

printf("0x%x\n", dku);

printf("0x%x\n", mit);

printf("0x%x\n", ucb);

printf("%d, %d, %d, %d\n", dku[-10], dku[-5], dku[10], dku[17]);

printf("%d, %d, %d, %d\n", ptr[-10], ptr[-5], ptr[10], ptr[17]);

}

Page 5: Introduction to Software Securitysecuresw.dankook.ac.kr/ISS20-1/ISS_2020 HW_3.pdf · 2020-05-04 · Introduction to Software Security The 3rd Homework (3번째과제) Computer Security

- 5 -

Answer the following questions (3번문제)

stack_guard.c를우측과같이작성한다음,

아래와같이컴파일하여, stack_guard0를생성하시오.

$ gcc -fno-stack-protector -o stack_guard0 stack_guard.c

Computer security & OS lab, DKU

#include <stdio.h> /* stack_guard.c */#include <string.h>#define goodPass "GOODPASS"int main () {

char passIsGood = 0;short canary = 20;char canary2 = '1';char buf[28];

printf("%08x, %x, %x, %08x\n", buf, &canary, &canary2, &passIsGood);

printf("Enter password: \n");gets(buf);

if(canary != 20 || canary2 != '1'){printf("BOF attack!\n");return(-1);

}if(strcmp (buf, goodPass)==0) passIsGood =1;if(passIsGood == 1)

printf("you win!\n");return 0;

}

다음물음에답하시오.

1) Find a input of gets() to print out ‘you win!’ by exploiting a buffer overflow bug. <번역> 버퍼오버플로우버그를악용하여 ‘you win!’을출력할

수있게하는 gets()의입력을보이시오. python을사용한입력

값과파이프라인(|)을 사용하여, 버퍼오버플로우로 you win!을

출력해보이시오.

$ python –c “print OOO … OOO” | ./stack_guard0

2) Explain how you could success to print out ‘you win! ’ using the input of 1).<번역> 위 1)의입력을사용하여공격에성공할수있는지

설명하시오.

Page 6: Introduction to Software Securitysecuresw.dankook.ac.kr/ISS20-1/ISS_2020 HW_3.pdf · 2020-05-04 · Introduction to Software Security The 3rd Homework (3번째과제) Computer Security

- 6 -

다음 질문에 답하시오. (4번 문제)

1) 우측프로그램(“my_cat.c”) 프로그램이왜보안에

취약한지설명하시오. 프로그램을다음과같이

실행할수있다.

$ make my_cat

$ ./my_cat ex2.c

$ ./my_cat my_cat.c

2) 구체적인예를들어, 어느경우에왜보안문제가

발생할수있는지를같이설명하시오.

보안상의문제가발생할수있는예를들어

설명하시오.

3) 방어기법(예방책)에대해서도설명하시오.

Computer Security & OS Lab, DKU

1. #include <stdio.h> /* my_cat.c */

2. #include <stdlib.h>

3. int main (int argc, char *argv[]) {

4. int retval;

5. char buffer[50];

6. if (argc < 2) {

7. printf("usage: my_cat file_name.'n");

8. return -1;

9. }

10. sprintf(buffer, "cat %s", argv[1]);

11. system(buffer);

12. }

Page 7: Introduction to Software Securitysecuresw.dankook.ac.kr/ISS20-1/ISS_2020 HW_3.pdf · 2020-05-04 · Introduction to Software Security The 3rd Homework (3번째과제) Computer Security

- 7 -

다음 질문에 답하시오. (5번 문제)

MITRE 사는 “2019 CWE Top 25 Most Dangerous Software Errors”를제공하고있다.

사이트: https://cwe.mitre.org/top25/archive/2019/2019_cwe_top25.html

CWE (Common Weakness Enumeration)으로, CWE 리스트에대해서는 9주차에설명예정

CWE Top 25 중에서, 다음 5개의 CWE 목록에대해간단하게설명하시오.

CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer

CWE-20: Improper Input Validation

CWE-125: Out-of-bounds Read

CWE-190: Integer Overflow or Wraparound

CWE-476: NULL Pointer Dereference

☞ https://cwe.mitre.org/top25/archive/2019/2019_cwe_top25.html 에접속하여, The CWE Top 25 표에서해당 CWE-ID를클릭하면구체적인정보를확인할수있음.

Computer Security & OS Lab, DKU

Page 8: Introduction to Software Securitysecuresw.dankook.ac.kr/ISS20-1/ISS_2020 HW_3.pdf · 2020-05-04 · Introduction to Software Security The 3rd Homework (3번째과제) Computer Security

- 8 -

앞 5번 문제에 대한 추가 설명 (The CWE Top 25, https://cwe.mitre.org/top25/archive/2019/2019_cwe_top25.html )

Computer Security & OS Lab, DKU

CWE-119https://cwe.mitre.org/data/definitions/119.html

CWE-20https://cwe.mitre.org/data/definitions/20.html

CWE-125https://cwe.mitre.org/data/definitions/125.html

CWE-190https://cwe.mitre.org/data/definitions/190.html

CWE-476https://cwe.mitre.org/data/definitions/476.html

Page 9: Introduction to Software Securitysecuresw.dankook.ac.kr/ISS20-1/ISS_2020 HW_3.pdf · 2020-05-04 · Introduction to Software Security The 3rd Homework (3번째과제) Computer Security

524660, S’20

- 9 -

보고서작성시포함내용

보고서표지에포함될내용

과목명(SW보안개론), 분반표시(2분반또는 3분반),

과제번호및제목 (3rd 과제: 소프트웨어보안실무이해)

성명, 학번

제출일 (반드시정확하게표시)

보고서내용에포함될내용

1) 앞서 설명한 문제들에 대한 답변

2) 참고한교재/자료/문서/논문등이있으면, 해당내용 표시하여 보고서에포함

3) Discussion

토론및논의사항

건의사항

Computer Security & OS Lab., DKU

Page 10: Introduction to Software Securitysecuresw.dankook.ac.kr/ISS20-1/ISS_2020 HW_3.pdf · 2020-05-04 · Introduction to Software Security The 3rd Homework (3번째과제) Computer Security

524660, S’20

- 10 -

과제물수행방식

개인과제

개별적으로조사/실습/실험하여보고서로정리

No Cheating

만약, 과제보고서복제가있다면, 보여준사람과복제한사람모두 0점

신뢰할만한교재/자료/문서/논문/사이트를활용

https://cwe.mitre.org/top25/archive/2019/2019_cwe_top25.html

보고서작성시에, 참조(참고)한교재/자료/문서/논문/사이트 정보를포함하여기술

Trusted websites: https://scholar.google.com/ , Scicece.gov, NIST – Glossary, …

Deadline

5월 18일까지

Computer Security & OS Lab., DKU

Page 11: Introduction to Software Securitysecuresw.dankook.ac.kr/ISS20-1/ISS_2020 HW_3.pdf · 2020-05-04 · Introduction to Software Security The 3rd Homework (3번째과제) Computer Security

524660, S’20

- 11 -

과제물제출

과제보고서파일을첨부하여이메일로제출

이메일제목및과제보고서파일이름

이메일제목: “SW보안개론(분반) 3번과제제출”

2분반이메일제목: SW보안개론(2) 3번과제제출

3분반이메일제목: SW보안개론(3) 3번과제제출

보고서파일이름은 “ISS(분반)_HW3_이름_학번_mmdd” 형식으로

예시) 3분반홍길동 (32165678), 제출일이 5월 14일이면

“ISS(3)_HW3_홍길동_32165678_0514”

조재희조교선생께제출

조재희 ([email protected]), 미디어센터 505호

Computer Security & OS Lab., DKU

Page 12: Introduction to Software Securitysecuresw.dankook.ac.kr/ISS20-1/ISS_2020 HW_3.pdf · 2020-05-04 · Introduction to Software Security The 3rd Homework (3번째과제) Computer Security

- 12 -

실습 관련 공지 사항

Linux 실습서버에수강생개인별계정을생성하였음.

ID : sw[분반]-[학번]

예) 2분반유근하학생학번이 72200115라면,

ID : sw2-72200115

PW : *******

주의사항: 접속하면바로, 패스워드를반드시변경바랍니다.

연락처: 유근하조교선생 ([email protected])

Computer Security & OS Lab, DKU

Page 13: Introduction to Software Securitysecuresw.dankook.ac.kr/ISS20-1/ISS_2020 HW_3.pdf · 2020-05-04 · Introduction to Software Security The 3rd Homework (3번째과제) Computer Security

- 13 -

이어폰을 사용한 강의를 들을 때의 문제 해결

요청사항 강의내용이왼쪽에서만들려이어폰등을사용하고강의를들을때조금불편합니다. 녹음환경을개선해주시길 바랍니다.

해결책: (2분반김찬경학생이제시)

스테레오로듣는경우에한쪽이어폰으로들리는현상이발생할경우의해결책:

Windows 10 기준

1. 시작 – 설정 – 접근성 클릭

2. 접근성 – 오디오

3. ‘모노오디오켜기'를켬(ON)으로설정한다.오디오탭의 ‘모노오디오켜기'를활성화시키면됨

“질의응답” 칸에도게시되어있음.

Computer Security & OS Lab, DKU