Skip to content

Instantly share code, notes, and snippets.

@anshumanbh
Created August 25, 2015 00:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anshumanbh/9623e39493745053310f to your computer and use it in GitHub Desktop.
Save anshumanbh/9623e39493745053310f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import os
import subprocess
import time
import urllib
from pprint import pprint
from zapv2 import ZAPv2
import sys
target = sys.argv[1]
print 'Target = %s' % target
print '\n '
zap = ZAPv2(proxies={'http': 'http://localhost:8090', 'https': 'http://localhost:8090'})
print 'Accessing target %s' % target
print '\n '
zap.urlopen(target)
time.sleep(2)
print 'Spidering target %s' % target
print '\n '
zap.spider.scan(target)
time.sleep(10)
while (int(zap.spider.status()) < 100):
print 'Spider progress %: ' + zap.spider.status()
time.sleep(2)
print 'Spider completed'
print '\n '
time.sleep(5)
print 'Scanning target %s' % target
zap.ascan.scan(target)
while (int(zap.ascan.status()) < 100):
print 'Scan progress %: ' + zap.ascan.status()
time.sleep(60)
print '\n '
print 'Scan completed'
print 'Reports saved'
print '\n '
urllib.urlretrieve ("http://localhost:8090/OTHER/core/other/xmlreport", "report_%s.xml" % (time.strftime("%m-%d-%Y-%H%M", time.localtime())))
urllib.urlretrieve ("http://localhost:8090/OTHER/core/other/htmlreport", "report_%s.html" % (time.strftime("%m-%d-%Y-%H%M", time.localtime())))
print 'Shutting down ZAP'
print '\n '
zap.core.shutdown()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment