Learning Penetration Testing with Python
eBook - ePub

Learning Penetration Testing with Python

  1. 314 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Learning Penetration Testing with Python

About this book

Utilize Python scripting to execute effective and efficient penetration tests

About This Book

  • Understand how and where Python scripts meet the need for penetration testing
  • Familiarise yourself with the process of highlighting a specific methodology to exploit an environment to fetch critical data
  • Develop your Python and penetration testing skills with real-world examples

Who This Book Is For

If you are a security professional or researcher, with knowledge of different operating systems and a conceptual idea of penetration testing, and you would like to grow your knowledge in Python, then this book is ideal for you.

What You Will Learn

  • Familiarise yourself with the generation of Metasploit resource files
  • Use the Metasploit Remote Procedure Call (MSFRPC) to automate exploit generation and execution
  • Use Python's Scapy, network, socket, office, Nmap libraries, and custom modules
  • Parse Microsoft Office spreadsheets and eXtensible Markup Language (XML) data files
  • Write buffer overflows and reverse Metasploit modules to expand capabilities
  • Exploit Remote File Inclusion (RFI) to gain administrative access to systems with Python and other scripting languages
  • Crack an organization's Internet perimeter
  • Chain exploits to gain deeper access to an organization's resources
  • Interact with web services with Python

In Detail

Python is a powerful new-age scripting platform that allows you to build exploits, evaluate services, automate, and link solutions with ease. Python is a multi-paradigm programming language well suited to both object-oriented application development as well as functional design patterns. Because of the power and flexibility offered by it, Python has become one of the most popular languages used for penetration testing.

This book highlights how you can evaluate an organization methodically and realistically. Specific tradecraft and techniques are covered that show you exactly when and where industry tools can and should be used and when Python fits a need that proprietary and open source solutions do not.

Initial methodology, and Python fundamentals are established and then built on. Specific examples are created with vulnerable system images, which are available to the community to test scripts, techniques, and exploits. This book walks you through real-world penetration testing challenges and how Python can help.

From start to finish, the book takes you through how to create Python scripts that meet relative needs that can be adapted to particular situations. As chapters progress, the script examples explain new concepts to enhance your foundational knowledge, culminating with you being able to build multi-threaded security tools, link security tools together, automate reports, create custom exploits, and expand Metasploit modules.

Style and approach

This book is a practical guide that will help you become better penetration testers and/or Python security tool developers. Each chapter builds on concepts and tradecraft using detailed examples in test environments that you can simulate.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

Information

Learning Penetration Testing with Python


Table of Contents

