Ejemplo n.º 1
0
def task(target_url, project_id, scanner, **kwargs):
    rescan_id = ''
    rescan = 'No'
    target__split = target_url.split(',')
    split_length = target__split.__len__()
    for i in range(0, split_length):
        target = target__split.__getitem__(i)
        # noinspection PyInterpreter
        if scanner == 'zap_scan':
            scan_id = uuid.uuid4()
            thread = threading.Thread(target=launch_schudle_zap_scan,
                                      args=(target, project_id, rescan_id,
                                            rescan, scan_id,
                                            kwargs["username"]))
            thread.daemon = True
            thread.start()
        elif scanner == 'burp_scan':
            scan_id = uuid.uuid4()
            do_scan = burp_plugin.burp_scans(project_id,
                                             target,
                                             scan_id,
                                             user=kwargs["username"])
            thread = threading.Thread(target=do_scan.scan_launch, )
            thread.daemon = True
            thread.start()

        return HttpResponse(status=200)
Ejemplo n.º 2
0
def burp_scan_launch(request):
    """
    Burp Scan Trigger.
    :param request:
    :return:
    """
    global vuln_id, burp_status
    if request.POST.get("url"):
        target_url = request.POST.get('url')
        project_id = request.POST.get('project_id')
        target__split = target_url.split(',')
        split_length = target__split.__len__()
        for i in range(0, split_length):
            target = target__split.__getitem__(i)
            print "Targets", target
            scan_id = uuid.uuid4()
            try:
                do_scan = burp_plugin.burp_scans(project_id, target, scan_id)
                # do_scan.scan_lauch(project_id,
                #                    target,
                #                    scan_id)

                thread = threading.Thread(target=do_scan.scan_launch, )
                thread.daemon = True
                thread.start()
                time.sleep(5)
            except Exception as e:
                print e

    return render(request, 'burpscanner/burp_scan_list.html')
Ejemplo n.º 3
0
def task(target_url, project_id, scanner):
    """
    :param target_url:
    :param project_id:
    :param scanner:
    :return:
    """
    rescan_id = ''
    rescan = 'No'
    target__split = target_url.split(',')
    split_length = target__split.__len__()
    for i in range(0, split_length):
        target = target__split.__getitem__(i)
        if scanner == 'zap_scan':
            scan_id = uuid.uuid4()
            thread = threading.Thread(target=launch_zap_scan,
                                      args=(target, project_id, rescan_id,
                                            rescan, scan_id))
            thread.daemon = True
            thread.start()
        elif scanner == 'burp_scan':
            scan_id = uuid.uuid4()
            do_scan = burp_plugin.burp_scans(project_id, target, scan_id)
            thread = threading.Thread(target=do_scan.scan_launch, )
            thread.daemon = True
            thread.start()

        return HttpResponse(status=200)
