[SWPUCTF 2022 新生赛]numgame

打开发现不能直接更改数值,会变成负数,快捷键不能用,输入view-source查看源代码,发现js文件

点开后发现最下面有个酷似flag的东西

提交后是错的,看着像是base64,解码后得到另外一个文件

访问后得到一个新的界面,有个正则匹配,过滤了n,c,\m
补充
call_user_func(): 把第一个参数作为回调函数(作为参数传递给另一个函数,并在被调用函数执行完毕后被调用)调用
双冒号运算符:在PHP中双冒号(::)操作符是一种范围解析操作符,又作用域限定操作符。它是对类中的方法的静态引用,可以访问静态、const和类中重写的属性与方法

构造payload并访问,发现提示

更改后再次访问,查看源代码得到flag
[SWPUCTF 2022 新生赛]funny_php
第一个if既要小于3又要大于999999999,可以用数组绕过或科学计数法绕过

看到输出:D说明成功绕过

第二个if是一个正则匹配,NSSCTF被替换

出现wow说明成功绕过

接下来是一个md5弱比较

数组绕过md5,发现后面有字符串检测,应该使用科学计数法绕过

得到flag
[NSSRound#8 Basic]MyDoor

进来是一个空白界面,看到file想到伪协议
php://filter用于读取源码

查看后得到一串base64编码

解码后得到php源代码,需要传参N_S.S进行命令执行

补充:
PHP需要将所有参数转换为有效的变量名,因此在解析查询字符串时,它会做两件事:
1.删除空白符
2.将某些字符转换为下划线(包括空格)
利用PHP的字符串解析特性Bypass - FreeBuf网络安全行业门户
所以这里N_S.S就会被解析为N_S_S,接下来就可以访问phpinfo界面(查看php各种信息)

得到flag
[SWPUCTF 2022 新生赛]funny_web

先随便提交一个,发现提示,得知用户名是NSS

再次出现提示,是招新群某位的QQ号,这里不知道,就去搜索了一下别人的wp,得到密码2122693401

得到php代码
大致意思是关闭报错,包含文件flag.php,get传参传入num,然后是一个弱比较,后面还有一个inval()函数需要截断即可输出flag
补充:
include():找不到被包含的文件只会产生警告,脚本继续执行,并且include()函数并不在意被包含的文件是什么类型,只要有php代码,都会被解析出来
inval():获取变量整数值,用于强制类型转换,传入的参数不是整数就会返回1,当某个字符被过滤时,可以通过8进制或16进制绕过

得到flag
[BJDCTF 2020]ZJCTF,不过如此

大致意思是关闭报错,get传入两个参数,text内容为I have a dream,可以使用data伪协议提交数据,后面提示读取next.php文件,可以用file伪协议读取
补充:
file_get_contents()函数用于读取文件中的内容,并将其作为字符串返回
text/plain,则以文本类型展示
PHP函数指南- file_get_contents()-php教程-PHP中文网
构造payload:?text=data://text/plain,I have a dream&file=php://filter/read=convert.base64-encode/resource=next.php

得到一串base64编码

解码后获得另外一个php代码
大致意思是使用GET方式传入一个值,该值会传入complex函数,然后complex函数中return语句返回的值用preg_replace进行了处理,需要绕过preg_replace
补充:
在PHP中,使用$_SESSION[]可以存储特定用户的Session信息。并且每个用户的Session信息都是不同的
preg_replace的第一个re参数就是我们输入的匹配模式 ,我们使用GET传参来输入
preg_replace的第二个参数用于替换的字符串, \\1表示匹配出第一个分组的正则(即$re,也就是我们使用GET传入的),把输入的值转为小写,然后用于替换
preg_replace的第一个参数是要进行所有的字符串,这个str也是我们可以使用GET传参控制的
preg_replace 使用了 /e 模式,导致了代码可以被执行,/e 修正符使 preg_replace() 将 replacement 参数当作 PHP 代码
r e 和 re和 re和str就是get的键值对,由于是eval(strtolower("\\1"))
本身strtolower是需要接受一个string,而这里转义数字,表示正则表达式 \1 实际上指定的是第一个子匹配项,也就是一旦匹配到,会进入strtolower() 先执行匹配到的内容(替换"\1"的位置),然后再变成小写,这里就可以命令执行,但是替换进来的不是字符串么?($str值) 是,如果普通地传进来确实是字符串,但是如果用可变变量就不一定了。因为这里是双引号,双引号能够对其包裹地内容进行转义等等操作,之所以是\S*,是因为可以快速匹配

最后传入构造好的payload
next.php?\S*=${getFlag()}&cmd=system('cat /flag');
得到flag