Code execution vulnerability in a CMS example of a PHP Training

Source: Internet
Author: User

The download volume on VeryCD is still quite high. It shows that it is an example provided by the teacher to introduce MVC. From the perspective of development, it is still good. However, for the convenience of the picture, I have neglected some things. Here is an article for notes.
 
What is MVC? In order to achieve a single entry, all the actions (Control) usually start from a file. Let's see how he wrote it here (admin. php In the root directory ):
 
<? PHP
Require ('init. php ');
Eval ('$ action = new'. ucfirst (isset ($ _ GET ["m"])? $ _ GET ["m"]: "index"). "Action ();");
$ Action-> run ();
 
?>
Note: The main function of the init. PHP file contained here is to use the magic method of PHP _ autoload () to automatically load class files. Then, the $ action = new SomeAction (); statement is followed to instantiate an entity class. But unfortunately, he directly used the eval function for the convenience of the graph.
 
The famous saying "any input is harmful" is shining at the moment ~
 
The characters after new are passed in through the GET method. Here, the data input is controlled by me, so we can request
 
Admin. php? M = xxxxx www.2cto.com
 
Then use your evil imagination to do something evil.
 
At the same time, we found a class named UserModel. We can construct it like this.
 
Admin. php? M = UserModel (); phpinfo ();//
 
So the statements we run in eval become
 
$ Action = new UserModel (); phpinfo (); // Action ();
 
The code execution is so generated. The repair method will be discussed next time. I just think that the training institution will have a similar tutorial program ctrl + c or ctrl + v. Hv fun


From DarkRay's BLoG .!

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.