Ejemplo n.º 4
0
    def post(self, request, format=None, **kwargs):
        """
        Launch scans using this api
        """
        serializer = WebScanSerializer(data=request.data)
        if serializer.is_valid():
            scan_id = uuid.uuid4()
            scanner = request.data.get('scanner')
            target_url = request.data.get('scan_url', )
            project_id = request.data.get('project_id', )
            rescanid = None
            rescan = 'No'
            user = request.user
            if scanner == 'zap_scan':
                # run_s = launch_zap_scan
                thread = threading.Thread(target=launch_zap_scan, args=(target_url,
                                                                        project_id,
                                                                        rescanid,
                                                                        rescan,
                                                                        scan_id,
                                                                        user))
                thread.daemon = True
                thread.start()

            elif scanner == 'burp_scan':
                user = request.user
                date_time = datetime.datetime.now()
                scan_dump = burp_scan_db(scan_id=scan_id,
                                         project_id=project_id,
                                         url=target_url,
                                         date_time=date_time)
                scan_dump.save()
                try:
                    do_scan = burp_plugin.burp_scans(
                        project_id,
                        target_url,
                        scan_id,
                        user
                    )
                    thread = threading.Thread(
                        target=do_scan.scan_launch,
                    )
                    thread.daemon = True
                    thread.start()
                except Exception as e:
                    print(e)
            elif scanner == 'arachni':
                thread = threading.Thread(target=launch_arachni_scan, args=(target_url,
                                                                            project_id,
                                                                            rescanid,
                                                                            rescan,
                                                                            scan_id,
                                                                            user))
                thread.daemon = True
                thread.start()

            if not target_url:
                return Response({"error": "No name passed"})
            return Response({"message": "Scan Launched", "scanid": scan_id})
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Ejemplo n.º 5
0
    def post(self, request, format=None, **kwargs):
        """
        Launch scans using this api
        """
        serializer = WebScanSerializer(data=request.data)
        if serializer.is_valid():
            scan_id = uuid.uuid4()
            scanner = request.data.get('scanner')
            target_url = request.data.get('scan_url', )
            project_id = request.data.get('project_id',)
            if scanner == 'zap_scan':
                run_s = web_views.launch_web_scan
                thread = threading.Thread(target=run_s, args=(target_url, project_id))
                thread.daemon = True
                thread.start()

            elif scanner == 'burp_scan':
                date_time = timezone.now()
                scan_dump = burp_scan_db(scan_id=scan_id,
                                         project_id=project_id,
                                         url=target_url,
                                         date_time=date_time)
                scan_dump.save()
                do_scan = burp_plugin.burp_scans(project_id, target_url, scan_id)
                o = do_scan.scan_lauch
                thread = threading.Thread(target=o, args=(project_id, target_url, scan_id))
                thread.daemon = True
                thread.start()

            if not target_url:
                return Response({"error": "No name passed"})
            return Response({"message": "Scan Launched", "scanid": scan_id})
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Ejemplo n.º 6
0
    def post(self, request, format=None, **kwargs):
        """
        Launch scans using this api
        """
        serializer = WebScanSerializer(data=request.data)
        if serializer.is_valid():
            scan_id = uuid.uuid4()
            scanner = request.data.get('scanner')
            target_url = request.data.get('scan_url', )
            project_id = request.data.get('project_id',)
            if scanner == 'zap_scan':
                run_s = web_views.launch_web_scan
                thread = threading.Thread(target=run_s, args=(target_url, project_id))
                thread.daemon = True
                thread.start()

            elif scanner == 'burp_scan':
                date_time = datetime.datetime.now()
                scan_dump = burp_scan_db(scan_id=scan_id,
                                         project_id=project_id,
                                         url=target_url,
                                         date_time=date_time)
                scan_dump.save()
                # do_scan = burp_plugin.burp_scans(project_id, target_url, scan_id)
                # # o = ()
                # thread = threading.Thread(target=do_scan.scan_launch(), args=(project_id, target_url, scan_id))
                # thread.daemon = True
                # thread.start()
                try:
                    do_scan = burp_plugin.burp_scans(
                        project_id,
                        target_url,
                        scan_id)
                    # do_scan.scan_lauch(project_id,
                    #                    target,
                    #                    scan_id)

                    thread = threading.Thread(
                        target=do_scan.scan_launch,
                    )
                    thread.daemon = True
                    thread.start()
                    # time.sleep(5)
                except Exception as e:
                    print e

            if not target_url:
                return Response({"error": "No name passed"})
            return Response({"message": "Scan Launched", "scanid": scan_id})
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Ejemplo n.º 7
0
def burp_scan_launch(request):
    """
    Burp Scan Trigger.
    :param request:
    :return:
    """
    user = request.user
    username = request.user.username
    if request.POST.get("url"):
        target_url = request.POST.get('url')
        project_id = request.POST.get('project_id')
        target__split = target_url.split(',')
        split_length = target__split.__len__()
        for i in range(0, split_length):
            target = target__split.__getitem__(i)
            print("Targets", target)
            scan_id = uuid.uuid4()
            date_time = datetime.now()
            scan_dump = burp_scan_db(username=username,
                                     scan_id=scan_id,
                                     project_id=project_id,
                                     url=target,
                                     date_time=date_time)
            scan_dump.save()
            try:
                do_scan = burp_plugin.burp_scans(
                    project_id,
                    target,
                    scan_id, user)
                # do_scan.scan_lauch(project_id,
                #                    target,
                #                    scan_id)

                thread = threading.Thread(
                    target=do_scan.scan_launch,
                )
                thread.daemon = True
                thread.start()
                time.sleep(5)
            except Exception as e:
                print(e)

    return render(request, 'burpscanner/burp_scan_list.html')
