Membersihkan Logs dan menyimpan yang di butuhkan saja
import re import glob # Define the patterns to search for and exclude patterns = [ {"pattern": r'wp-login\.php', "exclude_pattern": r'127\.0\.0|localhost|\.local|needrom|addon|UNKNOWN|null|000webhost|wordpress\.com|192\.168', "result_file": "wordpress.text"}, {"pattern": r'\/wp-admin\/', "exclude_pattern": r'127\.0\.0|localhost|\.local|needrom|addon|UNKNOWN|null|000webhost|wordpress\.com|192\.168', "result_file": "wp-admin.text"}, {"pattern": r'hostinger|weblink\.com\.br|hosting24\.com', "exclude_pattern": r'mail\.hostinger|webmail\.hostinger|webmail1|titan\.email|NOT_SAVED|UNKNOWN|joomla|needrom|null|telnet|fakepassword', "result_file": "hostinger.text"} ] # Find all.txt files in the current directory txt_files = glob.glob('*.txt') # Iterate over the patterns for pattern_dict in patterns: pattern = pattern_dict["pattern"] exclude_pattern = pattern_dict["exclude_pattern"] result_file = pattern_dict["result_file"] # Open the result file in append mode with open(result_file, 'a', encoding='utf-8') as result_file: for file in txt_files: with open(file, 'r', encoding='utf-8', errors='ignore') as f: for num, line in enumerate(f, 1): if re.search(pattern, line) and not re.search(exclude_pattern, line, re.IGNORECASE): result_file.write(f"{line.strip()}\n")