自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

幽靈漏洞(GHOST)檢測(cè)方法及修復(fù)建議

安全 漏洞
昨日,【CVE 2015-0235: GNU glibc gethostbyname 緩沖區(qū)溢出漏洞 】全面爆發(fā),該漏洞的產(chǎn)生是Qualys公司在進(jìn)行內(nèi)部代碼審核時(shí),發(fā)現(xiàn)了一個(gè)在GNU C庫(glibc)中存在的__nss_hostname_digits_dots函數(shù)導(dǎo)致的緩沖區(qū)溢出漏洞。

0x01 前言

昨日,【CVE 2015-0235: GNU glibc gethostbyname 緩沖區(qū)溢出漏洞 】全面爆發(fā),該漏洞的產(chǎn)生是Qualys公司在進(jìn)行內(nèi)部代碼審核時(shí),發(fā)現(xiàn)了一個(gè)在GNU C庫(glibc)中存在的__nss_hostname_digits_dots函數(shù)導(dǎo)致的緩沖區(qū)溢出漏洞。這個(gè)bug可以通過gethostbyname *()函數(shù)來觸發(fā),本地和遠(yuǎn)程均可行。該漏洞(幽靈漏洞)造成了遠(yuǎn)程代碼執(zhí)行,攻擊者可以利用此漏洞遠(yuǎn)程獲取系統(tǒng)進(jìn)程當(dāng)前的權(quán)限。

幽靈漏洞(GHOST)檢測(cè)方法及修復(fù)建議

鑒于網(wǎng)上諸多glibc的原理普及,本文章就不多啰嗦了,直接實(shí)踐如何檢測(cè)服務(wù)器是否存在該漏洞,以及修復(fù)漏洞的方法。

0x02 檢測(cè)是否存在幽靈漏洞(GHOST)

檢測(cè)方法1【RedHat官方檢測(cè)方法】:

幽靈漏洞(GHOST)檢測(cè)方法及修復(fù)建議