Ejemplo n.º 8
0
    def post(self, request):
        user = request.user
        target_url = request.POST.get("url")
        project_uu_id = request.POST.get("project_id")
        project_id = (ProjectDb.objects.filter(
            uu_id=project_uu_id).values("id").get()["id"])
        target__split = target_url.split(",")
        split_length = target__split.__len__()
        for i in range(0, split_length):
            target = target__split.__getitem__(i)
            print("Targets"), target
            scan_id = uuid.uuid4()
            try:
                do_scan = burp_plugin.burp_scans(project_id, target, scan_id,
                                                 user)

                thread = threading.Thread(target=do_scan.scan_launch, )
                thread.daemon = True
                thread.start()
                time.sleep(5)
            except Exception as e:
                print(e)

        return render(request, "webscanners/scans/list_scans.html")
Ejemplo n.º 9
0
def xml_upload(request):
    """
    Handling XML upload files.
    :param request:
    :return:
    """
    all_project = project_db.objects.all()

    if request.method == "POST":
        project_id = request.POST.get("project_id")
        scanner = request.POST.get("scanner")
        xml_file = request.FILES['xmlfile']
        scan_url = request.POST.get("scan_url")
        scan_id = uuid.uuid4()
        scan_status = "100"
        if scanner == "zap_scan":
            date_time = datetime.now()
            scan_dump = zap_scans_db(scan_url=scan_url,
                                     scan_scanid=scan_id,
                                     date_time=date_time,
                                     project_id=project_id,
                                     vul_status=scan_status,
                                     rescan='No')
            scan_dump.save()
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            zap_xml_parser.xml_parser(project_id=project_id,
                                      scan_id=scan_id,
                                      root=root_xml)
            return HttpResponseRedirect("/zapscanner/zap_scan_list/")
        elif scanner == "burp_scan":
            date_time = datetime.now()
            scan_dump = burp_scan_db(url=scan_url,
                                     scan_id=scan_id,
                                     date_time=date_time,
                                     project_id=project_id,
                                     scan_status=scan_status)
            scan_dump.save()
            # Burp scan XML parser
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            do_xml_data = burp_plugin.burp_scans(project_id, target_url,
                                                 scan_id)
            do_xml_data.burp_scan_data(root_xml)
            print("Save scan Data")
            return HttpResponseRedirect("/burpscanner/burp_scan_list")

        elif scanner == "arachni":
            date_time = datetime.now()
            scan_dump = arachni_scan_db(url=scan_url,
                                        scan_id=scan_id,
                                        date_time=date_time,
                                        project_id=project_id,
                                        scan_status=scan_status)
            scan_dump.save()
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            arachni_xml_parser.xml_parser(project_id=project_id,
                                          scan_id=scan_id,
                                          root=root_xml)
            print("Save scan Data")
            return HttpResponseRedirect("/arachniscanner/arachni_scan_list")

        elif scanner == 'netsparker':
            date_time = datetime.now()
            scan_dump = netsparker_scan_db(url=scan_url,
                                           scan_id=scan_id,
                                           date_time=date_time,
                                           project_id=project_id,
                                           scan_status=scan_status)
            scan_dump.save()
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            netsparker_xml_parser.xml_parser(project_id=project_id,
                                             scan_id=scan_id,
                                             root=root_xml)
            print("Saved scan data")
            return HttpResponseRedirect(
                "/netsparkerscanner/netsparker_scan_list/")
        elif scanner == 'webinspect':
            date_time = datetime.now()
            scan_dump = webinspect_scan_db(url=scan_url,
                                           scan_id=scan_id,
                                           date_time=date_time,
                                           project_id=project_id,
                                           scan_status=scan_status)
            scan_dump.save()
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            webinspect_xml_parser.xml_parser(project_id=project_id,
                                             scan_id=scan_id,
                                             root=root_xml)
            print("Saved scan data")
            return HttpResponseRedirect(
                "/webinspectscanner/webinspect_scan_list/")

        elif scanner == 'acunetix':
            date_time = datetime.now()
            scan_dump = acunetix_scan_db(url=scan_url,
                                         scan_id=scan_id,
                                         date_time=date_time,
                                         project_id=project_id,
                                         scan_status=scan_status)
            scan_dump.save()
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            acunetix_xml_parser.xml_parser(project_id=project_id,
                                           scan_id=scan_id,
                                           root=root_xml)
            print("Saved scan data")
            return HttpResponseRedirect("/acunetixscanner/acunetix_scan_list/")

        elif scanner == 'dependencycheck':
            date_time = datetime.now()
            scan_dump = dependencycheck_scan_db(project_name=scan_url,
                                                scan_id=scan_id,
                                                date_time=date_time,
                                                project_id=project_id,
                                                scan_status=scan_status)
            scan_dump.save()
            data = etree.parse(xml_file)
            dependencycheck_report_parser.xml_parser(project_id=project_id,
                                                     scan_id=scan_id,
                                                     data=data)
            print("Saved scan data")
            return HttpResponseRedirect(
                "/dependencycheck/dependencycheck_list")

        elif scanner == 'findbugs':
            date_time = datetime.now()
            scan_dump = findbugs_scan_db(project_name=scan_url,
                                         scan_id=scan_id,
                                         date_time=date_time,
                                         project_id=project_id,
                                         scan_status=scan_status)
            scan_dump.save()
            tree = ET.parse(xml_file)
            root = tree.getroot()
            findbugs_report_parser.xml_parser(project_id=project_id,
                                              scan_id=scan_id,
                                              root=root)
            print("Saved scan data")
            return HttpResponseRedirect("/findbugs/findbugs_list")

        elif scanner == 'nikto':
            date_time = datetime.now()
            scan_dump = nikto_result_db(
                date_time=date_time,
                scan_url=scan_url,
                scan_id=scan_id,
                project_id=project_id,
            )
            scan_dump.save()

            nikto_html_parser(xml_file, project_id, scan_id)
            print("Saved scan data")
            return HttpResponseRedirect("/tools/nikto/")

    return render(request, 'upload_xml.html', {'all_project': all_project})
