日前Linux GNU glibc标准库的 gethostbyname函数爆出缓冲区溢出漏洞,漏洞编号为CVE-2015-0235。黑客可以通过gethostbyname系列函数实现远程代码执行,获取服务器的控制权及Shell权限,此漏洞触发途径多,影响范围大,请大家关注和及时临时修复,后续我们会尽快更新镜像修复。
按照说明操作即可。
#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
$./GHOST
vulnerable
表示存在漏洞,需要进行修复。
$./GHOST
notvulnerable
表示修复成功。
修复方法:
特别提示:由于glibc属于Linux系统基础组件,为了避免修补对您服务器造成影响,建议您选择合适时间进行修复,同时务必在修复前通过快照操作进行备份,如果修复出现问题,可以迅速回滚快照恢复。
Centos 5/6/7:
yum update glibc
Ubuntu 12/14
apt-get update
apt-get install libc6
Debian 6
wget -O /etc/apt/sources.list.d/debian6-lts.list http://mirrors.aliyun.com/repo/debian6-lts.list
apt-get update
apt-get install libc6
Debian 7
apt-get update
apt-get install libc6
Opensuse 13
zypper refresh
zypper update glibc*
Aliyun linux 5u7
wget -O /etc/yum.repos.d/aliyun-5.repo http://mirrors.aliyun.com/repo/aliyun-5.repo
yum update glibc
更多文章信息请查阅:http://bbs.aliyun.com/read/227885.html