Learn Python and Ethical Hacking from Scratch

Video description

Are you intrigued by how hackers hack into any computer system easily? Do you want to develop the same skills, but not sure where to start? Don’t worry! This course has got you covered. By combining the power of Python and ethical hacking skills, this course shows you how to write Python programs to break into any computer system with ease.

The course starts with the fundamentals of ethical hacking and Python programming and guides you through the installation process of the software needed. Once the setup is ready, you will learn Python programming from scratch and start writing hacking programs without any delay. You will learn how a system works and find its weaknesses and will learn how to then write a Python program to exploit those weaknesses to hack the system.

To master the craft of hacking, you will learn to write ethical hacking programs from backdoors, keyloggers, credential harvesters, network hacking tools, website hacking tools, the list goes on. You will also have gained a deep understanding of how computer systems work and how to model problems, design an algorithm to solve problems, and implement solutions using Python.

By the end of this course, you will be well-versed with Python programming and will have developed the skills to write programs in Python to hack a system.

What You Will Learn

  • Become confident in writing programs in Python 2 and 3
  • Write a backdoor program that works on Windows, OS X, and Linux
  • Write a program that can discover vulnerabilities in websites
  • Convert malware to Trojans that take the form of an image or a PDF
  • Find out techniques to bypass anti-virus programs
  • Run dictionary attacks and guess login information on login pages


If you are new to ethical hacking or Python programming and are eager to learn to hack into systems by writing programs in Python, this course is for you.

No prior programming or hacking knowledge is needed to get started with this course.

About The Author

Zaid Sabih: Zaid Sabih is an ethical hacker, a computer scientist, and the founder and CTO of zSecurity. He has valuable experience in ethical hacking—he started working as a pentester with iSecurity. In 2013, he started teaching his first network hacking course—which received amazing feedback—leading him to publish a number of online ethical hacking courses, each focusing on a specific topic, all of which are dominating ethical hacking. Now, Zaid has more than 300,000 students worldwide.

Publisher resources

Download Example Code

