buuctf web方向刷题记录
本文最后更新于 465 天前,其中的信息可能已经有所发展或是发生改变。
前言
又一新坑,马上就要工作了,但是觉得自己那叫一个菜,述开此坑,多刷点题提升一下自己。
正文
[NCTF2019]True XML cookbook
非常简单的一道题,因为我之前做过这方面的题。很明显是一道XXE题。
尝试读取文件
通过xxe读取内网存活主机
后面再使用http访问内网服务器即可得到flag
[MRCTF2020]套娃
$_SERVER['QUERY_STRING']会获取到传入的参数和内容,如localhost?a=1会获取到a=1 首先是传入的内容不能包含_和%5f 绕过方法参考:利用PHP的字符串解析特性Bypass
第二个if需要绕过传入内容不等于23333同时还要绕过正则表达式,这里正则表达式部分可以使用%0a绕过,即换行绕过。^匹配开始$匹配结尾。
//1st
$query = $_SERVER['QUERY_STRING'];
if( substr_count($query, '_') !== 0 || substr_count($query, '%5f') != 0 ){
die('Y0u are So cutE!');
}
if($_GET['b_u_p_t'] !== '23333' &
&
preg_match('/^23333$/', $_GET['b_u_p_t'])){
echo "you are going to the next ~";
}
新页面访问得到一串不明所以的东西,百度一下得知这注释内容可以使用浏览器控制台执行
执行完提升使用post传递Merak参数
随便传递内容得到新的源码
?php
error_reporting(0);
include 'takeip.php';
ini_set('open_basedir','.');
include 'flag.php';
if(isset($_POST['Merak'])){
highlight_file(__FILE__);
die();
}
function change($v){
$v = base64_decode($v);
$re = '';
for($i=0;
$istrlen($v);
$i++){
$re .= chr ( ord ($v[$i]) + $i*2 );
}
return $re;
}
echo 'Local access only!'."br/>
";
$ip = getIp();
if($ip!='127.0.0.1')
echo "Sorry,you don't have permission! Your ip is :".$ip;
if($ip === '127.0.0.1' &
&
file_get_contents($_GET['2333']) === 'todat is a happy day' ){
echo "Your REQUEST is:".change($_GET['file']);
echo file_get_contents(change($_GET['file']));
}
?>
这部分的绕过分为三个部分,第一个为访问ip必须为127.0.0.1,这里可以在包头添加Client-ip来解决,file_get_contents获取的2333参数可以使用php伪协议绕过?2333=data:text/plain,todat is a happy day
,第三部分是对传入的字符进行了处理,写个代码逆向处理一下即可。
?php
function change($v){
$re = '';
for($i=0;
$istrlen($v);
$i++){
$re .= chr ( ord ($v[$i]) - $i*2 );
}
return $re;
}
$a = base64_encode(change('flag.php'));
print($a);
获取flag
[极客大挑战 2019]RCE ME
从RCE_ME一题来了解如何绕过disable_function:https://www.yulate.com/229.html
[Zer0pts2020]Can you guess it?
?php
include 'config.php';
// FLAG is defined in config.php
if (preg_match('/config\.php\/*$/i', $_SERVER['PHP_SELF'])) {
exit("I don't know what you are thinking, but I won't let you read it :)");
}
if (isset($_GET['source'])) {
highlight_file(basename($_SERVER['PHP_SELF']));
exit();
}
$secret = bin2hex(random_bytes(64));
if (isset($_POST['guess'])) {
$guess = (string) $_POST['guess'];
if (hash_equals($secret, $guess)) {
$message = 'Congratulations! The flag is: ' . FLAG;
}
else {
$message = 'Wrong.';
}
}
?>
!doctype html>
html lang="en">
head>
meta charset="utf-8">
title>
Can you guess it?/title>
/head>
body>
h1>
Can you guess it?/h1>
p>
If your guess is correct, I'll give you the flag./p>
p>
a href="?source">
Source/a>
/p>
hr>
?php if (isset($message)) {
?>
p>
?= $message ?>
/p>
?php }
?>
form action="index.php" method="POST">
input type="text" name="guess">
input type="submit">
/form>
/body>
/html>
这一题的做法应该是第一部分通过highlight_file显示config.php,下面的随机数应该没法做。 做这一题前先要了解$_SERVER['PHP_SELF']、basename是什么
_SERVER['PHP_SELF']_SERVER['PHP_SELF'] 表示当前 php 文件相对于网站根目录的位置地址,与 document root 相关。 假设我们有如下网址,
http://www.aaa.com/php/ :/php/index.php
http://www.aaa.com/php/index.php :/php/index.php
http://www.aaa.com/php/index.php?test=foo :/php/index.php
http://www.aaa.com/php/index.php/test/foo :/php/index.php/test/foo
浏览量: 248
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: buuctf web方向刷题记录
本文地址: https://pptw.com/jishu/291344.html