Learning Penetration Testing with Python
Credits
Disclaimer
About the Author
Acknowlegements
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Understanding the Penetration Testing Methodology
An overview of penetration testing
Understanding what penetration testing is not
Vulnerability assessments
Reverse engineering engagements
Hacking
Assessment methodologies
The penetration testing execution standard
Pre-engagement interactions
White Box Testing
Grey Box Testing
Black Box Testing
Double Blind Testing
Intelligence gathering
Threat modeling
Vulnerability analysis
Exploitation
Post exploitation
Reporting
An example engagement
Penetration testing tools
NMAP
Metasploit
Veil
Burp Suite
Hydra
John the Ripper
Cracking Windows passwords with John
oclHashcat
Ophcrack
Mimikatz and Incognito
SMBexec
Cewl
Responder
theHarvester and Recon-NG
pwdump and fgdump
Netcat
Sysinternals tools
Summary
2. The Basics of Python Scripting
Understanding the difference between interpreted and compiled languages
Python – the good and the bad
A Python interactive interpreter versus a script
Environmental variables and PATH
Understanding dynamically typed languages
The first Python script
Developing scripts and identifying errors
Reserved words, keywords, and built-in functions
Global and local variables
Understanding a namespace
Modules and imports
Python formatting
Indentation
Python variables
Debugging variable values
String variables
Number variables
Converting string and number variables
List variables
Tuple variables
Dictionary variables
Understanding default values and constructors
Passing a variable to a string
Operators
Comparison operators
Assignment operators
Arithmetic operators
Logical and membership operators
Compound statements
The if statements
Python loops
The while loop
The for loop
The break condition
Conditional handlers
Functions
The impact of dynamically typed languages on functions on functions
Curly brackets
How to comment your code
The Python style guide
Classes
Functions
Variables and instance names
Arguments and options
Your first assessor script
Summary
3. Identifying Targets with Nmap, Scapy, and Python
Understanding how systems communicate
The Ethernet frame architecture
Layer 2 in Ethernet networks
Layer 2 in wireless networks
The IP packet architecture
The TCP header architecture
Understanding how TCP works
The TCP three-way handshake
The UDP header architecture
Understanding how UDP works
Understanding Nmap
Inputting the target ranges for Nmap
Executing the different scan types
Executing TCP full connection scans
Executing SYN scans
Executing ACK scans
Executing UDP scans
Executing combined UDP and TCP scans
Skipping the operating system scans
Different output types
Understanding the Nmap Grepable output
Understanding the Nmap XML output
The Nmap scripting engine
Being efficient with Nmap scans
Determining your interface details with the netifaces library
Nmap libraries for Python
The Scapy library for Python
Summary
4. Executing Credential Attacks with Python
The types of credential attacks
Defining the online credential attack
Defining the offline credential attack
Identifying the target
Creating targeted usernames
Generating and verifying usernames with help from the U.S. census
Generating the usernames
Testing for users using SMTP VRFY
Creating the SMTP VRFY script
Summary
5. Exploiting Services with Python
Understanding the new age of service exploitation
Understanding the chaining of exploits
Checking for weak, default, or known passwords
Gaining root access to the system
Understanding the cracking of Linux hashes
Testing for the synchronization of account credentials
Automating the exploit train with Python
Summary
6. Assessing Web Applications with Python
Identifying live applications versus open ports
Identifying hidden files and directories with Python
Credential attacks with Burp Suite
Using twill to walk through the source
Understanding when to use Python for web assessments
Understanding when to use specific libraries
Being efficient during web assessments
Summary
7. Cracking the Perimeter with Python
Understanding today's perimeter
Clear-text protocols
Web applications
Encrypted remote access services
Virtual Private Networks (VPNs)
Mail services
Domain Name Service (DNS)
User Datagram Protocol (UDP) services
Understanding the link between accounts and services
Cracking inboxes with Burp Suite
Identifying the attack path
Understanding the limitations of perimeter scanning
Downloading backup files from a TFTP server
Determining the backup filenames
Cracking Cisco MD5 hashes
Gaining access through websites
The execution of file inclusion attacks
Verifying an RFI vulnerability
Exploiting the hosts through RFI
Summary
8. Exploit Development with Python, Metasploit, and Immunity
Getting started with registers
Understanding general purpose registers
The EAX
The EBX
The ECX
The EDX
Understanding special purpose registers
The EBP
The EDI
The EIP
The ESP
Understanding the Windows memory structure
Understanding the stack and the heap
Understanding the program image and dynamic-link libraries
Understanding the process environment block
Understanding the thread environment block
Kernel
Understanding memory addresses and endianness
Understanding the manipulation of the stack
Understanding immunity
Understanding basic buffer overflow
Writing a basic buffer overflow exploit
Understanding stack adjustments
Understanding the purpose of local exploits
Understanding other exploit scripts
Exploiting standalone binaries by executing scripts
Exploiting systems by TCP service
Exploiting systems by UDP service
Reversing Metasploit modules
Understanding protection mechanisms
Summary
9. Automating Reports and Tasks with Python
Understanding how to parse XML files for reports
Understanding how to create a Python class
Creating a Python script to parse an Nmap XML
Creating a Python script to generate Excel spreadsheets
Summary
10. Adding Permanency to Python Tools
Understanding logging within Python
Understanding the difference between multithreading and multiprocessing
Creating a multithreaded script in Python
Creating a multiprocessing script in Python
Building industry-standard tools
Summary
Index

Learning Penetration Testing with Python

Copyright © 2015 ...

Table of contents

  1. Learning Penetration Testing with Python

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Learning Penetration Testing with Python by Christopher Duffy in PDF and/or ePUB format, as well as other popular books in Computer Science & Cyber Security. We have over one million books available in our catalogue for you to explore.