Linux Glibc库严重安全漏洞检测与修复方案

来源:互联网 发布:ios tableview优化 编辑:程序博客网 时间:2024/06/08 07:35

2015年1月27日 Linux GNU glibc标准库的 gethostbyname函数爆出缓冲区溢出漏洞,漏洞编号为CVE-2015-0235。黑客可以通过gethostbyname系列函数实现远程代码执行,获取服务器的控制权及 Shell 权限,此漏洞触发途径多,影响范围大,已确认被成功利用的软件及系统:Glibc 2.2到2.17 (包含2.2和2.17版本)。

GNU glibc标准库的gethostbyname 函数爆出缓冲区溢出漏洞,漏洞编号:CVE-2015-0235。 Glibc 是提供系统调用和基本函数的 C 库,比如open, malloc, printf 等等。所有动态连接的程序都要用到Glibc。远程攻击者可以利用这个漏洞执行任意代码并提升运行应用程序的用户的权限。

漏洞检测方法

按照说明操作即可:

#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("notvulnerable");       exit(EXIT_SUCCESS);     }     puts("should nothappen");     exit(EXIT_FAILURE);}

将上述代码内容保存为GHOST.c,执行:

gcc GHOST.c -o GHOST$./GHOSTvulnerable   //表示存在漏洞,需要进行修复。$./GHOSTnotvulnerable //表示修复成功。

建议修补方案

特别提示:由于glibc属于Linux系统基础组件,为了避免修补对您服务器造成影响,建议您选择合适时间进行修复,同时务必在修复前通过快照操作进行备份。

CentOS 5/6/7

yum update glibc

Ubuntu 12/14

apt-get updateapt-get install libc6

Debian 6

wget -O /etc/apt/sources.list.d/debian6-lts.list http://mirrors.aliyun.com/repo/debian6-lts.listapt-get updateapt-get install libc6

Debian 7

apt-get updateapt-get install libc6

openSUSE 13

zypper refreshzypper update glibc*

Aliyun linux 5u7

wget -O /etc/yum.repos.d/aliyun-5.repo http://mirrors.aliyun.com/repo/aliyun-5.repoyum update glibc
  • 本文来自:Linux学习网
0 0
原创粉丝点击