Ejemplo n.º 10
0
    def post(self, request, format=None):

        project_id = request.data.get("project_id")
        scanner = request.data.get("scanner")
        xml_file = request.data.get("filename")
        scan_url = request.data.get("scan_url")
        scan_id = uuid.uuid4()
        scan_status = "100"
        print xml_file
        print scanner
        if scanner == "zap_scan":
            date_time = datetime.datetime.now()
            scan_dump = zap_scans_db(scan_url=scan_url,
                                     scan_scanid=scan_id,
                                     date_time=date_time,
                                     project_id=project_id,
                                     vul_status=scan_status,
                                     rescan='No')
            scan_dump.save()
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            zap_xml_parser.xml_parser(project_id=project_id,
                                      scan_id=scan_id,
                                      root=root_xml)
            return Response({
                "message": "ZAP Scan Data Uploaded",
                "scanner": scanner,
                "project_id": project_id,
                "scan_id": scan_id
            })
        elif scanner == "burp_scan":
            date_time = datetime.datetime.now()
            scan_dump = burp_scan_db(url=scan_url,
                                     scan_id=scan_id,
                                     date_time=date_time,
                                     project_id=project_id,
                                     scan_status=scan_status)
            scan_dump.save()
            # Burp scan XML parser
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            do_xml_data = burp_plugin.burp_scans(project_id, scan_url, scan_id)
            do_xml_data.burp_scan_data(root_xml)
            return Response({
                "message": "Burp Scan Data Uploaded",
                "project_id": project_id,
                "scan_id": scan_id,
                "scanner": scanner
            })

        elif scanner == "arachni":
            date_time = datetime.datetime.now()
            scan_dump = arachni_scan_db(url=scan_url,
                                        scan_id=scan_id,
                                        date_time=date_time,
                                        project_id=project_id,
                                        scan_status=scan_status)
            scan_dump.save()
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            arachni_xml_parser.xml_parser(project_id=project_id,
                                          scan_id=scan_id,
                                          root=root_xml)
            return Response({
                "message": "Scan Data Uploaded",
                "project_id": project_id,
                "scan_id": scan_id,
                "scanner": scanner
            })

        elif scanner == 'netsparker':
            date_time = datetime.datetime.now()
            scan_dump = netsparker_scan_db(url=scan_url,
                                           scan_id=scan_id,
                                           date_time=date_time,
                                           project_id=project_id,
                                           scan_status=scan_status)
            scan_dump.save()
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            netsparker_xml_parser.xml_parser(project_id=project_id,
                                             scan_id=scan_id,
                                             root=root_xml)
            return Response({
                "message": "Scan Data Uploaded",
                "project_id": project_id,
                "scan_id": scan_id,
                "scanner": scanner
            })
        elif scanner == 'webinspect':
            date_time = datetime.datetime.now()
            scan_dump = webinspect_scan_db(url=scan_url,
                                           scan_id=scan_id,
                                           date_time=date_time,
                                           project_id=project_id,
                                           scan_status=scan_status)
            scan_dump.save()
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            webinspect_xml_parser.xml_parser(project_id=project_id,
                                             scan_id=scan_id,
                                             root=root_xml)
            return Response({
                "message": "Scan Data Uploaded",
                "project_id": project_id,
                "scan_id": scan_id,
                "scanner": scanner
            })

        elif scanner == 'banditscan':
            date_time = datetime.datetime.now()
            scan_dump = bandit_scan_db(project_name=scan_url,
                                       scan_id=scan_id,
                                       date_time=date_time,
                                       project_id=project_id,
                                       scan_status=scan_status)
            scan_dump.save()
            data = json.loads(xml_file)
            bandit_report_json(data=data,
                               project_id=project_id,
                               scan_id=scan_id)
            return Response({
                "message": "Scan Data Uploaded",
                "project_id": project_id,
                "scan_id": scan_id,
                "scanner": scanner
            })

        elif scanner == 'dependencycheck':
            date_time = datetime.datetime.now()
            scan_dump = dependencycheck_scan_db(project_name=scan_url,
                                                scan_id=scan_id,
                                                date_time=date_time,
                                                project_id=project_id,
                                                scan_status=scan_status)
            scan_dump.save()
            data = etree.parse(xml_file)
            dependencycheck_report_parser.xml_parser(project_id=project_id,
                                                     scan_id=scan_id,
                                                     data=data)
            return Response({
                "message": "Scan Data Uploaded",
                "project_id": project_id,
                "scan_id": scan_id,
                "scanner": scanner
            })
        elif scanner == 'findbugs':
            date_time = datetime.datetime.now()
            scan_dump = findbugs_scan_db(project_name=scan_url,
                                         scan_id=scan_id,
                                         date_time=date_time,
                                         project_id=project_id,
                                         scan_status=scan_status)
            scan_dump.save()
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            findbugs_report_parser.xml_parser(project_id=project_id,
                                              scan_id=scan_id,
                                              root=root_xml)
            return Response({
                "message": "Scan Data Uploaded",
                "project_id": project_id,
                "scan_id": scan_id,
                "scanner": scanner
            })
        elif scanner == 'clair':
            date_time = datetime.datetime.now()
            scan_dump = clair_scan_db(project_name=scan_url,
                                      scan_id=scan_id,
                                      date_time=date_time,
                                      project_id=project_id,
                                      scan_status=scan_status)
            scan_dump.save()
            data = json.loads(xml_file)
            clair_json_report_parser.clair_report_json(project_id=project_id,
                                                       scan_id=scan_id,
                                                       data=data)
            return Response({
                "message": "Scan Data Uploaded",
                "project_id": project_id,
                "scan_id": scan_id,
                "scanner": scanner
            })

        elif scanner == 'inspec':
            date_time = datetime.datetime.now()
            scan_dump = inspec_scan_db(project_name=scan_url,
                                       scan_id=scan_id,
                                       date_time=date_time,
                                       project_id=project_id,
                                       scan_status=scan_status)
            scan_dump.save()
            data = json.loads(xml_file)
            inspec_json_parser.inspec_report_json(project_id=project_id,
                                                  scan_id=scan_id,
                                                  data=data)
            return Response({
                "message": "Scan Data Uploaded",
                "project_id": project_id,
                "scan_id": scan_id,
                "scanner": scanner
            })

        elif scanner == 'nikto':
            date_time = datetime.datetime.now()
            scan_dump = nikto_result_db(
                date_time=date_time,
                scan_url=scan_url,
                scan_id=scan_id,
                project_id=project_id,
            )
            scan_dump.save()

            nikto_html_parser(xml_file, project_id, scan_id)
            return Response({
                "message": "Scan Data Uploaded",
                "project_id": project_id,
                "scan_id": scan_id,
                "scanner": scanner
            })

        return Response({"message": "Scan Data Uploaded"})
