golismero / openvas_lib

OpenVAS connector for versions 6, 7, 8 and 9
BSD 3-Clause "New" or "Revised" License
80 stars 97 forks source link

Example code broken #12

Closed DannyLee12 closed 7 years ago

DannyLee12 commented 7 years ago

When I try and run the example code I get this error:

Traceback (most recent call last):
  File "test.py", line 36, in <module>
    my_launch_scanner()
  File "test.py", line 26, in my_launch_scanner
    callback_progress=my_print_status)
  File "/usr/local/lib/python3.4/dist-packages/openvas_lib/__init__.py", line 613, in launch_scan
    "Unknown error while try to start the task '%s'. Error: %s" % (m_task_id, e.message))
openvas_lib.VulnscanScanError: Unknown error while try to start the task '13662e1a-ae21-409b-854a-361f571ddf8e'. Error: Can't receive info from the server: The read operation timed out

Im using python3 and

Package: openvas
Status: install ok installed
Priority: optional
Section: metapackages
Installed-Size: 26
Maintainer: Mohammad Razavi <mrazavi64@gmail.com>
Architecture: amd64
Source: openvas-manager
Version: 6.0.9-1

Here is my code:


# -*- coding: utf-8 -*-

from __future__ import print_function

from functools import partial
from threading import Semaphore

from openvas_lib import VulnscanManager, VulnscanException

def my_print_status(i):
    print(str(i))

def my_launch_scanner():
    sem = Semaphore(0)

    # Configure
    manager = VulnscanManager("localhost", "admin", "admin")

    # Launch
    manager.launch_scan("10.132.0.4",
                        profile="empty",
                        callback_end=partial(lambda x: x.release(), sem),
                        callback_progress=my_print_status)

    # Wait
    sem.acquire()

    # Finished scan
    print("finished")

if __name__ == '__main__':
    my_launch_scanner()

Any assistance will be appreciated.