简体   繁体   中英

OWASP ZAP python API error running script

i want to use python-owasp-zap api. I downloaded and installed all the repositories required for python-owasp-zap . when i run a sample code which was given in the web site https://github.com/zaproxy/zaproxy/wiki/ApiPython I am getting the below error, please help me .

Traceback (most recent call last):
  File "zap2.py", line 34, in <module>
    while (int(zap.spider.status()) < 100):
ValueError: invalid literal for int() with base 10: 'Does Not Exist'

Then, i tried removing paranthesis from status method:

while (int(zap.spider.status) < 100):
     print 'Spider progress %: ' + zap.spider.status
     time.sleep(2)

And i get the following error:

TypeError: Int argument must be an Int or string not an InstanceMethod

Help on rectifying the error is most appreciated.

You need to use:

while (int(zap.spider.status()) < 100):
    print 'Spider progress %: ' + zap.spider.status()
    time.sleep(5)

We have an example script here which we use for scanning wavsep: https://github.com/zapbot/zap-mgmt-scripts/blob/master/wavsep/wavsep-1.5-spider-scan.py

I'll update the ZAP wiki asap ;)

Simon (ZAP Project Lead)

Spider.status() takes a parameter, scanid. This is to keep track of different scans. You need to specify which scan this is and can be done as shown below.

target = 'some decimal base address'
scanid = zap.spider.scan(target)
while (int(zap.spider.status(scanid)) < 100):
    print 'Spider progress %: ' + zap.spider.status(scanid)
    time.sleep(5)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM