官术网_书友最值得收藏!

A Simple SQLi Example

Let's look at how SQLi breaks down into actual code.

Take a look at the following query, where the value of $id would be input supplied by the user:

SELECT title, author FROM posts WHERE id=$id

One common SQLi technique is to input data that can change the context or logic of the SQL statement's execution. Because that $id value is being inserted directly—with no data sanitization, removal of dangerous code, or data type transformation—the SQL statement is dynamic, and subject to tampering.

Let's make a change that will affect the execution of the statement:

SELECT title, author FROM posts WHERE id=10 OR 1=1

In this case, 10 OR 1=1 is the user-supplied data. By modifying the WHERE clause, the user can alter the logic of the developer-supplied part of the executed example. The preceding example is pretty innocuous, but if the statement asked for account information from a user table, or a part of the database associated with privileges, instead of just information about a blog post, that could represent a way to seriously damage the application.

主站蜘蛛池模板: 浑源县| 古丈县| 综艺| 洞口县| 敖汉旗| 富锦市| 寻甸| 藁城市| 太仆寺旗| 洛浦县| 邹平县| 都兰县| 尉氏县| 同仁县| 二连浩特市| 石台县| 双辽市| 白朗县| 铅山县| 桐梓县| 敦煌市| 如皋市| 山东省| 云浮市| 白沙| 云霄县| 洛扎县| 隆子县| 子长县| 鹿邑县| 阿拉善左旗| 江安县| 保靖县| 双牌县| 新津县| 石狮市| 霍城县| 页游| 藁城市| 尉犁县| 乌什县|