Skip to content

Commit

Permalink
Add: Support for OpenVAS 7 and 8!
Browse files Browse the repository at this point in the history
Add: Suport for Python 3.

The patches are currently unstable. They need more tests.
  • Loading branch information
cr0hn committed Jul 4, 2016
1 parent 12cfafb commit 1621cc3
Show file tree
Hide file tree
Showing 12 changed files with 1,856 additions and 1,763 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
@@ -1,3 +1,9 @@
Version 0.1.1
=============

- Added support for OpenVAS 7 and 8! (currently in beta mode).
- Support for Python 3 (in testing also)

Version 0.1.0
=============

Expand Down
24 changes: 14 additions & 10 deletions README.rst
Expand Up @@ -69,9 +69,9 @@ _____________________
try:
scanner = VulnscanManager(HOST, USER, PASSWORD, PORT, TIMEOUT)
except VulnscanException, e:
print "Error:"
print e
except VulnscanException as e:
print("Error:")
print(e)
Launch a simple scan
____________________
Expand All @@ -97,14 +97,14 @@ The library supports callbacks. They will be run every 10 seconds and report the
from openvas_lib import VulnscanManager, VulnscanException
def my_print_status(i):
print str(i)
print(str(i))
def my_launch_scanner():
Sem = Semaphore(0)
sem = Semaphore(0)
# Configure
manager = VulnscanManager("localhost", "admin", "admin)
manager = VulnscanManager("localhost", "admin", "admin")
# Launch
manager.launch_scan(target,
Expand All @@ -116,11 +116,11 @@ The library supports callbacks. They will be run every 10 seconds and report the
Sem.acquire()
# Finished scan
print "finished"
print("finished")
Running it:

.. code-block:: pycon
.. code-block:: python
>>> my_launch_scanner() # It can take some time
0
Expand All @@ -135,6 +135,7 @@ ___________________

.. code-block:: python
from __future__ import print_function
from openvas_lib import VulnscanManager, VulnscanException
scanner = VulnscanManager(HOST, USER, PASSWORD, PORT, TIMEOUT)
Expand All @@ -145,6 +146,7 @@ ___________

.. code-block:: python
from __future__ import print_function
from openvas_lib import VulnscanManager, VulnscanException
scanner = VulnscanManager(HOST, USER, PASSWORD, PORT, TIMEOUT)
Expand All @@ -155,6 +157,7 @@ _____________

.. code-block:: python
from __future__ import print_function
from openvas_lib import VulnscanManager, VulnscanException
scanner = VulnscanManager(HOST, USER, PASSWORD, PORT, TIMEOUT)
Expand All @@ -169,9 +172,10 @@ Linux distribution.

.. code-block:: pycon
>>> from __future__ import print_function
>>> from openvas_lib import report_parser
>>> results = report_parser("tests/metasploitable_all.xml")
>>> print results
>>> print(results)
[<openvas_lib.data.OpenVASResult object at 0x108f2d250>, <openvas_lib.data.OpenVASResult object at 0x108f2d290>, <openvas_lib.data.OpenVASResult object at 0x108e7fcd0>, <openvas_lib.data.OpenVASResult object at 0x108e88e90>, <openvas_lib.data.OpenVASResult object at 0x108e88050>, <openvas_lib.data.OpenVASResult object at 0x108e88410>, <openvas_lib.data.OpenVASResult object at 0x108e88550>, <openvas_lib.data.OpenVASResult object at 0x108f2d650>, <openvas_lib.data.OpenVASResult object at 0x108f2d750>, <openvas_lib.data.OpenVASResult object at 0x108f2d850>, <openvas_lib.data.OpenVASResult object at 0x108f2d950>, <openvas_lib.data.OpenVASResult object at 0x108f2da50>, <openvas_lib.data.OpenVASResult object at 0x108f2db50>, <openvas_lib.data.OpenVASResult object at 0x108f2dc50>, <openvas_lib.data.OpenVASResult object at 0x108eb56d0>, <openvas_lib.data.OpenVASResult object at 0x108eb5750>, <openvas_lib.data.OpenVASResult object at 0x108f2ded0>, <openvas_lib.data.OpenVASResult object at 0x108f2dfd0>, <openvas_lib.data.OpenVASResult object at 0x108f35110>, <openvas_lib.data.OpenVASResult object at 0x108eb5950>, <openvas_lib.data.OpenVASResult object at 0x108f35210>, <openvas_lib.data.OpenVASResult object at 0x108eb5a90>, <openvas_lib.data.OpenVASResult object at 0x108eb5ad0>, <openvas_lib.data.OpenVASResult object at 0x108f355d0>, <openvas_lib.data.OpenVASResult object at 0x108f356d0>, <openvas_lib.data.OpenVASResult object at 0x108eb5dd0>, <openvas_lib.data.OpenVASResult object at 0x108f357d0>, <openvas_lib.data.OpenVASResult object at 0x108eb5f90>, <openvas_lib.data.OpenVASResult object at 0x108e101d0>, <openvas_lib.data.OpenVASResult object at 0x108e10390>, <openvas_lib.data.OpenVASResult object at 0x108eb5d90>, <openvas_lib.data.OpenVASResult object at 0x108f35910>, <openvas_lib.data.OpenVASResult object at 0x108f35a10>, <openvas_lib.data.OpenVASResult object at 0x108f35b10>, <openvas_lib.data.OpenVASResult object at 0x108f35c10>, <openvas_lib.data.OpenVASResult object at 0x108f35d10>, <openvas_lib.data.OpenVASResult object at 0x108f35e10>, <openvas_lib.data.OpenVASResult object at 0x108f35f10>, <openvas_lib.data.OpenVASResult object at 0x108f3a050>, <openvas_lib.data.OpenVASResult object at 0x108e102d0>, <openvas_lib.data.OpenVASResult object at 0x108e10910>, <openvas_lib.data.OpenVASResult object at 0x108e10ad0>, <openvas_lib.data.OpenVASResult object at 0x108e10c10>, <openvas_lib.data.OpenVASResult object at 0x108f3a150>, <openvas_lib.data.OpenVASResult object at 0x108f3a250>, <openvas_lib.data.OpenVASResult object at 0x108f3a350>, <openvas_lib.data.OpenVASResult object at 0x108f3a450>, <openvas_lib.data.OpenVASResult object at 0x108f3a550>, <openvas_lib.data.OpenVASResult object at 0x108e10e50>, <openvas_lib.data.OpenVASResult object at 0x108e10e90>, <openvas_lib.data.OpenVASResult object at 0x108e28090>, <openvas_lib.data.OpenVASResult object at 0x108f3a750>, <openvas_lib.data.OpenVASResult object at 0x108f3a910>, <openvas_lib.data.OpenVASResult object at 0x108f3aa10>, <openvas_lib.data.OpenVASResult object at 0x108e28250>, <openvas_lib.data.OpenVASResult object at 0x108e28210>, <openvas_lib.data.OpenVASResult object at 0x108e28350>, <openvas_lib.data.OpenVASResult object at 0x108e28450>, <openvas_lib.data.OpenVASResult object at 0x108f3ad10>, <openvas_lib.data.OpenVASResult object at 0x108f3ae10>, <openvas_lib.data.OpenVASResult object at 0x108f3ac10>, <openvas_lib.data.OpenVASResult object at 0x108e287d0>, <openvas_lib.data.OpenVASResult object at 0x108e28890>, <openvas_lib.data.OpenVASResult object at 0x108e289d0>, <openvas_lib.data.OpenVASResult object at 0x108e28ad0>, <openvas_lib.data.OpenVASResult object at 0x108e28c10>, <openvas_lib.data.OpenVASResult object at 0x108f3e210>, <openvas_lib.data.OpenVASResult object at 0x108e28710>, <openvas_lib.data.OpenVASResult object at 0x108e28d90>, <openvas_lib.data.OpenVASResult object at 0x108e28ed0>, <openvas_lib.data.OpenVASResult object at 0x108e28f10>, <openvas_lib.data.OpenVASResult object at 0x108e28f90>, <openvas_lib.data.OpenVASResult object at 0x108f3e510>, <openvas_lib.data.OpenVASResult object at 0x108f3e610>, <openvas_lib.data.OpenVASResult object at 0x108f3e710>, <openvas_lib.data.OpenVASResult object at 0x108f3e810>, <openvas_lib.data.OpenVASResult object at 0x108f3e910>, <openvas_lib.data.OpenVASResult object at 0x108f3ea10>, <openvas_lib.data.OpenVASResult object at 0x108f3eb10>]
# get properties from a vuln with more info
>>> r = None
Expand All @@ -184,7 +188,7 @@ Linux distribution.
'10.211.55.35'
>>> r.raw_description
"\n Summary:\n The host is running MySQL and is prone to Denial Of Service\n vulnerability.\n\n Vulnerability Insight:\n The flaw is due to an error when processing the 'ALTER DATABASE' statement and\n can be exploited to corrupt the MySQL data directory using the '#mysql50#'\n prefix followed by a '.' or '..'.\n\n NOTE: Successful exploitation requires 'ALTER' privileges on a database.\n Impact:\n Successful exploitation could allow an attacker to cause a Denial of Service.\n Impact Level: Application\n\n Affected Software/OS:\n MySQL version priot to 5.1.48 on all running platform.\n\n Solution:\n Upgrade to MySQL version 5.1.48\n For updates refer to http://dev.mysql.com/downloads\n"
>>> print r.raw_description
>>> print(r.raw_description)
Summary:
The host is running MySQL and is prone to Denial Of Service
vulnerability.
Expand Down
59 changes: 0 additions & 59 deletions example.py

This file was deleted.

36 changes: 36 additions & 0 deletions example_check_connection.py
@@ -0,0 +1,36 @@
# -*- 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", "openvas")

# Launch
manager.launch_scan("127.0.0.1",
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()

69 changes: 69 additions & 0 deletions example_legacy.py
@@ -0,0 +1,69 @@
#!/usr/bin/env python

from __future__ import print_function

from openvas_lib import VulnscanManager, VulnscanException
from threading import Semaphore
from functools import partial
from xml.etree import ElementTree
import base64
import datetime
import os
import sys, re
import subprocess
import time
import random


def my_print_status(i):
print(str(i)),
sys.stdout.flush()


def write_report(manager, report_id, ip):
result_dir = os.path.dirname(os.path.abspath(__file__)) + "/results"
try:
report = manager.get_report_html(report_id)
except Exception as e:
print(e)
return
else:
fout = open(result_dir + "/html/" + ip + ".html", "wb")
fout.write(base64.b64decode(report.find("report").text))
fout.close()
try:
report = manager.get_report_xml(report_id)
except Exception as e:
print(e)
return
else:
fout = open(result_dir + "/xml/" + ip + ".xml", "wb")
fout.write(ElementTree.tostring(report, encoding='utf-8', method='xml'))
fout.close()


def run(manager, ip):
Sem = Semaphore(0)
scan_id, target_id = manager.launch_scan(
target=ip,
profile="Full and fast",
callback_end=partial(lambda x: x.release(), Sem),
callback_progress=my_print_status
)
Sem.acquire()
report_id = manager.get_report_id(scan_id)
write_report(manager, report_id, ip)
manager.delete_scan(scan_id)
manager.delete_target(target_id)


if __name__ == '__main__':
try:
openvas_ip = sys.argv[1]
admin_name = sys.argv[2]
admin_password = sys.argv[3]
ip = sys.argv[4]
manager = VulnscanManager(openvas_ip, admin_name, admin_password)
run(manager, ip)
except Exception as e:
print(e)

0 comments on commit 1621cc3

Please sign in to comment.