Secondary exploitation of a PhpCMS Vulnerability

Source: Internet
Author: User
The second exploitation of a PhpCMS vulnerability: Flyh4tphpCMS has always been known for its many vulnerabilities. Its 2008 version inherits the glorious tradition of previous versions and has various vulnerabilities with different levels of hazards. Next we will look at a local file inclusion vulnerability that has been supplemented in later updates. However, the exploitation method of this vulnerability is quite interesting. The vulnerability code is simple.

Secondary exploitation of a PhpCMS Vulnerability

Author: Flyh4t

PhpCMS has always been known for its many vulnerabilities. Its 2008 version inherits the glorious tradition of previous versions and has various vulnerabilities with different levels of hazards. Next we will look at a local file inclusion vulnerability that has been supplemented in later updates. However, the exploitation method of this vulnerability is quite interesting.
The vulnerability code is very simple. I believe many people can see it.

Pay/respond. php

 
 
  1. Require\ './INcLude/common. inc. php \';
  2. $ Pay_code =! EmptyEmpty($ Code )?TrIm ($ code): ""; // $ pay_code is not filtered
  3. If(EmptyEmpty($ Pay_code ))
  4. {
  5. Showmessage (\ 'verification failed \');
  6. }
  7. ELsE 
  8. {
  9. $ Plugin _File=PHPCMS_ROOT. \ 'pay/include/payment/\ '. $ pay_code. \'. php \';
  10. If(Is_file ($ plugin_file ))
  11. {
  12. Include_once($ Plugin_file); // local File Inclusion Vulnerability


A lot of people may find this place very bad. % 00 or a number of [//] must be used to intercept the following logs. php. ini or the system has certain requirements. In fact, this is not the case. In combination with other defects of phpcms, we can exploit the vulnerability in the local file through a second attack. Below I will provide two methods of exploitation.

 

Method 1: bypass background authentication and convert to Code Execution Vulnerability
Those who carefully read the code of phpcms2008 earlier versions should have found that (the latest version seems to have been changed), and its background login authentication is in admin. PHP file, and then use the following code to include files under the admin directory to implement other complex management functions

 
 
  1. if(!@include PHPCMS_ROOT.(isset($M[\'path\']) ? $M[\'path\'] : \'\').\'admin/\'.$file.\'.inc.php\') showmessage("The file ./{$M[\'path\']}admin/{$file}.inc.php is not exists!"); 


To prevent non-administrator users from accessing related files in the admin directory, the following code is used at the beginning of all files in the directory for processing, and no permission authentication is performed.

 
 
  1. defined(\'IN_PHPCMS\') or exit(\'Access Denied\'); 

 

With this code, we basically cannot directly access it. The constant IN_PHPCMS is defined in the file/include/common. inc. php. The Code is as follows:

 
 
  1. define(\'PHPCMS_ROOT\', str_replace("\\", \'/\', substr(dirname(__FILE__), 0, -7)));  
  2. define(\'MICROTIME_START\', microtime());  
  3. define(\'IN_PHPCMS\', TRUE);  

 

In response to the vulnerability. PHP file. The first line contains/include/common. inc. PHP file. In this way, theoretically, we can directly use the background management function by exploiting the local file inclusion vulnerability to include files under the admin directory. However, in actual use, we also need to consider that some functions in the background file may be called admin. PHP files, so we may encounter undefined function errors, but we are lucky to avoid this problem in Phpcms. Check the Code:

Admin/template. inc. php

 
 
  1. Defined (\ 'In _ PHPCMS \')OrExit (\ 'Access Denied \');
  2.  
  3. // Introduce the template function File
  4. If($ Action! = \ 'Tag \ '& $ action! = \ 'Preview \')Require_once\ 'Template. func. php \';
  5.  
  6. // Initialize a bunch of Variables
  7. If(! $ Forward) $ forward = HTTP_REFERER;
  8. $ MoDuLe = isset ($ module )? $ Module: \ 'phpcms \';
  9. $ Project = isset ($ project )? $ Project: TPL_NAME;
  10. $ Templatedir = TPL_ROOT. $ project. \ '/\'. $ module .\'/\';
  11. $ Projects = cache_read (\ 'name. inc. php \ ', TPL_ROOT );
  12. // Common. inc. php already contains the cache_read file.
Related Article

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.