def Search(Query_List, Task_ID): Data_to_Cache = [] Cached_Data = [] Directory = General.Make_Directory(Concat_Plugin_Name) logger = logging.getLogger() logger.setLevel(logging.INFO) Log_File = General.Logging(Directory, Plugin_Name.lower()) handler = logging.FileHandler(os.path.join(Directory, Log_File), "w") handler.setLevel(logging.DEBUG) formatter = logging.Formatter("%(levelname)s - %(message)s") handler.setFormatter(formatter) logger.addHandler(handler) Cached_Data = General.Get_Cache(Directory, Plugin_Name) if not Cached_Data: Cached_Data = [] Query_List = General.Convert_to_List(Query_List) try: DNS_Info = checkdmarc.check_domains(Query_List) if len(Query_List) > 1: for DNS_Item in DNS_Info: Query = DNS_Item['base_domain'] Output_Dict = json.dumps(DNS_Item, indent=4, sort_keys=True) Link = "https://www." + Query Title = "DNS Information for " + DNS_Info['base_domain'] if Link not in Data_to_Cache and Link not in Cached_Data: Output_file = General.Main_File_Create( Directory, Plugin_Name, Output_Dict, Query, The_File_Extension) if Output_file: General.Connections(Output_file, Query, Plugin_Name, Link, Query, "Domain Spoof", Task_ID, Title, Concat_Plugin_Name) Data_to_Cache.append(Link) else: Query = DNS_Info['base_domain'] Output_Dict = json.dumps(DNS_Info, indent=4, sort_keys=True) Link = "https://www." + Query Title = "DNS Information for " + Query if Link not in Data_to_Cache and Link not in Cached_Data: Output_file = General.Main_File_Create(Directory, Plugin_Name, Output_Dict, Query, The_File_Extension) if Output_file: General.Connections(Output_file, Query, Plugin_Name, Link, Query, "Domain Spoof", Task_ID, Title, Concat_Plugin_Name) Data_to_Cache.append(Link) except: logging.warning(General.Date() + " Error retrieving DNS details.") if Cached_Data: General.Write_Cache(Directory, Data_to_Cache, Plugin_Name, "a") else: General.Write_Cache(Directory, Data_to_Cache, Plugin_Name, "w")
def Search(Query_List, Task_ID): try: Data_to_Cache = [] Directory = General.Make_Directory(Concat_Plugin_Name) logger = logging.getLogger() logger.setLevel(logging.INFO) Log_File = General.Logging(Directory, Plugin_Name.lower()) handler = logging.FileHandler(os.path.join(Directory, Log_File), "w") handler.setLevel(logging.DEBUG) formatter = logging.Formatter("%(levelname)s - %(message)s") handler.setFormatter(formatter) logger.addHandler(handler) Cached_Data = General.Get_Cache(Directory, Plugin_Name) Query_List = General.Convert_to_List(Query_List) try: DNS_Info = checkdmarc.check_domains(Query_List) if len(Query_List) > 1: for DNS_Item in DNS_Info: Query = DNS_Item['base_domain'] Output_Dict = json.dumps(DNS_Item, indent=4, sort_keys=True) Link = "https://www." + Query Title = "DNS Information for " + DNS_Item['base_domain'] if Link not in Data_to_Cache and Link not in Cached_Data: Response = requests.get(Link, headers=headers).text Main_File = General.Main_File_Create( Directory, Plugin_Name, Output_Dict, Query, The_File_Extensions["Main"]) Output_file = General.Create_Query_Results_Output_File( Directory, Query, Plugin_Name, Response, Title, The_File_Extensions["Query"]) if Output_file: Output_Connections = General.Connections( Query, Plugin_Name, Query, "Domain Information", Task_ID, Concat_Plugin_Name) Output_Connections.Output([Main_File, Output_file], Link, Title, Concat_Plugin_Name) Data_to_Cache.append(Link) else: logging.warning( f"{General.Date()} - {__name__.strip('plugins.')} - Failed to create output file. File may already exist." ) else: Query = DNS_Info['base_domain'] Output_Dict = json.dumps(DNS_Info, indent=4, sort_keys=True) Link = "https://www." + Query Title = "DNS Information for " + Query if Link not in Data_to_Cache and Link not in Cached_Data: Response = requests.get(Link, headers=headers).text Main_File = General.Main_File_Create( Directory, Plugin_Name, Output_Dict, Query, The_File_Extensions["Main"]) Output_file = General.Create_Query_Results_Output_File( Directory, Query, Plugin_Name, Response, Title, The_File_Extensions["Query"]) if Output_file: Output_Connections = General.Connections( Query, Plugin_Name, Query, "Domain Information", Task_ID, Concat_Plugin_Name) Output_Connections.Output([Main_File, Output_file], Link, Title, Concat_Plugin_Name) Data_to_Cache.append(Link) else: logging.warning( f"{General.Date()} - {__name__.strip('plugins.')} - Failed to create output file. File may already exist." ) except: logging.warning( f"{General.Date()} - {__name__.strip('plugins.')} - Error retrieving DNS details." ) if Cached_Data: General.Write_Cache(Directory, Data_to_Cache, Plugin_Name, "a") else: General.Write_Cache(Directory, Data_to_Cache, Plugin_Name, "w") except Exception as e: logging.warning( f"{General.Date()} - {__name__.strip('plugins.')} - {str(e)}")
def Search(self): try: Data_to_Cache = [] Directory = General.Make_Directory(self.Concat_Plugin_Name) logger = logging.getLogger() logger.setLevel(logging.INFO) Log_File = General.Logging(Directory, self.Plugin_Name.lower()) handler = logging.FileHandler(os.path.join(Directory, Log_File), "w") handler.setLevel(logging.DEBUG) formatter = logging.Formatter("%(levelname)s - %(message)s") handler.setFormatter(formatter) logger.addHandler(handler) Cached_Data_Object = General.Cache(Directory, self.Plugin_Name) Cached_Data = Cached_Data_Object.Get_Cache() try: DNS_Info = checkdmarc.check_domains(self.Query_List) if len(self.Query_List) > 1: for DNS_Item in DNS_Info: Query = DNS_Item['base_domain'] Output_Dict = Common.JSON_Handler(DNS_Item).Dump_JSON() Link = "https://www." + Query Title = "DNS Information for " + DNS_Item['base_domain'] if Link not in Data_to_Cache and Link not in Cached_Data: Responses = Common.Request_Handler( Link, Filter=True, Host=f"https://www.{Query}") Response = Responses["Filtered"] Main_File = General.Main_File_Create( Directory, self.Plugin_Name, Output_Dict, Query, self.The_File_Extensions["Main"]) Output_file = General.Create_Query_Results_Output_File( Directory, Query, self.Plugin_Name, Response, Title, self.The_File_Extensions["Query"]) if Output_file: Output_Connections = General.Connections( Query, self.Plugin_Name, Query, self.Result_Type, self.Task_ID, self.Concat_Plugin_Name) Output_Connections.Output( [Main_File, Output_file], Link, Title, self.Concat_Plugin_Name) Data_to_Cache.append(Link) else: logging.warning( f"{Common.Date()} - {self.Logging_Plugin_Name} - Failed to create output file. File may already exist." ) else: Query = DNS_Info['base_domain'] Output_Dict = Common.JSON_Handler(DNS_Item).Dump_JSON() Link = "https://www." + Query Title = "DNS Information for " + Query if Link not in Data_to_Cache and Link not in Cached_Data: Responses = Common.Request_Handler( Link, Filter=True, Host=f"https://www.{Query}") Response = Responses["Filtered"] Main_File = General.Main_File_Create( Directory, self.Plugin_Name, Output_Dict, Query, self.The_File_Extensions["Main"]) Output_file = General.Create_Query_Results_Output_File( Directory, Query, self.Plugin_Name, Response, Title, self.The_File_Extensions["Query"]) if Output_file: Output_Connections = General.Connections( Query, self.Plugin_Name, Query, self.Result_Type, self.Task_ID, self.Concat_Plugin_Name) Output_Connections.Output([Main_File, Output_file], Link, Title, self.Concat_Plugin_Name) Data_to_Cache.append(Link) else: logging.warning( f"{Common.Date()} - {self.Logging_Plugin_Name} - Failed to create output file. File may already exist." ) except: logging.warning( f"{Common.Date()} - {self.Logging_Plugin_Name} - Error retrieving DNS details." ) Cached_Data_Object.Write_Cache(Data_to_Cache) except Exception as e: logging.warning( f"{Common.Date()} - {self.Logging_Plugin_Name} - {str(e)}")