diff --git a/web/api/views.py b/web/api/views.py index 01a7d91b..37fd267e 100644 --- a/web/api/views.py +++ b/web/api/views.py @@ -649,49 +649,71 @@ class GetFileContents(APIView): req = self.request name = req.query_params.get('name') + response = {} + response['status'] = False + response['message'] = 'Invalid Query Params' + if 'nuclei_config' in req.query_params: path = "/root/.config/nuclei/config.yaml" if not os.path.exists(path): os.system('touch {}'.format(path)) + response['message'] = 'File Created!' f = open(path, "r") - return Response({'content': f.read()}) + response['status'] = True + response['content'] = f.read() + return Response(response) if 'subfinder_config' in req.query_params: path = "/root/.config/subfinder/config.yaml" if not os.path.exists(path): os.system('touch {}'.format(path)) + response['message'] = 'File Created!' f = open(path, "r") - return Response({'content': f.read()}) + response['status'] = True + response['content'] = f.read() + return Response(response) if 'naabu_config' in req.query_params: path = "/root/.config/naabu/config.yaml" if not os.path.exists(path): os.system('touch {}'.format(path)) + response['message'] = 'File Created!' f = open(path, "r") - return Response({'content': f.read()}) + response['status'] = True + response['content'] = f.read() + return Response(response) if 'theharvester_config' in req.query_params: path = "/usr/src/github/theHarvester/api-keys.yaml" if not os.path.exists(path): os.system('touch {}'.format(path)) + response['message'] = 'File Created!' f = open(path, "r") - return Response({'content': f.read()}) + response['status'] = True + response['content'] = f.read() + return Response(response) if 'amass_config' in req.query_params: path = "/root/.config/amass.ini" if not os.path.exists(path): os.system('touch {}'.format(path)) + response['message'] = 'File Created!' f = open(path, "r") - return Response({'content': f.read()}) + response['status'] = True + response['content'] = f.read() + return Response(response) if 'gf_pattern' in req.query_params: basedir = '/root/.gf' path = '/root/.gf/{}.json'.format(name) if is_safe_path(basedir, path) and os.path.exists(path): content = open(path, "r").read() + response['status'] = True + response['content'] = content else: - content = "Invalid path!" - return Response({'content': content}) + response['message'] = "Invalid path!" + response['status'] = False + return Response(response) if 'nuclei_template' in req.query_params: @@ -699,11 +721,14 @@ class GetFileContents(APIView): path = '/root/nuclei-templates/{}'.format(name) if is_safe_path(safe_dir, path) and os.path.exists(path): content = open(path.format(name), "r").read() + response['status'] = True + response['content'] = content else: - content = 'Invalid Path!' - return Response({'content': content}) + response['message'] = 'Invalid Path!' + response['status'] = False + return Response(response) - return Response({'content': "ping-pong"}) + return Response(response) class ListTodoNotes(APIView): diff --git a/web/dashboard/templates/dashboard/index.html b/web/dashboard/templates/dashboard/index.html index cc2a633b..f4409d79 100644 --- a/web/dashboard/templates/dashboard/index.html +++ b/web/dashboard/templates/dashboard/index.html @@ -20,209 +20,209 @@ Dashboard {% block main_content %}
-
Alive Subdomains: {{alive_count|intcomma}}
-Alive Endpoints: {{endpoint_alive_count|intcomma}}
-{{critical_count}} Critical, {{high_count}} High, {{medium_count}} Medium
-{{low_count}} Low, {{info_count}} Info, {{unknown_count}} Unknown Vulnerabilities
-+
Alive Subdomains: {{alive_count|intcomma}}
+Alive Endpoints: {{endpoint_alive_count|intcomma}}
+{{critical_count}} Critical, {{high_count}} High, {{medium_count}} Medium
+{{low_count}} Low, {{info_count}} Info, {{unknown_count}} Unknown Vulnerabilities
+${htmlEncode(data['content'])}`);
+ $('#modal_dialog').modal('show');
+
}).fail(function(){
- $('#modal-loader').empty();
- $("#modal-content").append(`Error loading GF Pattern
`); + swal.fire("Error!", 'Error loading gf pattern!', "error", { + button: "Okay", + }); }); }