- 题目首先给了一个
index.rar
文件,直接可以解压
- 第二个
hint.txt
文件,打开后提示
- 打开文件里面有个
source.zip
文件,有密码解压不了,点进去一看里面也有个hint.txt
,尝试明文攻击
- 一开始先用WinRAR添加到
hint.zip
的,发现ARCHPR报错**“在选定的档案中没有匹配的文件”**
- 后来发现直接右键,发送到zipped文件夹就能执行明文攻击了
- 开始明文攻击
- 口令获得成功
- 打开解压后的文件夹,里面有个
index.php
就是我们想要的源码
<?php
$re = array('and','or','count','select','from','union','group','by','limit','insert','where','order','alter','delete','having','max','min','avg','sum','sqrt','rand','concat','sleep');
setcookie('injection','c3FsaSBpcyBub3QgdGhlIG9ubHkgd2F5IGZvciBpbmplY3Rpb24=',time()+100000);
if(file_exists('slain.xml')) {
$xml = simplexml_load_file('slain.xml');
$user=$_GET['user'];
$user=str_replace($re, ' ', $user);
//$user=str_replace("'", "&apos", $user);
$query="user/username[@name='".$user."']";
$ans = $xml->xpath($query);
foreach($ans as $x => $x_value)
{
echo $x.": " . $x_value;
echo "<br />";
}
}
- 代码中setcookie里面有一段
c3FsaSBpcyBub3QgdGhlIG9ubHkgd2F5IGZvciBpbmplY3Rpb24=
用burp里面的解码器解出**“sqli is not the only way for injection”**说SQL不是唯一一种注入方式
- 然后结合这两段代码发现过滤掉了很多SQL关键字
$user=str_replace($re, ' ', $user);
$re = array('and','or','count','select','from','union','group','by','limit','insert','where','order','alter','delete','having','max','min','avg','sum','sqrt','rand','concat','sleep');
- SQL注入肯定不能用了,然后中间有一段
$xml = simplexml_load_file('slain.xml');
- 查阅资料,可以用xpath注入
- 提交一个单引号,返回的响应证明确实有xpath注入漏洞
- 利用这行代码
$query="user/username[@name='".$user."']";
构造payload:?user=']|//*|//*['
可以用这个payload访问这个xml文档里面的所有结点
- flag到手
- 写WP的时候其实还发现了个更简单的办法
$xml = simplexml_load_file('slain.xml');
这行代码说明服务器存在一个slain.xml
文件,说不定能够直接访问
- 试一下,还真行