Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Mastering Python for Networking and Security
Mastering Python for Networking and Security

Mastering Python for Networking and Security: Leverage Python scripts and libraries to overcome networking and security issues

Arrow left icon
Profile Icon José Manuel Ortega
Arrow right icon
$9.99 $39.99
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3 (2 Ratings)
eBook Sep 2018 426 pages 1st Edition
eBook
$9.99 $39.99
Paperback
$49.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon José Manuel Ortega
Arrow right icon
$9.99 $39.99
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3 (2 Ratings)
eBook Sep 2018 426 pages 1st Edition
eBook
$9.99 $39.99
Paperback
$49.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$9.99 $39.99
Paperback
$49.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Mastering Python for Networking and Security

System Programming Packages

Throughout this chapter, we will look at the main modules we can find in Python for working with the Python interpreter, the operating system, and executing commands. We will review how to work with the file system, reading, and creating files. Also, we'll review threads-management and other modules for multithreading and concurrency. We'll end this chapter with a review about the socket.io module for implementing asynchronous servers.

The following topics will be covered in this chapter:

  • Introducing system modules in Python
  • Working with the filesystem
  • Threads in Python
  • Multithreading and concurrency in Python
  • Python Socket.io

Technical requirements

Introducing system modules in python

Throughout this section, we'll explain the main modules you can find in Python for working with the Python interpreter, the operating system, and executing commands with the sub-procces module.

The system module

The sys module will allow us to interact with the interpreter and it contains most of the information related to the execution in progress, updated by the interpreter, as well as a series of functions and low-level objects.

sys.argv contains the list of parameters for executing a script. The first item in the list is the name of the script followed by the list of parameters.

We may, for example, want to parse command-line arguments at runtime. The sys.argv list contains all...

Working with the filesystem in Python

Throughout this section, we explain the main modules you can find in Python for working with the filesystem, accessing files and directories, reading and creating files, and operations with and without the context manager.

Accessing files and directories

In this section, we review how we can work with the filesystem and perform tasks such as browsing directories or reading each file individually.

Recursing through directories

In some cases, it is necessary to iterate recursively through the main directory to discover new directories...

Threads in Python

In this section, we are going to introduce the concept of threads and how we can manage them with Python modules.

Introduction to Threads

Threads are streams that can be scheduled by the operating system and can be executed across a single core in a concurrent way or in parallel way across multiple cores. Threads can interact with shared resources, such as memory, and they can also modify things simultaneously or even in parallel.

Types of threads

There are two distinct types of threads:

  • Kernel-level threads: Low-level threads, the user can not interact...

Multithreading and concurrency in Python

In this section, we are going to introduce the concepts of multithreading and concurrency and how we can manage them with python modules.

Introduction to Multithreading

The idea behind multithreading applications is that they allow us to have copies of our code and execute them on additional threads. This allows a program to execute multiple operations simultaneously. In addition, when a process is blocked, for example to wait for input/output operations, the operating system can allocate computation time to other processes.

When we mention multiprocess processors, we're referring to a processor that can execute multiple threads simultaneously. These typically have two or more...

Python Socket.io

In this section, we review how we can use the socket.io module to create a webserver based in Python.

Introducing WebSockets

WebSockets is a technology that offers realtime communication between a client and server through a TCP connection, and eliminates the need for customers to be continually checking whether API endpoints have updates or new content. Clients create a single connection to a WebSocket server and remain pending to listen for new events or messages from the server.

The main advantage of websockets is that they are more efficient as they reduce the network load and send information to a large number of clients in the form of messages.

...

Summary

In this chapter, we learned about the main system modules for python programming, such as os for working with the operating system, sys for working with the filesystem, and sub-proccess for executing commands. We also reviewed how to work with the filesystem, reading and creating files, managing threads, and concurrency.

In the next chapter, we will explore the socket package for resolving IP addresses and domains, and implement client and servers with TCP and UDP protocols.

