def __init__(self, config, phishtank, openphish, cleanmx): logging.debug("Instantiating the '%s' class" % (self.__class__.__name__)) self._cfg = config self._phishtank = phishtank self._openphish = openphish self._cleanmx = cleanmx Utils.remove_dir_content(self._cfg['dir_out'])
def save_ph_ws(ph_ws): logging.debug("XMLAdapter is storing phishing websites...") Utils.remove_dir_content(XMLAdapter.config['dir_out']) for cm_name, cm in ph_ws.items(): if len(cm) > 0: try: file_ph_ws_name = os.path.join(XMLAdapter.config['dir_out'], cm_name + '.xml') file_ph_ws = open(file_ph_ws_name, 'w') file_ph_ws.write(dicttoxml.dicttoxml(ph_ws)) file_ph_ws.close() except OSError, e: logging.error("Error saving phishing websites in xml format: %s" % (e)) raise OSError
def save_ph_ws(ph_ws): logging.debug("CSVAdapter is storing phishing websites...") Utils.remove_dir_content(CSVAdapter.config['dir_out']) for cm_name, cm in ph_ws.items(): if len(cm) > 0: try: file_ph_ws_name = os.path.join(CSVAdapter.config['dir_out'], cm_name + '.csv') file_ph_ws = open(file_ph_ws_name, 'w') for cm_elems in cm: cm_elems_string = '' for cm_elem_key in sorted(cm_elems): if type(cm_elems[cm_elem_key]) is int: cm_elems_string += str(cm_elems[cm_elem_key]) + ',' else: cm_elems_string += cm_elems[cm_elem_key].encode('utf-8') + ',' cm_elems_string = cm_elems_string[:-1] file_ph_ws.write(cm_elems_string + '\n') file_ph_ws.close() except OSError, e: logging.error("Error saving phishing websites in csv format: %s" % (e)) raise OSError
def run(self): logging.debug("Extracting files...") Utils.remove_dir_content(self._cfg['dir_out']) while Utils.compute_file_number(self._cfg['dir_in']) > 1: self._walk_dir(self._cfg['dir_in'], self._cfg['dir_out']) Utils.remove_dir_content(self._cfg['dir_in'])