Ejemplo n.º 11
0
    def post(self, request, format=None):

        project_id = request.data.get("project_id")
        scanner = request.data.get("scanner")
        xml_file = request.data.get("filename")
        scan_url = request.data.get("scan_url")
        scan_id = uuid.uuid4()
        scan_status = "100"
        print xml_file
        print scanner
        if scanner == "zap_scan":
            date_time = datetime.datetime.now()
            scan_dump = zap_scans_db(scan_url=scan_url,
                                     scan_scanid=scan_id,
                                     date_time=date_time,
                                     project_id=project_id,
                                     vul_status=scan_status,
                                     rescan='No')
            scan_dump.save()
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            zap_xml_parser.xml_parser(project_id=project_id,
                                      scan_id=scan_id,
                                      root=root_xml)
            return Response({"message": "Scan Data Uploaded"})
        elif scanner == "burp_scan":
            date_time = datetime.datetime.now()
            scan_dump = burp_scan_db(url=scan_url,
                                     scan_id=scan_id,
                                     date_time=date_time,
                                     project_id=project_id,
                                     scan_status=scan_status)
            scan_dump.save()
            # Burp scan XML parser
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            do_xml_data = burp_plugin.burp_scans(project_id, scan_url, scan_id)
            do_xml_data.burp_scan_data(root_xml)
            return Response({"message": "Scan Data Uploaded"})

        elif scanner == "arachni":
            date_time = datetime.datetime.now()
            scan_dump = arachni_scan_db(url=scan_url,
                                        scan_id=scan_id,
                                        date_time=date_time,
                                        project_id=project_id,
                                        scan_status=scan_status)
            scan_dump.save()
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            arachni_xml_parser.xml_parser(project_id=project_id,
                                          scan_id=scan_id,
                                          root=root_xml)
            return Response({"message": "Scan Data Uploaded"})

        elif scanner == 'netsparker':
            date_time = datetime.datetime.now()
            scan_dump = netsparker_scan_db(url=scan_url,
                                           scan_id=scan_id,
                                           date_time=date_time,
                                           project_id=project_id,
                                           scan_status=scan_status)
            scan_dump.save()
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            netsparker_xml_parser.xml_parser(project_id=project_id,
                                             scan_id=scan_id,
                                             root=root_xml)
            return Response({"message": "Scan Data Uploaded"})
        elif scanner == 'webinspect':
            date_time = datetime.datetime.now()
            scan_dump = webinspect_scan_db(url=scan_url,
                                           scan_id=scan_id,
                                           date_time=date_time,
                                           project_id=project_id,
                                           scan_status=scan_status)
            scan_dump.save()
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            webinspect_xml_parser.xml_parser(project_id=project_id,
                                             scan_id=scan_id,
                                             root=root_xml)
            return Response({"message": "Scan Data Uploaded"})

        elif scanner == 'banditscan':
            date_time = datetime.datetime.now()
            scan_dump = bandit_scan_db(project_name=scan_url,
                                       scan_id=scan_id,
                                       date_time=date_time,
                                       project_id=project_id,
                                       scan_status=scan_status)
            scan_dump.save()
            data = json.loads(xml_file)
            bandit_report_json(data=data,
                               project_id=project_id,
                               scan_id=scan_id)
            return Response({"message": "Scan Data Uploaded"})

        return Response({"message": "Scan Data Uploaded"})
