Book Image

Python Penetration Testing Cookbook

By : Rejah Rehim
Book Image

Python Penetration Testing Cookbook

By: Rejah Rehim

Overview of this book

Penetration testing is the use of tools and code to attack a system in order to assess its vulnerabilities to external threats. Python allows pen testers to create their own tools. Since Python is a highly valued pen-testing language, there are many native libraries and Python bindings available specifically for pen-testing tasks. Python Penetration Testing Cookbook begins by teaching you how to extract information from web pages. You will learn how to build an intrusion detection system using network sniffing techniques. Next, you will find out how to scan your networks to ensure performance and quality, and how to carry out wireless pen testing on your network to avoid cyber attacks. After that, we’ll discuss the different kinds of network attack. Next, you’ll get to grips with designing your own torrent detection program. We’ll take you through common vulnerability scenarios and then cover buffer overflow exploitation so you can detect insecure coding. Finally, you’ll master PE code injection methods to safeguard your network.
Table of Contents (15 chapters)

Getting ready

As we have to sniff the packets from the interface, we require a Wi-Fi card capable of sniffing the Wi-Fi signals with the Monitor Mode. So we have to make sure the card is capable of sniffing. Then we have to set the interface to the Monitor Mode which is different for different operating systems. As Scapy has some limitations in the Windows systems, we have to run this recipe in a Linux or macOS environment.

Before we start coding, we have to get an idea about the Wi-Fi packets. As with the other packets, Wi-Fi packets also have a structure. According to the specification 802.11, each beacon frame from the access point contains a lot of information about the specific SSID.

Here is the frame format for an 802.11 mgmt beacon frame:

From this, we can get an idea of the content of the beacon frame. The really important items in the beacon frame are as follows:

  • SSID...