Advertisement
Guest User

Untitled

a guest
Apr 9th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. from zapv2 import ZAPv2
  2. context = 'new_attack'
  3. authmethodname = 'formBasedAuthentication'
  4. authmethodconfigparams = "".join('loginUrl=https://192.168.0.1/dologin.html' '&loginRequestData=username%3D%7B%25username%25%7D%26' 'password%3D%7B%25password%25%7D')
  5. target = 'https://192.168.0.1'
  6. apikey = 'password'
  7. zap = ZAPv2(proxies={'http': 'http://127.0.0.1:8119', 'https': 'http://127.0.0.1:8119'}, apikey=apikey)
  8.  
  9. contextid = zap.context.new_context(context)
  10. print contextid
  11. print zap.context.include_in_context(context, 'https://192.168.0.1.*')
  12.  
  13. print zap.context.context(context)
  14.  
  15. print zap.authentication.set_authentication_method(contextid, authmethodname, authmethodconfigparams)
  16. # The indicators should be set after setting the authentication method.
  17. print zap.authentication.set_logged_in_indicator(contextid, loggedinindicatorregex='Logged in')
  18. print zap.authentication.set_logged_out_indicator(contextid, 'Sorry, the username or password you entered is incorrect')
  19.  
  20. userid = zap.users.new_user(contextid, 'User 1')
  21. print userid
  22. print zap.users.set_authentication_credentials(contextid, userid, 'username=MyUserName&password=MySecretPassword')
  23. print zap.users.set_user_enabled(contextid, userid, True)
  24.  
  25. print zap.spider.scan_as_user(contextid, userid, target)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement