1. What is SQL injection? Sql injection is an attack method that adds sql code to the input parameter and passes it to the Sql server for parsing and execution. 2. How did it come about? Web developers cannot guarantee that all input is sanitized The attacker constructs executable SQL code using the input data sent to the SQL server The database is not configured for security 3. How to find SQL vulnerabilities? Identify all input points in a web application Understand what types of requests trigger exceptions? (special characters " or ') Detect anomalies in server responses 4. How to perform SQL injection attack? Digital Injection: Select * from tablename where id=1 or 1=1; String injection: MySQL's comment feature: The characters after # and -- are commented out, so no matter what password is entered, it can be queried correctly. Please click here to enter image description 5. How to prevent SQL injection? Strictly check the input format: is_numeric(var), tp5 validate verification, and use regular expressions to check whether the string is between [A-Za-z] Escape: addslashes(str), mysqli_escape_string() function to escape 6.MySQLi's precompilation mechanism Parameterized Binding Parameterized binding is another barrier to prevent SQL injection. PHP MySQLi and PDO both provide such functionality. For example, MySQLi can query like this: PDO is even more convenient, for example: You may also be interested in:
|
<<: How to generate a free certificate using openssl
>>: How to write memory-efficient applications with Node.js
1. The color of the scroll bar under xhtml In the ...
Fast-Linux project address: https://gitee.com/uit...
Preface: This article is based on the experience ...
Table of contents One master and multiple slaves ...
Table of contents 1. Use help information 2. Crea...
When loading network data, in order to improve th...
Table of contents 1. Background 2. Understanding ...
MySQL query by year, month, week, day group 1. Qu...
When using nginx as a reverse proxy, you can simp...
If an index contains (or covers) the values of ...
Table of contents question: There are 2 tokens in...
Table of contents 1. Commonjs exports and require...
Written in front Sometimes you need to install so...
1. Open the CentOS 7 virtual machine. 2. Log in t...
<body style="scroll:no"> <tabl...