From d73d8ecdb1bcadd4e708f5d6e6c6f81ed6683326 Mon Sep 17 00:00:00 2001 From: Yogesh Ojha Date: Sat, 16 Apr 2022 15:32:22 +0530 Subject: [PATCH] render cms detection --- web/reNgine/common_func.py | 29 +++++--- web/static/custom/custom.js | 3 +- web/static/custom/toolbox.js | 127 +++++++++++++++++++++++++++++++++-- 3 files changed, 142 insertions(+), 17 deletions(-) diff --git a/web/reNgine/common_func.py b/web/reNgine/common_func.py index 6c91b878..15347660 100644 --- a/web/reNgine/common_func.py +++ b/web/reNgine/common_func.py @@ -5,9 +5,12 @@ import random import requests import tldextract import logging +import shutil from threading import Thread +from urllib.parse import urlparse + from bs4 import BeautifulSoup from lxml import html @@ -665,20 +668,26 @@ def get_whois(ip_domain, save_db=False, fetch_from_db=True): def get_cms_details(url): # this function will fetch cms details using cms_detector response = {} - cms_detector_command = 'python3 /usr/src/github/CMSeeK/cmseek.py -u {} --random-agent --batch'.format(url) + cms_detector_command = 'python3 /usr/src/github/CMSeeK/cmseek.py -u {} --random-agent --batch --follow-redirect'.format(url) output_lines = os.popen(cms_detector_command).read().splitlines() - result = [r for r in output_lines if "Result:" in r] response['status'] = False response['message'] = 'Could not detect CMS!' - if result: - result_path = re.search('32m(.*)0m', result[0]) - if result_path: - cms_json_path = result_path.group(1)[:-2] - cms_file_content = json.loads(open(cms_json_path, 'r').read()) - response = {} - response = cms_file_content - response['status'] = True + domain_name = urlparse(url).netloc + + cms_dir_path = '/usr/src/github/CMSeeK/Result/{}'.format(domain_name) + cms_json_path = cms_dir_path + '/cms.json' + + if os.path.isfile(cms_json_path): + cms_file_content = json.loads(open(cms_json_path, 'r').read()) + response = {} + response = cms_file_content + response['status'] = True + # remove cms dir path + try: + shutil.rmtree(cms_dir_path) + except Exception as e: + print(e) return response diff --git a/web/static/custom/custom.js b/web/static/custom/custom.js index 81d92b22..dda6dca8 100644 --- a/web/static/custom/custom.js +++ b/web/static/custom/custom.js @@ -1476,9 +1476,8 @@ function get_domain_whois(domain_name, show_add_target_btn=false) { 'Content-Type': 'application/json' }, }).then(response => response.json()).then(function(response) { - console.log(response); + swal.close(); if (response.status) { - swal.close(); display_whois_on_modal(response, show_add_target_btn=show_add_target_btn); } else { Swal.fire({ diff --git a/web/static/custom/toolbox.js b/web/static/custom/toolbox.js index 01aff074..cb2714cb 100644 --- a/web/static/custom/toolbox.js +++ b/web/static/custom/toolbox.js @@ -32,7 +32,7 @@ function cms_detector(){ $('#modal-content').append(`
- +
(reNgine uses CMSeeK to detect CMS.)
@@ -59,9 +59,9 @@ $(document).on('click', '#detect_cms_submit_btn', function(){ function cms_detector_api_call(url){ var api_url = `/api/tools/cms_detector/?format=json&url=${url}` Swal.fire({ - title: `Detecting CMS details on ${url}...` + title: `Detecting CMS`, + text: `reNgine is detecting CMS on ${url} and this may take a while. Please wait...` }); - $('.modal').modal('hide'); swal.showLoading(); fetch(api_url, { method: 'GET', @@ -74,8 +74,125 @@ function cms_detector_api_call(url){ console.log(response); if (response.status) { swal.close(); - console.log(response); - // display_whois_on_modal(response, show_add_target_btn=show_add_target_btn); + $('#modal_title').html('CMS Details for ' + url); + $('#modal-content').empty(); + + content = ` +
+ ${response.cms_name} +
+

${response.cms_name}

+ Visit CMS +
+
+ +
 CMS Details
+
+

CMS Name :

+

${response.cms_name}

+ +

CMS URL :

+

${response.cms_url}

+ +

Detection Method :

+

${response.detection_param}

+ +

URL :

+

+ (Includes redirected URL)
+ ${response.url} +

`; + + + if (response.wp_license) { + content += `

Wordpress License :

+

+ ${response.wp_license} +

`; + } + + if (response.wp_readme_file) { + content += `

Wordpress Readme file :

+

+ ${response.wp_readme_file} +

`; + } + + if (response.wp_uploads_directory) { + content += `

Wordpress Uploads Directory :

+

+ ${response.wp_uploads_directory} +

`; + } + + if (response.wp_users) { + content += `

Wordpress Users :

+

+ ${response.wp_users} +

`; + } + + if (response.wp_version) { + content += `

Wordpress Version :

+

+ ${response.wp_version} +

`; + } + + if (response.joomla_version) { + content += `

Joomla Version :

+

+ ${response.joomla_version} +

`; + } + + if (response.joomla_debug_mode) { + content += `

Joomla Debug Mode :

+

+ ${response.joomla_debug_mode} +

`; + } + + if (response.joomla_readme_file) { + content += `

Joomla Readme File :

+

+ ${response.joomla_readme_file} +

`; + } + + if (response.joomla_backup_files) { + content += `

Joomla Backup Files :

+

+ ${response.joomla_backup_files} +

`; + } + + if (response.directory_listing) { + content += `

Joomla Directory Listing :

+

+ ${response.directory_listing} +

`; + } + + if (response.joomla_config_files) { + content += `

Joomla Config Files :

+

+ ${response.joomla_config_files} +

`; + } + + if (response.user_registration_url) { + content += `

Joomla User Registration :

+

+ ${response.user_registration_url} +

`; + } + + + content += '
' + + $('#modal-content').append(content); + $('#modal_dialog').modal('show'); } else { Swal.fire({ title: 'Oops!',