编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

接口安全性测试技术(5):SQL注入(安全测试sql注入登录)

wxchong 2024-08-07 01:38:57 开源技术 26 ℃ 0 评论

DVWA环境搭建

DVWA-1.0.7.zip
http://IP:Port/dvwa/login.php。默认用户名 admin, 默认密码 password

什么是SQL注入

SQL注入是发生在应用程序数据库层的安全漏洞。简而言之,是输入的文本中注入SQL指令,在设计不良的程序当中忽略了检查,那么这些注入进去的指令就会被数据库服务器误认为是正常的SQL指令而执行,因此遭到破坏。

SQL注入类型

1.数字型注入

http://www.test.com/msg/test.php?myno=1'
http://www.test.com/msg/test.php?myno=1 or 1=1
http://www.test.com /msg/test.php?myno=1 and 1=2
http://www.test.com/msg/test/php?myno=1 or
'abc'='ab'||'c'



2. 字符串注入

http://www.test.com/msg/test.php?mychar=aaaa'
http://www.test.com/msg/test.php?mychar=aaaa' or
'1'='1
http://www.test.com /msg/test.php?mychar=aaaa' and
'1'='2
http://www.test.com/msg/test/php?mychar=aaaa' or
'abc'='ab'||'c



3. 终止式SQL注入



SQL注入防范

  • 使用绑定变量
  • 使用存储过程
  • 检查数据类型
  • 使用安全函数
  • ESAPI.encoder().encodeForSQL
OWASP防御方案,服务端输入校验和输出编码
规则一:进入HTML标签
HTML编码,& -> &
ESAPI.encoder().encodeForHTML
规则二:进入HTML属性值
value,width,height等,编码单引号和双引号为&#xHH
ESAPI.encoder().encodeForAttribute
规则三:进入JavaScript中
ESAPI.encoder().encodeForJavaScript
规则四:进入CSS中
ESAPI.encoder().encodeForCSS
规则五:进入URL
对特殊字符采用%HH编码
ESAPI.encoder.encodeForURL

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表