Exemple #1
0
def openvas_scanner(scan_ip, project_id, sel_profile, user):
    """
    The function is launch the OpenVAS scans.
    :param scan_ip:
    :param project_id:
    :param sel_profile:
    :return:
    """
    openvas = OpenVAS_Plugin(scan_ip, project_id, sel_profile)
    try:
        scanner = openvas.connect()
    except Exception as e:

        notify.send(user, recipient=user, verb='OpenVAS Setting not configured')
        subject = 'Archery Tool Notification'
        message = 'OpenVAS Scanner failed due to setting not found '

        email_notify(user=user, subject=subject, message=message)
        return

    notify.send(user, recipient=user, verb='OpenVAS Scan Started')
    subject = 'Archery Tool Notification'
    message = 'OpenVAS Scan Started'

    email_notify(user=user, subject=subject, message=message)
    scan_id, target_id = openvas.scan_launch(scanner)
    date_time = datetime.now()
    save_all = scan_save_db(scan_id=str(scan_id),
                            project_id=str(project_id),
                            scan_ip=scan_ip,
                            target_id=str(target_id),
                            date_time=date_time,
                            scan_status=0.0)
    save_all.save()
    openvas.scan_status(scanner=scanner, scan_id=scan_id)
    time.sleep(5)
    vuln_an_id(scan_id=scan_id, project_id=project_id)

    notify.send(user, recipient=user, verb='OpenVAS Scan Completed')

    all_openvas = scan_save_db.objects.all()
    all_vuln = ''
    total_high = ''
    total_medium = ''
    total_low = ''
    for openvas in all_openvas:
        all_vuln = openvas.total_vul
        total_high = openvas.high_total
        total_medium = openvas.medium_total
        total_low = openvas.low_total

    subject = 'Archery Tool Notification'
    message = 'OpenVAS Scan Completed  <br>' \
              'Total: %s  <br>Total High: %s <br>' \
              'Total Medium: %s  <br>Total Low %s' % (all_vuln, total_high, total_medium, total_low)

    email_notify(user=user, subject=subject, message=message)

    return HttpResponse(status=201)
Exemple #2
0
def openvas_scanner(scan_ip, project_id, sel_profile):
    """
    The function is launch the OpenVAS scans.
    :param scan_ip:
    :param project_id:
    :param sel_profile:
    :return:
    """
    openvas = OpenVAS_Plugin(scan_ip, project_id, sel_profile)
    scanner = openvas.connect()
    scan_id, target_id = openvas.scan_launch(scanner)
    date_time = datetime.now()
    save_all = scan_save_db(scan_id=str(scan_id),
                            project_id=str(project_id),
                            scan_ip=scan_ip,
                            target_id=str(target_id),
                            date_time=date_time)
    save_all.save()
    openvas.scan_status(scanner=scanner, scan_id=scan_id)
    time.sleep(5)
    vuln_an_id(scan_id=scan_id)

    return HttpResponse(status=201)
Exemple #3
0
def openvas_scanner(scan_ip, project_id, sel_profile):
    """
    The function is launch the OpenVAS scans.
    :param scan_ip:
    :param project_id:
    :param sel_profile:
    :return:
    """
    openvas = OpenVAS_Plugin(scan_ip, project_id, sel_profile)
    scanner = openvas.connect()
    scan_id, target_id = openvas.scan_launch(scanner)
    date_time = datetime.now()
    save_all = scan_save_db(scan_id=str(scan_id),
                            project_id=str(project_id),
                            scan_ip=scan_ip,
                            target_id=str(target_id),
                            date_time=date_time)
    save_all.save()
    openvas.scan_status(scanner=scanner, scan_id=scan_id)
    time.sleep(5)
    vuln_an_id(scan_id=scan_id)

    return HttpResponse(status=201)
Exemple #4
0
def openvas_scanner(scan_ip, project_id, sel_profile, user):
    """
    The function is launch the OpenVAS scans.
    :param scan_ip:
    :param project_id:
    :param sel_profile:
    :return:
    """
    openvas = OpenVAS_Plugin(
        scan_ip,
        project_id,
        sel_profile,
    )
    try:
        scanner = openvas.connect()
    except Exception as e:

        notify.send(user,
                    recipient=user,
                    verb="OpenVAS Setting not configured")
        subject = "Archery Tool Notification"
        message = "OpenVAS Scanner failed due to setting not found "

        email_notify(user=user, subject=subject, message=message)
        return

    notify.send(user, recipient=user, verb="OpenVAS Scan Started")
    subject = "Archery Tool Notification"
    message = "OpenVAS Scan Started"

    email_notify(user=user, subject=subject, message=message)
    scan_id, target_id = openvas.scan_launch(scanner)
    date_time = datetime.now()
    save_all = NetworkScanDb(
        scan_id=str(scan_id),
        project_id=str(project_id),
        ip=scan_ip,
        date_time=date_time,
        scan_status=0.0,
        scanner="Openvas",
    )
    save_all.save()
    openvas.scan_status(scanner=scanner, scan_id=scan_id)
    time.sleep(5)
    vuln_an_id(
        scan_id=scan_id,
        project_id=project_id,
    )

    notify.send(user, recipient=user, verb="OpenVAS Scan Completed")

    all_openvas = NetworkScanDb.objects.filter()
    all_vuln = ""
    total_high = ""
    total_medium = ""
    total_low = ""
    for openvas in all_openvas:
        all_vuln = openvas.total_vul
        total_high = openvas.high_vul
        total_medium = openvas.medium_vul
        total_low = openvas.low_vul

    subject = "Archery Tool Notification"
    message = ("OpenVAS Scan Completed  <br>"
               "Total: %s  <br>Total High: %s <br>"
               "Total Medium: %s  <br>Total Low %s" %
               (all_vuln, total_high, total_medium, total_low))

    email_notify(user=user, subject=subject, message=message)

    return HttpResponse(status=201)