# SSL/TLS协议信息泄露漏洞(CVE-2016-2183)处理采坑历程

6 篇文章 2 订阅
5 篇文章 1 订阅

第二个漏洞处理:CVE-2016-2183

当时看升级openssl能够解决此问题,于是,开始升级openssl

1. 下载新版本openssl

查看当前openssl版本信息

[root@localhost ~]# openssl version -a
OpenSSL 1.0.2r  26 Feb 2019   #openssl版本信息
built on: reproducible build, date unspecified
platform: linux-x86_64
options:  bn(64,64) rc4(16x,int) des(idx,cisc,16,int) idea(int) blowfish(idx) 
compiler: gcc -I. -I.. -I../include  -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -Wa,--noexecstack -m64 -DL_ENDIAN -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
OPENSSLDIR: "/usr/local/ssl"

下载新版本:

[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# ll
总用量 0
[root@localhost src]#  wget https://www.openssl.org/source/openssl-1.1.1h.tar.gz

下载过程:
--2021-06-04 10:51:29--  https://www.openssl.org/source/openssl-1.1.1h.tar.gz
正在解析主机 www.openssl.org (www.openssl.org)... 104.117.217.32, 2600:1417:1000:882::c1e, 2600:1417:1000:8a4::c1e
正在连接 www.openssl.org (www.openssl.org)|104.117.217.32|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:9810045 (9.4M) [application/x-gzip]
正在保存至: “openssl-1.1.1h.tar.gz”

100%[======================================================================================================================================>] 9,810,045    156KB/s 用时 73s    

2021-06-04 10:52:45 (132 KB/s) - 已保存 “openssl-1.1.1h.tar.gz” [9810045/9810045])

2. 备份证书文件和秘钥文件

[root@localhost src]# mv /usr/bin/openssl /usr/bin/openssl.old
[root@localhost src]# mv /usr/include/openssl /usr/include/openssl.old

3. 安装新版本openssl

解压:

[root@localhost src]# cd /usr/local/src/
[root@localhost src]# tar -zxvf openssl-1.1.1h.tar.gz 

安装:

#进入目录
[root@172-15-4-5 openssl-1.1.1h]# cd openssl-1.1.1h

预编译到指定安装路径,生成Makefile文件,-t参数可测试编译情况,–prefix:指定安装目录;–openssldir:指定openssl配置文件路径

[root@172-15-4-5 openssl-1.1.1h]# ./config --prefix=/usr/local/openssl

输出内容:

Operating system: x86_64-whatever-linux2
Configuring OpenSSL version 1.1.1h (0x1010108fL) for linux-x86_64
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile

**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL file first)         ***
***                                                                ***
**********************************************************************

编译

[root@172-15-4-5 openssl-1.1.1h]# make

输出结果(部分)

gcc  -Iinclude -pthread -m64 -Wa,--noexecstack -Wall -O3 -DNDEBUG  -MMD -MF test/x509_dup_cert_test.d.tmp -MT test/x509_dup_cert_test.o -c -o test/x509_dup_cert_test.o test/x509_dup_cert_test.c
rm -f test/x509_dup_cert_test
${LDCMD:-gcc} -pthread -m64 -Wa,--noexecstack -Wall -O3 -L.   \
	-o test/x509_dup_cert_test test/x509_dup_cert_test.o \
	 test/libtestutil.a -lcrypto -ldl -pthread 
gcc  -I. -Iinclude -pthread -m64 -Wa,--noexecstack -Wall -O3 -DNDEBUG  -MMD -MF test/x509_internal_test.d.tmp -MT test/x509_internal_test.o -c -o test/x509_internal_test.o test/x509_internal_test.c
rm -f test/x509_internal_test
${LDCMD:-gcc} -pthread -m64 -Wa,--noexecstack -Wall -O3 -L.   \
	-o test/x509_internal_test test/x509_internal_test.o \
	 test/libtestutil.a libcrypto.a -ldl -pthread 
gcc  -Iinclude -pthread -m64 -Wa,--noexecstack -Wall -O3 -DNDEBUG  -MMD -MF test/x509_time_test.d.tmp -MT test/x509_time_test.o -c -o test/x509_time_test.o test/x509_time_test.c
rm -f test/x509_time_test
${LDCMD:-gcc} -pthread -m64 -Wa,--noexecstack -Wall -O3 -L.   \
	-o test/x509_time_test test/x509_time_test.o \
	 test/libtestutil.a -lcrypto -ldl -pthread 
