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)
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)
def post(self, request, format=None, **kwargs): """ Launch scans using this api """ serializer = WebScanSerializer(data=request.data) if serializer.is_valid(): target_url = request.data.get('scan_url', ) project_id = request.data.get('project_id', ) web_views.launch_web_scan(target_url, project_id) if not target_url: return Response({"error": "No name passed"}) return Response({"message": "Scan Completed"}) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
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)
def get(self, request, format=None, **kwargs): """ GET List all scans and check status. """ all_scans = zap_scans_db.objects.all() serialized_scans = WebScanSerializer(all_scans, many=True) return Response(serialized_scans.data)
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': web_views.launch_web_scan(target_url, project_id) elif scanner == 'burp_scan': do_scan = burp_scan.burp_scans(project_id, target_url, scan_id) do_scan.scan_lauch() if not target_url: return Response({"error": "No name passed"}) return Response({"message": "Scan Completed"}) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
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': web_views.launch_web_scan(target_url, project_id) elif scanner == 'burp_scan': do_scan = burp_scan.burp_scans(project_id, target_url, scan_id) do_scan.scan_lauch() if not target_url: return Response({"error": "No name passed"}) return Response({"message": "Scan Completed"}) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)