Ejemplo n.º 12
0
def xml_upload(request):
    """
    Handling XML upload files.
    :param request:
    :return:
    """
    all_project = project_db.objects.all()

    if request.method == "POST":
        project_id = request.POST.get("project_id")
        scanner = request.POST.get("scanner")
        xml_file = request.FILES['xmlfile']
        scan_url = request.POST.get("scan_url")
        scan_id = uuid.uuid4()
        scan_status = "100"
        if scanner == "zap_scan":
            date_time = timezone.now()
            scan_dump = zap_scans_db(scan_url=scan_url,
                                     scan_scanid=scan_id,
                                     date_time=date_time,
                                     project_id=project_id,
                                     vul_status=scan_status,
                                     rescan='No')
            scan_dump.save()
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            zap_xml_parser.xml_parser(project_id=project_id,
                                      scan_id=scan_id,
                                      root=root_xml)
            return HttpResponseRedirect("/webscanners/scans_list/")
        elif scanner == "burp_scan":
            date_time = timezone.now()
            scan_dump = burp_scan_db(url=scan_url,
                                     scan_id=scan_id,
                                     date_time=date_time,
                                     project_id=project_id,
                                     scan_status=scan_status)
            scan_dump.save()
            # Burp scan XML parser
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            do_xml_data = burp_plugin.burp_scans(project_id,
                                                 target_url,
                                                 scan_id)
            do_xml_data.burp_scan_data(root_xml)
            print "Save scan Data"
            return HttpResponseRedirect("/webscanners/burp_scan_list")

        elif scanner == "arachni":
            print scanner
            print xml_file
            print scan_url
            date_time = timezone.now()
            scan_dump = arachni_scan_db(url=scan_url,
                                        scan_id=scan_id,
                                        date_time=date_time,
                                        project_id=project_id,
                                        scan_status=scan_status)
            scan_dump.save()
            tree = ET.parse(xml_file)
            root_xml = tree.getroot()
            arachni_xml_parser.xml_parser(project_id=project_id,
                                          scan_id=scan_id,
                                          root=root_xml)
            print "Save scan Data"
            return HttpResponseRedirect("/webscanners/arachni_scan_list")

    return render(request, 'upload_xml.html', {'all_project': all_project})