This editor is widely used in South Korea. It is used in www. hani. co. kr, www. kbs. co. kr, and www.joinsmsn.com. Because it involves many sites, the specific program name cannot be directly released. The following is a brief analysis of the problem code.
The main problem is that the upload class is not rigorous when verifying the file extension, which allows attackers to upload PHP files. By Ca3tie1
First look at the upload function:
If ($ file-> getFileSize ("Filedata")> 0 ){
$ Save_name = $ req-> get ("save_name ");
If ($ save_name = null | $ save_name = "")
$ Save_name = $ file-> nameUnique ('Ph _');
$ File_name = $ file-> getFileName ("Filedata ");
If ($ file-> isUploadable ($ file_name) // verify the extension. if the verification fails, the extension is set to tmp.
$ File_ext = $ file-> name2Ext ($ file_name); // retrieve the extension
Else
$ File_ext = 'tmp ';
$ Save_name = uniqid (date ('ymd _'));
$ File_server = $ file-> file_Copy ("Filedata", $ savearea. $ save_name. '.'. $ file_ext );
}
Follow up with the isUploadable function:
Function isUploadable ($ fileName ){
Return! (RainUtil: find ($ this-> forbidden_extension_patten, $ fileName ));
}
// Forbidden_extension_patten is involved here, which is defined as: var $ forbidden_extension_patten = '(html | htm | php | php3 | cgi | phtml | shtml | jsp | asp | exe | com | dll) $ ';
Continue to follow up the find function: www.2cto.com
Function find ($ patternStr, $ str, $ reg = Array ()){
Return (ereg ($ patternStr, $ str, $ reg ))? True: false; // the problem is here. The ereg function is case sensitive! Verification can be bypassed here as long as the file name extension we submit is pHp.
}
After the extension verification is bypassed, continue to view the code for retrieving the extension in the upload function:
$ File_ext = $ file-> name2Ext ($ file_name );
Follow up with the name2Ext function:
Function name2Ext ($ fileName ){
$ Tar_file_extension = "";
If ($ fileName! = ""){
If (ereg ("\. ([^ \.] +) $", $ fileName, $ tmp_reg ))
$ Tar_file_extension = substr (strtolower ($ tmp_reg [1]), 0, 4); // the file name extension is converted to lowercase !!
Else
$ Tar_file_extension = "tmp ";
} Else
$ Tar_file_extension = "";
Return $ tar_file_extension;
}
Perfect bypass. This is a program written by Korean experts. Of course, it cannot be compared with that in China. If the analysis is incorrect, we hope to point it out! Thank you!
From the space of Ca3tie1