Book Image

Mastering Python for Networking and Security

By : José Ortega
Book Image

Mastering Python for Networking and Security

By: José Ortega

Overview of this book

It’s becoming more and more apparent that security is a critical aspect of IT infrastructure. A data breach is a major security incident, usually carried out by just hacking a simple network line. Increasing your network’s security helps step up your defenses against cyber attacks. Meanwhile, Python is being used for increasingly advanced tasks, with the latest update introducing many new packages. This book focuses on leveraging these updated packages to build a secure network with the help of Python scripting. This book covers topics from building a network to the different procedures you need to follow to secure it. You’ll first be introduced to different packages and libraries, before moving on to different ways to build a network with the help of Python scripting. Later, you will learn how to check a network’s vulnerability using Python security scripting, and understand how to check vulnerabilities in your network. As you progress through the chapters, you will also learn how to achieve endpoint protection by leveraging Python packages along with writing forensic scripts. By the end of this book, you will be able to get the most out of the Python language to build secure and robust networks that are resilient to attacks.
Table of Contents (16 chapters)

What this book covers

Chapter 1, Working with Python Scripting, introduces you to the Python language, object-oriented programming, data structures, a methodology for developing with Python, and development environments.

Chapter 2, System Programming Packages, teaches you about the main Python modules for system programming, looking at topics inclusing reading and writing files, threads, sockets, multithreading, and concurrency.

Chapter 3, Sockets Programming, gives you some basics on Python networking using the socket module. The socket module exposes all of the necessary pieces to quickly write TCP and UDP clients, as well as servers for writing low-level network applications.

Chapter 4, HTTP Programming, covers the HTTP protocol and the main Python modules, such as the urllib standard library and the requests package. We also cover HTTP authentication mechanisms and how we can manage them with the requests module.

Chapter 5, Analyzing Network Traffic, gives you some basics on analyzing network traffic in Python using Scapy. An investigator can write Scapy scripts to investigate either real-time traffic by sniffing a promiscuous network interface, or load previously captured pcap files.

Chapter 6, Gathering Information from Servers, explores the modules that allow the extraction of information that the servers publicly expose, such as Shodan. We also look at getting servers banners and information on DNS servers, and introduce you to fuzzing processing.

Chapter 7, Interacting with FTP, SSH, and SNMP Servers, details the Python modules that allow us to interact with FTP, SSH, and SNMP servers.

Chapter 8, Working with Nmap Scanner, introduces Nmap as port scanner and covers how to implement network scanning with Python and Nmap to gather information on a network, a specific host, and the services that are running on that host. Also, we cover the programming of routines to find possible vulnerabilities in a given network with Nmap scripts.

Chapter 9, Connecting with the Metasploit Framework, covers the Metasploit Framework as a tool to exploit vulnerabilities, and explores how to use the python-msfprc and pymetasploit modules.

Chapter 10, Interacting with Vulnerability Scanners, gets into Nessus and Nexpose as vulnerability scanners and gives you reporting tools for the main vulnerabilities that can be found in servers and web applications with them. Also, we cover how to use them programmatically from Python with the nessrest and Pynexpose modules.

Chapter 11, Identifying Server Vulnerabilities in Web Applications, covers the main vulnerabilities in web applications with OWASP methodology and the tools we can find in the Python ecosystem for vulnerability scanning in web applications. We also we cover testing openSSL vulnerabilities in servers.

Chapter 12, Extracting Geolocation and Metadata from Documents, Images, and Browsers, explores the main modules we have in Python for extracting information about geolocation and metadata from images and documents, identifying web technologies, and extracting metadata from Chrome and Firefox.

Chapter 13, Cryptography and Steganography, dives into the main modules we have in Python for encrypting and decrypting information, such as pycrypto and cryptography. Also, we cover steganography techniques and how to hide information in images with the stepic module.