目录
1、Web应用发展历程
早期的WWW网,用户通过Web浏览器,相关信息流仅由服务器向浏览器单向传送。 多数站点并不验证用户的合法性,因为根本没有必要这样做;所有用户同等对待,提供同样的信息。
如今的万维网与早期的万维网已经完全不同,Web上的大多数站点实际上是应用程序。它们功能强大,在服务器和浏览器之间进行双向信息传送。 它们支持注册与登录、金融交易、搜索以及用户创作的内容。
举个简单栗子。
1、多数浏览器对于POST采用两阶段发送数据的,先发送请求头,再发送请求体,即使参数再少再短,也会被分成两个步骤来发送(相对于GET),也就是第一步发送header数据,第二步再发送body部分。HTTP是应用层的协议,而在传输层有些情况TCP会出现两次连结的过程,HTTP协议本身不保存状态信息,一次请求一次响应。对于TCP而言,通信次数越多反而靠性越低,能在一次连结中传输完需要的消息是最可靠的,尽量使用GET请求来减少网络耗时。如果通信时间增加,这段时间客户端与服务器端一直保持连接状态,在服务器侧负载可能会增加,可靠性会下降。
2、GET请求能够被cache,GET请求能够被保存在浏览器的浏览历史里面(密码等重要数据GET提交,别人查看历史记录,就可以直接看到这些私密数据)POST不进行缓存。
3、GET参数是带在URL后面,传统IE中URL的最大可用长度为2048字符,其他浏览器对URL长度限制实现上有所不同。POST请求无长度限制(目前理论上是这样的)。
4、GET提交的数据大小,不同浏览器的限制不同,一般在2k-8K之间,POST提交数据比较大,大小靠服务器的设定值限制,而且某些数据只能用 POST 方法「携带」,比如 file。
5、全部用POST不是十分合理,最好先把请求按功能和场景分下类,对数据请求频繁,数据不敏感且数据量在普通浏览器最小限定的2k范围内,这样的情况使用GET。其他地方使用POST。
6、GET 的本质是「得」,而 POST 的本质是「给」。而且,GET 是「幂等」的,在这一点上,GET 被认为是「安全的」。但实际上 server 端也可以用作资源更新,但是这种用法违反了约定,容易造成 CSRF(跨站请求伪造)。
GET请求
GET是最常见的一种请求方式,当客户端要从服务器中读取文档时,当点击网页上的链接或者通过在浏览器的地址栏输入网址来浏览网页的,使用的都是GET方式。
GET方法要求服务器将URL定位的资源放在响应报文的数据部分,回送给客户端。使用GET方法时,请求参数和对应的值附加在URL后面,利用一个问号(“?”)代表URL的结尾与请求参数的开始,传递参数长度受限制。
例如,/index.jsp?id=100&op=bind,这样通过GET方式传递的数据直接表示在地址中,所以我们可以把请求结果以链接的形式发送给好友。以用google搜索domety为例,Request格式如上图:
POST请求
对于上面提到的不适合使用GET方式的情况,可以考虑使用POST方式,因为使用POST方法可以允许客户端给服务器提供信息较多。
POST方法将请求参数封装在HTTP请求数据中,以名称/值的形式出现,可以传输大量数据,这样POST方式对传送的数据大小没有限制(具体看服务器限制),而且也不会显示在URL中。
还以上面的搜索domety为例,如果使用POST方式的话,格式如上图:
2、Web应用安全
在万维网早期,创建一个Web站点所带来的安全威胁主要与Web服务器软件的(诸多)漏洞有关。
- 攻击者入侵Web站点并不一定能获取任何敏感信息,因为服务器上保存的信息大部分都可以公开查看。
- 所以攻击者往往会修改服务器上的文件,以歪曲Web站点的内容,或者利用服务器的存储容量和带宽传播“非法软件”。
如今,如今的Web应用安全领域是攻击者与计算机资源和数据防御者之间最重要的战场,Web站点成为网络攻击的主要入口。
- 针对Web应用程序的最严重攻击,是那些能够披露敏感数据或获取对运行应用程序的后端系统的无限访问权限的攻击
- OWASP:OWASP被视为web应用安全领域的权威参考, TOP10:https://www.cnblogs.com/fatox/p/10405738.html
Malicious Client Attacking Server的分类:
- Injection
- File System Traversal
- Broken Access Control
a.SQL Injection--Retrieving hidden data
Shopping website, When the user clicks on the Gifts category, their browser requests the URL: https://insecure-website.com/products?category=Gifts。
This causes the application to make an SQL query to the database:
SELECT * FROM products WHERE category = 'Gifts' AND released = 1。
第一种攻击:
An attacker can construct an attack to display unreleased products like:
https://insecure-website.com/products?category=Gifts'--
This results in the SQL query:
SELECT * FROM products WHERE category = 'Gifts'--' AND released = 1。
思考:假如--前不如插入符号',还能正确执行吗?
解答:
The restriction released = 1 is being used to hide products that are not released. For unreleased products, presumably released = 0. The key thing here is that the double-dash sequence -- is a comment indicator in SQL, and means that the rest of the query is interpreted as a comment. This effectively removes the remainder of the query, so it no longer includes AND released = 1. This means that all products are displayed, including unreleased products.
第二种攻击:
An attacker can cause the application to display all the products in any category, including categories that they don't know about:
https://insecure-website.com/products?category=Gifts'+OR+1=1--
This results in the SQL query:
SELECT * FROM products WHERE category = 'Gifts' OR 1=1--' AND released = 1。
b.File System Traversal
Directory traversal (also known as file path traversal) is a web security vulnerability that allows an attacker to read arbitrary files on the server that is running an application
(. / 代表根目录,慎用 ../ 代表上一级目录 ../../ 代表上两级目录 /.. 代表下级目录 /../.. 代表下两级目录)
Consider a shopping application that displays images of items for sale. Images are loaded via some HTML like the following:
<img src="/loadImage?filename=218.png">
the server reads image from path: /var/www/images/218.png
The application implements no defenses against directory traversal attacks, so an attacker can request the following URL to retrieve an arbitrary file from the server's filesystem:
https://insecure-website.com/loadImage?filename=../../../etc/passwd
This causes the application to read from the following file path:
/etc/passwd
On Unix-based systems, this is a standard file containing details of the users that are registered on the server.
On Windows, ../ and ..\ are valid directory traversal sequences, and an equivalent attack to retrieve a standard operating system file would be:
https://insecure-website.com/loadImage?filename=..\..\..\windows\win.ini
and so the file that is actually read is:
/windows/win.ini
c.Broken Access Control
越权攻击,admin.php;访问这些敏感地址时,应该直接进入下面类似的登录页面:
A basic method of exploiting access control flaws in an application's code is known as forced browsing. Consider the hypothetical website http://web_net_thing.com. This website normally authenticates its users and administrators, and only delivers the appropriate pages after authentication. If attackers know the appropriate URL, they can simply enter in their browser:
http://web_net_thing.com/user_page or
http://website.com/admin_page
A properly secured website would simply redirect the user to the login page. If, however, this method allows access to those pages, it is a form of broken access control. Even a rudimentary attack like this can cause alarming damage if user data is stored improperly.
http://website.com/password_list.txt
could give an attacker direct access to the cleartext passwords for the website's users.
未完待续,如果对您有帮助,还请多多支持哦,谢谢!