10717-2 Introduction
10717-2 Introduction
you will need before you begin your web application security
testing.
2.2 Encoding
2.4 Cookies
2.5 Session
HEADERS\r\n
\r\n \r (Carriage Return): moves the cursors to the
beginning of the line
\n (Line Feed): moves the cursor down to the next line
\r\n: is the same of hitting enter on your keyboard
MESSAGE BODY\r\n
google.com:80
GET / HTTP/1.1
Host: www.google.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64;
rv:36.0) Gecko/20100101 Firefox/36.0
Accept: text/html,application/xhtml+xml
Accept-Encoding: gzip, deflate
Connection: keep-alive
Web Application Penetration Testing 2.0 - eLearnSecurity © 2015
GET / HTTP/1.1
Host: www.google.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64;
rv:36.0) Gecko/20100101 Firefox/36.0
Accept: text/html,application/xhtml+xml
Accept-Encoding: gzip, deflate
Connection: keep-alive
With HTTP 1.1 you can keep your connection to the remote web
server open for an unspecified amount of time using the value
"keep-alive". This indicates that all requests to the web server
will continue to be sent through this connection without
initiating a new connection every time (as in HTTP 1.0).
Web Application Penetration Testing 2.0 - eLearnSecurity © 2015
Now that we know how the request is composed, let us inspect the
web server response.
In response to the HTTP Request, the web server will respond with
the requested resource, preceded by a bunch of new Headers.
These new headers from the server will be used by your web
browser to interpret the content contained in the Response
content.
Web Application Penetration Testing 2.0 - eLearnSecurity © 2015
HTTP/1.1 200 OK
Date: Fri, 13 Mar 2015 11:26:05 GMT
Cache-Control: private, max-age=0
Content-Type: text/html; charset=UTF-8
Content-Encoding: gzip
Server: gws
Content-Length: 258
<PAGE CONTENT>
<PAGE CONTENT>
<PAGE CONTENT>
<PAGE CONTENT>
• 403 Forbidden, the client does not have enough privileges and the server
refuses to fulfill the request.
• 404 Not Found, the server cannot find a resource matching the request.
• 500 Internal Server Error, the server does not support the functionality
required to fulfill the request.
Web Application Penetration Testing 2.0 - eLearnSecurity © 2015
DATE
HTTP/1.1 200 OK
Date: Fri, 13 Mar 2015 11:26:05 GMT
Cache-Control: private, max-age=0
Content-Type: text/html; charset=UTF-8
Content-Encoding: gzip
Server: gws
Content-Length: 258
<PAGE CONTENT>
Date represents the date and time at which the message was
originated.
<PAGE CONTENT>
The Cache headers allow the Browser and the Server to agree
about caching rules. Cached contents save bandwidth because,
in short, they prevent your browser from re-requesting contents
that have not changed when the same resource is to be used.
Web Application Penetration Testing 2.0 - eLearnSecurity © 2015
CONTENT TYPE
HTTP/1.1 200 OK
Date: Fri, 13 Mar 2015 11:26:05 GMT
Cache-Control: private, max-age=0
Content-Type: text/html; charset=UTF-8
Content-Encoding: gzip
Server: gws
Content-Length: 258
<PAGE CONTENT>
Content-Type lets the client know how to interpret the body of the
message.
<PAGE CONTENT>
<PAGE CONTENT>
The Server header displays the Web Server banner. Apache and IIS
are common web servers. Google uses a custom webserver
banner: gws (that stands for Google Web Server).
<PAGE CONTENT>
<PAGE CONTENT>
???
GET / SSL/TLS
HTTP/1.1 HTTP
HTML5
<meta charset="UTF-8">
http://www.elswapt.site
http://www.elswapt.site
http://www.elswapt.site:80
Example 1 Example 2
a.elswapt.site b.elswapt.site
index.html home.html
window.location document.domain
Read
Write
<html>
…
<body>
<iframe src="http//www.elearnsecurity.com/index.html">
</iframe>
</body>
</html>
window.frames[0].location=http://www.google.com;
Origin A Origin B
a.elswapt.site b.elswapt.site
<script> <script>
document.domanin="elswapt.site" document.domanin="elswapt.site"
</script> </script>
index.html home.html
Web Application Penetration Testing 2.0 - eLearnSecurity © 2015
The new HTML5 feature known as Cross Window Messaging
permits different documents (iframes, popups, current
window) to communicate with each other regardless of the
same origin policy by using a simple synchronous mechanism.
Do not worry; this mechanism will be dealt with in-depth in
the HTML5 module.
Unspecified cookie
Specified cookie domain
domain
Internet Explorer
exception
POST /login.php
Host: www.google.com
usr=John&Pass=mypass
GET /mail.php
Host: www.google.com
Cookie=authenticated="1";
POST (http://a.elswapt.site/login.php)
The cookie is
accepted and will HTTP RESPONSE HEADER:
be available only …
Set-Cookie: SESSID=d8a4z21
to the target Path =/
domain
a.elswapt.site,
since the domain GET (http://a.elswapt.site/logout.php)
value was not HTTP Request Header:
specified. …
Cookie SESSID:=d8a4z21
• http://elswapt.site/* • http://*.elswapt.site/*
• https://elswapt.site/* • https://*.elswapt.site/*
Web Application Penetration Testing 2.0 - eLearnSecurity © 2015
This is what will happen. The cookie previously set is sent to
both a and b subdomains. a.elswapt.site
GET (http://a.elswapt.site/page1.php)
Web Browser HTTP Request Header:
…
Cookie SESSID:=d8a4z21
b.elswapt.site
GET (http://b.elswapt.site/index.php)
HTTP Request Header:
…
Cookie SESSID:=d8a4z21
learning/lab.php
GET (http://a.elswapt.site/learning/lab.php)
HTTP Request Header:
…
Cookie SESSID:=d8a4z21
elswapt.site
GET (http://elswapt.site/lab.php)
HTTP Request Header: lab.php
…
Cookie SESSID:=B
POST (http://a.elswapt.site/login.php)
The cookie is not
HTTP RESPONSE HEADER:
accepted
…
because the Set-Cookie: SESSID=d8a4z21;
domain domain:= b.elswapt.test ;
b.elswapt.test is Path =/
not a suffix of
the domain GET (http://a.elswapt.site/logout.php)
a.elswapt.site HTTP Request Header:
that sent the …
cookie. < No Cookie >
POST (http://a.elswapt.site/login.php)
The cookie is not
HTTP RESPONSE HEADER:
accepted because
…
the cookie Set-Cookie: SESSID=d8a4z21;
domain value domain:= a.elswapt.test ;
b.elswapt.site is Path =/
not a suffix of the
domain GET (http://a.elswapt.site/page1.php)
a.elswapt.site HTTP Request Header:
emitting it. …
< No Cookies>
Var1=abc
Var2=123
SessionID=02ab12
• SESSION=0wvCtOBWDH8w
• PHPSESSID=l3Kn5Z6Uo4pH
• JSESSIONID=W7DPUBgh7kTM
http://example.site/resource.php?sessid=k27rds7h8w
ZAP