(Python) Domain Generation Algorithm by Thomas Roccia
Created the Tuesday 13 December 2022. Updated 5 months, 3 weeks ago.
This code uses the random and datetime modules to generate a random number using the current date and time as a seed. It then constructs a domain name by concatenating the base domain name with the generated number. Finally, it prints the generated domain name.
Note that this is just an example, and there are many different ways that a DGA could be implemented. In a real-world scenario, the malware would use the generated domain name to communicate with its command and control server, and the domain name would be generated periodically using a pseudorandom number generator.
import random import datetime # Replace with the base domain name that you control base_domain = "example.com" # Get the current date and time date = datetime.datetime.now() # Generate a random number using the date and time as a seed random.seed(date) number = random.randint(0, 1000000) # Generate a domain name using the base domain and the random number domain_name = str(number) + "." + base_domain # Print the generated domain name print(domain_name)