gcc  -Iinclude -pthread -m64 -Wa,--noexecstack -Wall -O3 -DNDEBUG  -MMD -MF test/x509aux.d.tmp -MT test/x509aux.o -c -o test/x509aux.o test/x509aux.c
rm -f test/x509aux
${LDCMD:-gcc} -pthread -m64 -Wa,--noexecstack -Wall -O3 -L.   \
	-o test/x509aux test/x509aux.o \
	 test/libtestutil.a -lcrypto -ldl -pthread 
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" apps/CA.pl.in > "apps/CA.pl"
chmod a+x apps/CA.pl
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" apps/tsget.in > "apps/tsget.pl"
chmod a+x apps/tsget.pl
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" tools/c_rehash.in > "tools/c_rehash"
chmod a+x tools/c_rehash
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" util/shlib_wrap.sh.in > "util/shlib_wrap.sh"
chmod a+x util/shlib_wrap.sh
make[1]: Leaving directory `/usr/local/src/openssl-1.1.1h'

安装

[root@172-15-4-5 openssl-1.1.1h]# make install

输出结果(部分)

/opt/openssl/share/doc/openssl/html/man7/X448.html -> /opt/openssl/share/doc/openssl/html/man7/X25519.html
/opt/openssl/share/doc/openssl/html/man7/bio.html
/opt/openssl/share/doc/openssl/html/man7/crypto.html
/opt/openssl/share/doc/openssl/html/man7/ct.html
/opt/openssl/share/doc/openssl/html/man7/des_modes.html
/opt/openssl/share/doc/openssl/html/man7/evp.html
/opt/openssl/share/doc/openssl/html/man7/ossl_store-file.html
/opt/openssl/share/doc/openssl/html/man7/ossl_store.html
/opt/openssl/share/doc/openssl/html/man7/passphrase-encoding.html
/opt/openssl/share/doc/openssl/html/man7/proxy-certificates.html
/opt/openssl/share/doc/openssl/html/man7/scrypt.html
/opt/openssl/share/doc/openssl/html/man7/ssl.html
/opt/openssl/share/doc/openssl/html/man7/x509.html

4. 替换原有旧openssl文件

[root@localhost ~]#  ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
[root@localhost ~]#  ln -s /usr/local/openssl/include/openssl /usr/include/openssl

 #在/etc/ld.so.conf文件中写入openssl库文件的搜索路径
[root@localhost ~]#   echo "/usr/local/openssl/lib" >> /etc/ld.so.conf

 #使修改后的/etc/ld.so.conf生效 
[root@localhost ~]# ldconfig -v

5. 验证版本

[root@172-15-4-5 openssl-1.1.1h]# openssl version
OpenSSL 1.1.1h  22 Sep 2020

完美,也能正常查看版本信息。为了确保万无一失,决定重启一下系统。

[root@172-15-4-5 openssl-1.1.1h]# reboot

再次验证版本

[root@172-15-4-5 openssl-1.1.1h]# openssl version
OpenSSL 1.1.1h  22 Sep 2020

再次漏扫,已经没有该漏洞了。

6. 过程中遇到的坑

升级完openssl,直接裂开。

openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

于是上网查了一下,主要原因是缺少依赖。大部分网上解决方案,都是创建软连接。主要是执行以下命令:

[root@172-15-4-5 lib]# ln -s /usr/local/lib/libssl.so.1.1 /usr/lib/libssl.so.1.1
[root@172-15-4-5 lib]# ln -s /usr/local/lib/libcrypto.so.1.1 /usr/lib/libcrypto.so.1.1

然而,这并不能解决问题,因为我是通过源码安装的openssl新版本,在/usr/local/lib目录下,根本就没有上面的文件。也不知道如何下载这些文件。当然,这个过程中也试过了其他的方法,比如修改配置等。最终我是发现我根本没有上面两个依赖的文件,包括在lib64目录下也没有。

于是,我想试试yum安装,这样是不是就能够自动添加依赖。

yum安装openssl

[root@172-15-4-5 lib64]# yum -y install openssl

安装完成后验证版本:

[root@172-15-4-5 lib64]# openssl version -a
OpenSSL 1.0.2k-fips  26 Jan 2017
built on: reproducible build, date unspecified
platform: linux-x86_64
options:  bn(64,64) md2(int) rc4(16x,int) des(idx,cisc,16,int) idea(int) blowfish(idx) 
compiler: gcc -I. -I.. -I../include  -fPIC -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DKRB5_MIT -m64 -DL_ENDIAN -Wall -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic -Wa,--noexecstack -DPURIFY -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
OPENSSLDIR: "/etc/pki/tls"
engines:  rdrand dynamic 

没有报错。只不过openssl版本没有我自己下载的版本高,相当于其实是降低了版本的。并没有解决漏洞问题。没法,又重新用源码安装新版ssl(上述步骤),发现之前的步骤存在一点小问题,一个是confi阶段的参数问题,二是创建软连接时并未生效。总之,最终还是解决了问题。

1-5步骤,亲测已经可以使用,并且重启系统后,对ssh,nginx都没有带来影响。

  • 13
    点赞
  • 41
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值