简体   繁体   中英

How do you get the task_id in openvas_lib for python?

I get connected to openvas, and successfully run the scan. However, I can't get the results to show without the task_id. How do I find the task_id?

from threading import Semaphore
from functools import partial

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(target,
                    profile = "empty",
                    callback_end = partial(lambda x: x.release(), sem),
                    callback_progress = my_print_status)

# Wait
Sem.acquire()

# Finished scan
print "finished"

Code is from: https://pypi.python.org/pypi/openvas_lib/1.0 . The website suggests the following code; however, it says task not found when I use it. I believe it is supposed to use the task_id not scan_id. So how do I find the task_id?

from openvas_lib import VulnscanManager, VulnscanException  
scanner = VulnscanManager(HOST, USER, PASSWORD, PORT, TIMEOUT)
openvas_results = scanner.get_results(SCAN_ID)

Picture of error

There is another example, a bit earlier at the same page:

https://github.com/golismero/openvas_lib#launch-a-simple-scan

Basically, launch_scan method returns both scan id and task id, as a tuple.

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