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

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.

主站蜘蛛池模板: 额尔古纳市| 广德县| 瓮安县| 沙坪坝区| 宜城市| 河源市| 云霄县| 蒙阴县| 沭阳县| 介休市| 平果县| 舒城县| 金山区| 蓬溪县| 临颍县| 乌审旗| 峨眉山市| 峡江县| 南涧| 盈江县| 汝南县| 呼图壁县| 栾川县| 基隆市| 广饶县| 武乡县| 祁东县| 土默特右旗| 朝阳区| 金山区| 长岛县| 贺州市| 杂多县| 平泉县| 宝清县| 宁津县| 罗山县| 临武县| 怀集县| 阳山县| 醴陵市|