Testing for session hijacking
In this recipe, we will be walking through how to hijack a session by exploiting a web session’s control mechanism, known as the session token, and using this token, aka cookie, to take over an unsuspecting user’s session. Common compromises are due to tokens being predictable through session sniffing, malicious JavaScript code (i.e., XSS, CSRF), or machine-in-the-middle (MiTM) attacks.
We will use MiTM attacks to steal a session token via a cross-site scripting attack and replay the stolen token on another user that will compromise their session, logging into that user’s authenticated Juice Shop account.
Getting ready
To prepare for this recipe, please start ZAP and OWASP Juice Shop. Make sure that ZAP intercepts traffic at the OWASP Juice Shop application home page, and register/create two different users.
How to do it...
We’ll lead you through steps on how to conduct session hijacking by utilizing two users...