0%

Web Application Hacker's Handbook 读书笔记

好吧,标题是挺长的。但确实能表达这篇文章是要干嘛。

在拿到这本书后,我是像我看那本《数据结构与算法分析》一样,从头一字不漏地开始往后看的。说实话,那些内容有点让我痛苦。xD
在经历了长达一个多月的挣扎后,我终于领悟到跳脱这泥潭的方法————我可以跳着看,没必要纠结于前两章。毕竟它们很无趣,对我来说,起码现在是这样。
于是我开始了我快乐的第三章之旅。很明显,第三章要比前两章有趣得多,而且对于现在的我的帮助也大得多。显而易见的是,我有很多不懂得地方,而且我也保持了一贯的习惯:在书上瞎画哒。所以我以此作为我书上笔记的补充。

第三章

HTTP Headers

我在看书时发现Pragma和Cache_Control好像没啥区别。

HTTP缓存这篇文章讲的很细致(吧?)。
总的来说:http1.0时期,给client设置缓存有两个字段Pragma和Expires现在是为了向前兼容所以还留着。Pragma的优先级高于Expires。而Expires所定义的缓存时间是相对于服务器上的时间而言的,无法保证和客户端的时间统一。为了解决这个问题,http1.1新增了Cache-Control来定义缓存过期时间。

graph TD
    A[Pragma] --> B[Cache-Control] --> C[Expires]
    F[优先级]

HTTP Methods

emmm ,再看到稍后面一点的Web Functionality时重新返回来看了下HTTP Methods这里。对于POST迷惑了。

POST Vs PUT-来自StackOverflow

Better is to choose between PUT and POST based on idempotence of the action.
PUT implies putting a resource - completely replacing whatever is available at the given URL with a different thing. By definition, a PUT is idempotent. Do it as many times as you like, and the result is the same. x=5 is idempotent. You can PUT a resource whether it previously exists, or not (eg, to Create, or to Update)!
POST updates a resource, adds a subsidiary resource, or causes a change. A POST is not idempotent, in the way that x++ is not idempotent.

涉及幂等性这块,之前还真没觉得POST和PUT功能有点重复。现在这么一对比,有点懂了POST的功能。
Idempotence (UK: /ˌɪdɛmˈpoʊtəns/,[1] US: /ˌaɪdəm-/)[2] is the property of certain operations in mathematics and computer science whereby they can be applied multiple times without changing the result beyond the initial application.

“多次运算而不改变最初的结果” ( 如’x=5’)

GET不过是请求信息的,给server的Parameters都在Query String里了。容易泄露。无论咋样,一样的Parameters,Server给的都是一样的。但POST是用于modify and update a resource。

插一嘴,没看过RFC,上来看Stackoverflow问题中贴的这段直接给我干懵了
The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line.
这啥啊!

第九章

是的,我又跳了

我看我记的时间上写的是5.6开始看的,现在5.19,看了接近一半。我也感觉得到我的英语阅读速度大幅提高。为什么跳到第九章来了呢?主要是我当时第三章也没看完,我就又跳了。跳哪呢,跳第四章”Mapping the Application”那儿去看去了。emmmmm,说是还行吧也还行,但是说实话动手的地方儿不是很多,兴致阑珊。我能受得了这个气?我刚学得擒拿术然后就来到了第九章。┑( ̄Д  ̄)┍

第九章讲SQLI(SQL Injection)的。他一开始说了个

Because of how interpreted languages are excuted,a family of vulnerabilities known as code injection arises.

我认为他这个 Code Injection 提的很有意思。这么一想那些payload不也是这种分类下吗?(虽然我没用过、甚至都没大看过payload)很妙很妙。

剩下的就比较零散了,他讲得尽力比较系统,也讲了蛮多 tricks 的。但是实验虽然有,有点不尽人意啊。他把实验改了,这也是我第一次上他网站。说啥啥啥时效性不行巴拉巴拉,第三版不出了,整了个Web Academic。是免费的,我很开心很感动。虽然不知道原来的Lab啥样,但现在的Lab就感觉跟填空题一样,后端不知道是不是真的数据库。当然我只做了一个Lab,再做做才能有发言权。这个Web Academic也没书本详细,再出第三版不挺好。(如果是因为我白嫖的原因,我致歉。诚恳地致歉。

当时觉得他实验不行的时候就去找环境了,才发现docker是真方便。pull一下run就完了。用docker搭了DVWA和OWASP JuiceShop 的环境。感慨真是美好。