1 개요[ | ]
- CVE-2015-0235
- 리눅스 Ghost 취약점
- 리눅스 GNU C 라이브러리(glibc)의 특정 함수에서 임의코드를 실행할 수 있는 취약점
- 리눅스 계열에서 사용하고 있는 glibc 라이브러리에 있는 __nss_hostname_digits_dots 함수에서 잘못된 메모리 사용으로 인해 메모리 변조 가능
2 점검방법[ | ]
- ghosttest.c 작성
Console
Copy
root@zetawiki:~# vi ghosttest.c
C
Copy
/* ghosttest.c: GHOST vulnerability tester */
/* Credit: http://www.openwall.com/lists/oss-security/2015/01/27/9 */
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define CANARY "in_the_coal_mine"
struct {
char buffer[1024];
char canary[sizeof(CANARY)];
} temp = { "buffer", CANARY };
int main(void) {
struct hostent resbuf;
struct hostent *result;
int herrno;
int retval;
/*** strlen (name) = size_needed - sizeof (*host_addr) - sizeof (*h_addr_ptrs) - 1; ***/
size_t len = sizeof(temp.buffer) - 16*sizeof(unsigned char) - 2*sizeof(char *) - 1;
char name[sizeof(temp.buffer)];
memset(name, '0', len);
name[len] = '\0';
retval = gethostbyname_r(name, &resbuf, temp.buffer, sizeof(temp.buffer), &result, &herrno);
if (strcmp(temp.canary, CANARY) != 0) {
puts("vulnerable");
exit(EXIT_SUCCESS);
}
if (retval == ERANGE) {
puts("not vulnerable");
exit(EXIT_SUCCESS);
}
puts("should not happen");
exit(EXIT_FAILURE);
}
- 컴파일 및 실행
Console
Copy
root@zetawiki:~# gcc ghosttest.c -o ghosttest
root@zetawiki:~# ./ghosttest
not vulnerable
- → 취약하지 않음(not vulnerable)
3 같이 보기[ | ]
4 참고[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.