using a true preprocessing statement that has MySQL to execute a preprocessing statement. This ensures that statements and parameters are not processed by PHP before they are sent to MySQL, which will make it impossible for an attacker to inject malicious SQL. To understand why, refer to this blog post: PDO anti-injection principle analysis and considerations fo
This article simply describes the anti-XSS attacks in PHP and SQL injection in detail, you need to understand the friends can refer to the next.
XSS attack
The code is as follows
Copy Code
Arbitrary code Executionfile contains and CSRF.}
There are many articles about SQL attacks and
Generally, the general programmers or novice programmers who have problems preventing SQL injection do not filter the data submitted by users, as a result, your database was cracked at the moment of the test. Next we will briefly introduce an SQL injection method that may occur when you log on without security configur
Vulnerabilities are just a few categories, XSS, SQL injection, command execution, upload vulnerabilities, local inclusion, remote inclusion, permission bypass, information disclosure, cookie forgery, CSRF (Cross station request), and so on. These vulnerabilities are not just for the PHP language, this article simply describes how
::attr_errmode, pdo::errmode_exception); In the example above, the error mode (Attr_errmode) is not required, but it is recommended. In this way, when a fatal error (Fatal error) occurs, the script does not stop running, but it gives the programmer an opportunity to capture the pdoexceptions in order to properly handle the error. However, the first setattribute () call is required, which prohibits PDO analog preprocessing statements, and the use of a true preprocessing statement, in which MySQ
);
$dbConnection->setattribute (Pdo::attr_errmode, pdo::errmode_exception);
In the above example, the error mode (Attr_errmode) is not required, but it is recommended. In this way, when a fatal error (Fatal error) occurs, the script does not stop running, but it gives the programmer an opportunity to capture the pdoexceptions in order to properly handle the error. However, the first setattribute () call is required, which prohibits PDO analog preprocessing statements, and the use of a
1. phpBB Remote Arbitrary SQL Injection Vulnerability
Affected Systems:
PhpBB Group phpBB 2.0.9PhpBB Group phpBB 2.0.8PhpBB Group phpBB 2.0.8PhpBB Group phpBB 2.0.7PhpBB Group phpBB 2.0.6 dPhpBB Group phpBB 2.0.6 cPhpBB Group phpBB 2.0.6PhpBB Group phpBB 2.0.5PhpBB Group phpBB 2.0.4PhpBB Group phpBB 2.0.3PhpBB Group phpBB 2.0.2PhpBB Group phpBB 2.0.10PhpBB Group phpBB 2.0.1PhpBB Group phpBB 2.0Description:
A few days ago the site has been injected, and now I give you to introduce PHP to prevent SQL injection of several of the processing functions, such as PHP addslashes (), mysql_real_escape_string (), the MySQL operation function (), Mysql_escape _string () and other functions
Specific usage: addslashes prevent
How php prevents SQL injection
$ Unsafe_variable = $ _ POST ['User _ input'];
Mysql_query ("insert into table (column) VALUES ('". $ unsafe_variable ."')");
This is because you can enter a TABLE similar to VALUE "); drop table;-to convert the query:
Insert into table (column) VALUES ('value'); drop table table ;
Recently in a topic polling site, customers know something about the program. There are special requirements to filter some characters to prevent SQL injection. There was no particular study on this front. Oh, and carry forward a back take doctrine. Take the SQL anti-injection function from the Discuz forum!
Copy the
'] $_post[' Admin_pass '])
{
To determine if the Admin user name and password submitted are correct for the corresponding processing code
// ...
$admin = 1;
}
Else
{
$admin = 0;
}
if ($admin)
{
Echo ' landed successfully! '';
Include (' admin.php ');
}
Else
{
Echo ' You're not an admin, you can't manage! '';
}
Then you will not be able to submit the http://www.target.com/login.php?admin=1, because we initially put the variable into $admin = 0, then you can not get administrator rights throug
Php filters out special characters of SQL anti-injection code
// Method 1
// Filter ', ", SQL language name
Addslashes ();
// Method 2: Remove all html tags
Strip_tags ();
// Method 3: filter the code that may be generated
Function php_sava ($ str)
{
Label:the most comprehensive approach to preventing SQL injection PHP prevents SQL injection from being detailed and protected Preventing SQL Injection implementation code in PHPSQL
If the user enters a query that is inserted directly into an SQL statement, the application is vulnerable to SQL injection, such as the following example:
$unsafe_variable$_POST['user_input'];mysql_query("INSERT INTO table (column) VALUES ('"$unsafe_variable"')");
This is because the user can enter similar value "); DROP table tables; -To make the query into:
IN
The precondition is that we need to have the server management permission, that is, we can modify php. ini file. next I will introduce how to modify the php configuration file to prevent SQL injection methods. For more information, see. to ensure security, you can open quot; php
Tag:turninjection judgment adddiv else anti-SQL injection combination ash PHP anti-SQL injection attack collection does not have much filtering, mainly for the combination of PHP and MySQL. General anti-
(Empty ($_post[' sub ')) {
echo $_post[' test '];
}
A very simple piece of code, here only simulates the use of the scene.
Join an attacker commit
You should display the cookie information for the current page on the returned page.
We can apply to some of the message boards (not filtered in advance), and then when the Administrator audit the change message to steal cookie information, and sent to the attacker's space or mailbox. An attacker could use the cookie modifier to log in a
1. The MAGIC_QUOTES_GPC option in the PHP configuration file php.ini is not turned on and is set to off2. Developers do not check and escape data typesBut in fact, the 2nd is the most important. I think that it is the most basic quality of a web programmer to check the data type entered by the user and submit the correct data type to MYSQL. But in reality, many small white Web developers often forget this, leading to a backdoor opening.Why is the 2nd
Label:For a long time, the security of web has great controversy and challenge. Among them, SQL injection is a common attack method, the common practice of developers is to keep filtering, escaping parameters, but we php inherently weak type of mechanism, always let hackers have the advantage, bypassing defense and defense is always in the infighting.PHP Daniel s
PHP and SQL injection attacks [II]
Magic Quotes
As mentioned above, SQL injection is primarily about committing unsafe data to the database for attack purposes. To prevent SQL note
Into the attack,
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.