Skip to content

Commit

Permalink
Merge pull request golismero#20 from blackat87/ompv7
Browse files Browse the repository at this point in the history
Ompv7
  • Loading branch information
MarioVilas authored Jan 26, 2018
2 parents 5e72780 + d975706 commit ee38109
Show file tree
Hide file tree
Showing 4 changed files with 1,293 additions and 212 deletions.
63 changes: 43 additions & 20 deletions example_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,49 @@
from functools import partial
from xml.etree import ElementTree
import base64
import datetime
import os
import sys, re
import subprocess
import time
import random

import os,sys
import argparse

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"
if not os.path.exists(result_dir):
os.makedirs(result_dir)

try:
report = manager.get_report_html(report_id)
report = manager.get_report_xml(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_path = result_dir + "/xml/"
if not os.path.exists(fout_path):
os.makedirs(fout_path)

fout = open(fout_path + ip + ".xml", "wb")
fout.write(ElementTree.tostring(report, encoding='utf-8', method='xml'))
fout.close()

try:
report = manager.get_report_xml(report_id)
report = manager.get_report_html(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()
fout_path = result_dir + "/html/"
if not os.path.exists(fout_path):
os.makedirs(fout_path)

html_text = report.find("report").text
if not html_text:
html_text = report.find("report").find("report_format").tail

fout = open(fout_path + ip + ".html", "wb")
fout.write(base64.b64decode(html_text))
fout.close()

def run(manager, ip):
Sem = Semaphore(0)
Expand All @@ -52,17 +61,31 @@ def run(manager, ip):
)
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__':

parser = argparse.ArgumentParser(description='Features Selection')
parser.add_argument('-u', '--user', required=True, help='OpenVas user')
parser.add_argument('-p', '--password', required=True, help='OpenVas password')
parser.add_argument('-i', '--ip', required=True, help='OpenVas ip host')
parser.add_argument('-t', '--target', required=True, help='Host target')

args = parser.parse_args()

if args.user:
admin_name = args.user
if args.user:
admin_password = args.password
if args.ip:
openvas_ip = args.ip
if args.target:
ip = args.target

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:
Expand Down
Loading

0 comments on commit ee38109

Please sign in to comment.