Table of contents

  1. Chapter 1 : Introduction
    1. Introduction
    2. Teaser
    3. Introduction to Python Programming and Ethical Hacking
    4. Lab Overview
    5. Initial Preparation
    6. Installing Kali Linux as a VM on Windows
    7. Installing Kali Linux as a VM on Apple Mac OS
    8. Installing Kali Linux as a VM on Linux
    9. Basic Overview of Kali Linux
    10. Terminal and Linux Commands
    11. Python 2 Versus Python 3 and Writing Your First Program
    12. Installing and Using a Python Integrated Development Environment (IDE)
  2. Chapter 2 : Writing a Media Access Control (MAC) Address Changer - Python Basics
    1. What is Media Access Control (MAC) Address and How to Change it?
    2. Using Python Modules and Executing System Commands
    3. Implementing a very Basic Media Access Control (MAC) Changer
    4. Variables and Strings
    5. Using Variables in a Media Access Control (MAC) Changer
    6. Getting Input from the User
    7. Handling User Input
    8. Handling Command-Line Arguments
    9. Initializing Variables Based on Command-Line Arguments
    10. Functions in Python
    11. Returning Values from Functions
    12. Decision Making in Python
    13. Using Conditional Statements in Media Access Control (MAC) Changer
  3. Chapter 3 : Media Access Control (MAC) Changer - Algorithm Design
    1. What is an Algorithm?
    2. Reading Output Returned by System Commands
    3. Regular Expressions (Regex)
    4. Extracting a Substring Using Regex
    5. Refactoring and Housekeeping
    6. Implementing the Algorithm to Check the Media Access Control (MAC) Changer
    7. Python 3 Compatibility
  4. Chapter 4 : Programming a Network Scanner
    1. Introduction and Teaser
    2. Installing Windows as a Virtual Machine
    3. What is the Address Resolution Protocol (ARP) and What is it Used For?
    4. Designing an Algorithm to Discover Clients Connected to the Same Network
    5. Using Scapy to Create an Address Resolution Protocol (ARP) Request
    6. Combining Frames to Broadcast Packets
    7. Sending and Receiving Packets
    8. Introduction to Lists in Python
    9. Iterating over Lists and Analyzing Packet
    10. Using Escape Characters to Enhance Program Output
    11. Dictionaries
    12. Improving the Program Using a List of Dictionaries
    13. Iterating over Nested Data Structures
    14. Testing the Network Scanner With Python 3
  5. Chapter 5 : Writing an Address Resolution Protocol (ARP) Spoofer
    1. What is Address Resolution Protocol (ARP) Spoofing?
    2. Redirecting the Flow of Packets in a Network Using arpspoof
    3. Creating an Address Resolution Protocol (ARP) Response
    4. Sending Address Resolution Protocol (ARP) Responses
    5. Extracting Media Access Control (MAC) Address from Responses
    6. Loops
    7. More on Loops and Counters
    8. Dynamic Printing
    9. Handling Exceptions
    10. Implementing a Restore Function
    11. Restoring Address Resolution Protocol (ARP) Tables When an Exception Occurs
  6. Chapter 6 : Writing a Packet Sniffer
    1. Introduction and Teaser
    2. Sniffing Packets Using Scapy
    3. Extracting Data from a Specific Layer
    4. Analyzing Sniffed Packets and Extracting Fields from Layers
    5. Analyzing Fields and Extracting Passwords
    6. Extracting URLs
    7. Capturing Passwords from any Computer Connected to the Same Network
    8. Strings and Bytes in Python 3
  7. Chapter 7 : Writing a Domain Name Server (DNS) Spoofer
    1. Intercepting Packets - Creating a Proxy
    2. Converting Packets to Scapy Packets
    3. What is Domain Name Server (DNS) Spoofing?
    4. Filtering Domain Name Server (DNS) Responses
    5. Analyzing and Creating a Custom Domain Name Server (DNS) Response
    6. Modifying Packets on the Fly
    7. Redirecting Domain Name Server (DNS) Responses
  8. Chapter 8 : Writing a File Interceptor
    1. Introduction and Teaser
    2. Filtering Traffic Based on Port Used
    3. Analyzing HTTP Requests
    4. Intercepting HTTP Requests
    5. Modifying HTTP Responses on the Fly
    6. Intercepting and Replacing Downloads on the Network
  9. Chapter 9 : Writing a Code Injector
    1. Introduction and Teaser
    2. Analyzing HTTP Responses
    3. Replacing a Substring Using Regex
    4. Decoding HTTP Responses
    5. Modifying HTTP Responses and Injecting JavaScript Code in HTML Pages
    6. Refactoring and Housekeeping
    7. Debugging Issues
    8. Using Groups and Non-Capturing Regex
    9. Recalculating Content Length
    10. Browser Exploitation Framework (BeEF) Overview and Basic Hook Method
    11. Hooking Computers Using Code Injector
    12. Basic Browser Exploitation Framework (BeEF) Commands
    13. Delivering Malware Using the Browser Exploitation Framework (BeEF)
  10. Chapter 10 : Bypassing HTTPS
    1. How to Bypass HTTPS?
    2. Bypassing HTTPS and Sniffing Login Credentials
    3. Replacing Downloads on HTTPS Pages
    4. Injecting Code into HTTPS Pages
  11. Chapter 11 : Writing an Address Resolution Protocol (ARP) Spoof Detector
    1. Running Python Programs on Windows
    2. Capturing and Analyzing Address Resolution Protocol (ARP) Responses
    3. Detecting Address Resolution Protocol (ARP) Spoofing Attacks
  12. Chapter 12 : Writing Malware
    1. Introduction
    2. Executing a System Command Payload
    3. Sending Reports by Email
    4. Filtering Command Output Using Regex
    5. Stealing Wi-Fi Passwords Saved on a Computer
    6. Downloading Files from a Program
    7. Writing Files on a Disk
    8. Password Recovery Basics
    9. Using All the Above to Steal Saved Passwords Remotely
    10. Interacting with the File System
  13. Chapter 13 : Writing Malware - Keylogger
    1. Introduction and Teaser
    2. Writing a Basic Local Keylogger
    3. Global Variables
    4. Logging Special Keys
    5. Threading and Recursion
    6. Object-Oriented Programming (OOP) Basics
    7. Constructor Methods and Instance Variables
    8. Logging Keystrokes and Reporting Them by Email
  14. Chapter 14 : Writing Malware – Backdoors
    1. Introduction and Teaser
    2. Client-Server Communication and Connection Types
    3. Connecting Two Remote Computers Using Sockets
    4. Sending and Receiving Data over Transmission Control Protocol (TCP)
    5. Executing System Commands Remotely
    6. Implementing a Server
    7. Implementing Skeleton for Server-Client Communication
    8. Refactoring – Creating a Listener Class
    9. Refactoring – Creating a Backdoor Class
    10. Serialization – Theory
    11. Serialization - Implementing Reliable Methods to Send and Receive Data over Transmission Control Protocol (TCP)
    12. Serialization – Reliably Sending and Receiving Data
    13. Sending Commands as List and Implementing the Exit Command
    14. Interacting with the File System – Implementing the "cd" Command
    15. Reading Files
    16. Writing Files
    17. Downloading Files from a Hacked Computer
    18. Implementing Upload Functionality Using Listener
    19. Implementing Upload Functionality Using Backdoor
    20. Handling Unknown Exceptions
    21. Using the Backdoor to Hack Windows, Linux, and OS X
    22. Testing the Backdoors with Python 3.
  15. Chapter 15 : Writing Malware – Packaging
    1. Introduction and Teaser
    2. Converting Python Programs to Windows Binary Executables
    3. Running Executables Silently
    4. Installing Windows PyInstaller on Linux
    5. Packaging Programs for Windows from Linux
    6. Persistence Idea
    7. Running Programs on Startup
    8. Creating a Basic Trojan Using the Download and Execute Payload
    9. Creating a Trojan by Embedding Files in Program Code
    10. Bypassing Anti-Virus Programs – Theory
    11. Bypassing Anti-Virus Programs - Practical
    12. Adding an Icon to Generated Executables
    13. Spoofing File Extension
    14. Converting Python Programs to OS X Executables
    15. Converting Python Programs to Linux Executables
  16. Chapter 16 : Website/Web Application Hacking
    1. Introduction
    2. What is a Website?
    3. How to Hack a Website?
  17. Chapter 17 : Website Hacking - Writing a Crawler
    1. Sending GET Requests to Web Servers
    2. Discovering Subdomains
    3. Discovering Hidden Paths on Websites
    4. Reading Response Content
    5. Extracting Useful Data from Responses
    6. Filtering Results
    7. Extracting Unique Links and Storing Them in a List
    8. Recursively Discovering All Paths on a Target Website
    9. Testing the Crawler with Python 3
  18. Chapter 18 : Writing a Program to Guess Login Information
    1. Sending POST Requests for Websites
    2. Guessing Login Information on Login Pages
  19. Chapter 19 : Writing a Vulnerability Scanner
    1. Introduction and Teaser
    2. HTTP Requests – POST versus GET
    3. Parsing the HTML Code
    4. Extracting HTML Attributes
    5. Posting Forms
    6. Building Basic Structure for a Vulnerability Scanner
    7. Using Default Parameters
    8. Sending Requests in a Session
    9. Extracting and Submitting Forms Automatically
    10. Implementing a Method to Run the Scanner
    11. Discovering Cross-Site Scripting (XSS) Vulnerabilities
    12. Exploiting Cross-Site Scripting (XSS) Vulnerabilities
    13. Implementing Code to Discover Cross-Site Scripting (XSS) in Forms
    14. Implementing Code to Discover Cross-Site Scripting (XSS) in Parameters
    15. Automatically Discovering Vulnerabilities Using the Vulnerability Scanner

Product information

  • Title: Learn Python and Ethical Hacking from Scratch
  • Author(s): Zaid Sabih
  • Release date: October 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781839214561