Advanced Penetration Testing for Highly-Secured Environments - Second Edition
By Lee Allen and Kevin Cardwell
()
About this ebook
About This Book
- Learn how to build your own pentesting lab environment to practice advanced techniques
- Customize your own scripts, and learn methods to exploit 32-bit and 64-bit programs
- Explore a vast variety of stealth techniques to bypass a number of protections when penetration testing
Who This Book Is For
This book is for anyone who wants to improve their skills in penetration testing. As it follows a step-by-step approach, anyone from a novice to an experienced security tester can learn effective techniques to deal with highly secured environments.
Whether you are brand new or a seasoned expert, this book will provide you with the skills you need to successfully create, customize, and plan an advanced penetration test.
What You Will Learn
- A step-by-step methodology to identify and penetrate secured environments
- Get to know the process to test network services across enterprise architecture when defences are in place
- Grasp different web application testing methods and how to identify web application protections that are deployed
- Understand a variety of concepts to exploit software
- Gain proven post-exploitation techniques to exfiltrate data from the target
- Get to grips with various stealth techniques to remain undetected and defeat the latest defences
- Be the first to find out the latest methods to bypass firewalls
- Follow proven approaches to record and save the data from tests for analysis
In Detail
The defences continue to improve and become more and more common, but this book will provide you with a number or proven techniques to defeat the latest defences on the networks. The methods and techniques contained will provide you with a powerful arsenal of best practices to increase your penetration testing successes.
The processes and methodology will provide you techniques that will enable you to be successful, and the step by step instructions of information gathering and intelligence will allow you to gather the required information on the targets you are testing. The exploitation and post-exploitation sections will supply you with the tools you would need to go as far as the scope of work will allow you. The challenges at the end of each chapter are designed to challenge you and provide real-world situations that will hone and perfect your penetration testing skills. You will start with a review of several well respected penetration testing methodologies, and following this you will learn a step-by-step methodology of professional security testing, including stealth, methods of evasion, and obfuscation to perform your tests and not be detected!
The final challenge will allow you to create your own complex layered architecture with defences and protections in place, and provide the ultimate testing range for you to practice the methods shown throughout the book. The challenge is as close to an actual penetration test assignment as you can get!
Style and approach
The book follows the standard penetration testing stages from start to finish with step-by-step examples. The book thoroughly covers penetration test expectations, proper scoping and planning, as well as enumeration and foot printing
Lee Allen
Born in South Wales, Lee Allen was writing from a young age, developing his fascination with mystery and thrillers. His debut Those Crimes of Passion was published in 2012, and he is currently working on his second novel.
Read more from Lee Allen
Advanced Penetration Testing for Highly-Secured Environments: The Ultimate Security Guide Rating: 5 out of 5 stars5/5Kali Linux – Assuring Security by Penetration Testing Rating: 3 out of 5 stars3/5The Little White Wolf Rating: 0 out of 5 stars0 ratingsHarbinger: A Jack O'Lantern Tale Rating: 0 out of 5 stars0 ratingsKali Linux 2 – Assuring Security by Penetration Testing - Third Edition Rating: 0 out of 5 stars0 ratingsThe Ghost Train Rating: 0 out of 5 stars0 ratingsWhispers from the Dead of Night - The Deluxe Collection Rating: 0 out of 5 stars0 ratingsWill o' the Wisp: A Jack O'Lantern Tale Rating: 0 out of 5 stars0 ratingsThose Crimes of Passion Rating: 0 out of 5 stars0 ratings
Related to Advanced Penetration Testing for Highly-Secured Environments - Second Edition
Related ebooks
Learning Penetration Testing with Python Rating: 0 out of 5 stars0 ratingsMastering Kali Linux for Advanced Penetration Testing Rating: 4 out of 5 stars4/5Web Penetration Testing with Kali Linux - Second Edition Rating: 0 out of 5 stars0 ratingsMastering the Nmap Scripting Engine Rating: 0 out of 5 stars0 ratingsMastering Metasploit Rating: 0 out of 5 stars0 ratingsNetcat Power Tools Rating: 3 out of 5 stars3/5Hacking Android Rating: 4 out of 5 stars4/5Metasploit Penetration Testing Cookbook Rating: 0 out of 5 stars0 ratingsKali Linux Wireless Penetration Testing Essentials Rating: 5 out of 5 stars5/5Kali Linux 2: Windows Penetration Testing Rating: 5 out of 5 stars5/5Mastering Python Forensics Rating: 4 out of 5 stars4/5Mastering Kali Linux for Advanced Penetration Testing - Second Edition Rating: 0 out of 5 stars0 ratingsKali Linux Web Penetration Testing Cookbook Rating: 0 out of 5 stars0 ratingsBuilding Virtual Pentesting Labs for Advanced Penetration Testing Rating: 0 out of 5 stars0 ratingsKali Linux Network Scanning Cookbook Rating: 0 out of 5 stars0 ratingsKali Linux Network Scanning Cookbook - Second Edition Rating: 0 out of 5 stars0 ratingsMetasploit Bootcamp Rating: 5 out of 5 stars5/5Hands-On Network Forensics: Investigate network attacks and find evidence using common network forensic tools Rating: 0 out of 5 stars0 ratingsPenetration Testing Bootcamp Rating: 5 out of 5 stars5/5Mastering Modern Web Penetration Testing Rating: 0 out of 5 stars0 ratingsKali Linux Intrusion and Exploitation Cookbook Rating: 5 out of 5 stars5/5Mastering Kali Linux for Web Penetration Testing Rating: 4 out of 5 stars4/5Penetration Tester's Open Source Toolkit Rating: 0 out of 5 stars0 ratingsPython Penetration Testing Essentials Rating: 5 out of 5 stars5/5Professional Penetration Testing: Volume 1: Creating and Learning in a Hacking Lab Rating: 4 out of 5 stars4/5Nmap 6: Network Exploration and Security Auditing Cookbook Rating: 0 out of 5 stars0 ratingsNmap A Complete Guide - 2021 Edition Rating: 0 out of 5 stars0 ratingsKali Linux Wireless Penetration Testing: Beginner's Guide Rating: 0 out of 5 stars0 ratingsBuilding Virtual Pentesting Labs for Advanced Penetration Testing - Second Edition Rating: 0 out of 5 stars0 ratings
Software Development & Engineering For You
Python For Dummies Rating: 4 out of 5 stars4/5How to Write Effective Emails at Work Rating: 4 out of 5 stars4/5Learning Python Rating: 5 out of 5 stars5/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Hand Lettering on the iPad with Procreate: Ideas and Lessons for Modern and Vintage Lettering Rating: 4 out of 5 stars4/5Beginning C++ Programming Rating: 3 out of 5 stars3/5Adobe Illustrator CC For Dummies Rating: 5 out of 5 stars5/5iOS App Development For Dummies Rating: 0 out of 5 stars0 ratingsLevel Up! The Guide to Great Video Game Design Rating: 4 out of 5 stars4/5Tiny Python Projects: Learn coding and testing with puzzles and games Rating: 5 out of 5 stars5/5Ry's Git Tutorial Rating: 0 out of 5 stars0 ratingsLearn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Lua Game Development Cookbook Rating: 0 out of 5 stars0 ratings27 PROGRAM MANAGEMENT INTERVIEW TECHNIQUES - To Ace That Dream Job Offer ! Rating: 5 out of 5 stars5/5Reversing: Secrets of Reverse Engineering Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsRESTful API Design - Best Practices in API Design with REST: API-University Series, #3 Rating: 5 out of 5 stars5/5PYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5Good Code, Bad Code: Think like a software engineer Rating: 5 out of 5 stars5/5Beginning Programming For Dummies Rating: 4 out of 5 stars4/5Engineering Management for the Rest of Us Rating: 5 out of 5 stars5/5Modern C++ for Absolute Beginners: A Friendly Introduction to C++ Programming Language and C++11 to C++20 Standards Rating: 0 out of 5 stars0 ratingsiPhone Application Development For Dummies Rating: 4 out of 5 stars4/5DevOps For Dummies Rating: 4 out of 5 stars4/5Android App Development For Dummies Rating: 0 out of 5 stars0 ratingsHow Do I Do That in Photoshop?: The Quickest Ways to Do the Things You Want to Do, Right Now! Rating: 4 out of 5 stars4/5OneNote: The Ultimate Guide on How to Use Microsoft OneNote for Getting Things Done Rating: 1 out of 5 stars1/5
Reviews for Advanced Penetration Testing for Highly-Secured Environments - Second Edition
0 ratings0 reviews
Book preview
Advanced Penetration Testing for Highly-Secured Environments - Second Edition - Lee Allen
Table of Contents
Advanced Penetration Testing for Highly-Secured Environments Second Edition
Credits
About the Authors
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the color images of this book
Errata
Piracy
Questions
1. Penetration Testing Essentials
Methodology defined
Example methodologies
Penetration testing framework
Penetration Testing Execution Standard
Pre-engagement interactions
Intelligence gathering
Threat modeling
Vulnerability analysis
Exploitation
Post-exploitation
Reporting
Abstract methodology
Final thoughts
Summary
2. Preparing a Test Environment
Introducing VMware Workstation
Why VMware Workstation?
Installing VMware Workstation
Network design
VMnet0
VMnet1
VMnet8
Folders
Understanding the default architecture
Installing Kali Linux
Creating the switches
Putting it all together
Installing Ubuntu LTS
Installing Kioptrix
Creating pfSense VM
Summary
3. Assessment Planning
Introducing advanced penetration testing
Vulnerability assessments
Penetration testing
Advanced penetration testing
Before testing begins
Determining scope
Setting limits – nothing lasts forever
Rules of Engagement documentation
Planning for action
Configuring Kali
Updating the applications and operating system
Installing LibreOffice
Effectively managing your test results
Introduction to MagicTree
Starting MagicTree
Adding nodes
Data collection
Report generation
Introduction to the Dradis framework
Exporting a project template
Importing a project template
Preparing sample data for import
Importing your Nmap data
Exporting data into HTML
Dradis Category field
Changing the default HTML template
Summary
4. Intelligence Gathering
Introducing reconnaissance
Reconnaissance workflow
DNS recon
nslookup – it's there when you need it
Default output
Changing nameservers
Creating an automation script
What did we learn?
Domain information groper
Default output
Zone transfers using Dig
Advanced features of Dig
Shortening the output
Listing the bind version
Reverse DNS lookup using Dig
Multiple commands
Tracing the path
Batching with dig
DNS brute-forcing with fierce
Default command usage
Creating a custom word list
Gathering and validating domain and IP information
Gathering information with Whois
Specifying which registrar to use
Where in the world is this IP?
Defensive measures
Using search engines to do your job for you
Shodan
Filters
Understanding banners
HTTP banners
Finding specific assets
Finding people (and their documents) on the web
Google hacking database
Google filters
Searching the Internet for clues
Creating network baselines with scanPBNJ
Metadata collection
Extracting metadata from photos using exiftool
Summary
5. Network Service Attacks
Configuring and testing our lab clients
Kali – manual ifconfig
Ubuntu – manual ifconfig
Verifying connectivity
Maintaining IP settings after reboot
Angry IP Scanner
Nmap – getting to know you
Commonly seen Nmap scan types and options
Basic scans – warming up
Other Nmap techniques
Remaining stealthy
Taking your time
Trying different scan types
SYN scan
Null scan
ACK scan
Conclusion
Shifting blame – the zombies did it!
IDS rules and how to avoid them
Using decoys
Adding custom Nmap scripts to your arsenal
Deciding if a script is right for you
Adding a new script to the database
Zenmap – for those who want the GUI
SNMP – a goldmine of information just waiting to be discovered
When the SNMP community string is NOT public
Network baselines with scanPBNJ
Setting up MySQL for PBNJ
Preparing the PBNJ database
First scan
Reviewing the data
Enumeration avoidance techniques
Naming conventions
Port knocking
Intrusion detection and avoidance systems
Trigger points
SNMP lockdown
Reader challenge
Summary
6. Exploitation
Exploitation – why bother?
Manual exploitation
Enumerating services
Quick scans with unicornscan
Full scanning with Nmap
Banner grabbing with Netcat and Ncat
Banner grabbing with Netcat
Banner grabbing with Ncat
Banner grabbing with smbclient
Searching Exploit-DB
Exploit-DB at hand
Compiling the code
Compiling proof-of-concept code
Troubleshooting the code
What are all of these ^M characters and why won't they go away?
Broken strings – the reunion
Running the exploit
Getting files to and from victim machines
Starting a TFTP server on Kali
Installing and configuring pure-ftpd
Starting pure-ftpd
Passwords – something you know…
Cracking the hash
Brute-forcing passwords
Metasploit – learn it and love it
Databases and Metasploit
Performing an nmap scan from within Metasploit
Using auxiliary modules
Using Metasploit to exploit Kioptrix
Reader challenge
Summary
7. Web Application Attacks
Practice makes perfect
Creating a KioptrixVM Level 3 clone
Installing and configuring Mutillidae on the Ubuntu virtual machine
Configuring pfSense
Configuring the pfSense DHCP server
Starting the virtual lab
pfSense DHCP – Permanent reservations
Installing HAProxy for load balancing
Adding Kioptrix3.com to the host file
Detecting load balancers
Quick reality check – Load Balance Detector
So, what are we looking for anyhow?
Detecting web application firewalls (WAF)
Taking on Level 3 – Kioptrix
Web Application Attack and Audit framework (w3af)
Using w3af GUI to save configuration time
Using a second tool for comparisons
Scanning using the w3af console
Using WebScarab as an HTTP proxy
Introduction to browser plugin HackBar
Reader challenge
Summary
8. Exploitation Concepts
Buffer overflows – a refresher
Memory basics
C
ing is believing – Create a vulnerable program
Turning ASLR on and off in Kali
Understanding the basics of buffer overflows
64-bit exploitation
Introducing vulnserver
Fuzzing tools included in Kali
Bruteforce Exploit Detector (BED)
sfuzz – Simple fuzzer
Social Engineering Toolkit
Fast-Track
Reader challenge
Summary
9. Post-Exploitation
Rules of Engagement
What is permitted?
Can you modify anything and everything?
Are you allowed to add persistence?
How is the data that is collected and stored handled by you and your team?
Employee data and personal information
Data gathering, network analysis, and pillaging
Linux
Important directories and files
Important commands
Putting this information to use
Enumeration
Exploitation
We are connected, now what?
Which tools are available on the remote system?
Finding network information
Determine connections
Checking installed packages
Package repositories
Programs and services that run at startup
Searching for information
History files and logs
Configurations, settings, and other files
Users and credentials
Moving the files
Microsoft Windows™ post-exploitation
Important directories and files
Using Armitage for post-exploitation
Enumeration
Exploitation
We are connected, now what?
Networking details
Finding installed software and tools
Pivoting
Reader challenge
Summary
10. Stealth Techniques
Lab preparation
Kali guest machine
Ubuntu guest machine
The pfSense guest machine configuration
The pfSense network setup
WAN IP configuration
LAN IP configuration
Firewall configuration
Stealth scanning through the firewall
Finding the ports
Traceroute to find out if there is a firewall
Finding out if the firewall is blocking certain ports
Hping3
Nmap firewalk script
Now you see me, now you don't – avoiding IDS
Canonicalization
Timing is everything
Blending in
PfSense SSH logs
Looking at traffic patterns
Cleaning up compromised hosts
Using a checklist
When to clean up
Local log files
Miscellaneous evasion techniques
Divide and conquer
Hiding out (on controlled units)
File Integrity Monitoring (FIM)
Using common network management tools to do the deed
Reader challenge
Summary
11. Data Gathering and Reporting
Record now – sort later
Old school – the text editor method
Nano
VIM –the power user's text editor of choice
Gedit – Gnome text editor
Dradis framework for collaboration
Binding to an available interface other than 127.0.0.1
The report
Reader challenge
Summary
12. Penetration Testing Challenge
Firewall lab setup
Installing additional packages in pfSense
The scenario
The virtual lab setup
AspenMLC Research Labs' virtual network
Additional system modifications
Ubuntu 8.10 server modifications
The challenge
The walkthrough
Defining the scope
Determining the why
So what is the why
of this particular test?
Developing the Rules of Engagement document
Initial plan of attack
Enumeration and exploitation
Reporting
Summary
Index
Advanced Penetration Testing for Highly-Secured Environments Second Edition
Advanced Penetration Testing for Highly-Secured Environments Second Edition
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: May 2012
Second edition: March 2016
Production reference: 1210316
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78439-581-0
www.packtpub.com
Credits
Authors
Lee Allen
Kevin Cardwell
Reviewer
S Boominathan
Commissioning Editor
Kartikey Pandey
Acquisition Editor
Subho Gupta
Content Development Editor
Mayur Pawanikar
Technical Editor
Murtaza Tinwala
Copy Editor
Charlotte Carneiro
Project Coordinator
Nidhi Joshi
Proofreader
Safis Editing
Indexer
Rekha Nair
Graphics
Jason Monteiro
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
About the Authors
Lee Allen is currently the vulnerability management program lead for one of the Fortune 500. Among many other responsibilities, he performs security assessments and penetration testing.
Lee is very passionate and driven about the subject of penetration testing and security research. His journey into the exciting world of security began back in the 80s, while visiting BBSs with his trusty Commodore 64 and a room carpeted with 5 ¼-inch floppy disks. Over the years, he has continued his attempts at remaining up to date with the latest and greatest in the security industry and the community. He has several industry certifications, including OSWP, and has been working in the IT industry for over 15 years. His hobbies include validating and reviewing proof-of-concept exploit code, programming, security research, attending security conferences, discussing technology, writing, and skiing.
He lives in Ohio with his wife, Kellie, and their 6 children, Heather, Kristina, Natalie, Mason, Alyssa, and Seth.
Kevin Cardwell currently works as a freelance consultant and provides consulting services for companies throughout the world, and as an advisor to numerous government entities in the USA, Middle East, Africa, Asia and the UK. He is an instructor, technical editor, and author for computer forensics and hacking courses. He is the author of the Center for Advanced Security and Training (CAST) Advanced Network Defense and Advanced Penetration Testing courses. He is a technical editor of the Learning Tree course, Penetration Testing Techniques and Computer Forensics. He has presented at the Black Hat USA, Hacker Halted, ISSA, and TakeDownCon conferences, as well as many others. He has chaired the cybercrime and cyber defense summit in Oman and was the executive chairman of the oil and gas cyber defense summit. He is the author of Building Virtual Pentesting Labs for Advanced Penetration Testing and Backtrack – Testing Wireless Network Security. He holds a BS in computer science from National University in California and an MS in software engineering from the Southern Methodist University (SMU) in Texas. He developed the strategy and training development plan for the first Government CERT in the country of Oman, which was recently rated as the top CERT in the Middle East. He serves as a professional training consultant to the Oman Information Technology Authority and developed the team to man the first Commercial Security Operations Center in Oman. He has worked extensively with banks and financial institutions throughout the Middle East, Europe, and the UK in the planning of a robust and secure architecture and implementing requirements to meet compliance. He currently provides consultancy to commercial companies, governments, federal agencies, major banks, and financial institutions throughout the globe. Some of his recent consulting projects include the Muscat Securities Market (MSM), Petroleum Development Oman, and the Central Bank of Oman. He designed and implemented the custom security baseline for the existing Oman Airport Management Company (OAMC) airports and the two new airports opening in 2016. He created custom security baselines for all of the Microsoft Operating Systems, Cisco devices, and other applications as well.
About the Reviewer
S Boominathan is a highly professional security expert with 4 plus years of experience in the field of information security, malware analysis, vulnerability assessment, and network and wireless pentesting. He is currently working with a bellwether of an Indian-based MNC company and is privileged to be doing so. He possesses certifications and knowledge in N+, CCNA, CCSA, CEHV8, CHFIV4, QCP (QualysGuard certified professional), and wireless pentesting expert.
I would like to thank my parents, Sundaram and Valli, my wife, Uthira, and my brother, Sriram, for helping throughout this book. I would like to thank the author and Packt Publishing for providing me with the opportunity to review this book.
www.PacktPub.com
eBooks, discount offers, and more
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Preface
Defenses continue to improve and become more and more common, but this book will provide you with a number of proven techniques to defeat the latest defenses on networks. The methods and techniques contained will provide you with a powerful arsenal of best practices to increase your penetration testing success. Many of the chapters end with a challenge to the reader that is designed to enhance and perfect their penetration testing skills.
What this book covers
Chapter 1, Penetration Testing Essentials, discusses why an essential element of penetration testing is planning, and a key component of this is having a methodology that emulates and matches the threat that we are portraying.
Chapter 2, Preparing a Test Environment, deals with the test environment, compares a number of different platforms, and prepares the reader for the foundation of building an advanced range for testing.
Chapter 3, Assessment Planning, talks about the test environment and how to evaluate the different platforms for your environment. The process of documenting and recording your testing results is covered, as well as methods to automate the process.
Chapter 4, Intelligence Gathering, reviews some of the tools and focuses on how to use the information to ensure your penetration tests are efficient, focused, and effective.
Chapter 5, Network Service Attacks, discusses how to successfully penetrate a secured environment and how to analyze what you are facing. The enumeration data gathered will assist in determining target prioritization and how to choose which targets are ideal candidates for your initial attacks.
Chapter 6, Exploitation, reviews the basics of exploitation and then moves on to the more interesting techniques and methods that will let us understand the true security posture of the network environment we are testing. Additionally, you will see the challenges of writing exploits today in 64-bit architectures.
Chapter 7, Web Application Attacks, explores various methods of testing web applications using freely available tools such as your web browser, w3af, WebScarab, and others. Methods of bypassing web application firewalls and IDSs are discussed as well how to determine if your targets are being load balanced or filtered.
Chapter 8, Exploitation Concepts, investigates methods that assist us in testing the effectiveness of a corporation's security awareness training and client-side protection mechanisms. The research performed during the information gathering stages of your testing will finally be used to the fullest extent. Furthermore, we look at some of the techniques and tools used by security researchers and crafty attackers to bypass even those system controls that at first glance seem theoretically sound.
Chapter 9, Post-Exploitation, covers the methods of conducting post-exploitation once you have compromised a machine and established a foothold in the environment. The process of extracting credentials, gathering data, and scraping the environment once access is gained is covered in detail.
Chapter 10, Stealth Techniques, reviews the challenges of penetrating firewalled environments, and methods of evading detection and blocks from the different endpoint protection mechanisms that may encounter during your testing.
Chapter 11, Data Gathering and Reporting, introduces the usage of tools and techniques that can make documenting the testing progress less painful and report writing easier, which is an essential but often overlooked component of penetration testing.
Chapter 12, Penetration Testing Challenge, allows you to put some of the information that has been covered throughout the book to work and bring it into perspective. The chapter provides preparation specifications for the practice environment and presents a challenge to the reader to perform a penetration test of this fictional company.
What you need for this book
You can use a virtual software platform of your choice, but the examples throughout the book use VMware Workstation Professional, the Kali 2.0 Linux distribution, and a number of other prebuilt virtual machine images, such as the Kioptrix and OWASP distributions. The iso images for pfsense firewall, Ubuntu 8, 14.04, Debian 4.0, CentOS 5.0, FreeBSD, and Windows Server 2003.
Who this book is for
This book is for anyone who wants to improve their skills in penetration testing. As it follows a step-by-step approach, anyone from a novice to an experienced security tester can learn effective techniques to deal with highly secured environments.
Whether you are brand new or a seasoned expert, this book will provide you with the skills you need to successfully create, customize, and plan an advanced penetration test.
Conventions
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: Aside from Oracle, another port of interest is the port 3306.
A block of code is set as follows:
You can change this template to suit your needs.
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
Not shown: 999 closed ports
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd/2.4.7 ((Ubuntu)) |_http-title: Site doesn't have a title (text/html)
TRACEROUTE
HOP RTT ADDRESS
Any command-line input or output is written as follows:
$ sudo -i # apt-get update # apt-get upgrade
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: Once you verified your settings, click on Apply | OK.
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <feedback@packtpub.com>, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Downloading the color images of this book
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/AdvancedPenetrationTestingforHighlySecuredEnvironmentsSecondEdition_ColoredImages.pdf.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <copyright@packtpub.com> with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
Questions
If you have a problem with any aspect of this book, you can contact us at <questions@packtpub.com>, and we will do our best to address the problem.
Chapter 1. Penetration Testing Essentials
In this chapter, we will discuss why an essential element of penetration testing is planning, and a key component of this is having a methodology that emulates and matches the threat that we are portraying. We will discuss the following:
The need for a methodology approach
Examples of different methodologies available
How to establish the testing methodology
If you have been performing penetration testing for some time and are very familiar with the methodology and concept of professional security testing, you can skip this chapter, or just skim it; however, you may learn something new or at least a different approach to how you approach penetration testing.
Methodology defined
What exactly is a methodology? This is a term that we use often in the Information Technology (IT) world, but what exactly does it mean? As you might expect, there are a number of different interpretations of this term that usually is dependent on whom you ask. If we use the search capability of the Internet, we can possibly get a better idea of what the term means. From the Wikipedia website, at https://en.wikipedia.org/wiki/Methodology, we see that the term is defined as a systematic, theoretical analysis of the methods applied to a field of study. This definition is a bit too vague for our purposes, so we will look at another source. The site at http://www.wisegeek.com defines the term as a set of practices.
This term may be used to refer to practices, which are widely used across an industry or scientific discipline, the techniques used in a particular research study, or the techniques used to accomplish a particular project."
This definition is closer to what we are looking for, but as with most definition sources, we will use their information as guidance and define the term in our own words. For the concept of this book, we look at a methodology as a systematic approach to professional security testing that follows a structured process based on the motives of a potential attacker when targeting an organization.
Example methodologies
In this section, we will take a look at a number of the testing methodologies that exist for us to use. This is by no means an exhaustive list, and you are encouraged to research the different references with respect to a methodology that exists. Additionally, we will not explore the methodologies in detail; for more, refer to the links that are listed with reference to each approach. The first methodology we will look at is the penetration testing framework.
Penetration testing framework
Before we discuss the framework, we will look at the Pre-site Inspection Checklist that is contained at the site that hosts the framework; this assessment consists of the following main steps:
Introduction: The essential element of this is the authority to work on the project. Remember, there is only one thing that separates the malicious hacker from the ethical one, and that is the written authorization the ethical hacker receives prior to doing any testing. Another component of this is the organization's testing background.
Accreditation status: This is where we list the status as to what type of test it is. That is, a pre-test, interim test, or a full test.
Scope of the test: The objective of this section is to determine what type of test you are actually doing, and it is broken into several different areas such as the stage of the lifecycle and test type. The stage we want to review is the test type. This is because this is the main component that we need when it comes to building our penetration testing methodology. This stage is broken down into the following categories:
Compliance test: There are a number of standards that are out there in the industry, and there are many of them that require some form of penetration testing. Your engagements might include verifying that a client is within the requirements of a selected standard. There are many different standards out there, and it is beyond the scope of the book to cover them. You are encouraged to research the different standards available and become familiar with them, in case it is a part of a future test.
Vulnerability assessment: According to the pre-inspection recommendation, when we refer to vulnerability assessment, we are looking for the flaws or weaknesses of a system, and we can further categorize this process as what type of credentials will be provided as part of the test.
Penetration testing: This is defined in the standard as a process when the state of the system, and/or network security, is likely subjected to an attack. Within this section, the standard defines the type of test, whether it is black (limited or not provided information from the target), grey (where the client provides with some specific information), and white (where the testing team is provided with as much information as possible). This is also where you work with the client to ensure that the scope of work is understood, since you have complete details of the client architecture.
An example of the web page for the framework is shown in the following image:
The framework starts with the identification of the network footprint to gather as much information as possible for the selected network. As with most methodologies, the step is broken down into two types, active and passive. The framework defines the active part of the reconnaissance as being intrusive and involves attempting zone transfers and other types of activity that will be detected and/or blocked by the Intrusion Detection System (IDS) and Intrusion Prevention System (IPS), respectively. Additionally, passive refers to the nonintrusive approach of testing. The framework lists a number of sites to assist with gathering the information. Many of these are covered by others, so we will not focus on them here; however, we will look at one site that combines a number of different tools: the http://www.centralops.net website. An example of this is shown in the following image:
As the image shows, there are a number of tools at the site, and you are encouraged to research them and identify the ones that you want to use as part of your professional security testing work. Two of the tools that you might want to take a look at are Domain Dossier and Email Dossier. Both of these tools will allow you to glean some important information about a domain and also an e-mail address. The following image is a cropped example of Email Dossier:
As with any of the sites within this chapter and throughout the book, there are a number of examples for you as the reader to explore and make decisions on your own as to which ones you want to use or not use. The important thing is to have a plan and practice it. This is so that, when you do go against targets, you have practiced it and examined how the different tools work and can recognize patterns when you are performing your testing; when you reach a point where there is something you do not recognize, take a break and think about it, and try harder to get past it. This is all the process of testing.
Another item that is useful in the framework is the examples for input validation. If you try and follow the link provided, it will result in a 404 error; but the examples that are in this section, are very good to follow and get information from. A brief example of this is shown in the following image:
This is just