Reader small image

You're reading from  Practical Web Penetration Testing

Product typeBook
Published inJun 2018
PublisherPackt
ISBN-139781788624039
Edition1st Edition
Right arrow
Author (1)
Gus Khawaja
Gus Khawaja
author image
Gus Khawaja

Gus Khawaja holds a bachelor's degree in computer science. He specializes in IT security and ethical hacking. He is an author and shares his passion with millions of viewers around the world using his online courses. He also works as a cybersecurity consultant in Montreal, Canada. After many years of experience in programming, he turned his attention to cybersecurity and the importance that security brings to this minefield. His passion for the ethical hacking mixed with his background in programming and IT makes him a wise swiss-knife professional in the computer science domain.
Read more about Gus Khawaja

Right arrow

Pentest Automation Using Python

Folks, this is the last chapter of this book, and I would like to congratulate you on getting this far. Only disciplined and motivated people get to the finishing line, and you all have my respect. So far, you've learned many Terminal commands that you can execute during security tests. However, one thing that you will realize during pentests is that a lot of commands will just repeat over and over again, so why not automate these commands using a scripting language such as Python?

In this chapter, I will quickly show you how to install a Python IDE on Kali, and after that, we will look at a practical scenario and try to develop a program using Python. I will walk you through all the steps needed for you to start automating your penetration testing tasks, using practical examples as much as possible.

I created a full reference section for Python...

Python IDE

You will need a Python Integrated Development Environment (IDE) to develop your own scripts. You're not obliged to use a Python IDE, and instead, you can use any text editor in Kali Linux (for example, nano, vim, or gedit). However, using a professional IDE is a must if you want to easily develop large scripts that allow you to debug errors, format the source code, visualize the output, and detect errors even before the application is run. In this chapter, we will use a very popular and free Python IDE called PyCharm. You can find it at https://www.jetbrains.com/pycharm/.

You can also use the Python interpreter using your Terminal window. Let's say you have an idea and you want to test it quickly. Open your Terminal window in Kali, type python, and then press Enter. Let's look at an example. I will create a variable called ip_address, give it a value...

Penetration testing automation

In this section, I will show you how to develop a fully functioning application that can automatically perform a TCP scan and perform a service enumeration as well. The application will first execute an Nmap TCP scan, then we will check whether the FTP or HTTP ports are opened, and finally we will enumerate those services. I have limited this application to only FTP and HTTP ports, but you can add more services to your liking.

Automate.py in action

Summary

We're done, folks! I hope that you loved reading this book, and to make sure that I can help you with any questions or comments regarding the contents of this book, here's a list of contact details that you can use to communicate with me:

  • Email: gus.khawaja@guskhawaja.me
  • Twitter: @gusKhawaja
  • LinkedIn: https://ca.linkedin.com/in/guskhawaja
  • Blog: http://ethicalhackingblog.com

Hacking is not a sin—it's an art!

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Practical Web Penetration Testing
Published in: Jun 2018Publisher: PacktISBN-13: 9781788624039
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Gus Khawaja

Gus Khawaja holds a bachelor's degree in computer science. He specializes in IT security and ethical hacking. He is an author and shares his passion with millions of viewers around the world using his online courses. He also works as a cybersecurity consultant in Montreal, Canada. After many years of experience in programming, he turned his attention to cybersecurity and the importance that security brings to this minefield. His passion for the ethical hacking mixed with his background in programming and IT makes him a wise swiss-knife professional in the computer science domain.
Read more about Gus Khawaja