Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

make a python program that can generate typosquat domains for qwerty keyboard

  1. User

    make a python program that can generate typosquat domains for qwerty keyboard

  2. Assistant

    Sure! Here's a Python program that will generate typosquat domains for the QWERTY keyboard layout:

    import random
    
    # Define the QWERTY keyboard layout
    keyboard_layout = [
        ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'],
        ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l'],
        ['z', 'x', 'c', 'v', 'b', 'n', 'm']
    ]
    
    # Function to generate typosquat domains
    def generate_typosquat_domains(domain, num_domains):
        typosquat_domains = []
        for _ in range(num_domains):
            typosquat = ""
            for char in domain:
                # Check if the character is present in the keyboard layout
                found = False
                for i in range(len(keyboard_layout)):
                    if char.lower() in keyboard_layout[i]:
                        found = True
                        row_idx = i
                        col_idx = keyboard_layout[i].index(char.lower())
                        break
                
                # Generate a random typo based on the keyboard layout
                if found:
                    typo_row_idx = max(0, row_idx + random.randint(-1, 1))
                    typo_col_idx = max(0, col_idx + random.randint(-1, 1))
                    typo = keyboard_layout[typo_row_idx][typo_col_idx]
                    
                    # Keep the same case as the original character
                    if char.isupper():
                        typo = typo.upper()
                    
                    typosquat += typo
                else:
                    typosquat += char
            
            typosquat_domains.append(typosquat + ".com")  # Append the domain extension
            
        return typosquat_domains
    
    # Example usage
    original_domain = "example"
    num_domains = 5
    typosquat_domains = generate_typosquat_domains(original_domain, num_domains)
    
    print("Original domain:", original_domain + ".com")
    print("Typosquat domains:")
    for domain in typosquat_domains:
        print(domain)
    

    This program defines a QWERTY keyboard layout, and the generate_typosquat_domains() function takes a domain name and the number of typosquat domains to generate. It then loops through each character of the domain name and generates a random typo based on the keyboard layout. The new domain is constructed by replacing each character with a typo or keeping it unchanged if it's not present in the layout.

    The program then appends the ".com" extension to each typosquat domain and prints the original domain along with the generated typosquat domains.

    Note: This program generates typosquat domains by randomly swapping characters adjacent on the keyboard. It may not produce valid or available domain names, so please use it responsibly.