SQL injection labs exercises

 Less 17

This update is off injection.

 

update statement: update users (table) set passwd (field) = $ _POST [ 'the passwd'] (Closed unknown) where uname (field) = $ _POST [ 'the uname']  (Closed unknown);

For update statements can be injected in the User Name and New Password two, but the success will not return useful information can not be used in conjunction injection, can be considered an error injection, injection delay, you can not use Boolean injection.

The first step, determining the closed mode

After adding uname = admin1 'failed

In passwd = admin1 added after 'successful, thereby determining the closed mode is a closed single quotes. Closed way to determine general is quite troublesome, but the principle is simple not too much talk about it.

Question: Why can inject here New Password and User Name can not inject it?

By looking at the source code off 17 we can see that the authors used check_input ($ _ POST [ 'uname']); and stressed that this does not make uname injection

We first learn about this function

Two important conditions mysql implantation does not occur is the escape 1. Inject statement is not injected into the filter 2. Statement

In this check_input () function by first substr () function limits the maximum password length is 15, will be taken over discarded, and then determines whether the escape opening (i.e., when the escape opening get_magic_quotes_gpc () = on get_magic_quotes_gpc () Returns 1,

While () function is removed by a backslash stripslashes. Then crype_digit () function check is not a decimal number, it returns true, false if not, can be seen in the case where the input is not a decimal, will function was filtered through mysql_real_escape_string ().

以上字符会受到影响,最后通过intval()函数转换为整数,进行数据类型转换,check_input()可以被视作是作者编写的安全过滤函数,通过各种过滤转义避免了sql注入的发生,但究竟是不是绝对安全的杜绝了sql注入,

由于水平有限无法回答,但至少避免了绝大部分的sql注入。

问题2 为什么不能布尔注入

先查看user表数据

然后执行一下SQL语句,发现虽然逻辑错误但是依旧显示语句成功执行

再次查看users表发现数据并没有改变,因为语句并没有执行但显示成功执行

如果是1=1呢?

 

虽然不能进行布尔注入但是还是能进行延时注入,由于无法直观显示就不展示了,可以自己尝试一下。

第二步,报错注入

通过updatexml语句成功爆出数据库名字,修改(select database())也能爆出其他信息,这里也不一一显示了

常用报错语句

1. union select 1,count(*),concat(0x7e,(查询语句),0x7e,floor(rand(0)*2))x from information_schema.columns group by x --+

2. and extractvalue(1,concat(0x7e,(查询语句),0x7e) --+

3. and updatexml(1,concat(0x7e,(查询语句),0x7e),1)

这三款最常用,也比较方便记忆。

 

Guess you like

Origin www.cnblogs.com/zyx2019/p/11269696.html