freeCodeCamp/guide/chinese/sql/sql-injection/index.md

696 B

title localeTitle
SQL Injection SQL注入

SQL注入

SQL注入是一种旨在危害或破坏数据库的恶意技术。它是最常见的网络黑客技术之一。

通过输入将恶意代码放入SQL语句中来执行SQL注入。

以下示例是一个代码段,它将基于AccountId从数据库中检索用户。

passedInAccountId = getRequestString("AccountId"); 
 sql = "select * from Accounts where AccountId = " + passedInAccountId; 

通过注入1=1;可以使用SQL注入来破坏此代码1=1; AccountId声明。

https://www.foo.com/get-user?AccountId="105 OR 1=1;"

1=1将始终评估为TRUE 。这将导致执行的代码输出所有Accounts表。