Exemple #1
0
    def __init__(self, resourceManager):
        #setting for the folders
        self.folderConfig = "config"  #configurations
        self.folderLang = 'lang'  #languages

        # take the user name of the current pc
        self.pc_name = getpass.getuser()

        # search the UserConfig file
        # if there isn't... create a user config file from the DefaultConfig file
        if (os.path.exists(
                resourceManager.getResource(self.folderConfig + "/" +
                                            self.pc_name +
                                            "Config.var"))) != True:
            shutil.copyfile(
                resourceManager.getResource(self.folderConfig + "/" +
                                            "DefaultConfig.var"),
                resourceManager.getResource(self.folderConfig + "/" +
                                            self.pc_name + "Config.var"))

        # directory is the directory of the UserConfig file
        self.directory = resourceManager.getResource(self.folderConfig + "/" +
                                                     self.pc_name +
                                                     "Config.var")
        extractor = Extractor()

        # setting the list of all the config file
        self.config = extractor.extractText(self.directory)
Exemple #2
0
    def __init__(self, inputfile, phishtank, openphish, cleanmx, output, alivecheck, emailnotifiers):
        logging.debug("Instantiating the '%s' class" % (self.__class__.__name__))

        self._inputfile = inputfile
        self._phishtank = phishtank
        self._openphish = openphish
        self._cleanmx = cleanmx
        self._output = output
        self._alivecheck = alivecheck
        self._emailnotifiers = emailnotifiers

        check_passed = CheckDependencies.run()
        if not check_passed:
            exit()
        else:
            self._cfg = ConfigReader.run()

            if not self._inputfile:
                self._downloader = Downloader(self._cfg, self._phishtank, self._openphish, self._cleanmx)
                self._extractor = Extractor(self._cfg, self._phishtank, self._openphish, self._cleanmx)
                
            if self._alivecheck:
                AliveChecker.config = self._cfg

            if 'json' in self._output:
                JSONAdapter.config = self._cfg
            if 'csv' in self._output:
                CSVAdapter.config = self._cfg
            if 'xml' in self._output:
                XMLAdapter.config = self._cfg

            if self._emailnotifiers:
                EmailNotifiers.config = self._cfg
Exemple #3
0
class Core:

    def __init__(self, inputfile, phishtank, openphish, cleanmx, output, alivecheck, emailnotifiers):
        logging.debug("Instantiating the '%s' class" % (self.__class__.__name__))

        self._inputfile = inputfile
        self._phishtank = phishtank
        self._openphish = openphish
        self._cleanmx = cleanmx
        self._output = output
        self._alivecheck = alivecheck
        self._emailnotifiers = emailnotifiers

        check_passed = CheckDependencies.run()
        if not check_passed:
            exit()
        else:
            self._cfg = ConfigReader.run()

            if not self._inputfile:
                self._downloader = Downloader(self._cfg, self._phishtank, self._openphish, self._cleanmx)
                self._extractor = Extractor(self._cfg, self._phishtank, self._openphish, self._cleanmx)
                
            if self._alivecheck:
                AliveChecker.config = self._cfg

            if 'json' in self._output:
                JSONAdapter.config = self._cfg
            if 'csv' in self._output:
                CSVAdapter.config = self._cfg
            if 'xml' in self._output:
                XMLAdapter.config = self._cfg

            if self._emailnotifiers:
                EmailNotifiers.config = self._cfg

    def run(self):
        print("Running...")

        if not self._inputfile:
            self._downloader.run()
            ph_ws = self._extractor.run()
        else:
            logging.debug("Reading possible phishing website from '%s'" % (self._inputfile))

            fp = open(self._inputfile, 'rb')
            lines = fp.readlines()
            logging.debug(lines)
            fp.close()
         
            ph_ws = dict()
            cm_elems = []
            for line in lines:
                cm_elem = dict()
                cm_elem['domain'] = line.replace('\n','')
                cm_elem['url'] = line.replace('\n','')
                cm_elem['ip'] = 'n.d.'
                cm_elem['brand'] = 'custom'
                cm_elem['time'] = 'n.d.'
                cm_elem['country'] = 'n.d.'
                cm_elems.append(cm_elem)
            ph_ws['custom'] = cm_elems 

        if self._alivecheck:
            ph_ws = AliveChecker.are_alive(ph_ws)

        if len(ph_ws) > 0:
            if 'json' in self._output:
                JSONAdapter.save_ph_ws(ph_ws)
            if 'csv' in self._output:
                CSVAdapter.save_ph_ws(ph_ws)
            if 'xml' in self._output:
                XMLAdapter.save_ph_ws(ph_ws)

            if self._emailnotifiers:
                EmailNotifiers.notify()
        else:
            logging.debug('Empty phishing_website list')

        print("Done...")