Questions

  1. What is the main module that allows us to interact with the python interpreter?
  2. What is the main module that allows us to interact with the OS environment, filesystem, and permissions?
  3. What are the module and the method used to list the contents of the current working directory?
  4. What is the module to execute a command or invoke a process via the call() function?
  5. What is the approach that we can follow in python to handle files and manage exceptions in an easy and secure way?

  1. What is the difference between processes and threads?
  2. What are the main modules in python for creating and managing threads?
  3. What is the limitation that python has when working with threads?
  4. Which class provides a high-level interface for executing input/output tasks in an asynchronous way?
  5. What is the function in the threading module that determines which thread has performed?
...

Further reading

In these links, you will find more information about the mentioned tools and the official python documentation for some of the modules we discussed:

Readers interested in web server programming with technologies such aiohttp and asyncio should look to frameworks such as Flask (http://flask.pocoo.org) and Django (https://www.djangoproject.com).

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Learn to handle cyber attacks with modern Python scripting
  • Discover various Python libraries for building and securing your network
  • Understand Python packages and libraries to secure your network infrastructure

Description

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.

Who is this book for?

This book is ideal for network engineers, system administrators, or any security professional looking at tackling networking and security challenges. Programmers with some prior experience in Python will get the most out of this book. Some basic understanding of general programming structures and Python is required.

What you will learn

  • Develop Python scripts for automating security and pentesting tasks
  • Discover the Python standard library s main modules used for performing security-related tasks
  • Automate analytical tasks and the extraction of information from servers
  • Explore processes for detecting and exploiting vulnerabilities in servers
  • Use network software for Python programming
  • Perform server scripting and port scanning with Python
  • Identify vulnerabilities in web applications with Python
  • Use Python to extract metadata and forensics

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 28, 2018
Length: 426 pages
Edition : 1st
Language : English
ISBN-13 : 9781788990707
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Sep 28, 2018
Length: 426 pages
Edition : 1st
Language : English
ISBN-13 : 9781788990707
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 143.97
Mastering Python Networking
$54.99
Mastering Python for Networking and Security
$49.99
Python Automation Cookbook
$38.99
Total $ 143.97 Stars icon
Banner background image

Table of Contents

15 Chapters
Working with Python Scripting Chevron down icon Chevron up icon
System Programming Packages Chevron down icon Chevron up icon
Socket Programming Chevron down icon Chevron up icon
HTTP Programming Chevron down icon Chevron up icon
Analyzing Network Traffic Chevron down icon Chevron up icon
Gathering Information from Servers Chevron down icon Chevron up icon
Interacting with FTP, SSH, and SNMP Servers Chevron down icon Chevron up icon
Working with Nmap Scanners Chevron down icon Chevron up icon
Connecting with the Metasploit Framework Chevron down icon Chevron up icon
Interacting with the Vulnerabilities Scanner Chevron down icon Chevron up icon
Identifying Server Vulnerabilities in Web Applications Chevron down icon Chevron up icon
Extracting Geolocation and Metadata from Documents, Images, and Browsers Chevron down icon Chevron up icon
Cryptography and Steganography Chevron down icon Chevron up icon
Assessments Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
(2 Ratings)
5 star 50%
4 star 0%
3 star 0%
2 star 0%
1 star 50%
William Bussey Jan 07, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Ok, this is hands down one of the best python books I've purchased about security. I've always had questions about some of the OOP stuff as well as developing my own modules. This books explains everything in Barney style language so we can understand. Some great chapters on web app pentesting. Love this book
Amazon Verified review Amazon
oleg Feb 27, 2020
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
typos on every page. Level of English is so bad that sometimes it's hard to determine what the author really meant.A waste of time to try reading the book, though may be useful to glance through some topics to get an overview (that's what I actually did). Really bad quality of content.Partially that's probably because of the lack of editors.The Author himself is a professional and based on some youtube videos I saw, I think he is a professional in this field.But still someone reads a book because it usually gives a structured complete knowledge. That's what this book lacks. It's messy, with lots of repetitions, some explanations miss. Such books IMHO do not require Python general overview, so as it's anyway not even close to the level required to understand concepts. Makes more sens to throw overview away but give more details on main subjects. Like sockets (for me they are not described enough here so had to look somewhere else (like Brandon Rhodes, John Goerzen book)
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.