Skip to content
  • Categories
  • Recent
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Slate)
  • No Skin
Collapse
Brand Logo

hashpwn

Home | Donate | GitHub | Matrix Chat | PrivateBin | Rules

  1. Home
  2. Tools
  3. Scripts
  4. Emails rules extractor

Emails rules extractor

Scheduled Pinned Locked Moved Scripts
1 Posts 1 Posters 148 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A1131A Offline
    A1131A Offline
    A1131
    Trusted
    wrote on last edited by
    #1

    Title: Emails rules extractor
    Author: chatgpt

    AI written Python 3 interactive script that does the following:

    Features:

    • Reads email addresses from a file.

    Extracts:

    • Numbers at the end of the username ([email protected] → 123)

    • The domain (e.g., gmail.com)

    • Filters for specific domains (gmail.com, yahoo.com, etc. — user input).

    • Sorts results by frequency (how often each number + domain pair appears).

    • Creates Hashcat rules like $1$2$3$@$g$m$a$i$l$.$c$o$m.

    • Writes the output to a file of your choice.

    #!/usr/bin/env python3
    
    import re
    from collections import Counter, defaultdict
    
    def extract_data_from_email(email):
        match = re.match(r'^([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$', email.strip())
        if not match:
            return None
        user, domain = match.groups()
        digits_match = re.search(r'(\d+)$', user)
        if digits_match:
            digits = digits_match.group(1)
            return digits, domain.lower()
        return None
    
    def string_to_hashcat_rule(s):
        return ''.join(f"${c}" for c in s)
    
    def main():
        input_path = input("Enter path to input file containing emails: ").strip()
        domains_input = input("Enter comma-separated domains to filter (e.g., gmail.com,yahoo.com): ").strip()
        output_path = input("Enter path to save generated hashcat rules: ").strip()
    
        domains_to_include = set(domain.strip().lower() for domain in domains_input.split(',') if domain.strip())
        counter = Counter()
        examples = defaultdict(list)
    
        with open(input_path, 'r', encoding='utf-8') as f:
            for line in f:
                email = line.strip()
                extracted = extract_data_from_email(email)
                if extracted:
                    digits, domain = extracted
                    if domain in domains_to_include:
                        key = (digits, domain)
                        counter[key] += 1
                        if len(examples[key]) < 3:
                            examples[key].append(email)
    
        sorted_items = counter.most_common()
    
        with open(output_path, 'w', encoding='utf-8') as out:
            for (digits, domain), count in sorted_items:
                rule = string_to_hashcat_rule(digits + '@' + domain)
                out.write(f"{rule}\n")
    
        print(f"\nDone! {len(sorted_items)} rules written to {output_path}")
        print("Top 5 extracted rules with examples:")
        for (digits, domain), count in sorted_items[:5]:
            rule = string_to_hashcat_rule(digits + '@' + domain)
            print(f"  Rule: {rule} | Count: {count} | Examples: {examples[(digits, domain)]}")
    
    if __name__ == '__main__':
        main()
    
    

    Example
    Input:

    File contains:

    [email protected]
    [email protected]
    [email protected]
    [email protected]
    [email protected]
    bad.email.com
    

    Output:

    $1$2$3$@$g$m$a$i$l$.$c$o$m
    $4$5$6$@$g$m$a$i$l$.$c$o$m
    $1$2$3$@$y$a$h$o$o$.$c$o$m
    

    Amateur of mycology and hashcracking | 1x3060Ti | 1x1050Ti
    PGP:4B0A386530D789157435DC7489138FB52FDD7FC1

    1 Reply Last reply
    👍
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    Who's Online [Full List]

    5 users active right now (3 members and 2 guests).
    cyclone, hashpwn-bot

    Board Statistics

    Our members have made a total of 4.0k posts in 150 topics.
    We currently have 260 members registered.
    Please welcome our newest member, iceman.
    The most users online at one time was 49 on Thursday, December 26, 2024.

    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent