SQL Injection statements sometimes use the replacement query technology, that is, to make the original query statement fail to find the result and make it run the self-constructed query statement, the execution result is displayed instead of the query result of the original query statement.
For example, the original query statement is select username, email, content from test_table where user_id = uid, where uid is input by the user. The user name, user email address, and user message content are displayed normally. However, if the uid filtering is lax, we can construct the following SQL statement to obtain information about any data table.
Uid =-1 union select username, password, content from test_talbe where user_id = administrator id;
The actual execution is select username, email, content from test_table where user_id =-1 union select username, password, content from test_talbe where user_id = administrator id; where emai is a normal user, changed to display the administrator password.
However, it is often not that simple. First, you need to find the vulnerability. Second, when constructing such statements, you need to consider the types of each field. It is obviously inappropriate to display fields of the int or samllint type in varchar. Finally, I will talk about it in this article.
If the SQL statement has only one or two fields, we want to know a lot. One or two fields are too few to meet our needs. Then we can use the concat function.
The concat function uses select concat (My, S, QL) in this way. The execution result is MySQL. That is, the connection function. We use it to serve us,
Uid =-1 union select username, concat (password, sex, address, telephone), content from test_talbe where user_id = administrator id;
This statement actually queries six fields, but when it is displayed, the password, sex, address, telephone and other fields are combined and displayed in the original place where the email should be displayed.
This article from the CSDN blog, reprinted please indicate the source: aspx "> http://blog.csdn.net/carefree31441/archive/2008/12/16/3529601.aspx