-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to Spider and Scan after Webpage Authentication #7
Comments
Hi. The current version of zap-cli doesn't support specifying a context when starting the spider or scan, but I definitely want to add support for that, hopefully I can get to trying to get that into the tool soon. :) |
Thank you Grunny, actually I'm also working on that with my team. Thank You anyway |
Cool, are you working on it in your own scripts or adding it to zap-cli? If it's for zap-cli, I'd be grateful for a PR. :) |
We are adding it to Zap-Cli only and of course I'll be giving a PR. One more thing, have u been able to enable a forced user mode using Zap-Cli ? Actually my team has found out that the ZAP API has some issues while spidering after authentication using context. Due to this also we are unable to spider from command line. But the GUI works well for everything. Any help will be great :) |
Any progress on this? It would be very helpful! |
Hi Grunny, do you plan to work on this issue on a near future ? We want to use zap in our devops pipelines, and we're currently stuck because we can't authenticate before we scan our app... |
@isaguimiot I have most of it done, but I'm not sure of the best way to allow actually setting up an auth method via commandline, so I'm still playing with that. What I could provide and release now is the ability to import a context that already has authentication set up and then use that to run scans as logged-in users. You could then open ZAP on your local machine, setup the authentication method and users for a context for the site you're running ZAP against, export the context to a file, and then import that file using a command like Would that work for your use case? I should be able to do that fairly quickly. :) |
@Grunny : yes, that's exactly what I was trying to do (the "zap-cli context import file"), I already have a context that was manually exported from Zap with authentication information. I just didn't find a way to specify it in the command line. If you can't fix it quickly, I'll be able to test it on my application, and I'll give you some feedback right after. Thanks ! |
@isaguimiot OK, I put together a quick implementation today, which you can find here: https://github.com/Grunny/zap-cli/compare/context-and-user-scans It was a quick PoC, so I want to clean it up, add some validation, add tests, etc. but did you want to give it a test and see if it meets your needs, and give any feedback on the parameters and so forth? :) You can install it in a virtualenv by cloning the repo, checking out the branch You can check out each of the
The ZAP API in general requires the context ID and user ID (both integers), but I figured using the plain text names was easier for users, so Let me know what you think. :) |
Oh that's perfect, I have some time this afternoon to test it, I come back to you when it's done :) |
Hi again @Grunny , I tried your new version, and I have an error when I launch the
There must be a way to set the |
The error you're getting is: Is ZAP definitely running on port 8090? You can change the port to use with I also noticed your API key is missing in the logs, which you may have just redacted when pasting. If it is missing, I'd make sure it's set in the Let me know if any of that helps. :) |
Hi @Grunny , thanks for your answer, the issue was the API key, I didn't know it was mandatory. Now I can launch everything without any error, but it seems that the scan still doesn't parse the pages that need authentication to be accessed... I'm sorry I'm not a ZAP expert, just discovering it, and I noticed that in the ZAP full app, I have to manually browse to the login page and effectively log into it with my credentials, if I want the whole website to be attacked by ZAP, even if I set up everything in the context, authentication thru a form, user, login URL with POST args, etc etc. Perhaps I have to do something before I run the zap-cli scan ? Perhaps the context file isn't enough ? I'm sorry for those dummy questions, and I hope you can help me... Thanks ! :) |
Does the form-based authentication you have configured work for your site? A simple way to test if it works is to:
If it's configured properly, then ZAP should log you in to the configured user credentials using the form-based authentication you set up. If it doesn't, something is wrong with the authentication setup. If it's not working, I'd suggest reading over https://github.com/zaproxy/zap-core-help/wiki/HelpStartConceptsAuthentication and also check if form-based authentication is sufficient for the site you're testing. For example, if the login form has CSRF protection it won't work, and you may need to write a script for script-based authentication. I hope that helps! |
Hi @Grunny , yes I confirm that everything is fine in ZAP, I tested it again this morning : start with a new session, load the context, force the user, and then browse to the page I want to test : I'm logged in ! Is there a way to enable the "forced user mode" in zap-cli ? is it supposed to be enabled by default ? Here is an extract of my context :
Any clue ? Thanks ! :) |
There isn't currently an option to enable forced user mode in zap-cli, but I can add one easily enough I think. But, if that works, then the user option should work if
Does that work? Or is that not logged in when it runs? It works for me locally at least, so I'd need to figure out what might be breaking when run with your config. |
Yes I ran the spider and scan commands with the context name and user name, and the verbose mode doesn't give a lot of details, but it runs much faster than thru the ZAP application, and when I generate the report, it's shorter and doesn't seem to refer any issue from any authenticated page, so I guess that that authentication doesn't work... If you could easily add the "force user mode", perhaps it would fix this issue ? Thanks for your quick responses :) |
It would be awesome to get this feature soon merged into main branch. I abandoned writing my own python wrapper for ZAP because zap-cli appeared to have everything I was interested in. Apart from this. |
I don't know if I bumped into what @isaguimiot mentioned, but I tried running the scan with imported context and compared to "active scan" run from the GUI using the same context it is indeed much faster. The reason is that it generates significantly smaller number of requests and doesn't detect as much problems. I have not yet figured out the reason for this. |
How foolish of me.. I copied the command from this discussion thread for active scan and it lacks the option -r and therefore does not do a recursive scan. Given that option it seems that everything works for me like this:
My test was based on a small target application so I might have missed something. |
@lokori you're probably right, I think I forgot the -r, because with the new version of zap-cli, I had more vulnerabilities than before, but not as many as thru owsap zap, this might be an explanation... I will test it again this week and I'll tell you if it works... :) |
Sorry for the slow response here! Ah, yeah, I really need to make recursive scanning the default and just use a flag to turn recursive scanning off. I can do that as part of releasing this change. @isaguimiot Let me know if that makes it work for you, and I'll release the changes. :) |
Hi @Grunny |
OK, I've released the changes for this in version 0.9.0 and it's available on PyPI now. I also added a brief explanation to the README. Let me know if there are any issues. :) |
I am trying to scan using zap-cli. I imported the context. The context clearly shows the URL pattern is included in the context : e.g.
However when I try to scan with the following command, it gives ERROR saying the URL is not in the context. zap-cli spider --context-name contextName --user-name user https://NNN.19.106:8080 [INFO] Running spider... |
I want to spider and scan the webpage after authentication (form-based). It's working on the ZAP GUI but not working with zap-cli in the command line. I was able to login and authenticate using context but that's it. As soon as I run the spider or active scan after authentication, it's not working. Kindly Help.
The text was updated successfully, but these errors were encountered: