Mh07
Mh07

Reputation: 33

Form Based Authentication OWASP ZAP for HTTPS application

I'm trying to use Form-Based Authentication feature of OWASP ZAP using ZAP's python API.

I noticed that while using a HTTP application (for example - http://demo.testfire.net/) it is able to spider and give additional URLs once logged in. However, when I try the same for HTTPS application it isn't fetching additional URLs once logged in.

My question here is - Does ZAP support Form-Based authentication for HTTP related web application only?

Upvotes: 2

Views: 6562

Answers (1)

Simon Bennetts
Simon Bennetts

Reputation: 6186

Yes, and we have a FAQ for it: https://github.com/zaproxy/zaproxy/wiki/FAQformauth

Its difficult to debug issues when just using the API, so I recommend using the UI first and once you've got that working then converting what you've done to the API.

Via the UI:

  1. List item
  2. Explore your app while proxying through ZAP
  3. Login using a valid username and password
  4. Define a Context, eg by right clicking the top node of your app in the Sites tab and selecting "Include in Context"
  5. Find the 'Login request' in the Sites or History tab
  6. Right click it and select "Flag as Context" / " Form-based Auth Login request"
  7. Check that the Username and Password parameters are set correctly - they almost certainly wont be!
  8. Find a string in a response which can be used to determine if the user is logged in or not
  9. Highlight this string, right click and select "Flag as Context" / " Logged in/out Indicator" as relevant - you only need to set one of these, not both
  10. Double click on the relevant Context node and navigate to the "Users" page - check the user details are correct, add any other users you want to use and enable them all
  11. Navigate to the Context "Forced User" page and make sure the user you want to test is selected
  12. The "Forced User Mode disabled - click to enable" button should now be enabled
  13. Pressing this button in will cause ZAP to resend the authentication request whenever it detects that the user is no longer logged in, ie by using the 'logged in' or 'logged out' indicator.

Via the API the process is the same but using the API calls:

context/includeInContext
authentication/setAuthenticationMethod

authMethodName : formBasedAuthentication
authMethodConfigParams : loginUrl=http://example.com/login.html&loginRequestData=username%3D%7B%25username%25%7D%26password%3D%7B%25password%25%7D
    authentication/setLoginIndicator or setLogoutIndicator
    forcedUser/setForcedUserModeEnabled

The values for authMethodConfigParams parameters must be URL encoded, in this case loginRequestData is username={%username%}&password={%password%}

Upvotes: 4

Related Questions