ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Linux glibc 幽灵漏洞修复方案

Linux glibc 幽灵漏洞修复方案

原创 Linux操作系统 作者:fjzcau 时间:2015-02-27 11:00:22 0 删除 编辑

Linux glibc 幽灵漏洞修复方案

http://mirrors.ustc.edu.cn/gnu/libc/

#include  
#include  
#include  
#include  
#include   
#include   
#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);  
}

将上述代码保存为ghost.c文件
编译:gcc ghost.c -o ghost
执行:./ghost

返回Not vulnerable, 表示不存在此漏洞:
返回 Vulnerable ,表示存在漏洞:

--Linux 6环境下执行成功 
选择2.18以上版本升级
1、mkdir /root/glibc
2、把glibc-2.20.tar.gz上传到 /root/glibc
3、cd /root/glibc
     tar -zxvf glibc-2.20.tar.gz  
     cd glibc-2.20
4、./configure --prefix=/usr
5、make
6、make instal

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22661144/viewspace-1442505/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: db2卸载
请登录后发表评论 登录
全部评论

注册时间:2011-04-03

  • 博文量
    208
  • 访问量
    547152