2222 from colorama import Fore , Style
2323 import webbrowser
2424 import sqlite3
25- except ImportError :
26- print (Fore .RED + "[Error #001 - Import error] Can't import some requirements that are necessary to start DPULSE. Please check that all necessary requirements are installed!" + Style .RESET_ALL )
25+ except ImportError as e :
26+ print (Fore .RED + "Import error appeared. Reason: {}" . format ( e ) + Style .RESET_ALL )
2727 sys .exit ()
28+
2829def insert_pdf (file ):
2930 with open (file , 'rb' ) as pdf_file :
3031 blob_data = pdf_file .read ()
@@ -43,8 +44,8 @@ def insert_blob(pdf_blob, db_casename, creation_date, case_comment):
4344 sqlite_connection .commit ()
4445 print (Fore .GREEN + "Scanning results are successfully saved in report storage database" )
4546 cursor .close ()
46- except sqlite3 .Error as error :
47- print (Fore .RED + "[Error #002 - Sqlite3 error] Failed to insert scanning results in report storage database" , error )
47+ except sqlite3 .Error as e :
48+ print (Fore .RED + "Failed to insert scanning results in report storage database. Reason: {}" . format ( e ) )
4849 finally :
4950 if sqlite_connection :
5051 sqlite_connection .close ()
@@ -92,8 +93,8 @@ def read_config(cfg_string_name):
9293 current_directory = os .path .dirname (current_script )
9394 cfg_file_path = os .path .join (current_directory , find_files ('config.txt' ))
9495 print (Fore .GREEN + 'Main config file was found at {}' .format (cfg_file_path ))
95- except TypeError :
96- print (Fore .RED + '[Error #003 - No CFG error] Main config file was not found in DPULSE root directory.' + Style .RESET_ALL )
96+ except TypeError as e :
97+ print (Fore .RED + 'Main config file was not found in DPULSE root directory. Reason: {}' . format ( e ) + Style .RESET_ALL )
9798 sys .exit ()
9899
99100short_domain = ''
@@ -121,7 +122,7 @@ def create_report(short_domain, url, case_comment):
121122 db_creation_date = str (now .year ) + str (now .month ) + str (now .day )
122123 report_folder = "report_{}" .format (foldername )
123124 os .makedirs (report_folder , exist_ok = True )
124-
125+ print ( Fore . GREEN + "Started scanning domain" + Style . RESET_ALL )
125126 print (Fore .GREEN + "Getting domain IP address" + Style .RESET_ALL )
126127 ip = cp .ip_gather (short_domain )
127128 print (Fore .GREEN + 'Processing WHOIS scanning' + Style .RESET_ALL )
@@ -142,30 +143,34 @@ def create_report(short_domain, url, case_comment):
142143 sitemap_links_status = np .extract_links_from_sitemap (report_folder )
143144 print (Fore .GREEN + 'Gathering info about website technologies' + Style .RESET_ALL )
144145 web_servers , cms , programming_languages , web_frameworks , analytics , javascript_frameworks = np .get_technologies (url )
145- print (Fore .GREEN + 'Processing Shodan InternetDB search' )
146+ print (Fore .GREEN + 'Processing Shodan InternetDB search' + Style . RESET_ALL )
146147 ports , hostnames , cpes , tags , vulns = np .query_internetdb (ip )
147148 print (Fore .GREEN + 'Processing Google Dorking' + Style .RESET_ALL )
148149 dorking_status = dp .save_results_to_txt (report_folder , dp .get_dorking_query (short_domain ))
149150
151+ common_socials = {key : social_medias .get (key , []) + sd_socials .get (key , []) for key in set (social_medias ) | set (sd_socials )}
152+
153+ for key in common_socials :
154+ common_socials [key ] = list (set (common_socials [key ]))
155+
156+ total_socials = sum (len (values ) for values in common_socials .values ())
157+
150158 context = {'sh_domain' : short_domain , 'full_url' : url , 'ip_address' : cp .ip_gather (short_domain ),'registrar' : res ['registrar' ],
151159 'creation_date' : res ['creation_date' ],'expiration_date' : res ['expiration_date' ],
152160 'name_servers' : ', ' .join (res ['name_servers' ]),'org' : res ['org' ],
153161 'mails' : cp .mail_gather (url ), 'subdomain_mails' : subdomain_mails , 'subdomain_socials' : social_medias ,
154- 'subdomain_ip' : subdomain_ip , 'fb_links_s' : ' ' .join (sd_socials ['Facebook' ]), 'inst_links_s' : ' ' .join (sd_socials ['Instagram' ]), 'tw_links_s' : ' ' .join (sd_socials ['Twitter' ]),
155- 'tg_links_s' : ' ' .join (sd_socials ['Telegram' ]), 'tt_links_s' : ' ' .join (sd_socials ['TikTok' ]),
156- 'li_links_s' : ' ' .join (sd_socials ['LinkedIn' ]), 'vk_links_s' : ' ' .join (sd_socials ['VKontakte' ]), 'yt_links_s' : ' ' .join (sd_socials ['YouTube' ]),
157- 'wc_links_s' : ' ' .join (sd_socials ['WeChat' ]), 'ok_links_s' : ' ' .join (sd_socials ['Odnoklassniki' ]),
158- 'subdomains' : ' // ' .join (subdomains ), 'fb_links' : ' ' .join (social_medias ['Facebook' ]),
159- 'tw_links' : ' ' .join (social_medias ['Twitter' ]), 'inst_links' : ' ' .join (social_medias ['Instagram' ]),
160- 'tg_links' : ' ' .join (social_medias ['Telegram' ]), 'tt_links' : ' ' .join (social_medias ['TikTok' ]),
161- 'li_links' : ' ' .join (social_medias ['LinkedIn' ]), 'vk_links' : ' ' .join (social_medias ['VKontakte' ]),
162- 'yt_links' : ' ' .join (social_medias ['YouTube' ]), 'wc_links' : ' ' .join (social_medias ['WeChat' ]),
163- 'ok_links' : ' ' .join (social_medias ['Odnoklassniki' ]), 'robots_txt_result' : robots_txt_result , 'sitemap_xml_result' : sitemap_xml_result , 'dorking_status' : dorking_status ,
162+ 'subdomain_ip' : subdomain_ip ,
163+ 'subdomains' : ' // ' .join (subdomains ), 'fb_links' : ' ' .join (common_socials ['Facebook' ]),
164+ 'tw_links' : ' ' .join (common_socials ['Twitter' ]), 'inst_links' : ' ' .join (common_socials ['Instagram' ]),
165+ 'tg_links' : ' ' .join (common_socials ['Telegram' ]), 'tt_links' : ' ' .join (common_socials ['TikTok' ]),
166+ 'li_links' : ' ' .join (common_socials ['LinkedIn' ]), 'vk_links' : ' ' .join (common_socials ['VKontakte' ]),
167+ 'yt_links' : ' ' .join (common_socials ['YouTube' ]), 'wc_links' : ' ' .join (common_socials ['WeChat' ]),
168+ 'ok_links' : ' ' .join (common_socials ['Odnoklassniki' ]), 'robots_txt_result' : robots_txt_result , 'sitemap_xml_result' : sitemap_xml_result , 'dorking_status' : dorking_status ,
164169 'sitemap_links' : sitemap_links_status , 'web_servers' : web_servers , 'cms' : cms , 'programming_languages' : programming_languages , 'web_frameworks' : web_frameworks , 'analytics' : analytics ,
165170 'javascript_frameworks' : javascript_frameworks ,
166171 'ctime' : ctime , 'a_tsf' : subdomains_amount , 'mx_records' : mx_records , 'issuer' : issuer , 'subject' : subject , 'notBefore' : notBefore , 'notAfter' : notAfter ,
167172 'commonName' : commonName , 'serialNumber' : serialNumber , 'ports' : ports , 'hostnames' : hostnames , 'cpes' : cpes ,
168- 'tags' : tags , 'vulns' : vulns }
173+ 'tags' : tags , 'vulns' : vulns , 'a_tsm' : total_socials }
169174
170175 print (Fore .GREEN + 'Processing report for {} case...' .format (short_domain ) + Style .RESET_ALL )
171176 template_loader = jinja2 .FileSystemLoader ('./' )
@@ -178,4 +183,4 @@ def create_report(short_domain, url, case_comment):
178183 print (Fore .GREEN + "Report for {} case was created at {}" .format ('' .join (short_domain ), ctime ) + Style .RESET_ALL )
179184 insert_blob (insert_pdf (report_file ), db_casename , db_creation_date , case_comment )
180185 except Exception as e :
181- print (Fore .RED + '[Error #005 - Report creation error] Unable to create PDF report. Reason: {}' .format (e ))
186+ print (Fore .RED + 'Unable to create PDF report. Reason: {}' .format (e ))
0 commit comments