Determine if it is a url with a combination of specifications

Source: Internet
Author: User
Determine whether or not the URL-based hostphoto. php is in conformity with the specification? Type1 & amp; id0 recently let's take a look at what the hacker tutorial says after these URLs add some 11 conditions to implement what SQL injection problems now I think the above photo. when the php file is accessed, the program checks whether it meets the character type. 'type' and 'id' can only be followed by numbers. There cannot be a url after the id to determine whether the url meets the specification
Http: // localhost/photo. php? Type = 1 & id = 0

Recently, let's take a look at what the hacker tutorial says about the SQL injection problems that can be achieved by adding 1 = 1 to these URLs.
Now I want to see if the above photo. php file is accessed, the program checks whether it has a combination of specifications. 'type = 'and 'Id =' can only be followed by numbers. There cannot be other parameters after the id, such:
Http: // localhost/photo. php? Type = 1 & id = 0 & 1 = 1
This way


Thank you for your advice.

------ Solution --------------------
Use intval or regular expression to filter submitted content based on the final object type. Determine the length of the submitted content...
Of course, the premise is that if you are not involved in database operations, you do not need to be so nervous.
------ Solution --------------------
It is necessary to escape data. It is not just a judgment on the effectiveness of data
------ Solution --------------------
Where can I use regular expressions. Is_numeric () is used to determine whether it is a number.
------ Solution --------------------
If the integer type is directly forced to convert (int) $ var; this is not a worry! For the character escape type, you must use filtering or other methods.
------ Solution --------------------
Checking and filtering the input data is basically the first step of the program... in fact, you must have done a lot...
Do not be frightened by hacker tutorials. input that is not used by programs will not cause any harm to security.

Whether intval, (int), is_numeric, or regular expressions are used depends on your needs,

Note that these methods may have different effects in special input,
For example, when a decimal number is input? Negative? Hexadecimal, octal digit? When it starts with a number but contains letters?
The result may be different, and then the program may go to different branches.

The best way is to perform multiple tests.

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.