CGI security tips

Source: Internet
Author: User
Tags mysql injection

Author: fallen leaves [J. L.S. T]
Information Source:Http://hi.baidu.com/jluoye


I have been working hard to keep up with the Internet for a long time.

See todayPhpeval has an article on CGI security.I was so careful when I was studying CGI.

The cgi program I encountered generally uses mysql as a database, or a plain text database.

For cgi + mysql injection, I will not mention the bird. Although the method is a bit different from the general mysql injection, it is also similar

Let's talk about some small things in the text database.

Almost all plain text CGI programs have a common problem, that is, generate a cgi file named after the user ID or user name in a specified directory.

All contents in this file are not filtered, which allows us to insert arbitrary cgi code and execute

For example, a program registration process is as follows: Check that the user folder does not exist, otherwise, create ==> create a cgi file named by user name under the users directory ==> write the corresponding registration information in this CGI File ==> complete registration

If the registration process is like this, we can execute any code. For example, the data for registering a user is as follows:

User name: luoye

User password: password

Email Address: luoye@00day.cn

The program creates a luoye. cgi file under the users directory, where the content is "luoye | password | luoye@00day.cn"

If we register a user like this:

Username: print (1 );#

User password: password

Email Address: luoye@00day.cn

After registration, we only need to browse the print (1) % 23. cgi program under the users directory to execute the cgi code. If it is evil, we will write the system @ ARGV. This station is ours.

If the program is created using the user ID as the file name, the harm is even greater.

The defense method is also very simple. It filters User Registration Information and moves the users directory to a non-web directory.

In fact, there are still a lot of skills. Here is only one of them. We will not say much about the other. You can explore E by yourself, =)

If the final exam is good, click here to get JJ's stuff ~~


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.