Tencent Daniel teaches Web front-end and back-end vulnerability analysis and defense skills

download: Tencent Daniel teaches Web front-end and back-end vulnerability analysis and defense skills

The project is finally online, but it faces security threats. Are you afraid? This course uses a practical project to demonstrate the main security issues and defense measures such as XSS, CSRF, clickjacking, SQL injection, etc., to dispel your worries about the security of the project, and to support your own development projects.

Suitable for the crowd and technical reserve requirements.
This course is an introductory course for Web security. You can learn the principles of Web security from scratch. It is suitable for developers who have certain development experience and want to improve their code security;
or they want to work on security.

Technical reserve requires
familiarity with HTML, JavaScript
, basic knowledge
of Node.js, Koa, basic knowledge of PHP, MySQL

//Don't act like a loser.//This code is written by huayucaiji//You can only use the code for studying or finding mistakes//Or,you'll be punished by Sakyamuni!!!#include<bits/stdc++.h>#define int long longusing namespace std;int read() { char ch=getchar(); int f=1,x=0; while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { x=x10+ch-'0'; ch=getchar(); } return fx;}const int MAXN=1e5+10;int n,m;int a[MAXN];struct seg_tree { int lazy,num[2][21];}s[MAXN<<2];void pushdown(int l,int r,int p) { if(l==r) { return ; } s[p<<1].lazy^=s[p].lazy; s[p<<1|1].lazy^=s[p].lazy; for(int i=0;i<=20;i++) { if(s[p].lazy&(1<<i)) { swap(s[p<<1].num[0][i],s[p<<1].num[1][i]); swap(s[p<<1|1].num[0][i],s[p<<1|1].num[1][i]); } } s[p].lazy=0;}void build(int l,int r,int p) { if(l==r) { for(int i=0;i<=20;i++) { s[p].num[a[l]&(1<<i)? 1:0][i]++; } s[p].lazy=0; return ; } int mid=(l+r)>>1; build(l,mid,p<<1); build(mid+1,r,p<<1|1); for(int i=0;i<=20;i++) { s[p].num[1][i]=s[p<<1].num[1][i]+s[p<<1|1].num[1][i]; s[p].num[0][i]=s[p<<1].num[0][i]+s[p<<1|1].num[0][i]; }}void modify(int l,int r,int p,int x,int y,int val) { pushdown(l,r,p); if(r<x||y<l) { return ; } if(x<=l&&r<=y) { for(int i=0;i<=20;i++) { if(val&(1<<i)) { swap(s[p].num[0][i],s[p].num[1][i]); } } s[p].lazy=val; return ; } int mid=(l+r)>>1; modify(l,mid,p<<1,x,y,val); modify(mid+1,r,p<<1|1,x,y,val); for(int i=0;i<=20;i++) { s[p].num[1][i]=s[p<<1].num[1][i]+s[p<<1|1].num[1][i]; s[p].num[0][i]=s[p<<1].num[0][i]+s[p<<1|1].num[0][i]; }}int query(int l,int r,int p,int x,int y) { pushdown(l,r,p); if(r<x||y<l) { return 0; } if(x<=l&&r<=y) { int ret=0; for(int i=0;i<=20;i++) { ret+=(1<<i)*s[p].num[1][i]; } return ret; } int mid=(l+r)>>1; return query(l,mid,p<<1,x,y)+query(mid+1,r,p<<1|1,x,y);}signed main() { cin>>n; for(int i=1;i<=n;i++) { a[i]=read(); } build(1,n,1); cin>>m; for(int i=1;i<=m;i++) { int opt=read(); if(opt==2) { int x=read(),y=read(),val=read(); modify(1,n,1,x,y,val); } else { int x=read(),y=read(); printf("%lld\n",query(1,n,1,x,y)); } } return 0;}

Guess you like

Origin blog.51cto.com/15101021/2636267