Skip to content

Commit

Permalink
Update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Deci8BelioS authored Oct 22, 2024
1 parent 6543998 commit ba883b8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
23 changes: 23 additions & 0 deletions AGH/AGH_filters+.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ def filter_lines(lines):
normal_domains.add(line.strip())
return normal_domains

def filter_domains_with_subdomains(lines, export_domains):
domain_pattern = r'([a-zA-Z0-9-]+\.[a-zA-Z]{2,8})$'
subdomain_pattern = r'([a-zA-Z0-9-]+\.[a-zA-Z0-9-]+\.[a-zA-Z]{2,8})$'
main_domains = set()
domains_with_subdomains = set()
for line in lines:
line = line.strip()
domain_match = re.match(domain_pattern, line)
subdomain_match = re.match(subdomain_pattern, line)
if domain_match:
main_domain = domain_match.group(1)
main_domains.add(main_domain)
elif subdomain_match:
subdomain = subdomain_match.group(1)
main_domain = ".".join(subdomain.split(".")[-2:])
domains_with_subdomains.add(main_domain)
export_domains.update(main_domains.intersection(domains_with_subdomains))

unified_content = set()

urls = [
Expand All @@ -71,6 +89,9 @@ def filter_lines(lines):
filtered_domains = filter_lines(lines)
unified_content.update(filtered_domains)

export_domains = set()
filter_domains_with_subdomains(unified_content, export_domains)

with open(output_file, 'w', encoding='utf-8') as f:
for domain in sorted(unified_content):
if any(pattern.search(domain) for pattern in REGEX) or not domain:
Expand All @@ -79,6 +100,8 @@ def filter_lines(lines):
continue
if domain.endswith(tuple(DOMAIN_LIST)) and not domain.startswith(tuple(DOMAIN_LIST)) or not domain:
continue
if domain.endswith(tuple(export_domains)) and not domain.startswith(tuple(export_domains)) or not domain:
continue
if not domain.startswith(('||', '@@', '|', '<')) and not domain.endswith('^'):
domain = f'||{domain}^'
f.write(f"{domain}\n")
Expand Down
25 changes: 24 additions & 1 deletion AGH/AGH_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ def filter_lines(lines):
normal_domains.add(line.strip())
return normal_domains

def filter_domains_with_subdomains(lines, export_domains):
domain_pattern = r'([a-zA-Z0-9-]+\.[a-zA-Z]{2,8})$'
subdomain_pattern = r'([a-zA-Z0-9-]+\.[a-zA-Z0-9-]+\.[a-zA-Z]{2,8})$'
main_domains = set()
domains_with_subdomains = set()
for line in lines:
line = line.strip()
domain_match = re.match(domain_pattern, line)
subdomain_match = re.match(subdomain_pattern, line)
if domain_match:
main_domain = domain_match.group(1)
main_domains.add(main_domain)
elif subdomain_match:
subdomain = subdomain_match.group(1)
main_domain = ".".join(subdomain.split(".")[-2:])
domains_with_subdomains.add(main_domain)
export_domains.update(main_domains.intersection(domains_with_subdomains))

unified_content = set()

urls = [
Expand All @@ -63,6 +81,9 @@ def filter_lines(lines):
filtered_domains = filter_lines(lines)
unified_content.update(filtered_domains)

export_domains = set()
filter_domains_with_subdomains(unified_content, export_domains)

with open(output_file, 'w', encoding='utf-8') as f:
for domain in sorted(unified_content):
if any(pattern.search(domain) for pattern in REGEX) or not domain:
Expand All @@ -71,8 +92,10 @@ def filter_lines(lines):
continue
if domain.endswith(tuple(DOMAIN_LIST)) and not domain.startswith(tuple(DOMAIN_LIST)) or not domain:
continue
if domain.endswith(tuple(export_domains)) and not domain.startswith(tuple(export_domains)) or not domain:
continue
if not domain.startswith(('||', '@@', '|', '<')) and not domain.endswith('^'):
domain = f'||{domain}^'
f.write(f"{domain}\n")

print(f"File '{output_file}' generated successfully.")
print(f"File '{output_file}' generated successfully.")
4 changes: 2 additions & 2 deletions AGH/regex.py

Large diffs are not rendered by default.

0 comments on commit ba883b8

Please sign in to comment.