ghost_check.sh源碼:

  1. #!/bin/bash  
  2. vercomp () {  
  3. if [[ $1 == $2 ]]  
  4. then  
  5. return 0  
  6. fi  
  7. local IFS=.  
  8. local i ver1=($1) ver2=($2)  
  9.     # fill empty fields in ver1 with zeros  
  10.     for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))  
  11. do  
  12. ver1[i]=0  
  13. done  
  14.     for ((i=0; i<${#ver1[@]}; i++))  
  15. do  
  16. if [[ -z ${ver2[i]} ]]  
  17. then  
  18.             # fill empty fields in ver2 with zeros  
  19. ver2[i]=0  
  20. fi  
  21.         if ((10#${ver1[i]} > 10#${ver2[i]}))  
  22. then  
  23. return 1  
  24. fi  
  25.         if ((10#${ver1[i]} < 10#${ver2[i]}))  
  26. then  
  27. return 2  
  28. fi  
  29. done  
  30. return 0  
  31. }  
  32.    
  33. glibc_vulnerable_version=2.17  
  34. glibc_vulnerable_revision=54 
  35. glibc_vulnerable_version2=2.5  
  36. glibc_vulnerable_revision2=122 
  37. glibc_vulnerable_version3=2.12  
  38. glibc_vulnerable_revision3=148 
  39. echo "Vulnerable glibc version <=" $glibc_vulnerable_version"-"$glibc_vulnerable_revision  
  40. echo "Vulnerable glibc version <=" $glibc_vulnerable_version2"-"$glibc_vulnerable_revision2  
  41. echo "Vulnerable glibc version <=" $glibc_vulnerable_version3"-1."$glibc_vulnerable_revision3  
  42.    
  43. glibc_version=$(rpm -q glibc | awk -F"[-.]" '{print $2"."$3}' | sort -u)  
  44. if [[ $glibc_version == $glibc_vulnerable_version3 ]]  
  45. then  
  46. glibc_revision=$(rpm -q glibc | awk -F"[-.]" '{print $5}' | sort -u)  
  47. else  
  48. glibc_revision=$(rpm -q glibc | awk -F"[-.]" '{print $4}' | sort -u)  
  49. fi  
  50. echo "Detected glibc version" $glibc_version" revision "$glibc_revision  
  51.    
  52. vulnerable_text=$"This system is vulnerable to CVE-2015-0235. <https://access.redhat.com/security/cve/CVE-2015-0235> 
  53. Update the glibc and ncsd packages on your system using the packages released with the following:  
  54. yum install glibc"  
  55.    
  56. if [[ $glibc_version == $glibc_vulnerable_version ]]  
  57. then  
  58. vercomp $glibc_vulnerable_revision $glibc_revision  
  59. elif [[ $glibc_version == $glibc_vulnerable_version2 ]]  
  60. then  
  61. vercomp $glibc_vulnerable_revision2 $glibc_revision  
  62. elif [[ $glibc_version == $glibc_vulnerable_version3 ]]  
  63. then  
  64. vercomp $glibc_vulnerable_revision3 $glibc_revision  
  65. else  
  66. vercomp $glibc_vulnerable_version $glibc_version  
  67. fi  
  68.    
  69. case $? in  
  70.     0) echo "$vulnerable_text";;  
  71.     1) echo "$vulnerable_text";;  
  72.     2) echo "Not Vulnerable.";;  
  73. esac 

檢測(cè)方法2【簡(jiǎn)單的檢測(cè)方法】:

幽靈漏洞(GHOST)檢測(cè)方法及修復(fù)建議

檢測(cè)方法2源碼:

  1. /usr/sbin/clockdiff `python -c "print '0' * $((0x10000-16*1-2*4-1-4))"` 

檢測(cè)方法3【二進(jìn)制檢測(cè)方法】:

幽靈漏洞(GHOST)檢測(cè)方法及修復(fù)建議

ghost.c源碼:

  1. #include <netdb.h> 
  2. #include <stdio.h> 
  3. #include <stdlib.h> 
  4. #include <string.h> 
  5. #include <errno.h> 
  6.    
  7. #define CANARY "in_the_coal_mine"  
  8.    
  9. struct {  
  10. char buffer[1024];  
  11. char canary[sizeof(CANARY)];  
  12. temp = { "buffer", CANARY };  
  13.    
  14. int main(void) {  
  15. struct hostent resbuf;  
  16. struct hostent *result;  
  17. int herrno;  
  18. int retval;  
  19.    
  20.   /*** strlen (name) = size_needed - sizeof (*host_addr) - sizeof (*h_addr_ptrs) - 1; ***/  
  21. size_t len = sizeof(temp.buffer) - 16*sizeof(unsigned char) - 2*sizeof(char *) - 1;  
  22. char name[sizeof(temp.buffer)];  
  23. memset(name, '0', len);  
  24. name[len] = '\0';  
  25.    
  26. retval = gethostbyname_r(name, &resbuf, temp.buffer, sizeof(temp.buffer), &result, &herrno);  
  27.    
  28. if (strcmp(temp.canary, CANARY) != 0) {  
  29.     puts("vulnerable");  
  30. exit(EXIT_SUCCESS);  
  31. }  
  32. if (retval == ERANGE) {  
  33.     puts("not vulnerable");  
  34. exit(EXIT_SUCCESS);  
  35. }  
  36.   puts("should not happen");  
  37. exit(EXIT_FAILURE);  

#p#

0x03 在線修復(fù)方案

CentOS, Red Hat, Fedora等系列衍生版本(RHN建議):

  1. yum update glibc 

Debian, Ubuntu等系列衍生版本:

  1. apt-get clean && apt-get update && apt-get upgrade 

#p#

0x04 離線修復(fù)方案

Centos6.5離線補(bǔ)丁

先檢查本地glibc包安裝了哪些相關(guān)包

  1. rpm -qa|grep glibc 

幽靈漏洞(GHOST)檢測(cè)方法及修復(fù)建議

然后,到阿里源下載對(duì)應(yīng)版本

  1. cat > update.txt << EOF 
  2. http://mirrors.aliyun.com/centos/6.6/updates/x86_64/Packages/glibc-2.12-1.149.el6_6.5.i686.rpm  
  3. http://mirrors.aliyun.com/centos/6.6/updates/x86_64/Packages/glibc-2.12-1.149.el6_6.5.x86_64.rpm  
  4. http://mirrors.aliyun.com/centos/6.6/updates/x86_64/Packages/glibc-common-2.12-1.149.el6_6.5.x86_64.rpm  
  5. http://mirrors.aliyun.com/centos/6.6/updates/x86_64/Packages/glibc-devel-2.12-1.149.el6_6.5.x86_64.rpm      
  6. http://mirrors.aliyun.com/centos/6.6/updates/x86_64/Packages/glibc-headers-2.12-1.149.el6_6.5.x86_64.rpm  
  7. EOF 

進(jìn)行后臺(tái)斷點(diǎn)下載補(bǔ)丁包

  1. wget -b -i update.txt -c 

使用yum本地安裝

  1. yum localinstall glibc-* 

或是rpm安裝

  1. rpm -ivUh glibc-* 

幽靈漏洞(GHOST)檢測(cè)方法及修復(fù)建議

Red Had系列衍生版本

使用方法參考上文【Centos6.5離線補(bǔ)丁】的修補(bǔ)方法

http://mirrors.aliyun.com/centos/7/updates/x86_64/Packages/glibc-2.17-55.el7_0.5.i686.rpm

http://mirrors.aliyun.com/centos/7/updates/x86_64/Packages/glibc-2.17-55.el7_0.5.x86_64.rpm

 

0x05 修復(fù)完成檢測(cè)

ghost_check.sh腳本檢測(cè)

幽靈漏洞(GHOST)檢測(cè)方法及修復(fù)建議

ghost.c腳本檢測(cè)

幽靈漏洞(GHOST)檢測(cè)方法及修復(fù)建議

注意:打好補(bǔ)丁后必須立即重啟操作系統(tǒng),否則會(huì)造成應(yīng)用業(yè)務(wù)無法使用。

0x06 參考來源

redhat官方

https://access.redhat.com/articles/1332213

redhat官方補(bǔ)丁介紹:

https://rhn.redhat.com/errata/RHSA-2015-0090.html

https://rhn.redhat.com/errata/RHSA-2015-0092.html

ubuntu官方補(bǔ)丁介紹:

http://www.ubuntu.com/usn/usn-2485-1/

責(zé)任編輯:藍(lán)雨淚 來源: sobug
相關(guān)推薦

2017-03-08 22:23:02

2015-01-29 11:47:35

2020-10-14 10:41:24

安全漏洞數(shù)據(jù)

2015-01-28 15:56:13

2011-05-20 10:11:04

RHEL 6.1紅帽

2023-12-01 16:21:42

2019-03-12 09:38:46

程序員技能溝通

2023-05-25 19:23:29

2010-01-18 10:11:36

ghosFreeBSDMBR

2018-01-18 15:32:07

2015-02-04 14:36:07

格式串漏洞Ghost漏洞安全漏洞

2018-06-27 10:07:28

2018-04-04 09:20:55

2018-04-04 12:21:39

2014-04-09 13:34:44

2019-01-16 14:20:42

2021-10-27 15:25:23

iOS蘋果系統(tǒng)

2023-10-12 07:52:08

2010-09-25 11:07:45

Java內(nèi)存泄漏

2018-11-15 11:00:27

Python漏洞修復(fù)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)