Adding authentication in ZAP tool to attack a URL
Asked Answered
S

3

36

How to pass authentication details to the ZAP tool to scan the website. Please help me to solve the problem.

Septima answered 20/7, 2015 at 12:22 Comment(0)
S
45

Quite old question but here it goes.

The most simple way to do this is setting your browser to Proxy through ZAP. On Firefox you can go to:

Options -> Advanced -> Network -> Settings.

Select Manual Proxy Configuration and fill the HTTP Host with the address of the machine running ZAP (most probably localhost) and the configured ZAP port.

You can check and configure ZAP port opening ZAP and accessing:

Tools -> Options -> Local Proxy.

Then open your web browser and login to your application. Now go to ZAP, in the Sites tab (left side of ZAP), select your site, right click on it and select:

Include in Context -> Default Context

Now open the HTTP Sessions tab right click on the session and "Set as Active". (HTTP Sessions Tab: View -> Show Tab -> HTTP Sessions)

Now you can perform ZAP Spider, Active Scan and so with an logged in session. If this is not your scenario, please provide more info about which authentication method your application is using.

Hope it still helps you or someone searching for similar questions. Thanks,

Statistician answered 22/6, 2016 at 15:48 Comment(8)
I can't see HTTP Session tabMetage
View -> Show Tabs -> HTTP Sessions TabFalster
How to include Default Context in Context?Epiphysis
I don't see any entries in HTTP Sessions tab after including my site in Default Context. What might be the issue? I have cookie-based authentication in my website.Thence
@Thence Have you logged-in as proxying through ZAP?Statistician
@RiponAlWasim default context is the default context. I not sure if I understood the question.Statistician
@Fabio yes, after proxying through ZAP, i logged into my website in the browser. Could see the authenitcated pages in the left Sites paneThence
@Thence so probably your application is stateless. If that's the case this method is unfortunately not going to work. Take a look here: #44931065 to find some direction! Hope that helps! :)Statistician
P
18

Authentication through ZAP proxy

ZAP supports multiple types of authentication implemented by the websites/webapps. Authentication Methods within ZAP is implemented through Contexts which defines how authentication is handled. The authentication is used to create Sessions that correspond to authenticated webapp Users.

Some of the authentication methods implemented by OWASP ZAP are:

  • Manual Authentication: This method allows users to perform the authentication manually (e.g. authenticate in the browser while proxy-ing through ZAP).
  • HTTP/NTLM Authentication: This method is used for websites / webapps where authentication is enforced using the HTTP or NTLM Authentication mechanisms employing HTTP message headers. Three authentication schemes are supported: Basic, Digest and NTLM.
  • Form-Based Authentication: This method is used for websites / webapps where authentication is done by submitting a form or performing a GET request to a ‘login url’ using a ‘username/password’ pair of authentication credentials.
  • JSON-Based Authentication: This method is used for websites / webapps where authentication is done by submitting a JSON object to a ‘login url’ using a ‘username/password’ pair of authentication credentials.
  • Script-Based Authentication: This method is useful for websites / webapps where the authentication is a more complex one and some custom scripts that handle the authentication process are beneficial. To use this method, you must first define an Authentication script which sends messages or performs other actions as needed by your web-application. This script is then selected for use for a given Context and it is called whenever an authentication is performed.

Demonstration

As an example I will demonstrate the Basic Authentication test implemented by HTTP/1.1 as per the RFC 1945 using the url https://jigsaw.w3.org/HTTP/Basic/


Steps

Follow the steps below to implement Basic Authentication through ZAP:

  • Open ZAP and open a browser e.g. Firefox by clicking on the icon for opening the browser you have choosen in the Quick Start Tab pre-configured to proxy through ZAP.

ZAP_fav_browser

  • Click on Basic Authentication test (the third last link on the webpage) on which the Basic Authentication popup appears.
  • Provide the credentials to login:
    • User Name: guest
    • Password: guest
  • Now within the ZAP tool, History tab, locate the GET request to the URL https://jigsaw.w3.org/HTTP/Basic/ and observe the Response which confirms of Basic Authentication.
    • Snapshot of the Request:

ZAP_request_Authorization_Basic

  • Snapshot of the Response:

ZAP_response_Authorization_Basic

  • Now you need to create a Context to include it with in the Default Context. So right-click on the URL and select Include In Context from the Context Menu and select Default Context.

ZAP_include_in_context

  • Within the Session Management menu, select HTTP Authentication Session Management.

HTTP Authentication Session Management

  • Within the Authentication menu, select HTTP/NTLM Authentication and provide the Hostname & Port.

HTTP_NTLM Authentication

  • Within the User menu, add the credentials of the desired user.

User

  • Click on OK button to save the configuration.
  • Finally you need to configure ZAP to use the forced user mode by enabling it from the ZAP pane.

ForcedUserMode

  • Double Click on the Default Context, select Forced User and ensure that the desired user is set.

ForcedUser

  • Now, select the URL, right-click, select Open URL in Browser and select Firefox

Open_URL_in_browser

  • You will automatically authorized through the Basic Authentication through ZAP.

Your browser made it

Phaih answered 14/5, 2020 at 0:16 Comment(0)
B
4

Old question, old answer, but here is a good tutorial by one of the core developer of OWASP ZAP: https://www.youtube.com/watch?v=cR4gw-cPZOA

Quick answer: It depends on the method used for authentication. You can set the options in the Session Properties in the "Authentication" menu and you can also define different users in the "Users" menu.

Broadus answered 7/4, 2017 at 7:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.