Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from zapv2 import ZAPv2
- context = 'new_attack'
- authmethodname = 'formBasedAuthentication'
- authmethodconfigparams = "".join('loginUrl=https://192.168.0.1/dologin.html' '&loginRequestData=username%3D%7B%25username%25%7D%26' 'password%3D%7B%25password%25%7D')
- target = 'https://192.168.0.1'
- apikey = 'password'
- zap = ZAPv2(proxies={'http': 'http://127.0.0.1:8119', 'https': 'http://127.0.0.1:8119'}, apikey=apikey)
- contextid = zap.context.new_context(context)
- print contextid
- print zap.context.include_in_context(context, 'https://192.168.0.1.*')
- print zap.context.context(context)
- print zap.authentication.set_authentication_method(contextid, authmethodname, authmethodconfigparams)
- # The indicators should be set after setting the authentication method.
- print zap.authentication.set_logged_in_indicator(contextid, loggedinindicatorregex='Logged in')
- print zap.authentication.set_logged_out_indicator(contextid, 'Sorry, the username or password you entered is incorrect')
- userid = zap.users.new_user(contextid, 'User 1')
- print userid
- print zap.users.set_authentication_credentials(contextid, userid, 'username=MyUserName&password=MySecretPassword')
- print zap.users.set_user_enabled(contextid, userid, True)
- print zap.spider.scan_as_user(contextid, userid, target)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement