LinuxGlibc库严重安全漏洞修复通知(重要)
=======正确的脚本(的确需要加个空格 在 CANARY和 "in_the_coal_mine"之间 加空格,否则gcc GHOST.c -o GHOST 报GHOST.c:6:15: warning: missing whitespace after the macro name )===============
root用户执行
-----------------
cat > GHOST.c << EOF
#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("notvulnerable");
exit(EXIT_SUCCESS);
}
puts("should nothappen");
exit(EXIT_FAILURE);
}
EOF
gcc GHOST.c -o GHOST
./GHOST
=============================================================
[[root@iZ25ztsovnAA test]# cat > GHOST.c << EOF
> #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("notvulnerable");
> exit(EXIT_SUCCESS);
> }
> puts("should nothappen");
> exit(EXIT_FAILURE);
> }
> EOF
[root@iZ25ztsovnAA test]# gcc GHOST.c -o GHOST
[root@iZ25ztsovnAA test]# ./GHOST
vulnerable 《vulnerable : 易受伤的,》
[=============================修复过程=====
[root@iZ25ztsovnAA test]# wget -O /etc/yum.repos.d/aliyun-5.repo http://mirrors.aliyun.com/repo/aliyun-5.repo
--2015-01-30 17:06:54-- http://mirrors.aliyun.com/repo/aliyun-5.repo
Resolving mirrors.aliyun.com... 112.124.140.210, 115.28.122.210
Connecting to mirrors.aliyun.com|112.124.140.210|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2780 (2.7K) [application/octet-stream]
Saving to: `/etc/yum.repos.d/aliyun-5.repo'
100%[=====================================================================>] 2,780 --.-K/s in 0s
2015-01-30 17:06:54 (221 MB/s) - `/etc/yum.repos.d/aliyun-5.repo' saved [2780/2780]
[root@iZ25ztsovnAA test]#
[root@iZ25ztsovnAA test]# yum update glibc
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository addons is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
addons | 1.9 kB 00:00
base | 1.1 kB 00:00
extras | 2.1 kB 00:00
updates | 1.9 kB 00:00
updates/primary_db | 266 kB 00:00
Excluding Packages in global exclude list
Finished
Setting up Update Process
Resolving Dependencies
--> Running transaction check
--> Processing Dependency: glibc = 2.5-65 for package: glibc-devel
--> Processing Dependency: glibc = 2.5-65 for package: nscd
--> Processing Dependency: glibc = 2.5-65 for package: glibc-headers
---> Package glibc.x86_64 0:2.5-123.el5_11.1 set to be updated
--> Processing Dependency: glibc-common = 2.5-123.el5_11.1 for package: glibc
--> Running transaction check
---> Package glibc-common.x86_64 0:2.5-123.el5_11.1 set to be updated
---> Package glibc-devel.x86_64 0:2.5-123.el5_11.1 set to be updated
---> Package glibc-headers.x86_64 0:2.5-123.el5_11.1 set to be updated
---> Package nscd.x86_64 0:2.5-123.el5_11.1 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================
Package Arch Version Repository Size
===============================================================================================================
Updating:
glibc x86_64 2.5-123.el5_11.1 updates 4.8 M
Updating for dependencies:
glibc-common x86_64 2.5-123.el5_11.1 updates 16 M
glibc-devel x86_64 2.5-123.el5_11.1 updates 2.4 M
glibc-headers x86_64 2.5-123.el5_11.1 updates 602 k
nscd x86_64 2.5-123.el5_11.1 updates 178 k
Transaction Summary
===============================================================================================================
Install 0 Package(s)
Upgrade 5 Package(s)
Total download size: 24 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): nscd-2.5-123.el5_11.1.x86_64.rpm | 178 kB 00:00
(2/5): glibc-headers-2.5-123.el5_11.1.x86_64.rpm | 602 kB 00:00
(3/5): glibc-devel-2.5-123.el5_11.1.x86_64.rpm | 2.4 MB 00:00
(4/5): glibc-2.5-123.el5_11.1.x86_64.rpm | 4.8 MB 00:00
(5/5): glibc-common-2.5-123.el5_11.1.x86_64.rpm | 16 MB 00:07
---------------------------------------------------------------------------------------------------------------
Total 2.7 MB/s | 24 MB 00:09
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : glibc-common 1/10
Updating : glibc 2/10
Updating : nscd 3/10
Updating : glibc-headers 4/10
Updating : glibc-devel 5/10
Cleanup : glibc-headers 6/10
Cleanup : glibc-common 7/10
Cleanup : glibc 8/10
Cleanup : nscd 9/10
Cleanup : glibc-devel 10/10
Updated:
glibc.x86_64 0:2.5-123.el5_11.1
Dependency Updated:
glibc-common.x86_64 0:2.5-123.el5_11.1 glibc-devel.x86_64 0:2.5-123.el5_11.1
glibc-headers.x86_64 0:2.5-123.el5_11.1 nscd.x86_64 0:2.5-123.el5_11.1
Complete!
[root@iZ25ztsovnAA test]# ./GHOST
notvulnerable 《notvulnerable : 不易受伤的,》
[root@iZ25ztsovnAA test]#
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8494287/viewspace-1421236/
,如需转载,请注明出处,否则将追究法律责任。