Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: Suport for Python 3. The patches are currently unstable. They need more tests.
- Loading branch information
Showing
12 changed files
with
1,856 additions
and
1,763 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
Oops, something went wrong.