Hi.
Sorry for taking so long to answer.
The option "Enable session tracking" manages (store/send) the cookies but is (a little) buggy [1] so it's better to avoid its use whenever possible (also note that the cookies should be disabled in the browser when using the option or else the cookies will be sent twice, added once by the browser and another by ZAP).
Using:
ZAP 2.1.0;
WordPress 3.5.1 under "
http://localhost/";
A browser proxying through ZAP.
Steps to spider the admin section of WP using GUI:
1. Run ZAP;
2. (browser) Access the admin page ("
http://localhost/wp-admin/") and login;
3. (ZAP) Select the "Params" tab and flag the cookies "wordpress_XYZ" and "wordpress_logged_in_XYZ" as session tokens (where XYZ is the MD5 hash of the WP option "siteurl");
4. (browser) Access another admin page (example: "
http://localhost/wp-admin/edit.php") (this step is to ensure that the ZAP session will have the cookies previously flagged as session tokens);
5. (ZAP) Select the "Http Sessions" tab and check that there's a session with the two cookies previously flagged, set it as active;
6. (browser) Disable (and remove) the cookies and access (again) an admin page (example: "
http://localhost/wp-admin/edit.php") it should access without requiring authentication (this step is to ensure that ZAP's active session has access to admin pages);
7. (ZAP) Exclude from spider the login page ("\Qhttp://localhost/wp-login.php\E.*") and profile ("\Qhttp://localhost/wp-admin/profile.php\E.*") pages (this is to ensure that the spider doesn't login/logout or change the password);
8. Start the spider;
9. Wait to finish and check the results.
Let me know if you've any question regarding the steps.
Using:
ZAP 2.1.0 (listening on port 8080);
WordPress 3.5.1 under "
http://localhost/";
python-owasp-zap-v2-0.0.6.
Example Python script to spider the admin section of WP:
#!/usr/bin/env python
import time
import os
import subprocess
import hashlib
import urllib
from pprint import pprint
from zapv2 import ZAPv2
print 'Starting ZAP.'
subprocess.Popen(['/path/to/zap.sh', '-daemon'], stdout=open(os.devnull, 'w'))
print 'Waiting for ZAP...'
time.sleep(20)
zap = ZAPv2()
target = 'http://localhost/'
zap.urlopen(target)
cookie_hash = hashlib.md5('http://localhost').hexdigest()
zap.httpsessions.add_session_token('localhost:80', 'wordpress_' + cookie_hash)
zap.httpsessions.add_session_token('localhost:80', 'wordpress_logged_in_' + cookie_hash)
zap.httpsessions.create_empty_session('localhost:80')
zap.httpsessions.rename_session('localhost:80', 'Session 0', 'WP Admin')
zap.httpsessions.set_active_session('localhost:80', 'WP Admin')
login_data = {'log': 'admin', 'pwd': 'ZAP'}
zap.urlopen(target + 'wp-login.php', urllib.urlencode(login_data))
zap.spider.exclude_from_scan('\Q' + target + 'wp-login.php\E.*')
zap.spider.exclude_from_scan('\Q' + target + 'wp-admin/profile.php\E.*')
print 'Spidering target %s' % target
zap.spider.scan(target)
# Give the Spider a chance to start
time.sleep(2)
print 'Status %s' % zap.spider.status
while (int(zap.spider.status) < 100):
print 'Spider progress %: ' + zap.spider.status
time.sleep(5)
print 'Spider completed'
print 'Results: '
pprint(zap.spider.results)
print 'Shutdown ZAP'
zap.core.shutdown
Regarding the "httpSessions" API it wasn't available in the Python client API but there's a new version (0.0.6) which already have it.
Let us know how it went.
[1]
https://code.google.com/p/zaproxy/issues/detail?id=15Best regards.