Home >Backend Development >PHP Tutorial >Block SQL Server injection vulnerability in three simple steps_PHP tutorial

Block SQL Server injection vulnerability in three simple steps_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:02:04863browse

What is SQL injection?
When writing many website programs, they do not judge the legality of user input data, causing security risks in the application. Users can submit a database query code (usually in the browser address bar, accessed through the normal www port), and obtain certain data they want to know based on the results returned by the program. This is the so-called SQL Injection, that is, SQL injection. .
SQL injection modifies the website database through web pages. It is able to add users with administrator rights directly in the database, thereby ultimately gaining system administrator rights. Hackers can use the obtained administrator rights to arbitrarily obtain files on the website or add Trojan horses and various malicious programs to the web page, causing great harm to the website and the netizens who visit the website.
There is a wonderful way to prevent SQL injection
Step 1: Many novices download the SQL universal anti-injection system program from the Internet, and use it in the header of the page that needs to prevent injection to prevent others from performing manual injection testing.
But if you use SQL injection analyzer, you can easily skip the anti-injection system and automatically analyze its injection points. Then it only takes a few minutes for your administrator account and password to be analyzed.
The second step: Regarding the prevention of injection analyzers, the author discovered a simple and effective prevention method through experiments. First we need to know how the SQL injection analyzer works. During the operation, I found that the software was not directed to the "admin" administrator account, but to the permissions (such as flag=1). In this way, no matter how your administrator account changes, you cannot escape detection.
Step 3: Since we can’t escape detection, we will create two accounts, one is an ordinary administrator account, and the other is an account to prevent injection. Why do we say this? The author thinks that if you find an account with the highest authority to create a false impression and attract detection by the software, and the content in this account is more than 1,000 Chinese characters, it will force the software to enter a full load state and even use resources when analyzing this account. Exhausted and crashed. Let's modify the database next.
 1. Modify the table structure. Modify the data type of the administrator's account field, changing the text type to the maximum field of 255 (actually it is enough, if you want to make it larger, you can choose the note type), and set the password field in the same way.
 2. Modify the table. Set the account with administrator rights in ID1, and enter a large number of Chinese characters (preferably more than 100 characters).
3. Put the real administrator password in any position after ID2 (such as ID549).
We have completed the modification of the database through the above three steps.
Is the modification finished now? In fact, it is not the case. You must understand that the ID1 account you created is actually an account with real permissions. Nowadays, computer processing speed is so fast. If you encounter a software that must calculate it, this is also unsafe. I think most people have already thought of a way at this time. Yes, just write the character limit in the page file where the administrator logs in! Even if the other party uses this account password with thousands of characters, it will be blocked, but the real password can be unrestricted.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631099.htmlTechArticleWhat is SQL injection? Many website programs are written without judging the legality of user input data, causing security risks in the application. Users can submit a database query...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn