def hunt_pans(gauge_update_function=None): global search_dir, excluded_directories, search_extensions, enable_pdf # find all files to check all_files = filehunt.find_all_files_in_directory(PANFile, search_dir, excluded_directories, search_extensions, enable_pdf, gauge_update_function) # check each file total_docs, doc_pans_found = filehunt.find_all_regexs_in_files([ afile for afile in all_files if not afile.errors and afile.type in ('TEXT', 'ZIP', 'SPECIAL') ], pan_regexs, search_extensions, enable_pdf, 'PAN', gauge_update_function) # check each pst message and attachment total_psts, pst_pans_found = filehunt.find_all_regexs_in_psts([ afile for afile in all_files if not afile.errors and afile.type == 'MAIL' ], pan_regexs, search_extensions, enable_pdf, 'PAN', gauge_update_function) total_files_searched = total_docs + total_psts pans_found = doc_pans_found + pst_pans_found return total_files_searched, pans_found, all_files
def hunt_pans(gauge_update_function=None): global search_dir, excluded_directories, search_extensions, enable_pdf # find all files to check all_files = filehunt.find_all_files_in_directory(PANFile, search_dir, excluded_directories, search_extensions, enable_pdf, gauge_update_function) # check each file total_docs, doc_pans_found = filehunt.find_all_regexs_in_files([afile for afile in all_files if not afile.errors and afile.type in ('TEXT','ZIP','SPECIAL')], pan_regexs, search_extensions, enable_pdf, 'PAN', gauge_update_function) # check each pst message and attachment total_psts, pst_pans_found = filehunt.find_all_regexs_in_psts([afile for afile in all_files if not afile.errors and afile.type == 'MAIL'], pan_regexs, search_extensions, enable_pdf, 'PAN', gauge_update_function) total_files_searched = total_docs + total_psts pans_found = doc_pans_found + pst_pans_found return total_files_searched, pans_found, all_files
text_extensions_string = unicode(args.textfiles) zip_extensions_string = unicode(args.zipfiles) special_extensions_string = unicode(args.specialfiles) mail_extensions_string = unicode(args.mailfiles) other_extensions_string = unicode(args.otherfiles) excluded_directories = [exc_dir.lower() for exc_dir in excluded_directories_string.split(',')] search_extensions = {} search_extensions['TEXT'] = text_extensions_string.split(',') search_extensions['ZIP'] = zip_extensions_string.split(',') search_extensions['SPECIAL'] = special_extensions_string.split(',') search_extensions['MAIL'] = mail_extensions_string.split(',') search_extensions['OTHER'] = other_extensions_string.split(',') # TO DO: how about network drives, other databases? pass_regexs = {'password': re.compile(regex_string, re.IGNORECASE)} # find all files to check all_files = filehunt.find_all_files_in_directory(PWDFile, search_dir, excluded_directories, search_extensions) # TODO: search for filenames containing 'password', and encrypted zip/documents # check each file total_docs, doc_pans_found = filehunt.find_all_regexs_in_files([afile for afile in all_files if not afile.errors and afile.type in ('TEXT','ZIP','SPECIAL')], pass_regexs, search_extensions, 'Pwd') # check each pst message and attachment total_psts, pst_pans_found = filehunt.find_all_regexs_in_psts([afile for afile in all_files if not afile.errors and afile.type == 'MAIL'], pass_regexs, search_extensions, 'Pwd') pans_found = doc_pans_found + pst_pans_found # report findings output_report(search_dir, excluded_directories_string, all_files, total_docs, pans_found, output_file)