IOError: [Errno socket error] [Errno 10060]

172 views
Skip to first unread message

skzaproxy

unread,
Mar 20, 2016, 11:12:58 AM3/20/16
to OWASP ZAP User Group
I am running Zap in daemon mode on windows.
Once I start my laptop, and run the code below, it works great and ends by shut down of zap. But command prompt remains open. that I close manually
Second time when I run the code.... I get error listed below. Everytime to run the code I need to restart my system.

Query:
1. How to resolve this IOError: [Errno socket error] [Errno 10060] error.
2. How to run zap in daemon on windows without APIkey.
3. Currently if I run without api key zap doesnot work.


Error:

Accessing target https://15.154.125.3
Traceback (most recent call last):
  File "zap7.py", line 55, in <module>
    zap.urlopen(target)
  File "C:\Python27\lib\site-packages\zapv2\__init__.py", line 120, in urlopen
    return urllib.urlopen(*args, **kwargs).read()
  File "C:\Python27\lib\urllib.py", line 87, in urlopen
    return opener.open(url)
  File "C:\Python27\lib\urllib.py", line 213, in open
    return getattr(self, name)(url)
  File "C:\Python27\lib\urllib.py", line 350, in open_http
    h.endheaders(data)
  File "C:\Python27\lib\httplib.py", line 1049, in endheaders
    self._send_output(message_body)
  File "C:\Python27\lib\httplib.py", line 893, in _send_output
    self.send(msg)
  File "C:\Python27\lib\httplib.py", line 855, in send
    self.connect()
  File "C:\Python27\lib\httplib.py", line 832, in connect
    self.timeout, self.source_address)
  File "C:\Python27\lib\socket.py", line 575, in create_connection
    raise err
IOError: [Errno socket error] [Errno 10060] A connection attempt failed because
the connected party did not properly respond after a period of time, or establis
hed connection failed because connected host has failed to respond




Code:


import time
import os, signal
import subprocess
from pprint import pprint
from zapv2 import ZAPv2
strSessionIDPath = 'somepath.........'
strZapDaemonLogPath = 'somepath.........'
pro = subprocess.Popen(['zap.bat','-daemon', '-port', '8090','-config', 'api.key=ssblmll55cevkoc22maq3kp6i9s', '-newsession', strSessionIDPath, '>>', strZapDaemonLogPath], cwd='C:\Program Files (x86)\OWASP\Zed Attack Proxy')
time.sleep(30)
zap = ZAPv2(proxies={'http': 'http://localhost:8090', 'https': 'http://localhost:8090'})
print("Accessing target " + target)
# Access the target
zap.urlopen(target)
# Give the sites tree a chance to get updated
time.sleep(2)
print('Spidering target %s' % target)
zap.spider.scan(target, apikey='ssblmll55cevkoc22maq3kp6i9s')
# Give the Spider a chance to start
time.sleep(5)
while (int(zap.spider.status()) < 100):
    print('Spider progress %: ' + zap.spider.status())
    time.sleep(2)
print('Spider completed')
# Give the passive scanner a chance to finish
time.sleep(5)
alerts = zap.core.alerts('ssblmll55cevkoc22maq3kp6i9s')
pprint(alerts)
# Shutdown ZAP
zap.core.shutdown('ssblmll55cevkoc22maq3kp6i9s')
Reply all
Reply to author
Forward
0 new messages