From c2ca214a9a040c2c092dfae5fcdb4bc86f2543ca Mon Sep 17 00:00:00 2001 From: OSINT-TECHNOLOGIES <77023667+OSINT-TECHNOLOGIES@users.noreply.github.com> Date: Mon, 9 Sep 2024 17:27:33 +0300 Subject: [PATCH] Added scan elapsed time output --- reporting_modules/pdf_report_creation.py | 178 +++++++++++------------ 1 file changed, 88 insertions(+), 90 deletions(-) diff --git a/reporting_modules/pdf_report_creation.py b/reporting_modules/pdf_report_creation.py index c519ada..b124768 100644 --- a/reporting_modules/pdf_report_creation.py +++ b/reporting_modules/pdf_report_creation.py @@ -41,84 +41,83 @@ def create_pdf(template_src, output_dst, context_data): return False return True -def report_assembling(short_domain, url, case_comment, data_array, report_info_array, pagesearch_ui_mark, pagesearch_keyword): - try: - ip = data_array[0] - res = data_array[1] - mails = data_array[2] - subdomains = data_array[3] - subdomains_amount = data_array[4] - social_medias = data_array[5] - subdomain_mails = data_array[6] - subdomain_ip = data_array[8] - issuer = data_array[9] - subject = data_array[10] - notBefore = data_array[11] - notAfter = data_array[12] - commonName = data_array[13] - serialNumber = data_array[14] - mx_records = data_array[15] - robots_txt_result = data_array[16] - sitemap_xml_result = data_array[17] - sitemap_links_status = data_array[18] - web_servers = data_array[19] - cms = data_array[20] - programming_languages = data_array[21] - web_frameworks = data_array[22] - analytics = data_array[23] - javascript_frameworks = data_array[24] - ports = data_array[25] - hostnames = data_array[26] - cpes = data_array[27] - tags = data_array[28] - vulns = data_array[29] - dorking_status = data_array[30] - common_socials = data_array[31] - total_socials = data_array[32] - ps_emails_return = data_array[33] - accessible_subdomains = data_array[34] - emails_amount = data_array[35] - files_counter = data_array[36] - cookies_counter = data_array[37] - api_keys_counter = data_array[38] - website_elements_counter = data_array[39] - exposed_passwords_counter = data_array[40] - total_links_counter = data_array[41] - accessed_links_counter = data_array[42] - keywords_messages_list = data_array[43] - casename = report_info_array[0] - db_casename = report_info_array[1] - db_creation_date = report_info_array[2] - report_folder = report_info_array[3] - report_ctime = report_info_array[6] +def report_assembling(short_domain, url, case_comment, data_array, report_info_array, pagesearch_ui_mark, pagesearch_keyword, end): + ip = data_array[0] + res = data_array[1] + mails = data_array[2] + subdomains = data_array[3] + subdomains_amount = data_array[4] + social_medias = data_array[5] + subdomain_mails = data_array[6] + subdomain_ip = data_array[8] + issuer = data_array[9] + subject = data_array[10] + notBefore = data_array[11] + notAfter = data_array[12] + commonName = data_array[13] + serialNumber = data_array[14] + mx_records = data_array[15] + robots_txt_result = data_array[16] + sitemap_xml_result = data_array[17] + sitemap_links_status = data_array[18] + web_servers = data_array[19] + cms = data_array[20] + programming_languages = data_array[21] + web_frameworks = data_array[22] + analytics = data_array[23] + javascript_frameworks = data_array[24] + ports = data_array[25] + hostnames = data_array[26] + cpes = data_array[27] + tags = data_array[28] + vulns = data_array[29] + dorking_status = data_array[30] + common_socials = data_array[31] + total_socials = data_array[32] + ps_emails_return = data_array[33] + accessible_subdomains = data_array[34] + emails_amount = data_array[35] + files_counter = data_array[36] + cookies_counter = data_array[37] + api_keys_counter = data_array[38] + website_elements_counter = data_array[39] + exposed_passwords_counter = data_array[40] + total_links_counter = data_array[41] + accessed_links_counter = data_array[42] + keywords_messages_list = data_array[43] + casename = report_info_array[0] + db_casename = report_info_array[1] + db_creation_date = report_info_array[2] + report_folder = report_info_array[3] + report_ctime = report_info_array[6] - pdf_templates_path = 'service//pdf_report_templates' + pdf_templates_path = 'service//pdf_report_templates' - if len(ps_emails_return) > 0: - subdomain_mails += ps_emails_return - subdomain_mails = list(set(subdomain_mails)) - subdomain_mails_cleaned = [] - substrings = ['m=Base64', 'Ë','Á','Æ','Å','Ä','Ò','Á','ó','ð','É','ë','â'] - for substring in substrings: - if any(substring in s for s in subdomain_mails): - subdomain_mails.remove(next(s for s in subdomain_mails if substring in s)) - for email in subdomain_mails: - new_emails = email.split(', ') - subdomain_mails_cleaned.extend(new_emails) - else: - subdomain_mails = list(set(subdomain_mails)) - subdomain_mails_cleaned = [] - substrings = ['m=Base64', 'Ë','Á','Æ','Å','Ä','Ò','Á','ó','ð','É','ë','â'] - for substring in substrings: - if any(substring in s for s in subdomain_mails): - subdomain_mails.remove(next(s for s in subdomain_mails if substring in s)) - for email in subdomain_mails: - new_emails = email.split(', ') - subdomain_mails_cleaned.extend(new_emails) + if len(ps_emails_return) > 0: + subdomain_mails += ps_emails_return + subdomain_mails = list(set(subdomain_mails)) + subdomain_mails_cleaned = [] + substrings = ['m=Base64', 'Ë','Á','Æ','Å','Ä','Ò','Á','ó','ð','É','ë','â'] + for substring in substrings: + if any(substring in s for s in subdomain_mails): + subdomain_mails.remove(next(s for s in subdomain_mails if substring in s)) + for email in subdomain_mails: + new_emails = email.split(', ') + subdomain_mails_cleaned.extend(new_emails) + else: + subdomain_mails = list(set(subdomain_mails)) + subdomain_mails_cleaned = [] + substrings = ['m=Base64', 'Ë','Á','Æ','Å','Ä','Ò','Á','ó','ð','É','ë','â'] + for substring in substrings: + if any(substring in s for s in subdomain_mails): + subdomain_mails.remove(next(s for s in subdomain_mails if substring in s)) + for email in subdomain_mails: + new_emails = email.split(', ') + subdomain_mails_cleaned.extend(new_emails) - if pagesearch_keyword == 'n': - template_path = pdf_templates_path + '//default_report_temp.html' - context = {'sh_domain': short_domain, 'full_url': url, 'ip_address': ip, 'registrar': res['registrar'], + if pagesearch_keyword == 'n': + template_path = pdf_templates_path + '//default_report_temp.html' + context = {'sh_domain': short_domain, 'full_url': url, 'ip_address': ip, 'registrar': res['registrar'], 'creation_date': res['creation_date'],'expiration_date': res['expiration_date'], 'name_servers': ', '.join(res['name_servers']),'org': res['org'], 'mails': mails, 'subdomain_mails': subdomain_mails_cleaned, 'subdomain_socials': social_medias, @@ -135,9 +134,9 @@ def report_assembling(short_domain, url, case_comment, data_array, report_info_a 'commonName': commonName, 'serialNumber': serialNumber, 'ports': ports, 'hostnames': hostnames, 'cpes': cpes, 'tags': tags, 'vulns': vulns, 'a_tsm': total_socials, 'pagesearch_ui_mark': pagesearch_ui_mark} - elif pagesearch_keyword == 'y': - template_path = pdf_templates_path + '//ps_report_temp.html' - context = {'sh_domain': short_domain, 'full_url': url, 'ip_address': ip, 'registrar': res['registrar'], + elif pagesearch_keyword == 'y': + template_path = pdf_templates_path + '//ps_report_temp.html' + context = {'sh_domain': short_domain, 'full_url': url, 'ip_address': ip, 'registrar': res['registrar'], 'creation_date': res['creation_date'],'expiration_date': res['expiration_date'], 'name_servers': ', '.join(res['name_servers']),'org': res['org'], 'mails': mails, 'subdomain_mails': subdomain_mails_cleaned, 'subdomain_socials': social_medias, @@ -156,9 +155,9 @@ def report_assembling(short_domain, url, case_comment, data_array, report_info_a 'acc_sd': accessible_subdomains, 'add_mails': emails_amount, 'extr_files': files_counter, 'cookies': cookies_counter, 'apis': api_keys_counter, 'wpe': website_elements_counter, 'exp_pass': exposed_passwords_counter, 'kml': keywords_messages_list} - elif pagesearch_keyword == 'si': - template_path = pdf_templates_path + '//si_report_temp.html' - context = {'sh_domain': short_domain, 'full_url': url, 'ip_address': ip, 'registrar': res['registrar'], + elif pagesearch_keyword == 'si': + template_path = pdf_templates_path + '//si_report_temp.html' + context = {'sh_domain': short_domain, 'full_url': url, 'ip_address': ip, 'registrar': res['registrar'], 'creation_date': res['creation_date'],'expiration_date': res['expiration_date'], 'name_servers': ', '.join(res['name_servers']),'org': res['org'], 'mails': mails, 'subdomain_mails': subdomain_mails_cleaned, 'subdomain_socials': social_medias, @@ -176,12 +175,11 @@ def report_assembling(short_domain, url, case_comment, data_array, report_info_a 'tags': tags, 'vulns': vulns, 'a_tsm': total_socials, 'pagesearch_ui_mark': pagesearch_ui_mark, 'a_sml': total_links_counter, 'acc_sml': accessed_links_counter, 'add_mails': emails_amount} - pdf_report_name = report_folder + '//' + casename - if create_pdf(template_path, pdf_report_name, context): - print(Fore.GREEN + "PDF report for {} case was created at {}".format(''.join(short_domain), report_ctime) + Style.RESET_ALL) - robots_content, sitemap_content, sitemap_links_content, dorking_content = fp.get_db_columns(report_folder) - pdf_blob = fp.get_blob(pdf_report_name) - db.insert_blob('PDF', pdf_blob, db_casename, db_creation_date, case_comment, robots_content, sitemap_content, sitemap_links_content, dorking_content) - except Exception as e: - print(Fore.RED + 'PDF report was not created. See journal for details') - logging.error(f'PDF REPORT CREATION: ERROR. REASON: {e}') + pdf_report_name = report_folder + '//' + casename + if create_pdf(template_path, pdf_report_name, context): + print(Fore.GREEN + "PDF report for {} case was created at {}".format(''.join(short_domain), report_ctime) + Style.RESET_ALL) + print(Fore.GREEN + f"Scan elapsed time: {end}" + Style.RESET_ALL) + robots_content, sitemap_content, sitemap_links_content, dorking_content = fp.get_db_columns(report_folder) + pdf_blob = fp.get_blob(pdf_report_name) + db.insert_blob('PDF', pdf_blob, db_casename, db_creation_date, case_comment, robots_content, sitemap_content, sitemap_links_content, dorking_content) +