zoukankan      html  css  js  c++  java
  • 接口安全性测试技术(5):SQL注入

    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

    下一节:更新接口安全测试之XS

    如果您看了本篇博客,觉得对您有所收获,请点击右下角的[推荐]. 如果您想转载本博客,请注明出处, 如果您对本文有意见或者建议,欢迎留言. 感谢您的阅读,请关注我的后续博客!
  • 相关阅读:
    清空数据库所有表数据
    sqlserver编号
    Inherits、CodeFile、CodeBehind的区别
    初识NuGet
    ASP.Net各个命名空间及作用
    SQL SERVER数据库性能优化之SQL语句篇
    Exercise 20: Functions And Files
    Exercise 19: Functions And Variables
    Exercise 18: Names, Variables, Code, Functions
    Exercise 17: More Files
  • 原文地址:https://www.cnblogs.com/chuansinfo/p/13588576.html
Copyright © 2011-2022 走看看