I believe everyone knows about the concept and harm of SQL injection attacks. if you don't know anything about SQL injection attacks, you can take a look at how to effectively prevent them in php: if the data entered by the user is inserted into an
This article mainly introduces how to prevent SQL injection in Pyhton. the method described in this article is simple and practical. if you need it, refer to the following code:
C = db. cursor ()Max_price = 5C.exe cute ("SELECT spam, eggs, sausage
Here, I will share with you some examples and experiences of preventing SQL injection attacks summarized by the webmaster. I hope this tutorial will help you.
1. Configure on the server
Security, PHP code writing is one aspect, and PHP configuration
Configure get_magic_quotes_gpc in php to prevent SQL injection usage
Get_magic_quotes_gpc (); is to obtain the value of the php environment variable magic_quotes_gpc. If the value is 1, it indicates that the configuration is enabled; if it is 0,
Code used to prevent SQL injection attacks. SQL injection attacks use designed vulnerabilities to run SQL commands on the target server and perform other attacks, when SQL commands are dynamically generated, the number of SQL injection attacks that
Problem Description:
If the data entered by the user is inserted into an SQL query statement without processing, then the application is likely to suffer a SQL injection attack, as in the following example:
$unsafe _variable = $_post[' user_input '
This article provides a detailed analysis on how to prevent SQL injection in php. if you want to insert a query directly into an SQL statement, applications are vulnerable to SQL injection, for example, the following example:
The code is as
If the data entered by the user is inserted into an SQL query statement without being processed, the application may be vulnerable to SQL injection attacks, as shown in the following example: Problem description:
If the data entered by the user is
(1) mysql_real_escape_string -- escape special characters in the strings used in SQL statements, and take into account the usage of the connected current character set as follows:
$sql = "select count(*) as ctr from users where
Mysql_real_escape_string ()
So the SQL statement has a similar wording: "SELECT * from CDR where src =". $userId; Change to $userId =mysql_real_escape_string ($userId)
All printed statements, such as Echo,print, should be filtered using htmlentities
Each record in this database has a username field and a password field. Create a logon form to allow users to log on. Each record in this database has a username field and a password field. Create a logon form to allow users to log on.
Rule 1:
I. Types of injection attacks
There may be many different types of attack motives, but at first glance there seems to be more types. This is very real-if a malicious user discovers a way to execute multiple queries. We'll discuss this in more detail
Problem description:If the data entered by the user is inserted into an SQL query statement without being processed, the application may be vulnerable to SQL injection attacks, as shown in the following example: The code is as
The operation of the site is sure that every webmaster must consider the issue, you know, most hackers attack the site is the use of SQL injection, this is what we often say why? The most original static website is the safest. Today we talk about
The following provides a. net program to prevent SQL injection (filter sensitive statements for reference only): Add the following code under the Global. asax file:Void Application_BeginRequest (Object sender, EventArgs e){StartProcessRequest ();
}
#
The SQL injection attack is successful because new logic is added to the original SQL statement.
For example, the original SQL = "select * from user where userid = '" + userid + "'";
If userid = "'or 1 = '1 ";
The concatenated SQL = "select * from
I. Numbers.
How to inject?
Suppose we want to implement a page for displaying news, we may write down the followingCode:
String id = request. querystring ["ID"];
String SQL ="Select * from news where colid ="+ ID;
If the
Functions used to prevent SQL injection attacks. You can use them directly. However, you may not be able to use them all. Therefore, you need to enhance security awareness.
CopyCode The Code is as follows: '================================
'Filter
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.