偶然发现一个校内网站的某处评论区有xss漏洞(html标签转义很Naive地依赖前端编辑器),于是通过抓包在评论区插入了段JavaScript。
我告诉她,打开那个网站的某个条目(我选择放置js代码的地方比较隐蔽,一般被人发现不了),会看到惊喜:
原本的网页上面不断有一大群彩色的心形在上浮。
效果(背景当然不是那个网站):
作者:androiosymbian
链接:https://www.zhihu.com/question/57172252/answer/162067481
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
移动端也做了适配:
然并卵。
varcanvas=document.getElementById("cavs");
constWIDTH=window.innerWidth;
constHEIGHT=window.innerHeight;
canvas.setAttribute("width",WIDTH);
canvas.setAttribute("height",HEIGHT);
varcontext=canvas.getContext("2d");
varstart=
{
loves:[],
DURATION:30,
begin:function()
{
this.createLove();
},
createLove:function()
{
for(vari=0; i
{
varlove=newLove();
this.loves.push(love);
}
setInterval(this.drawLove.bind(this),this.DURATION);
},
drawLove:function()
{
context.clearRect(0,0,WIDTH,HEIGHT);
for(varkeyinthis.loves)
{
this.loves[key].draw();
}
}
}
functionLove()
{
varme=this;
functionrand()
{
me.maxScale=(Math.random()*3.2+1.2)*WIDTH/521;
me.curScale=1.2*WIDTH/521;
me.x=Math.floor(Math.random()*WIDTH-40);
me.y=Math.floor(HEIGHT-Math.random()*200);
me.ColR=Math.floor(Math.random()*255);
me.ColG=Math.floor(Math.random()*255);
me.ColB=Math.floor(Math.random()*255);
me.alpha=Math.random()*0.2+0.8;
me.vector=Math.random()*5+0.4;
}
(function(){rand();} ());
me.draw=function()
{
if(me.alpha<0.01)rand();
if(me.curScale
x=me.x;
y=me.y;
scale=me.curScale;
context.fillStyle="rgba("+me.ColR+","+me.ColG+","+me.ColB+","+me.alpha+")";
context.shadowBlur=10;
context.shadowColor="white";
context.beginPath();
context.bezierCurveTo( x+2.5*scale, y+2.5*scale, x+2.0*scale, y, x, y );
context.bezierCurveTo( x-3.0*scale, y, x-3.0*scale, y+3.5*scale,x-3.0*scale,y+3.5*scale );
context.bezierCurveTo( x-3.0*scale, y+5.5*scale, x-1.0*scale, y+7.7*scale, x+2.5*scale, y+9.5*scale );
context.bezierCurveTo( x+6.0*scale, y+7.7*scale, x+8.0*scale, y+5.5*scale, x+8.0*scale, y+3.5*scale );
context.bezierCurveTo( x+8.0*scale, y+3.5*scale, x+8.0*scale, y, x+5.0*scale, y );
context.bezierCurveTo( x+3.5*scale, y, x+2.5*scale, y+2.5*scale, x+2.5*scale, y+2.5*scale );
context.fill();
context.closePath();
me.y-=me.vector;
me.alpha-=(me.vector/2.9*3.5/HEIGHT);
}
}
window.onload=function()
{
start.begin();
}