Kali Linux Wireless Penetration Testing - Master Wireless Testing Techniques To Survey and Attack Wireless Networks With Kali Linux (PDFDrive) PDF
Kali Linux Wireless Penetration Testing - Master Wireless Testing Techniques To Survey and Attack Wireless Networks With Kali Linux (PDFDrive) PDF
info
Kali Linux Wireless Penetration
Testing Beginner's Guide
Vivek Ramachandran
Cameron Buchanan
BIRMINGHAM - MUMBAI
www.it-ebooks.info
Kali Linux Wireless Penetration Testing Beginner's Guide
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.
ISBN 978-1-78328-041-4
www.packtpub.com
www.it-ebooks.info
Credits
Technical Editor
Naveenkumar Jain
Copy Editor
Rashmi Sawant
www.it-ebooks.info
About the Authors
Vivek Ramachandran has been working on Wi-Fi Security since 2003. He discovered the
Caffe Latte attack and also broke WEP Cloaking, a WEP protection schema, publicly in 2007
at DEF CON. In 2011, he was the first to demonstrate how malware could use Wi-Fi to
create backdoors, worms, and even botnets.
Earlier, he was one of the programmers of the 802.1x protocol and Port Security in Cisco's
6500 Catalyst series of switches and was also one of the winners of the Microsoft Security
Shootout contest held in India among a reported 65,000 participants. He is best known in
the hacker community as the founder of SecurityTube.net, where he routinely posts videos
on Wi-Fi Security, assembly language, exploitation techniques, and so on. SecurityTube.net
receives over 100,000 unique visitors a month.
Vivek's work on wireless security has been quoted in BBC Online, InfoWorld, MacWorld,
The Register, IT World Canada, and so on. This year, he will speak or train at a number
of security conferences, including Blackhat, Defcon, Hacktivity, 44con, HITB-ML, BruCON
Derbycon, Hashdays, SecurityZone, SecurityByte, and so on.
I would like to thank my lovely wife for all her help and support during the
book-writing process. I would also like to thank my parents, grandparents,
and sister for believing in me and encouraging me for all these years, and
last but not least, I would like to thank all the users of SecurityTube.net who
have always been behind me and supporting all my work. You guys rock!
Cameron Buchanan is a penetration tester by trade and a writer in his spare time.
He has performed penetration tests around the world for a variety of clients across many
industries. Previously, he was a member of the RAF. He enjoys doing stupid things, such
as trying to make things fly, getting electrocuted, and dunking himself in freezing cold
water in his spare time. He is married and lives in London.
www.it-ebooks.info
About the Reviewer
I'd like to thank my family and Packt Publishing for giving me the
opportunity to review this book.
www.it-ebooks.info
www.PacktPub.com
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
[email protected] for more details.
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.
TM
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
www.it-ebooks.info
Disclaimer
The content within this book is for educational purposes only. It is designed to help users test
their own system against information security threats and protect their IT infrastructure from
similar attacks. Packt Publishing and the author of this book take no responsibility for actions
resulting from the inappropriate usage of learning material contained within this book.
www.it-ebooks.info
www.it-ebooks.info
Table of Contents
Preface v
Chapter 1: Wireless Lab Setup 1
Hardware requirements 2
Software requirements 2
Installing Kali 3
Time for action – installing Kali 3
Setting up the access point 5
Time for action – configuring the access point 5
Setting up the wireless card 8
Time for action – configuring your wireless card 8
Connecting to the access point 9
Time for action – configuring your wireless card 9
Summary 12
Chapter 2: WLAN and its Inherent Insecurities 13
Revisiting WLAN frames 14
Time for action – creating a monitor mode interface 16
Time for action – sniffing wireless packets 19
Time for action – viewing management, control, and data frames 22
Time for action – sniffing data packets for our network 26
Time for action – packet injection 28
Important note on WLAN sniffing and injection 29
Time for action – experimenting with your adapter 29
The role of regulatory domains in wireless 31
Time for action – experimenting with your adapter 31
Summary 36
[i]
www.it-ebooks.info
Table of Contents
[ ii ]
www.it-ebooks.info
Table of Contents
[ iii ]
www.it-ebooks.info
Table of Contents
[ iv ]
www.it-ebooks.info
Preface
Wireless Networks have become ubiquitous in today's world. Millions of people use it
worldwide every day at their homes, offices and public hotspots to logon to the Internet
and do both personal and professional work. Even though wireless makes life incredibly
easy and gives us such great mobility, it comes with risks. In recent times, insecure wireless
networks have been used to break into companies, banks and government organizations.
The frequency of these attacks is only intensified, as network administrators are still
clueless when it comes to securing wireless networks in a robust and fool proof way.
Kali Linux Wireless Penetration Testing Beginner's Guide is aimed at helping the reader
understand the insecurities associated with wireless networks, and how to conduct
penetration tests to find and plug them. This is an essential read for those who would like
to conduct security audits on wireless networks and always wanted a step-by-step practical.
As every wireless attack explained in this book is immediately followed by a practical demo,
the learning is very complete.
We have chosen Kali Linux as the platform to test all the wireless attacks in this book.
Backtrack, as most of you may already be aware, is the world's most popular penetration
testing distribution. It contains hundreds of security and hacking tools, some of which we
will use in this course of this book.
[v]
www.it-ebooks.info
Preface
Chapter 2, WLAN and its Inherent Insecurities: This chapter focuses on inherent design flaws in
wireless networks, that make insecure out-of-the-box. We will begin with a quick recap of the
802.11 WLAN protocols using a network analyzer called Wireshark. This will give us a practical
understanding about how these protocols work. Most importantly, we will see how client and
access point communication works at the packer level by analyzing Management, Control and
Data frames. We will then learn about packet injection and packer sniffing in wireless networks,
and look at some tools which enable us to do the same.
Chapter 3, Bypassing WLAN Authentication: Now we get into how to break WLAN
authentication mechanism! We will go step by step and explore how to subvert Open and
Shared Key authentications. In the course of this, you will learn how to analyse wireless
packets and figure out the authentication mechanism of the network. We will also look
at how to break into networks with Hidden SSID and MAC Filtering enabled. These are
two common mechanisms employed by network administrators to make wireless networks
more stealthy and difficult to penetrate; however, these are extremely simple to bypass.
Chapter 4, WLAN Encryption Flaws: One of the most vulnerable parts of the WLAN protocol
is the Encryption schemas – WEP, WPA and WPA2. Over the past decade hackers have found
multiple flaws in these schemas and have written publically available software to break them
and decrypt the data. Also, even though WPA/WPA2 is secure by design, misconfiguring
those opens up security vulnerabilities, that can be easily exploited. In this chapter, we will
understand the insecurities in each of these encryption schemas and do practical demos on
how to break them.
Chapter 5, Attacks on the WLAN Infrastructure: We will now shift our focus to WLAN
Infrastructure vulnerabilities. We will look at vulnerabilities created due to both configuration
and design problem. We will do practical demos of attacks such as access point MAC spoofing,
bit flipping and replay attacks, rogue access points, fuzzing and denial of services. This chapter
will give the reader a solid understanding of how to do a penetration test of the WLAN
infrastructure.
Chapter 6, Attacking the Client: This chapter might open your eyes if you always believed
that wireless client security was something you did not have to worry about! Most people
exclude the client from their list when they think about WLAN security. This chapter will
prove beyond doubt why the client is just as important as the access point when penetration
testing a WLAN network. We will look at how to compromise the security using client side
attacks such as Miss-Association, Caffe Latte, disassociation, ad-hoc connections, fuzzing,
honeypots and a host of others.
[ vi ]
www.it-ebooks.info
Preface
Chapter 7, Advanced WLAN Attacks: Now that we have already covered most of the basic
attacks on both the infrastructure and the client, we will look at more advanced attacks in
this chapter. These attacks typically involve using multiple basic attacks in conjunction to
break security in more challenging scenarios. Some of the attacks which we will learn include
wireless device fingerprinting, man-in-the-middle over wireless, evading wireless intrusion
detection and prevention systems, rogue access points operating using custom protocol and
a couple of others. This chapter presents the absolute bleeding edge in wireless attacks out
in the real world.
Chapter 8, Attacking WPA-Enterprise and RADIUS: This chapter graduates the user to
the next level by introducing him to advanced attacks on WPA-Enterprise and the RADIUS
server setup. These attacks will come in handy when the reader has to penetration test large
enterprise networks which rely on WPA-Enterprise and RADIUS authentication to provide
them with security. This is probably as advanced as Wi-Fi attacks can get in the real world.
Chapter 9, WLAN Penetrating Testing Methodology: This is where all the learning from the
previous chapters comes together, and we will look at how to do a wireless penetration test
in a systematic and methodical way. We will learn about the various phases of penetration
testing—Planning, Discovery, Attack and Reporting, and apply it to wireless penetration
testing. We will also understand how to propose recommendations and best practices after
a wireless penetration test.
Chapter 10, WPS and Probes: This chapter covers the two new attacks in the industry
that have developed since the initial publication of this book—WPS brute-force and
probe sniffing for monitoring.
As an alternate to the two laptops, you could also create a Virtual Machine housing Kali
Linux and connect the card to it over the USB interface. This will help you get started with
using this book much faster, but we would recommend a dedicated machine running Kali
Linux for actual assessments in the field.
[ vii ]
www.it-ebooks.info
Preface
Conventions
In this book, you will find a number of styles of text 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: "Open
a console terminal and type in iwconfig."
New terms and important words are shown in bold. Words that you see on the screen, in
menus or dialog boxes for example, appear in the text like this: "Boot the laptop with this
DVD and select the option Install from the Boot menu."
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this
book—what you liked or may have disliked. Reader feedback is important for us to
develop titles that you really get the most out of.
[ viii ]
www.it-ebooks.info
Preface
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 on 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.
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 would 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 on our website, or added to any list of existing errata, under the Errata
section of that title. Any existing errata can be viewed by selecting your title from
http://www.packtpub.com/support.
Piracy
Piracy of copyright 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.
We appreciate your help in protecting our authors, and our ability to bring you
valuable content.
Questions
You can contact us at [email protected] if you are having a problem with any
aspect of the book, and we will do our best to address it.
[ ix ]
www.it-ebooks.info
www.it-ebooks.info
Wireless Lab Setup
1
"If I had eight hours to chop down a tree, I'd spend six hours sharpening
my axe."
[1]
www.it-ebooks.info
Wireless Lab Setup
Hardware requirements
We will need the following hardware to set up the wireless lab:
Two laptops with internal Wi-Fi cards: We will use one of the laptops as the
victim in our lab and the other as the penetration tester's laptop. Though almost
any laptop would fit this profile, laptops with at least 3 GB RAM are desirable. This is
because we may be running a lot of memory-intensive software in our experiments.
One wireless adapter (optional): Depending on the wireless card of your laptop,
we may need a USB Wi-Fi card that can support packet injection and packet sniffing,
which is supported by Kali. The best choice seems to be the Alfa AWUS036H card
from Alfa Networks, as Kali supports this out-of-the-box. This is available on
www.amazon.com for a retail price of £18 at the time of writing. An alternative
option is the Edimax EW-7711UAN, which is smaller and, marginally, cheaper.
One access point: Any access point that supports WEP/WPA/WPA2 encryption
standards would fit the bill. I will be using a TP-LINK TL-WR841N Wireless router
for the purpose of illustration in this book. You can purchase it from Amazon.com
for a retail price of around £20 at the time of writing.
An Internet connection: This will come in handy for performing research,
downloading software, and for some of our experiments.
Software requirements
We will need the following software to set up the wireless lab:
Kali: This software can be downloaded from the official website located at
http://www.kali.org. The software is open source, and you should be
able to download it directly from the website.
Windows XP/Vista/7: You will need any one of Windows XP, Windows Vista,
or Windows 7 installed on one of the laptops. This laptop will be used as the
victim machine for the rest of the book.
[2]
www.it-ebooks.info
Chapter 1
Installing Kali
Let's now quickly take a look at how to get up-and-running with Kali.
Kali will be installed on the laptop that will serve as the penetration tester's machine
for the rest of the book.
Burn the Kali ISO (we are using the Kali 32-bit ISO) you downloaded onto a bootable DVD.
1. Boot the laptop with this DVD and select the option Install from the Boot menu:
[3]
www.it-ebooks.info
Wireless Lab Setup
2. If booting was successful, then you should see an awesome retro screen as follows:
3. This installer is similar to the GUI-based installers of most Linux systems and
should be simple to follow. Select the appropriate options in every screen and
start the installation process. Once the installation is done, restart the machine
as prompted and remove the DVD.
4. Once the machine restarts, a login screen will be displayed. Type in the login as
root and the password as whatever you set it to during the installation process.
You should now be logged into your installed version of Kali. Congratulations!
I will change the desktop theme and some settings for this book. Feel free to
use your own themes and color settings!
[4]
www.it-ebooks.info
Chapter 1
One of the other ways in which we can install and use Kali is via USB drives. This is
particularly useful if you do not want to install on the hard drive but still want to store
persistent data on your Kali instance, such as scripts and new tools. We encourage
you to try this out as well!
1. Power on the access point and use an Ethernet cable to connect your laptop to
one of the access point's Ethernet ports.
[5]
www.it-ebooks.info
Wireless Lab Setup
2. Enter the IP address of the access point configuration terminal in your browser. For
the TP-Link, it is by default 192.168.1.1. You should consult your access point's
setup guide to find its IP address. If you do not have the manuals for the access
point, you can also find the IP address by running the route –n command. The
gateway IP address is typically the access point's IP. Once you are connected, you
should see a configuration portal that looks like this:
3. Explore the various settings in the portal after logging in and find the settings
related to configuring a new SSID.
4. Change the SSID to Wireless Lab. Depending on the access point, you may
have to reboot it for the settings to change:
[6]
www.it-ebooks.info
Chapter 1
5. Similarly, find the settings related to Wireless Security and change the setting to
Disable Security. Disable Security indicates that it is using Open Authentication mode.
6. Save the changes to the access point and reboot it if required. Now your access
point should be up-and-running with an SSID Wireless Lab.
An easy way to verify this is to use the Wireless Configuration utility on Windows and
observe the available networks using the Windows laptop. You should find Wireless Lab
as one of the networks in the listing:
It is important to note that we configured our access point in Open mode, which is the
least secure. It is advisable not to connect this access point to the Internet for the time
being, as anyone within the RF range will be able to use it to access the Internet.
[7]
www.it-ebooks.info
Wireless Lab Setup
Have a go hero – configuring the access point to use WEP and WPA
Play around with the configuration options of your access point. Try to get it up-and-running
using encryption schemes such as WEP and WPA/WPA2. We will use these modes in later
chapters to illustrate attacks against them.
1. Plug in the card to one of the Kali laptop's USB ports and boot it.
Once you log in, open a console terminal and type in iwconfig. Your screen
should look as follows:
As you can see, wlan0 is the wireless interface created for the wireless adapter.
Type in ifconfig wlan0 to bring the interface up. Then, type in ifconfig
wlan0 to see the current state of the interface:
[8]
www.it-ebooks.info
Chapter 1
2. The MAC address 00:c0:ca:3e:bd:93 should match the MAC address written
under your Alfa card. I am using the Edimax that gives me the preceding MAC
address 80:1f:02:8f:34:d5. This is a quick check to ensure that you have
enabled the correct interface.
1. Let's first see what wireless networks our adapter is currently detecting. Issue
the command iwlist wlan0 scanning and you will find a list of networks in
your vicinity:
[9]
www.it-ebooks.info
Wireless Lab Setup
Keep scrolling down and you should find the Wireless Lab network in this list.
In my setup, it is detected as Cell 05; it may be different in yours. The ESSID
field contains the network name.
2. As multiple access points can have the same SSID, verify that the MAC address
mentioned in the preceding Address field matches your access point's MAC.
A fast and easy way to get the MAC address is underneath the access point or
using web-based GUI settings.
3. Now, issue the iwconfig wlan0 essid "Wireless Lab" command and then
iwconfig wlan0 to check the status. If you have successfully connected to the
access point, you should see the MAC address of the access point in the Access
Point: field in the output of iwconfig.
4. We know that the access point has a management interface IP address 192.168.0.1
from its manual. Alternately, this is the same as the default router IP address when we
run the route –n command. Let's set our IP address in the same subnet by issuing
the ifconfig wlan0 192.168.0.2 netmask 255.255.255.0 up command.
Verify the command succeeded by typing ifconfig wlan0 and checking the output.
5. Now let's ping the access point by issuing the ping 192.168.0.1 command. If the
network connection has been set up properly, then you should see the responses from
the access point. You can additionally issue an arp –a command to verify that the
response is coming from the access point. You should see that the MAC address of the
IP 192.168.0.1 is the access point's MAC address we noted earlier. It is important
to note that some of the more recent access points might have responses to Internet
Control Message Protocol (ICMP) echo request packets disabled. This is typically
done to make the access point secure out-of-the-box with only minimal configuration
settings available. In such a case, you can try to launch a browser and access the
web interface to verify that the connection is up-and-running:
[ 10 ]
www.it-ebooks.info
Chapter 1
Q2. Can we run all our experiments using the Kali live CD alone? Can we not install the CD
to the hard drive?
[ 11 ]
www.it-ebooks.info
Wireless Lab Setup
Summary
This chapter provided you with detailed instructions on how to set up your own wireless
lab. Also, in the process, you learned the basic steps for:
Installing Kali on your hard drive and exploring other options such as Virtual
Machines and USBs
Configuring your access point over the web interface
Understanding and using several commands to configure and use your
wireless card
Verifying the connection state between the wireless client and the
access point
It is important that you gain confidence in configuring the system. If you aren't confident,
it is advisable that you repeat the preceding examples a couple of times. In later chapters,
we will design more complicated scenarios.
In the next chapter, we will learn about inherent design-based insecurities in WLANs
design. We will use the network analyzer tool, Wireshark, to understand these concepts
in a practical way.
[ 12 ]
www.it-ebooks.info
WLAN and its Inherent Insecurities
2
"The loftier the building, the deeper the foundation must be laid."
Thomas Kempis
Nothing great can be built on a weak foundation, and in our context, nothing
secure can be built on something that is inherently insecure.
WLANs, by design, have certain insecurities that are relatively easy to exploit,
for example, by packet spoofing, packet injection, and sniffing (this could even
happen from far away). We will explore these flaws in this chapter.
[ 13 ]
www.it-ebooks.info
WLAN and its Inherent Insecurities
Let's now quickly review some basic concepts of WLANs that most of you may already
be aware of. In WLANs, communication happens over frames. A frame would have the
following header structure:
[ 14 ]
www.it-ebooks.info
Chapter 2
2. Control frames: Control frames are responsible for ensuring a proper exchange
of data between access points and wireless clients. Control frames can have the
following subtypes:
Request to Send (RTS)
Clear to Send (CTS)
Acknowledgement (ACK)
3. Data frames: Data frames carry the actual data that is sent on the wireless network.
There are no subtypes for data frames.
We will discuss the security implications of each of these frames when we discuss different
attacks in later chapters.
We will now look at how to sniff these frames over a wireless network using Wireshark.
There are other tools—such as Airodump-NG, Tcpdump, or Tshark—that you can use for
sniffing as well. We will, however, mostly use Wireshark in this book, but we encourage you
to explore other tools as well. The first step to do this is to create a monitor mode interface.
This will create an interface for our adapter, which allows us to read all wireless frames
in the air, regardless of whether they are destined for us or not. In the wired world, this is
popularly called promiscous mode.
[ 15 ]
www.it-ebooks.info
WLAN and its Inherent Insecurities
1. Boot Kali with your adapter connected. Once you are within the console, enter
iwconfig to confirm that your card has been detected and the driver has been
loaded properly.
2. Use the ifconfig wlan1 up command to bring the card up (where wlan1
is your adapter). Verify whether the card is up by running ifconfig wlan1.
You should see the word UP in the second line of the output as shown in the
following screenshot:
[ 16 ]
www.it-ebooks.info
Chapter 2
3. To put our card into monitor mode, we will use the airmon-ng utility that
is available by default on Kali. First run airmon-ng command to verify whether it
detects the available cards. You should see the wlan0 interface listed in the output:
[ 17 ]
www.it-ebooks.info
WLAN and its Inherent Insecurities
5. Also, running ifconfig mon0 should now display a new interface called mon0.
[ 18 ]
www.it-ebooks.info
Chapter 2
Awesome! We have a monitor mode interface just waiting to read some packets off the air.
So let's get started.
In the next exercise, we will use Wireshark to sniff packets off the air using the mon0
monitor mode interface we just created.
1. Power up the Access Point Wireless Lab that we configured in Chapter 1, Wireless
Lab Setup.
2. Start Wireshark by typing Wireshark & in the console. Once Wireshark is running,
navigate to Capture | Interfaces.
[ 19 ]
www.it-ebooks.info
WLAN and its Inherent Insecurities
3. Select packet capture from the mon0 interface by clicking on the Start button to
the right of the mon0 interface as shown in the previous screenshot. Wireshark will
begin the capture, and now you should see packets within the Wireshark window.
4. These are wireless packets that your wireless adapter is sniffing off the air.
In order to view any packet, select it in the top window and the entire packet
will be displayed in the middle window.
[ 20 ]
www.it-ebooks.info
Chapter 2
Click on the triangle in front of IEEE 802.11 Wireless LAN management frame to
expand and view additional information.
Look at the different header fields in the packet and correlate them with the WLAN frame
types and sub-types you have learned earlier.
[ 21 ]
www.it-ebooks.info
WLAN and its Inherent Insecurities
If you are unable to do this, don't worry as this is the next thing we will learn.
1. To view all the Management frames in the packets being captured, enter the filter
wlan.fc.type == 0 into the filter window and click Apply. You can stop the
packet capture if you want to prevent the packets from scrolling down too fast.
[ 22 ]
www.it-ebooks.info
Chapter 2
[ 23 ]
www.it-ebooks.info
WLAN and its Inherent Insecurities
5. Alternately, you can right-click on any of the header fields in the middle window and
then select Apply as Filter | Selected to add it as a filter.
[ 24 ]
www.it-ebooks.info
Chapter 2
6. This will automatically add the correct filter expression for you in the Filter field.
Also, we can see that the packet headers of Management, Control and Data frames are in
plain text and are not encrypted. Anyone who can sniff the packets can read these headers.
It is also important to note that it is also possible for a hacker to modify any of these packets
and re-transmit them. As there is no integrity or replay attack mitigation in the protocol, this
is very easy to do. We will look at some of these attacks in later chapters.
[ 25 ]
www.it-ebooks.info
WLAN and its Inherent Insecurities
In the next exercise, we will look at how to sniff data packets transferred between our access
point and wireless client.
1. Switch on the access point we named Wireless Lab. Let it remain configured
to use no encryption.
2. We will first need to find the channel on which the Wireless Lab access point is
running. To do this, open a terminal and run airodump-ng --bssid <mac>
mon0 where <mac>, which is the MAC address of our access point. Let the program
run, and shortly you should see your access point shown on the screen along with
the channel it is running on.
3. We can see from the preceding screenshot that our access point Wireless Lab is
running on Channel 11. Note that this may be different for your access point.
In order to sniff data packets going to and fro from this access point, we need to
lock our wireless card on the same channel, that is channel 11. To do this, run
the iwconfig mon0 channel 11 command and then run iwconfig mon0 to
verify it. You should see the Frequency: 2.462 GHz value in the output. This
corresponds to Channel 11.
[ 26 ]
www.it-ebooks.info
Chapter 2
4. Now fire up Wireshark and start sniffing on the mon0 interface. After Wireshark
has started sniffing the packets, apply a filter for the bssid of our access point as
shown below using wlan.bssid == <mac> in the filter area. Use the appropriate
MAC address for your access point.
5. In order to see the data packets for our access point, add the following to the filter
(wlan.bssid == <mac>) && (wlan.fc.type_subtype == 0x20). Open
your browser on the client laptop and type in the management interface the URL of
the access point. In my case, as we have seen in Chapter 1, Wireless Lab Setup, it is
http://192.168.0.1. This will generate data packets that Wireshark will capture.
6. Packet sniffing allows us to analyze unencrypted data packets very easily. This is
the reason why we need to use encryption in wireless.
[ 27 ]
www.it-ebooks.info
WLAN and its Inherent Insecurities
Also, try logging into www.gmail.com or any other popular website and analyze the data
traffic generated.
We will now see a demonstration of how to inject packets into a wireless network.
1. In order to do an injection test, first start Wireshark and the filter expression
(wlan.bssid == <mac>) && !(wlan.fc.type_subtype == 0x08).
This will ensure that we only see non-beacon packets for our lab network.
2. Now run the following command aireplay-ng -9 -e Wireless Lab -a <mac>
mon0 on a terminal.
3. Go back to Wireshark and you should see a lot of packets on the screen now.
Some of these packets have been sent by aireplay-ng, which we launched, and
others are from the access point Wireless Lab in response to the injected packets.
[ 28 ]
www.it-ebooks.info
Chapter 2
Another interesting aspect of Wi-Fi is that, in each of these bands, there are multiple channels.
It is important to note that your Wi-Fi card can only be on one channel at any given moment.
It is not possible to tune into multiple channels at the same time. The best analogy I can give
you is your car radio. You can tune it to only one of the available channels at any given time. If
you want to hear to something else, you will have to change the channel. The same principle
applies to WLAN Sniffing. This brings us to an important conclusion—we cannot sniff all
channels at the same time; we will need to select the channel that is of interest to us. What
this means is that, if our access point of interest is on channel 1, we will need to set our card
on channel 1.
Though we have addressed WLAN sniffing in the above paragraphs, the same applies to
injection as well. To inject packets on a specific channel, we will need to put the card radio
on that channel.
Let's now do some exercises on setting our card to specific channels, channel hopping,
setting regulatory domains, power levels etc.
1. Enter the iwconfig wlan0 command to check the capabilities of your card.
As you can see in the figure below, my adapter can operate in the b, g, and n bands.
[ 29 ]
www.it-ebooks.info
WLAN and its Inherent Insecurities
2. To set the card on a particular channel, we use the iwconfig mon0 channel X
commands.
3. The iwconfig series of commands does not have a channel hopping mode.
One could write a simple script over it to make it do so. An easier way is to use
Airodump-NG with options to either hop channels arbitrarily, use only a subset,
or use only selected bands. All these options are illustrated in the screenshot below
when we run airodump-ng --help:
[ 30 ]
www.it-ebooks.info
Chapter 2
Now let's look at how we can find the default regulatory settings and then how to change
them if required.
[ 31 ]
www.it-ebooks.info
WLAN and its Inherent Insecurities
Insert the adapter, and you should see something that resembles the following
screenshot. This shows the default regulatory settings applied to your card:
3. Let's assume that you are based in the US. To change your regulatory domain to
the US, we issue the command iw reg set US in a new terminal:
If the command is successful, we get an output such as the one in the following
screenshot in the terminal where we monitoring /var/log/messages:
[ 32 ]
www.it-ebooks.info
Chapter 2
4. Now try changing the card to channel 11; it will work. But, when you try changing
it to channel 12, you get an error. This is because channel 12, cannot be used in
the US.
[ 33 ]
www.it-ebooks.info
WLAN and its Inherent Insecurities
5. The same applies for power levels. The US only allows a maximum of 27 dBm
(500 milliwatts); thus even though my adapter has an advertised power of 1 Watt
(30 dBm), we cannot set the card to the maximum transmit power:
[ 34 ]
www.it-ebooks.info
Chapter 2
1. Control
2. Management
3. Data
4. QoS
Q2. What is the name of the second monitor mode interface that can be created on wlan0
using airmon-ng?
1. Mon0
2. Mon1
3. 1Mon
4. Monb
Q3. What is the filter expression to view all non-beacon frames in Wireshark?
1. !(wlan.fc.type_subtype == 0x08)
2. wlan.fc.type_subtype == 0x08
3. (no beacon)
4. Wlan.fc.type == 0x08
[ 35 ]
www.it-ebooks.info
WLAN and its Inherent Insecurities
Summary
In this chapter, we have made some key observations about WLAN protocols.
Management, Control and Data frames are unencrypted and thus can be easily read by
someone who is monitoring the airspace. It is important to note here that the data packet
payload can be protected using encryption to keep it confidential. We will talk about this
in the next chapter.
We can sniff the entire airspace in our vicinity by putting our card into monitor mode.
As there is no integrity protection in Management and Control frames, it is very easy to inject
these packets by modifying them or replaying them as-is using tools such as aireplay-ng.
Unencrypted data packets can also be modified and replayed back to the network. If the
packet is encrypted, we can still replay the packet as-is, as WLAN by design does not have
packet replay protection.
In the next chapter, we will look at different authentication mechanisms that are used in
WLANs such as MAC filtering and shared Authentication etc. and understand the various
security flaws in them through live demonstrations.
[ 36 ]
www.it-ebooks.info
Bypassing WLAN Authentication
3
"A false sense of security is worse than being unsure."
Anonymous
A false sense of security is worse than being insecure, as you may not be
prepared to face the eventuality of being hacked.
WLANs can have weak authentication schemas that can be easily broken and
bypassed. In this chapter, we will take a look at the various basic authentication
schemas used in WLANs and learn how to beat them.
[ 37 ]
www.it-ebooks.info
Bypassing WLAN Authentication
Hidden SSIDs
In the default configuration mode, all access points send out their SSIDs in Beacon frames.
This allows clients in the vicinity to discover them easily. Hidden SSIDs is a configuration
where the access point does not broadcast its SSID in Beacon frames. Thus, only clients that
know the SSID of the access point can connect to it.
Unfortunately, this measure does not provide robust security, but most network
administrators think it does. Hidden SSIDs should not be considered a security measure by
any stretch of the imagination. We will now take a look at how to uncover hidden SSIDs.
[ 38 ]
www.it-ebooks.info
Chapter 3
2. Configure your access point to set the Wireless Lab network as a hidden SSID.
The configuration option to do this may differ across access points. In my case, I
need to check the Invisible option in the Visibility Status option,
as shown in the following screenshot:
[ 39 ]
www.it-ebooks.info
Bypassing WLAN Authentication
3. Now if you take a look at the Wireshark trace, you will find that the SSID
Wireless Lab has disappeared from the Beacon frames. This is what hidden
SSIDs are all about:
[ 40 ]
www.it-ebooks.info
Chapter 3
4. In order to bypass Beacon frames, we will first use the passive technique of waiting
for a legitimate client to connect the access point. This will generate probe request
and probe response packets that will contain the SSID of the network, thus revealing
its presence:
[ 41 ]
www.it-ebooks.info
Bypassing WLAN Authentication
5. Alternately, you can use the aireplay-ng utility to send deauthentication packets
to all stations on behalf of the Wireless Lab access point by typing aireplay-ng
-0 5 -a <mac> --ignore-negative mon0, where <mac> is the MAC address
of the router. The -0 option is used to choose a deauthentication attack, and 5 is the
number of deauthentication packets to send. Finally, -a specifies the MAC address
of the access point you are targeting:
6. The preceding deauthentication packets will force all legitimate clients to disconnect
and reconnect. It would be a good idea to add a filter for deauthentication packets
to view them in an isolated way:
[ 42 ]
www.it-ebooks.info
Chapter 3
7. The probe responses from the access point will end up revealing its hidden SSID.
These packets will show up on Wireshark as shown next. Once the legitimate clients
connect back, we can see the hidden SSID using the probe request and probe
response frames. You can use the filter (wlan.bssid == 00:21:91:d2:8e:25) &&
!(wlan.fc.type_subtype == 0x08) to monitor all non-Beacon packets to and fro from
the access point. The && sign stands for the logical AND operator and the ! sign
stands for the logical NOT operator:
We will cover using probe requests for other purposes such as tracking in a later chapter.
In many cases, all clients may be already connected to the access point and there may be
no probe request/response packets available in the Wireshark trace. Here, we can forcibly
disconnect the clients from the access point by sending forged deauthentication packets
on the air. These packets will force the clients to reconnect back to the access point, thus
revealing the SSID.
[ 43 ]
www.it-ebooks.info
Bypassing WLAN Authentication
It is important to note that, even though we are illustrating many of these concepts using
Wireshark, it is possible to orchestrate these attacks with other tools, such as the aircrack-
ng suite as well. We encourage you to explore the entire aircrack-NG suite of tools and other
documentation located on their website at http://www.aircrack-ng.org.
MAC filters
MAC filters are an age-old technique used for authentication and authorization and have
their roots in the wired world. Unfortunately, they fail miserably in the wireless world.
The basic idea is to authenticate based on the MAC address of the client. The MAC filter is
an identification code assigned to a network interface; a router will be able to check this
code and compare it to a list of approved MACs. This list of allowed MAC addresses will be
maintained by the network administrator and will be fed into the access point. We will now
take a look at how easy it is to bypass MAC filters.
1. Let's first configure our access point to use MAC filtering and then add the client
MAC address of the victim laptop. The settings pages on my router looks as follows:
[ 44 ]
www.it-ebooks.info
Chapter 3
2. Once MAC filtering is enabled, only the allowed MAC address will be able to
successfully authenticate with the access point. If we try to connect to the access
point from a machine with a non-whitelisted MAC address, the connection will fail.
3. Behind the scenes, the access point is sending Authentication failure messages to
the client. The packet trace resembles the following:
[ 45 ]
www.it-ebooks.info
Bypassing WLAN Authentication
4. In order to beat MAC filters, we can use airodump-ng to find the MAC addresses
of clients connected to the access point. We can do this by issuing the airodump-
ng -c 11 -a --bssid <mac> mon0 command. By specifying the bssid
command, we will only monitor the access point, which is of interest to us. The -c
11 command sets the channel to 11 where the access point is. The -a command
ensures that, in the client section of the airodump-NG output, only clients
associated and connected to an access point are shown. This will show us all the
client MAC addresses associated with the access point:
5. Once we find a whitelisted client's MAC address, we can spoof the MAC address
of the client using the macchanger utility, which ships with BackTrack. You can use
the macchanger –m <mac> wlan0 command to get this done. The MAC address
you specify with the -m command option is the new spoofed MAC address for the
wlan0 interface:
6. As you can clearly see, we are now able to connect to the access point after spoofing
the MAC address of a whitelisted client.
[ 46 ]
www.it-ebooks.info
Chapter 3
You are encouraged to explore the different options of the airodump-NG utility by going
through the documentation on their website at http://www.aircrack-ng.org/doku.
php?id=airodump-ng.
Open Authentication
The term Open Authentication is almost a misnomer, as it actually provides no
authentication at all. When an access point is configured to use Open Authentication,
it will successfully authenticate all clients that connect to it.
1. We will first set our lab access point Wireless Lab to use Open Authentication.
On my access point, this is simply done by setting Security Mode to Disable Security:
[ 47 ]
www.it-ebooks.info
Bypassing WLAN Authentication
2. We then connect to this access point using the iwconfig wlan0 essid
Wireless Lab command and verify that the connection has succeeded
and that we are connected to the access point.
3. Note that we did not have to supply any username/password/passphrase to
get through Open Authentication.
The wireless client sends an authentication request to the access point, which responds
back with a challenge. The client now needs to encrypt this challenge with the shared key
and send it back to the access point, which decrypts this to check whether it can recover the
original challenge text. If it succeeds, the client successfully authenticates; if not, it sends an
authentication failed message.
[ 48 ]
www.it-ebooks.info
Chapter 3
The security problem here is that an attacker passively listening to this entire communication
by sniffing the air has access to both the plain text challenge and the encrypted challenge. He
can apply the XOR operation to retrieve the keystream. This keystream can be used to encrypt
any future challenge sent by the access point without needing to know the actual key.
The most common form of shared authentication is known as WEP or Wired Equivalent
Protocol. It is easy to break, and numerous tools have been created over time to facilitate
the cracking of WEP networks.
In this exercise, we will learn how to sniff the air to retrieve the challenge and the encrypted
challenge, retrieve the keystream, and use it to authenticate to the access point without
needing the shared key.
1. Let's first set up Shared Authentication for our Wireless Lab network. I have done
this on my access point by setting the security mode as WEP and Authentication as
Shared Key:
[ 49 ]
www.it-ebooks.info
Bypassing WLAN Authentication
2. Let's now connect a legitimate client to this network using the shared key we have
set in step 1.
3. In order to bypass Shared Key Authentication, we will first start sniffing packets
between the access point and its clients. However, we would also like to log the
entire shared authentication exchange. To do this, we use the airodump-ng
utility using the airodump-ng mon0 -c 11 --bssid <mac> -w keystream
command. The -w option, which is new here, requests Airodump-NG to store the
packets in a file whose name is prefixed with the word keystream. Incidentally, it
might be a good idea to store different sessions of packet captures in different files.
This allows you to analyze them long after the trace has been collected:
4. We can either wait for a legitimate client to connect to the access point or force
a reconnect using the deauthentication technique used previously. Once a client
connects and the shared key authentication succeeds, airodump-ng will capture
this exchange automatically by sniffing the air. An indication that the capture has
succeeded is when the AUTH column reads WEP.
5. The captured keystream is stored in a file prefixed with the words keystream file
in the current directory. In my case, the name of the file is keystream-01-00-21-
91-D2-8E-25.xor.
6. In order to fake a shared key authentication, we will use the aireplay-ng tool.
We run the aireplay-ng -1 0 -e "Wireless Lab" -y keystream-
01-00-21-91-D2-8E-25.xor -a <mac> -h AA:AA:AA:AA:AA:AA mon0
command. This aireplay-ng command uses the keystream we retrieved in
step 5 and tries to authenticate with the access point with SSID Wireless Lab and
MAC address 00:21:91:D2:8E:25, and uses an arbitrary client MAC address
AA:AA:AA:AA:AA:AA. Fire up Wireshark and sniff all packets of interest by
applying a wlan.addr == AA:AA:AA:AA:AA:AA filter. We can verify this using
Wireshark. You should see a trace on the Wireshark screen, as shown in the
following screenshot:
[ 50 ]
www.it-ebooks.info
Chapter 3
7. The first packet is the authentication request sent by the aireplay-ng tool to the
access point:
[ 51 ]
www.it-ebooks.info
Bypassing WLAN Authentication
8. The second packet consists of the access point sending the client challenge text,
as shown in the following screenshot:
9. In the third packet, the tool sends the encrypted challenge to the access point:
[ 52 ]
www.it-ebooks.info
Chapter 3
10. As the aireplay-ng tool used the derived keystream for encryption, the
authentication succeeds and the access point sends a success message in
the fourth packet:
11. After the authentication succeeds, the tool fakes an association with the access
point, which succeeds as well:
[ 53 ]
www.it-ebooks.info
Bypassing WLAN Authentication
12. If you check the wireless logs in your access point's administrative interface,
you should now see a wireless client with the MAC address AA:AA:AA:AA:AA:AA
connected:
[ 54 ]
www.it-ebooks.info
Chapter 3
Summary
In this chapter, we learnt about WLAN Authentication. Hidden SSIDs are a security-through-
obscurity feature and are is relatively simple to beat. MAC address filters do not provide
any security, as MAC addresses can be sniffed from the air from the wireless packets. This is
possible because the MAC addresses are unencrypted in the packet. Open Authentication
provides no real authentication at all. Shared Key Authentication is a bit tricky to beat but,
with the help of the right tools, we can derive the store and the keystream, using which it is
possible to answer all future challenges sent by the access point. The result is that we can
authenticate without needing to know the actual key.
In the next chapter, we will take a look at different WLAN encryption mechanisms—WEP,
WPA, and WPA2—and look at the insecurities that plague them.
[ 55 ]
www.it-ebooks.info
www.it-ebooks.info
WLAN Encryption Flaws
4
"640K is more memory than anyone will ever need."
[ 57 ]
www.it-ebooks.info
WLAN Encryption Flaws
WLAN encryption
WLANs transmit data over the air and thus there is an inherent need to protect data
confidentiality. This is best done using encryption. The WLAN committee (IEEE 802.11)
formulated the following protocols for data encryption:
In this chapter, we will take a look at each of these encryption protocols and demonstrate
various attacks against them.
WEP encryption
The WEP protocol was known to be flawed as early as 2000 but, surprisingly, it is still
continuing to be used and access points still ship with WEP enabled capabilities.
There are many cryptographic weaknesses in WEP and they were discovered by Walker,
Arbaugh, Fluhrer, Martin, Shamir, KoreK, and many others. Evaluation of WEP from a
cryptographic standpoint is beyond the scope of this book, as it involves understanding
complex math. In this section, we will take a look at how to break WEP encryption using
readily available tools on the BackTrack platform. This includes the entire aircrack-ng
suite of tools—airmon-ng, aireplay-ng, airodump-ng, aircrack-ng, and others.
The fundamental weakness in WEP is its use of RC4 and a short IV value that is recycled
every 224 frames. While this is a large number in itself, there is a 50 percent chance of four
reuses every 5,000 packets. To use this to our advantage, we generate a large amount of
traffic so that we can increase the likelihood of IVs that have been reused and thus compare
two cipher texts encrypted with the same IV and key.
Let's now first set up WEP in our test lab and see how we can break it.
[ 58 ]
www.it-ebooks.info
Chapter 4
1. Let's first connect to our access point Wireless Lab and go to the settings area that
deals with wireless encryption mechanisms:
[ 59 ]
www.it-ebooks.info
WLAN Encryption Flaws
2. On my access point, this can be done by setting the Security Mode to WEP. We will
also need to set the WEP key length. As shown in the following screenshot, I have
set WEP to use 128bit keys. I have set the default key to WEP Key 1 and the value in
hex to abcdefabcdefabcdefabcdef12 as the 128-bit WEP key. You can set this to
whatever you choose:
3. Once the settings are applied, the access point should now be offering WEP as the
encryption mechanism of choice. Let's now set up the attacker machine.
4. Let's bring up Wlan0 by issuing the following command:
ifconfig wlan0 up
[ 60 ]
www.it-ebooks.info
Chapter 4
6. This is done so as to create mon0, the monitor mode interface, as shown in the
following screenshot. Verify that the mon0 interface has been created using the
iwconfig command:
7. Let's run airodump-ng to locate our lab access point using the following command:
airodump-ng mon0
[ 61 ]
www.it-ebooks.info
WLAN Encryption Flaws
8. As you can see in the following screenshot, we are able to see the Wireless Lab
access point running WEP:
9. For this exercise, we are only interested in the Wireless Lab, so let's enter the
following command to only see packets for this network:
airodump-ng –bssid 00:21:91:D2:8E:25 --channel 11 --write
WEPCrackingDemo mon0
[ 62 ]
www.it-ebooks.info
Chapter 4
10. We will request airodump-ng to save the packets into a pcap file using the
--write directive:
[ 63 ]
www.it-ebooks.info
WLAN Encryption Flaws
11. Now let's connect our wireless client to the access point and use the WEP key as
abcdefabcdefabcdefabcdef12. Once the client has successfully connected,
airodump-ng should report it on the screen.
12. If you do an ls in the same directory, you will be able to see files prefixed with
WEPCrackingDemo-*, as shown in the following screenshot. These are traffic
dump files created by airodump-ng:
[ 64 ]
www.it-ebooks.info
Chapter 4
13. If you notice the airodump-ng screen, the number of data packets listed under
the #Data column is very few in number (only 68). In WEP cracking, we need a
large number of data packets, encrypted with the same key to exploit weaknesses
in the protocol. So, we will have to force the network to produce more data packets.
To do this, we will use the aireplay-ng tool:
[ 65 ]
www.it-ebooks.info
WLAN Encryption Flaws
14. We will capture ARP packets on the wireless network using Aireplay-ng and inject
them back into the network to simulate ARP responses. We will be starting Aireplay-
ng in a separate window, as shown in the next screenshot. Replaying these packets a
few thousand times, we will generate a lot of data traffic on the network. Even though
Aireplay-ng does not know the WEP key, it is able to identify the ARP packets by
looking at the size of the packets. ARP is a fixed header protocol; thus, the size of the
ARP packets can be easily determined and can be used to identify them even within
encrypted traffic. We will run aireplay-ng with the options that are discussed
next. The -3 option is for ARP replay, -b specifies the BSSID of our network, and -h
specifies the client MAC address that we are spoofing. We need to do this, as replay
attacks will only work for authenticated and associated client MAC addresses:
[ 66 ]
www.it-ebooks.info
Chapter 4
15. Very soon you should see that aireplay-ng was able to sniff ARP packets and
started replaying them into the network. If you encounter channel-related errors
as I did, append –ignore-negative-one to your command, as shown in the
following screenshot:
[ 67 ]
www.it-ebooks.info
WLAN Encryption Flaws
16. At this point, airodump-ng will also start registering a lot of data packets.
All these sniffed packets are being stored in the WEPCrackingDemo-* files that
we saw previously:
17. Now let's start with the actual cracking part! We fire up aircrack-ng with
the option WEPCRackingDemo-0*.cap in a new window. This will start the
aircrack-ng software and it will begin working on cracking the WEP key using
the data packets in the file. Note that it is a good idea to have Airodump-ng collect
the WEP packets, aireplay-ng do the replay attack, and aircrack-ng attempt
to crack the WEP key based on the captured packets, all at the same time. In this
experiment, all of them are open in separate windows.
[ 68 ]
www.it-ebooks.info
Chapter 4
18. Your screen should look like the following screenshot when aircrack-ng is
working on the packets to crack the WEP key:
[ 69 ]
www.it-ebooks.info
WLAN Encryption Flaws
19. The number of data packets required to crack the key is nondeterministic, but
generally in the order of a hundred thousand or more. On a fast network (or using
aireplay-ng), this should take 5-10 minutes at most. If the number of data
packets currently in the file is not sufficient, then aircrack-ng will pause, as
shown in the following screenshot, and wait for more packets to be captured; it will
then restart the cracking process:
[ 70 ]
www.it-ebooks.info
Chapter 4
20. Once enough data packets have been captured and processed, aircrack-ng
should be able to break the key. Once it does, it proudly displays it in the terminal
and exits, as shown in the following screenshot:
21. It is important to note that WEP is totally flawed and any WEP key (no matter how
complex) will be cracked by Aircrack-ng. The only requirement is that a large
enough number of data packets, encrypted with this key, are made available to
aircrack-ng.
[ 71 ]
www.it-ebooks.info
WLAN Encryption Flaws
Note that we can also fake an authentication to the access point using the Shared Key
Authentication bypass technique we learnt in the last chapter. This can come in handy if the
legitimate client leaves the network. This will ensure that we can spoof an authentication
and association and continue to send our replayed packets into the network.
Your challenge will be to fake an authentication and association using the Shared Key
Authentication bypass we learnt in the last chapter, while WEP cracking is going on. Log off
the legitimate client from the network and verify that you are still able to inject packets into
the network and whether the access point accepts and responds to them.
WPA/WPA2
WPA( or WPA v1 as it is referred to sometimes) primarily uses the TKIP encryption algorithm.
TKIP was aimed at improving WEP, without requiring completely new hardware to run it.
WPA2 in contrast mandatorily uses the AES-CCMP algorithm for encryption, which is much
more powerful and robust than TKIP.
Both WPA and WPA2 allow either EAP-based authentication, using RADIUS servers
(Enterprise) or a Pre-Shared key (PSK) (personal)-based authentication schema.
WPA/WPA2 PSK is vulnerable to a dictionary attack. The inputs required for this attack are
the four-way WPA handshake between client and access point, and a wordlist that contains
common passphrases. Then, using tools such as Aircrack-ng, we can try to crack the WPA/
WPA2 PSK passphrase.
[ 72 ]
www.it-ebooks.info
Chapter 4
The way WPA/WPA2 PSK works is that it derives the per-session key, called the Pairwise
Transient Key (PTK), using the Pre-Shared Key and five other parameters—SSID of Network,
Authenticator Nounce (ANounce), Supplicant Nounce (SNounce), Authenticator MAC
address (Access Point MAC), and Suppliant MAC address (Wi-Fi Client MAC). This key is
then used to encrypt all data between the access point and client.
An attacker who is eavesdropping on this entire conversation by sniffing the air can get
all five parameters mentioned in the previous paragraph. The only thing he does not have
is the Pre-Shared Key. So, how is the Pre-Shared Key created? It is derived by using the
WPA-PSK passphrase supplied by the user, along with the SSID. The combination of both of
these is sent through the Password-Based Key Derivation Function (PBKDF2), which outputs
the 256-bit shared key.
[ 73 ]
www.it-ebooks.info
WLAN Encryption Flaws
In a typical WPA/WPA2 PSK dictionary attack, the attacker would use a large dictionary of
possible passphrases with the attack tool. The tool would derive the 256-bit Pre-Shared key
from each of the passphrases and use it with the other parameters, described earlier, to
create the PTK. The PTK will be used to verify the Message Integrity Check (MIC) in one of
the handshake packets. If it matches, then the guessed passphrase from the dictionary was
correct; if not, it was incorrect.
Eventually, if the authorized network passphrase exists in the dictionary, it will be identified.
This is exactly how WPA/WPA2 PSK cracking works! The following figure illustrates the
steps involved:
In the next exercise, we will take a look at how to crack a WPA PSK wireless network. The
exact same steps will be involved in cracking a WPA2-PSK network using CCMP(AES) as well.
[ 74 ]
www.it-ebooks.info
Chapter 4
1. Let's first connect to our access point Wireless Lab and set the access point to use
WPA-PSK. We will set the WPA-PSK passphrase to abcdefgh so that it is vulnerable
to a dictionary attack:
2. We start airodump-ng with the following command so that it starts capturing and
storing all packets for our network:
airodump-ng –bssid 00:21:91:D2:8E:25 –channel 11 –write
WPACrackingDemo mon0"
[ 75 ]
www.it-ebooks.info
WLAN Encryption Flaws
3. Now we can wait for a new client to connect to the access point so that we can
capture the four-way WPA handshake, or we can send a broadcast deauthentication
packet to force clients to reconnect. We do the latter to speed things up. The same
thing can happen again with the unknown channel error. Again, use –-ignore-
negative-one. This can also require more than one attempt:
[ 76 ]
www.it-ebooks.info
Chapter 4
5. We can stop the airodump-ng utility now. Let's open up the cap file in Wireshark
and view the four-way handshake. Your Wireshark terminal should look like the
following screenshot. I have selected the first packet of the four-way handshake in
the trace file in the screenshot. The handshake packets are the one whose protocol
is EAPOL:
[ 77 ]
www.it-ebooks.info
WLAN Encryption Flaws
6. Now we will start the actual key cracking exercise! For this, we need a dictionary
of common words. Kali ships with many dictionary files in the metasploit folder
located as shown in the following screenshot. It is important to note that, in
WPA cracking, you are just as good as your dictionary. BackTrack ships with some
dictionaries, but these may be insufficient. Passwords that people choose depend
on a lot of things. This includes things such as which country users live in, common
names and phrases in that region the, security awareness of the users, and a host of
other things. It may be a good idea to aggregate country- and region-specific word
lists, when undertaking a penetration test:
[ 78 ]
www.it-ebooks.info
Chapter 4
7. We will now invoke the aircrack-ng utility with the pcap file as the input
and a link to the dictionary file, as shown in the following screenshot. I have used
nmap.lst , as shown in the terminal:
[ 79 ]
www.it-ebooks.info
WLAN Encryption Flaws
9. Please note that, as this is a dictionary attack, the prerequisite is that the passphrase
must be present in the dictionary file you are supplying to aircrack-ng. If the
passphrase is not present in the dictionary, the attack will fail!
[ 80 ]
www.it-ebooks.info
Chapter 4
As WPA-PSK is vulnerable to a dictionary attack, we feed the capture file that contains the
WPA four-way handshake and a list of common passphrases (in the form of a wordlist) to
Aircrack-ng. As the passphrase abcdefgh is present in the wordlist, Aircrack-ng is
able to crack the WPA-PSK shared passphrase. It is very important to note again that, in
WPA dictionary-based cracking, you are just as good as the dictionary you have. Thus, it is
important to compile a large and elaborate dictionary before you begin. Though BackTrack
ships with its own dictionary, it may be insufficient at times and might need more words,
especially taking into account the localization factor.
Also, set an uncommon passphrase that is not present in the dictionary and try
the attack again. You will now be unsuccessful in cracking the passphrase with both
Aircrack-ng and Cowpatty.
It is important to note that the same attack applies even to a WPA2 PSK network. I encourage
you to verify this independently.
[ 81 ]
www.it-ebooks.info
WLAN Encryption Flaws
We can speed this up by precalculating the Pre-Shared Key, also called the Pairwise Master
Key (PMK) in 802.11 standard parlance. It is important to note that, as the SSID is also used
to calculate the PMK, with the same passphrase and with a different SSID, we will end up
with a different PMK. Thus, the PMK depends on both the passphrase and the SSID.
In the next exercise, we will take a look at how to precalculate the PMK and use it for
WPA/WPA2 PSK cracking.
1. We can precalculate the PMK for a given SSID and wordlist using the genpmk tool
with the following command:
genpmk –f <chosen wordlist>–d PMK-Wireless-Lab –s "Wireless Lab
[ 82 ]
www.it-ebooks.info
Chapter 4
2. We now create a WPA-PSK network with the passphrase abcdefgh (present in the
dictionary we used) and capture a WPA-handshake for that network. We now use
Cowpatty to crack the WPA passphrase, as shown in the following screenshot:
It takes approximately 7.18 seconds for Cowpatty to crack the key, using the
precalculated PMKs.
3. We now use aircrack-ng with the same dictionary file, and the cracking
process takes over 22 minutes. This shows how much we are gaining because
of the precalculation.
[ 83 ]
www.it-ebooks.info
WLAN Encryption Flaws
4. In order to use these PMKs with aircrack-ng, we need to use a tool called
airolib-ng. We will give it the options airolib-ng, PMK-Aircrack
--import,and cowpatty PMK-Wireless-Lab, where PMK-Aircrack is the
aircrack-ng compatible database to be created and PMK-Wireless-Lab is the
genpmk compliant PMK database that we created previously.
5. We now feed this database to aircrack-ng and the cracking process speeds up
remarkably. We use the following command:
aircrack-ng –r PMK-Aircrack WPACrackingDemo2-01.cap
6. There are additional tools available on BackTrack such as Pyrit that can leverage
multi CPU systems to speed up cracking. We give the pcap filename with the -r
option and the genpmk compliant PMK file with the -i option. Even on the same
system used with the previous tools, Pyrit takes around 3 seconds to crack the key,
using the same PMK file created using genpmk.
In the next exercise, we will decrypt the WEP and WPA packets in the same trace file that we
captured over the air, using the keys we cracked.
[ 84 ]
www.it-ebooks.info
Chapter 4
1. We will decrypt packets from the WEP capture file we created earlier:
WEPCrackingDemo-01.cap. For this, we will use another tool in the Aircrack-ng
suite called airdecap-ng. We will run the following command, as shown in the
following screenshot, using the WEP key we cracked previously:
airdecap-ng -w abcdefabcdefabcdefabcdef12 WEPCrackingDemo-02.cap
[ 85 ]
www.it-ebooks.info
WLAN Encryption Flaws
3. WPA/WPA2 PSK will work in exactly the same way as with WEP, using
the airdecap-ng utility, as shown in the following screenshot, with the
following command:
airdecap-ng –p abdefg WPACrackingDemo-02.cap –e "Wireless Lab"
[ 86 ]
www.it-ebooks.info
Chapter 4
[ 87 ]
www.it-ebooks.info
WLAN Encryption Flaws
1. Use the iwconfig utility to connect to a WEP network, once you have the key. In a
past exercise, we broke the WEP key—abcdefabcdefabcdefabcdef12:
[ 88 ]
www.it-ebooks.info
Chapter 4
1. In the case of WPA, the matter is a bit more complicated. The iwconfig utility
cannot be used with WPA/WPA2 Personal and Enterprise, as it does not support
it. We will use a new tool called WPA_supplicant for this lab. To use WPA_
supplicant for a network, we will need to create a configuration file, as shown
in the following screenshot. We will name this file wpa-supp.conf:
2. We will then invoke the WPA_supplicant utility with the following options:
-D wext -i wlan0 –c wpa-supp.conf to connect to the WPA network we
just cracked. Once the connection is successful, WPA_supplicant will give you the
message: Connection to XXXX completed.
3. For both the WEP and WPA networks, once you are connected, you can use
dhcpclient to grab a DHCP address from the network by typing dhclient3 wlan0.
[ 89 ]
www.it-ebooks.info
WLAN Encryption Flaws
1. Deauthentication packet.
2. Associated packet.
3. Encrypted ARP packet.
4. None of the above.
1. Always.
2. Only if a weak key/passphrase is chosen.
3. Under special circumstances only.
4. Only if the access point runs old software.
1. Always.
2. Only if a weak key/passphrase is chosen.
3. If the client contains old firmware.
4. Even with no client connected to the wireless network.
Summary
In this chapter, we learnt about WLAN encryption. WEP is flawed and no matter what
the WEP key is, with enough data packet samples: it is always possible to crack WEP.
WPA/WPA2 is cryptographically un-crackable currently; however, under special
circumstances, such as when a weak passphrase is chosen in WPA/WPA2-PSK,
it is possible to retrieve the passphrase using dictionary attacks.
In the next chapter, we will take a look at different attacks on the WLAN infrastructure,
such as rogue access points, evil twins, bit-flipping attacks, and so on.
[ 90 ]
www.it-ebooks.info
Attacks on the WLAN Infrastructure
5
"Thus, what is of supreme importance in war is to attack the enemy's strategy"
In this chapter, we will attack the WLAN infrastructure's core! We will focus on
how we can penetrate into the authorized network using various new attack
vectors and lure authorized clients to connect to us, as an attacker.
The WLAN infrastructure is what provides wireless services to all the WLAN clients in a
system. In this chapter, we will take a look at the various attacks that can be conducted
against the infrastructure:
[ 91 ]
www.it-ebooks.info
Attacks on the WLAN Infrastructure
1. Let's first connect to our access point Wireless Lab and attempt to navigate to
the HTTP management interface. We see that the access point model is TP-Link
WR841N, as shown in the following screenshot:
2. From the manufacturer's website, we find the default account credentials for
admin are admin. We try this on the login page and we succeed in logging in.
This shows how easy it is to break into accounts with default credentials. We highly
encourage you to obtain the router's user manual online. This will allow you to
understand what you are dealing with during the penetration test and gives you
an insight into other configuration flaws you could check for:
[ 92 ]
www.it-ebooks.info
Chapter 5
[ 93 ]
www.it-ebooks.info
Attacks on the WLAN Infrastructure
deauthentication attack
Disassociation attack
CTS-RTS attack
Signal interference or spectrum jamming attack
In the scope of this book, we will discuss deauthentication attacks on the Wireless LAN
infrastructure using the following experiment:
1. Let's configure the Wireless Lab network to use Open Authentication and no
encryption. This will allow us to see the packets using Wireshark easily:
[ 94 ]
www.it-ebooks.info
Chapter 5
2. Let's connect a Windows client to the access point. We will see the connection in
the airodump-ng screen:
[ 95 ]
www.it-ebooks.info
Attacks on the WLAN Infrastructure
[ 96 ]
www.it-ebooks.info
Chapter 5
4. Note how the client gets disconnected from the access point completely. We can
verify this on the airodump-ng screen as well:
[ 97 ]
www.it-ebooks.info
Attacks on the WLAN Infrastructure
5. If we use Wireshark to see the traffic, you will notice a lot of deauthentication
packets over the air that we just sent:
[ 98 ]
www.it-ebooks.info
Chapter 5
We also sent out Broadcast deauthentication packets, which will ensure that no client in
the vicinity can successfully connect to our access point.
It is important to note that, as soon as the client is disconnected, it will try to connect back
once again to the access point, and thus the deauthentication attack has to be carried out
in a sustained way to have a full denial of service effect.
[ 99 ]
www.it-ebooks.info
Attacks on the WLAN Infrastructure
This is one of the easiest attacks to orchestrate but has the most devastating effect. This can
easily be used in the real world to bring a wireless network down on its knees.
Many wireless users may accidently connect to this malicious access point, thinking it is part
of the authorized network. Once a connection is established, the attacker can orchestrate a
man-in-the-middle attack and transparently relay traffic while eavesdropping on the entire
communication. We will take a look at how a man-in-the-middle attack is done in a later
chapter. In the real world, an attacker would ideally use this attack close to the authorized
network so that the user gets confused and accidently connects to the attacker's network.
An evil twin having the same MAC address as an authorized access point is even more
difficult to detect and deter. This is where access point MAC Spoofing comes in! In the next
experiment, we will take a look at how to create an evil twin, coupled with access point
MAC spoofing.
[ 100 ]
www.it-ebooks.info
Chapter 5
1. Use airodump-ng to locate the access point's BSSID and ESSID, which we would
like to emulate in the evil twin:
[ 101 ]
www.it-ebooks.info
Attacks on the WLAN Infrastructure
[ 102 ]
www.it-ebooks.info
Chapter 5
3. Using this information, we create a new access point with the same ESSID but a
different BSSID and MAC address using the airbase-ng command. Minor errors
may occur with newer releases:
[ 103 ]
www.it-ebooks.info
Attacks on the WLAN Infrastructure
4. This new access point also shows up in the airodump-ng screen.. It is important to
note that you will need to run airodump-ng in a new window with the following
command:
airodump-ng --channel 11 wlan0
[ 104 ]
www.it-ebooks.info
Chapter 5
6. As we are closer to this client, our signal strength is higher, and it connects to our
evil twin access point.
7. We can also spoof the BSSD and MAC address of the access point using the following
command:
airbase-ng –a <router mac> --essid "Wireless Lab" –c 11 mon0
[ 105 ]
www.it-ebooks.info
Attacks on the WLAN Infrastructure
9. Even airodump-ng is unable to discern that there are actually two different physical
access points on the same channel. This is the most potent form of the evil twin.
[ 106 ]
www.it-ebooks.info
Chapter 5
It is important to note that, in the case of the authorized access point using encryption such
as WEP/WPA, it might be more difficult to conduct an attack in which traffic eavesdropping
is possible. We will take a look at how to break the WEP key with just a client using the Caffe
Latte attack in a later chapter.
In the most common case, a rogue access point is set to Open Authentication and no
encryption. The rogue access point can be created in the following two ways:
[ 107 ]
www.it-ebooks.info
Attacks on the WLAN Infrastructure
1. Let's first bring up our rogue access point using airbase-ng and give it the
ESSID Rogue:
[ 108 ]
www.it-ebooks.info
Chapter 5
2. We now want to create a bridge between the Ethernet interface, which is part of the
authorized network, and our rogue access point interface. To do this, we will first
install bridge-utils files, create a bridge interface, and name it Wifi-Bridge.
The following screenshot shows the required commands in action:
apt-get install bridge-utils
brctl addbr Wifi-Bridge
[ 109 ]
www.it-ebooks.info
Attacks on the WLAN Infrastructure
3. We will then add both the Ethernet and the At0 virtual interface created by Airbase-
ng to this bridge:
brctl addif Wifi-Bridge eth0
brctl addif Wifi-Bridge ath0
[ 110 ]
www.it-ebooks.info
Chapter 5
4. We will then bring with these interfaces up to bring the bridge up with the
following commands:
ifconfig eth0 0.0.0.0 up
ifconfig ath0 0.0.0.0 up
[ 111 ]
www.it-ebooks.info
Attacks on the WLAN Infrastructure
[ 112 ]
www.it-ebooks.info
Chapter 5
6. Brilliant! We are done. Now, any wireless client connecting to our rogue access
point will have full access to the authorized network using the wireless-to-wired
Wifi-Bridge we just built. We can verify this by connecting a client to the rogue
access point. Once connected, if you are using Vista, your screen might look like
the following:
[ 113 ]
www.it-ebooks.info
Attacks on the WLAN Infrastructure
8. We can now access any host on the wired network from this wireless client using
this rogue access point. Next, we will ping the gateway on the wired network:
[ 114 ]
www.it-ebooks.info
Chapter 5
1. None.
2. WEP.
3. WPA.
4. WPA2.
Q2. What is the advantage of having the same MAC address as the authorized access point
in an evil twin?
Q4. What do rogue access points do and how can they be created?
[ 115 ]
www.it-ebooks.info
Attacks on the WLAN Infrastructure
Summary
In this chapter, we explored different ways to compromise the security of the Wireless
LAN infrastructure:
In the next chapter, we will take a look at different attacks on the wireless LAN client.
Interestingly, most administrators feel that the client has no security problems to
worry about. We will see how nothing could be furthers from the truth.
[ 116 ]
www.it-ebooks.info
Attacking the Client
6
"Security is just as strong as the weakest link."
Most penetration testers seem to give all their attention to the WLAN
infrastructure and don't give the wireless client even a fraction of that.
However, it is interesting to note that a hacker can gain access to the
authorized network by compromising a wireless client as well.
In this chapter, we will shift our focus from the WLAN infrastructure to the
wireless client. The client can be either a connected or isolated unassociated
client. We will take a look at the various attacks that can be used to target
the client.
[ 117 ]
www.it-ebooks.info
Attacking the Client
Silently monitor the probes and bring up a fake access point with the same ESSID
the client is searching for. This will cause the client to connect to the hacker
machine, thinking it is the legitimate network.
Create fake access points with the same ESSID as neighboring ones to persuade the
user to connect to him. Such attacks are very easy to conduct in coffee shops and
airports where a user might be looking to connect to a Wi-Fi connection.
Use recorded information to learn about the victim's movements and habits,
as we show in detail in a later chapter.
These attacks are called Honeypot attacks, because the hacker's access point is
mis-associated with the legitimate one.
In the next exercise, we will carry out both these attacks in our lab.
1. In the previous labs, we used a client that had connected to the Wireless Lab access
point. Let's switch on the client but not the actual Wireless Lab access point. Let's
now run airodump-ng mon0 and check the output. You will very soon find the
client to be in the not associated mode and probing for Wireless Lab and other
SSIDs in its stored profile:
[ 118 ]
www.it-ebooks.info
Chapter 6
2. To understand what is happening, let's run Wireshark and start sniffing on the mon0
interface. As expected, you might see a lot of packets that are not relevant to our
analysis. Apply a Wireshark filter to only display Probe Request packets from the
client MAC you are using:
[ 119 ]
www.it-ebooks.info
Attacking the Client
5. Within a minute or so, the client should connect to us automatically. This shows
how easy it is to have un-associated clients:
6. Now we will try it in competition with another router. We will create a fake access
point Wireless Lab in the presence of the legitimate one. Let's turn our access point
on to ensure that Wireless Lab is available to the client. For this experiment, we
have set the access point channel to 3. Let the client connect to the access point.
We can verify this from airodump-ng, as shown in the following screenshot:
[ 120 ]
www.it-ebooks.info
Chapter 6
7. Now let's bring up our fake access point with the SSID Wireless Lab:
8. Notice that the client is still connected to Wireless Lab, the legitimate access point:
[ 121 ]
www.it-ebooks.info
Attacking the Client
10. Assuming the signal strength of our fake access point Wireless Lab is stronger than
the legitimate one to the client, it connects to our fake access point instead of the
legitimate access point:
11. We can verify this by looking at the airodump-ng output to see the new
association of the client with our fake access point:
[ 122 ]
www.it-ebooks.info
Chapter 6
The Caffe Latte attack was invented by Vivek, one of the authors of this book, and was
demonstrated in Toorcon 9, San Diego, USA. The Caffe Latte attack is a WEP attack that
allows a hacker to retrieve the WEP key of the authorized network, using just the client.
The attack does not require the client to be anywhere close to the authorized WEP
network. It can crack the WEP key using just the isolated client.
In the next exercise, we will retrieve the WEP key of a network from a client using the
Caffe Latte attack.
[ 123 ]
www.it-ebooks.info
Attacking the Client
1. Let's first set up our legitimate access point with WEP for the network Wireless Lab
with the ABCDEFABCDEFABCDEF12 key in Hex:
[ 124 ]
www.it-ebooks.info
Chapter 6
2. Let's connect our client to it and verify that the connection is successful using
airodump-ng, as shown in the following screenshot:
3. Let's unplug the access point and ensure that the client is in the un-associated stage
and searches for the WEP network Wireless Lab.
4. Now we use airbase-ng to bring up an access point with Wireless Lab as the SSID,
with the parameters as shown here:
[ 125 ]
www.it-ebooks.info
Attacking the Client
5. As soon as the client connects to this access point, airbase-ng starts the
Caffe Latte attack, as shown here:
6. We now start airodump-ng to collect the data packets from this access point only, as
we did before in the WEP cracking scenario:
[ 126 ]
www.it-ebooks.info
Chapter 6
In basic terms, a WEP access point doesn't need to prove to a client that it knows the WEP
key in order to receive encrypted traffic. The first piece of traffic that will always be sent to
a router upon connecting to a new network will be an ARP request to ask for an IP.
The attack works by bit flipping and replaying ARP packets sent by the wireless client post
association with the fake access point created by us. These bit flipped ARP Request packets
cause more ARP response packets to be sent by the wireless client.
Bit-flipping takes an encrypted value and alters it to create a different encrypted value. In this
circumstance, we can take an encrypted ARP request and create an ARP response with a high
degree of accuracy. Once we send back a valid ARP response, we can replay this value over
and over again to generate the traffic we need to decrypt the WEP key.
Note that all these packets are encrypted using the WEP key stored on the client. Once we
are able to gather a large number of these data packets, aircrack-NG is able to recover
the WEP key easily.
In the next lab, we will send deauthentication packets to just the client and break an
established connection between the access point and the client.
[ 127 ]
www.it-ebooks.info
Attacking the Client
1. Let's first bring our access point Wireless Lab online again. Let's keep it running
on WEP to prove that, even with encryption enabled, it is possible to attack the
access point and client connection. Let's verify that the access point is up using
airodump-ng:
2. Let's connect our client to this access point and verify it with airodump-ng:
[ 128 ]
www.it-ebooks.info
Chapter 6
4. The client gets disconnected and tries to reconnect to the access point. We can
verify this using Wireshark just as we did earlier:
5. We have now seen that, even in the presence of WEP encryption, it is possible to
deauthenticate a client and disconnect it. The same is valid even in the presence
of WPA/WPA2. Let's now set our access point to WPA encryption and verify it:
[ 129 ]
www.it-ebooks.info
Attacking the Client
6. Let's connect our client to the access point and ensure that it is connected:
7. Let's now run aireplay-ng to disconnect the client from the access point:
[ 130 ]
www.it-ebooks.info
Chapter 6
More information on the Hirte attack is available on the Aircrack-ng website at http://
www.aircrack-ng.org/doku.php?id=hirte.
We will now use aircrack-ng to conduct a Hirte attack on the same client.
1. Create a WEP access point exactly as in the Caffe Latte attack using the airbase-ng
tool. The only additional option is the -N option instead of the -L option to launch
the Hirte attack:
3. Now, airodump-ng will start monitoring this network and storing the packets in
the Hirte-01.cap file:
[ 131 ]
www.it-ebooks.info
Attacking the Client
4. Once the roaming client connects to our Honeypot AP, the Hirte attack is
automatically launched by airbase-ng:
5. We start aircrack-ng as in the case of the Caffe Latte attack and eventually,
the key will be cracked.
The million dollar question is: Would it be possible to crack WPA-Personal with just the
client? No access point!
[ 132 ]
www.it-ebooks.info
Chapter 6
To crack WPA, we need the following four parameters from the four-way handshake—
Authenticator Nounce, Supplicant Nounce, Authenticator MAC, and Supplicant MAC. Now,
the interesting thing is that we do not need all of the four packets in the handshake to extract
this information. We can get this information with four packets; packets 1 and 2 or just packets
2 and 3.
In order to crack WPA-PSK, we will bring up a WPA-PSK Honeypot and, when the client
connects to us, only Message 1 and Message 2 will come through. As we do not know the
passphrase, we cannot send Message 3. However, Message 1 and Message 2 contain all
the information required to begin the key cracking process:
[ 133 ]
www.it-ebooks.info
Attacking the Client
3. Now when our roaming client connects to this access point, it starts the handshake
but fails to complete it after Message 2, as discussed previously; however, the data
required to crack the handshake has been captured.
4. We run the airodump-ng capture file through aircrack-ng with the same
dictionary file as before; eventually, the passphrase is cracked as before.
1. None
2. WEP
3. WPA
4. WPA2
[ 134 ]
www.it-ebooks.info
Chapter 6
1. Mis-Association attacks
2. Deauthentication attacks
3. Disassociation attacks
4. Both 2 and 3
Summary
In this chapter, we learned that even the wireless client is susceptible to attacks. These
include the Honeypot and other Mis-Association attacks; Caffe Latte attack to retrieve the
key from the wireless client; deauthentication and disassociation attacks causing a Denial
of service, Hirte attack as an alternative to retrieve the WEP key from a roaming client;
and, finally, cracking the WPA-Personal passphrase with just the client.
In the next chapter, we will use what we've learned so far to conduct various advanced
wireless attacks on both the client and infrastructure side. So, quickly flip the page to the
next chapter!
[ 135 ]
www.it-ebooks.info
www.it-ebooks.info
Advanced WLAN Attacks
7
"To know your enemy, you must become your enemy."
In this chapter, we will take a look at how we can conduct advanced attacks using what
we have learned so far. We will primarily focus on the man-in-the-middle attack (MITM),
which requires a certain amount of skill and practice to conduct successfully. Once we have
done this, we will use this MITM attack as a base from which to conduct more sophisticated
attacks such as Eavesdropping and session hijacking.
MITM attack
Wireless Eavesdropping using MITM
Session hijacking using MITM
[ 137 ]
www.it-ebooks.info
Advanced WLAN Attacks
A man-in-the-middle attack
MITM attacks are probably one of the most potent attacks on a WLAN system. There
are different configurations that can be used to conduct the attack. We will use the most
common one—the attacker is connected to the Internet using a wired LAN and is creating
a fake access point on his client card. This access point broadcasts an SSID similar to a local
hotspot in the vicinity. A user may accidently get connected to this fake access point (or can
be forced to via the higher signal strength theory we discussed in the previous chapters)
and may continue to believe that he is connected to the legitimate access point.
The attacker can now transparently forward all the user's traffic over the Internet using
the bridge he has created between the wired and wireless interfaces.
1. To create the man-in-the-middle attack setup, we will first create a soft access
point called mitm on the hacker laptop using airbase-ng. We run the following
command:
airbase-ng --essid mitm –c 11 mon0
2. It is important to note that airbase-ng, when run, creates an interface at0 (a tap
interface). Think of this as the wired-side interface of our software-based access
point mitm:
[ 138 ]
www.it-ebooks.info
Chapter 7
3. Let's now create a bridge on the hacker's laptop, consisting of the wired (eth0) and
wireless interface (at0). The succession of commands used for this is as follows:
brctl addbr mitm-bridge
brctl addif mitm-bridge eth0
brctl addif mitm-bridge at0
ifconfig eth0 0.0.0.0 up
ifconfig at0 0.0.0.0 up
4. We can assign an IP address to this bridge and check the connectivity with the
gateway. Please note that we can do this using DHCP as well. We can assign
an IP address to the bridge interface with the following command:
ifconfig mitm-bridge 192.168.0.199 up
We can then try pinging the gateway 192.168.0.1 to ensure that we are
connected to the rest of the network.
5. Let's now turn on IP forwarding in the kernel, so that routing and packet
forwarding can happen correctly, using the following command:
echo 1 > /proc/sys/net/ipv4/ip_forward
[ 139 ]
www.it-ebooks.info
Advanced WLAN Attacks
6. Now let's connect a wireless client to our access point mitm. It will automatically
get an IP address over DHCP (the server running on the wired-side gateway). The
client machine in this case receives the IP address 192.168.0.197. We can ping
the wired-side gateway 192.168.0.1 to verify connectivity:
7. We can see that the host responds to the ping requests, as shown here:
8. We can also verify that the client is connected by looking at the airbase-ng
terminal on the hacker's machine:
9. It is interesting to note here that, because all the traffic is being relayed from the
wireless interface to the wired-side, we have full control over the traffic. We can
verify this by starting Wireshark and sniffing on the at0 interface:
[ 140 ]
www.it-ebooks.info
Chapter 7
10. Let's now ping the gateway 192.168.0.1 from the client machine. We can see the
packets in Wireshark (apply a display filter for ICMP), even though the packets are
not destined for us. This is the power of man-in-the-middle attacks:
[ 141 ]
www.it-ebooks.info
Advanced WLAN Attacks
Please note that this configuration would require the use of two wireless cards on the
attacker's laptop.
Check whether you can conduct this attack using the in-built card on your laptop along
with the external one—bear in mind, you may not have the injection drives required for
this activity. This should be a good challenge!
The whole lab revolves around the principle that all the victim's traffic is now routed through
the attacker's computer. Thus, the attacker can eavesdrop on all the traffic sent to and from
the victim's machine wirelessly.
1. Replicate the entire setup as in the previous lab. Fire up Wireshark. Interestingly,
even the MITM-bridge shows up. This interface would allow us to peer into the
bridge traffic, if we wanted to:
[ 142 ]
www.it-ebooks.info
Chapter 7
2. Start sniffing on the at0 interface so that we can monitor all traffic sent and
received by the wireless client:
[ 143 ]
www.it-ebooks.info
Advanced WLAN Attacks
3. On the wireless client, open up any web page. In my case, the wireless access
point is also connected to LAN and I will open it up by using the address
http://192.168.0.1:
[ 144 ]
www.it-ebooks.info
Chapter 7
[ 145 ]
www.it-ebooks.info
Advanced WLAN Attacks
7. We can easily locate the HTTP post request that was used to send the password to
the wireless access point:
[ 146 ]
www.it-ebooks.info
Chapter 7
9. Expanding on the HTTP header, allows us to see that actually the password we entered
in plain text was not sent as is; instead, a hash has been sent. If we take a look at the
packet, labeled as number 64 in a screenshot on the previous page, we can see that a
request was made for /md5.js, which makes us suspect that it is a md5 hash of the
password. It is interesting to note here that this technique may be prone to a replay
attack if a cryptographic salt is not used on a per session basis in the creation of the
hash. We leave it as an exercise for the user to find out the details, as this is not part
of wireless security and hence beyond the scope of this book:
10. This shows how easy it is to monitor and eavesdrop on traffic sent by the client
during a man-in-the-middle attack.
Can you think of an intelligent display filter you could use with Wireshark to view all
Google searches made by the victim?
In this next example, we will take a look at DNS hijacking over wireless using the MITM setup.
Then, using DNS hijacking, we will hijack the browser session to https://www.google.com.
[ 147 ]
www.it-ebooks.info
Advanced WLAN Attacks
2. Apply a Wireshark filter for DNS and, as we can see, the victim is making DNS
requests for https://www.google.com:
[ 148 ]
www.it-ebooks.info
Chapter 7
3. In order to hijack the browser session, we will need to send fake DNS responses that
will resolve the IP address of https://www.google.com to the hacker machine's
IP address 192.168.0.199. The tool that we will use for this is called dnsspoof
and the syntax is as follows:
dnspoof –i mitm-bridge
4. Refresh the browser windows and now, as we can see through Wireshark, as soon
as the victim makes a DNS request for any host (including google.com), Dnsspoof
replies back:
[ 149 ]
www.it-ebooks.info
Advanced WLAN Attacks
5. On the victim's machine, we see an error that says Unable to connect. This is
because we made the IP address for google.com as 192.168.0.199, which is
the hacker machine's IP, but there is no service listening on port 80:
7. Now, once we refresh the browser on the victim, we are greeted with the It Works!
default page of Apache:
[ 150 ]
www.it-ebooks.info
Chapter 7
8. This demonstration shows how it is possible to intercept data and send spoofed
responses to hijack sessions on the victim.
In the first part of the experiment, there was no listening process on port 80 of the attacker's
machine and thus, Firefox responded with an error. Then, once we started the Apache server
on the attacker's machine on port 80 (the default port), the browser's requested received a
response from the attacker's machine with the default It Works! page.
This lab shows us that, once we have full control of the lower layers (Layer 2 in this case), it is
easy to hijack applications running on higher layers such as DNS clients and web browsers.
In this challenge, write a simple filter to replace all occurrences of security in the network
traffic to insecurity. Try searching Google for security and check whether the results show
up for insecurity instead.
Though this seems tricky at first, the solution to this problem is simple. We need to
create access points advertising the same SSID but with different security configurations
simultaneously. When a roaming client searches for a network, it will automatically
connect to one of these access points based on the network configuration stored on it.
[ 151 ]
www.it-ebooks.info
Advanced WLAN Attacks
2. You can view all these newly created interfaces using the ifconfig –a command:
[ 152 ]
www.it-ebooks.info
Chapter 7
7. We can run airodump-ng on the same channel to ensure that all four access
points are up and running, as shown in the following screenshot:
[ 153 ]
www.it-ebooks.info
Advanced WLAN Attacks
8. Now let's switch the Wi-Fi on on the roaming client. Depending on which Wireless
Lab network you connected it to previously, it will connect to that security
configuration. In my case, it connects to the WPA-PSK network, as shown in the
following screenshot:
This technique can come in handy as, if you are doing a penetration test, you won't know
which security configurations the client has on its laptop. This allows you to find the
appropriate one by setting a bait for the client. This technique is also called WiFishing.
It is important to note that many Wi-Fi clients might not actively probe for networks they
have stored in their profile. It might not be possible to detect these networks using the
technique we discussed here.
[ 154 ]
www.it-ebooks.info
Chapter 7
Q2. Dnsspoof:
Q4. Which is the interface closest to the victim in our MITM setup?
1. At0.
2. Eth0.
3. Br0.
4. En0.
Summary
In this chapter, we learned how to conduct advanced attacks using wireless as the base.
We created a setup for a MITM attack over wireless and then used it to eavesdrop on the
victim's traffic. We then used the same setup to hijack the application layer of the victim
(web traffic, to be specific) using a DNS poisoning attack.
In the next chapter, we will learn how to conduct a wireless penetration test right from the
planning, discovery, and attack to the reporting stage. We will also touch upon the best
practices to secure WLANs.
[ 155 ]
www.it-ebooks.info
www.it-ebooks.info
Attacking WPA-Enterprise
8
and RADIUS
"The bigger they are, the harder they Fall."
Popular Saying
In this chapter, we will learn how to attack WPA-Enterprise using different tools and
techniques available on Kali.
Setting up FreeRADIUS-WPE
Attacking PEAP on Windows clients
Security best practices for Enterprises
Setting up FreeRADIUS-WPE
We will need a RADIUS server for orchestrating WPA-Enterprise attacks. The most widely
used open source RADIUS server is FreeRADIUS. However, setting it up is difficult and
configuring it for each attack can be tedious.
[ 157 ]
www.it-ebooks.info
Attacking WPA-Enterprise and RADIUS
Joshua Wright, a well-known security researcher, created a patch for FreeRADIUS that makes
it easier to set up and conduct attacks. This patch was released as the FreeRADIUS-WPE
(Wireless Pwnage Edition). Kali doesn't naturally come with FreeRADIUS-WPE, so you
need to perform the following steps to set up FreeRADIUS-WPE:
1. Connect one of the LAN ports of the access point to the Ethernet port on your
machine running Kali. In our case, the interface is eth0. Bring up the interface
and get an IP address by running DHCP, as shown in the following screenshot:
[ 158 ]
www.it-ebooks.info
Chapter 8
2. Login to the access point and set the security mode to WPA/WPA2-Enterprise,
set Version to WPA2, Encryption to AES. Then, under the EAP (802.1x) section,
enter the Radius Server IP address as your Kali build's IP address. The Radius
Password will be test, as shown in the following screenshot:
[ 159 ]
www.it-ebooks.info
Attacking WPA-Enterprise and RADIUS
4. Let's open eap.conf. You will find that the default_eap_type command is
set to MD5. Let's change this to peap:
5. Let's open clients.conf. This is where we define the allowed list of clients that
can connect to our Radius server. Interestingly, if you browse right to the bottom,
ignoring the example settings, the secret for clients in the range 192.168.0.0/16
defaults to test. This is exactly what we used in step 2:
6. We are now all set to start the RADIUS server with the radiusd –s –X command:
7. Once you run this, you will see a lot of debug messages on the screen, but
eventually the server will settle down to listen for requests. Awesome! We are
all set now to start our lab sessions in this chapter:
[ 160 ]
www.it-ebooks.info
Chapter 8
Attacking PEAP
Protected Extensible Authentication Protocol (PEAP) is the most popular version of EAP
in use. This is the EAP mechanism shipped natively with Windows.
PEAPv0 with EAP-MSCHAPv2 (the most popular as this has native support
on Windows)
PEAPv1 with EAP-GTC
[ 161 ]
www.it-ebooks.info
Attacking WPA-Enterprise and RADIUS
PEAP uses server-side certificates for validation of the RADIUS server. Almost all attacks on
PEAP leverage misconfigurations in certificate validation.
In the next lab, we will take look at how to crack PEAP when certificate validation is turned
off on the client.
[ 162 ]
www.it-ebooks.info
Chapter 8
4. Windows has native support for PEAP. Let's ensure that certificate verification has
been turned off:
[ 163 ]
www.it-ebooks.info
Attacking WPA-Enterprise and RADIUS
5. We need to click on the Configure tab that is next to Secured password and tell
Windows not to automatically use our Windows logon name and password:
[ 164 ]
www.it-ebooks.info
Chapter 8
7. Once the client connects to the access point, the client is prompted for a user
name and password. We use Monster as the user name and abcdefghi as
the password:
9. We now use asleap to crack this using a password list file that contains the password
abcdefghi, and we are able to crack the password! (For the purposes of this
demonstration, we simply created a one-line file called list with the password in it):
[ 165 ]
www.it-ebooks.info
Attacking WPA-Enterprise and RADIUS
MSCHAP-v2 is prone to dictionary attacks. We use asleap to crack the challenge and
response pair, as it seems to be based on a dictionary word.
EAP-TTLS
We encourage you to try attacks similar to those we have suggested for PEAP against
EAP-TTLS.
For SOHOs and medium-sized businesses, use WPA2-PSK with a strong passphrase.
You have up to 63 characters at your disposal. Make use of them.
For large enterprises, use WPA2-Enterprise with EAP-TLS. This uses both the
client- and server-side certificates for authentication, and currently is unbreakable.
If you have to use PEAP or EAP-TTLS with WPA2-Enterprise, then ensure that
certificate validation is turned on, the right certifying authorities are chosen, RADIUS
servers that are authorized are used, and finally, that any setting that allows users
to accept new RADIUS servers, certificates, or certifying authorities is turned off.
[ 166 ]
www.it-ebooks.info
Chapter 8
1. Fake credentials.
2. Fake certificates.
3. Using WPA-PSK.
4. All of the above.
1. Client-side Certificates.
2. Server-side certificates.
3. Either 1 or 2.
4. Both 1 and 2.
Summary
In this chapter, we saw how we could compromise the security of a WPA-Enterprise
network running PEAP or EAP-TTLS, the two most common authentication mechanisms
used in Enterprises.
In the next chapter, we will take a look at how to put all that we have learned into use
during an actual penetration test.
[ 167 ]
www.it-ebooks.info
www.it-ebooks.info
WLAN Penetration Testing
9
Methodology
"The proof is in the pudding."
Popular saying
This chapter will lay out the steps that go in to taking the techniques taught in
the previous chapters and turning them into a full wireless penetration test.
Broadly, we can break up a wireless penetration testing exercise into the following phases:
1. Planning phase.
2. Discovery phase.
3. Attack phase.
4. Reporting phase.
[ 169 ]
www.it-ebooks.info
WLAN Penetration Testing Methodology
Planning
In this phase, we must understand the following:
Scope of the assessment: The penetration tester should work with the client to define
a scope that is achievable and will also provide the greatest amount of insight into the
security of a network. Typically, the following information is gathered:
Location of the penetration test
Total coverage area of the premises
Approximate number of access points and wireless clients deployed
Which wireless networks are included in the assessment?
Is exploitation in scope?
Are attacks against users in scope?
Is denial of service in scope?
Effort estimation: Based on the scope defined, the tester will then have to estimate
how much time is required. Bear in mind that rescoping may occur following this
estimate, as organizations may have limited resources available in terms of both
time and money.
Legality: Prior to performing a test, the client must give consent. This should explain
the testing to be covered and clearly define the level of indemnity, insurance,
and the limitations of the scope. If you are unsure, you will need to speak to a
professional in these areas. Most organizations will have their own versions that
will likely also incorporate an Non-Disclosure Agreement (NDA).
Once all of the preceding requirements are in place, we are ready to go!
Discovery
In this phase, the aim is to identify and apply characteristics to the wireless devices and
wireless networks within the scope.
All the techniques to perform these have been laid out in the previous chapters but, in brief,
the aim is to:
[ 170 ]
www.it-ebooks.info
Chapter 9
All of this information should be recorded. If the test is limited to the performance of
reconnaissance only, the test will end here, and the tester will attempt to draw conclusions
based on this information. Some statements that would be useful to a client are be
as follows:
The number of devices that have associations with open networks and the
corporate network
The number of devices that have networks that can be linked to locations
through solutions such as WiGLE
The existence of weak encryption
The networks set up are too strong
Attack
Once reconnaissance has been performed, exploitation must be performed for proof of
concept. If the attack is being performed as part of a red team or wider assessment, then
exploitation should be performed to gain access to the network as surreptitiously as possible.
At this time, set up your WPA key retrieval setup as shown in Chapter 4, WLAN Encryption
Flaws. Alternatively, perform the deauthentication attack, as shown in Chapter 6, Attacking
the Client.
[ 171 ]
www.it-ebooks.info
WLAN Penetration Testing Methodology
If WPA-Enterprise is in place, bear in mind you will have to use the information gathered from
the reconnaissance to target the correct network and set up your dummy Enterprise setup as
shown in the Attacking PEAP section in Chapter 8, Attacking WPA-Enterprise and RADIUS.
You can attempt to break all passphrases but bear in mind that some will be unbreakable.
Following the performance of the test, check with the wireless administrator for the
passphrase in use. Check to see whether it is a secure passphrase and that you, as a tester,
did not experience a tool failure or were merely unlucky.
Attacking infrastructure
If network access is gained through cracking the encryption, perform a standard network
penetration test if allowed in scope. The following should be performed as a minimum:
A port scan
Identifying which services are running
Enumerating any open services, such as unauthenticated FTP, SMB, or HTTP
Exploiting any vulnerable services identified
Compromising clients
After enumerating and testing all wireless systems, there are various types of engagements
that would suit performing attacks against clients.
If necessary, after establishing which clients are vulnerable to Karma attacks, create a Honeypot
to force them to connect with the methods laid out in the Attacking PEAP section in Chapter 8,
Attacking WPA-Enterprise and RADIUS. There are various useful pieces of information that can
be gathered through this method, but ensure that the collected data serves a purpose and
is stored, transmitted, and used in an ethical and safe manner.
Reporting
Finally, at the end of testing, it is necessary to report your findings to the client. It's
important to ensure that the report matches the quality of your testing. As the client
will only see the report, you have to give it as much love and attention as you do to
your testing. The following is a guideline to the layout of the report:
1. Management summary.
2. Technical summary.
[ 172 ]
www.it-ebooks.info
Chapter 9
3. Findings:
Vulnerability description
Severity
Affected devices
Vulnerability type—software/hardware/configuration
Remediation
4. Appendices.
The technical summary should be a midpoint between the management summary and
findings list. It should be aimed at a developer or a technical lead with a focus on how to
fix the issues and broad solutions that could be implemented.
The findings list should describe each vulnerability at a low level, explaining the methods
to identify, and replicate, and vulnerabilities.
Appendices should contain any extra information that would be too long to describe in
a short description. This is where any screenshots, proof-of-concept code, or stolen data
should be presented.
Summary
In this chapter, we discussed a methodology for performing a range of wireless tests and
referred to the relevant chapters for each step. We also listed methods for reporting
vulnerabilities and techniques for making technical data presentable. In the next and final
chapter, we will cover new techniques developed since the initial publication of this book,
WPS, and probe monitoring for surveillance.
[ 173 ]
www.it-ebooks.info
www.it-ebooks.info
WPS and Probes
10
"Nothing is new under the sun."
Popular Saying
This chapter incorporates the new techniques related to attacking WPS and
probe monitoring and also covers the pineapple tool that makes much of
wireless testing a lot easier. These attacks and tools have appeared since
the publication of the original book, and we'll be making sure we're being
as holistic as possible.
WPS attacks
Wireless Protected Setup (WPS) was introduced in 2006 to help users without wireless
knowledge to have secure networks. The idea was that their Wi-Fi device would have a single
hidden hardcoded value that would allow access with key memorization. New devices would
be authenticated through a button press on the Wi-Fi router. Individuals outside the house
without access to the device would not be able to have access, thus reducing the issues
surrounding remembering WPA keys or setting short ones.
In late 2011, a security vulnerability was disclosed enabling brute force attacks on the WPS
authentication system. The traffic required to negotiate a WPS exchange was spoofable,
and the WPS pin itself is only eight characters between 0-9. To start with, this provides
only 100,000,000 possibilities in comparison with an eight character azAZ09 password
having 218,340,105,584,896 combinations.
[ 175 ]
www.it-ebooks.info
WPS and Probes
Of the eight characters of the WPS pin, the last character is a checksum of the
previous seven and therefore predictable, leaving a maximum of 10,000,000 options
In addition, the first four and the following three of the remaining characters are
checked separately, which means that there are 104 + 103 options or 11,000
Through the two decisions made in the authentication mechanism, we have gone from
100,000,000 possible combinations to 11,000. This equates to a six-hours difference when
brute-forcing the algorithm. It is these decisions that make attacks against WPS viable.
In the next lab exercise, we will go through identifying and attacking vulnerable WPS
setups with Wash and Reaver.
2. Now we've confirmed that it's ready. We need to set up our target. We need to set
up our testing environment. We're going to use the Wash tool, and Wash requires a
monitoring interface to function. As we have done many times before, we need to
set up one with the following command:
airmon-ng start wlan0
[ 176 ]
www.it-ebooks.info
Chapter 10
3. We have a monitoring interface set up as mon0, and we can call Wash with the
following command:
wash --ignore-fcs -i mon0
The ignore fcs option is due to an issue with an expected format for requests
that wash causes:
4. Wash will display all the nearby devices that support WPS as well as whether they
have WPS active or unlocked and what version is running:
[ 177 ]
www.it-ebooks.info
WPS and Probes
5. We can see the Wireless Lab network supports WPS. It uses Version 1 and it's
not locked. Fantastic. We take note of the MAC address, which in my case is
E8:94:F6:62:1E:8E, as this will be used to target our next tool: reaver.
6. Reaver attempts to brute-force the WPS pin for a given MAC address. The syntax
for starting this is as follows:
reaver -i mon0 -b <mac> -vv
7. Once it is started, the tool runs through all the possible combinations for the WPS
and attempts to authenticate. Once it does this, it will return the WPS code and the
password, as shown in the following screenshot:
[ 178 ]
www.it-ebooks.info
Chapter 10
Make an attempt to set the WPS pin to an arbitrary value and try again, to see whether
Reaver is as effective at cracking it.
Acquire a wireless router that allows you to rate-limit the WPS attempts. Try and configure
your attack to avoid triggering lockouts.
Probe sniffing
We have spoken about probes previously, and how they can be used to identify hidden
networks and perform effective rogue access point attacks. They can also be used to
identify individuals as targets or track them on a mass scale with minimal equipment.
When a device wishes to connect to a network, it sends a probe request that contains its
own MAC address and the name of the network it wishes to connect to. We can use tools
such as airodump-ng to track these. However, if we wish to identify whether an individual
was present at a specific location at a specific time or look for trends in Wi-Fi usage, we will
need to use a different approach.
In this section, we will utilize tshark and Python to collect data. You will receive the code
and an explanation of what is being done.
1. First of all, we need a device that's looking for multiple networks. Generally, a
normal smartphone such as an Android device or iPhone will do the trick. Desktops
don't generally make good targets as they tend to remain in one location. Newer
iPhones and Android devices may have probe requests disabled or obfuscated,
so do check before you give up.
[ 179 ]
www.it-ebooks.info
WPS and Probes
2. Once you have your device, make sure the Wi-Fi is turned on.
3. Then set up your monitoring interface as we have done many times before:
4. The next thing to be done is to look for probe requests with tshark via the
following command:
tshark -n -i mon0 subtype probereq
5. Your output at this point is a little rough, as the default output from tshark is not
designed to be readable, just to have as much information in it as possible. It should
look like the following:
[ 180 ]
www.it-ebooks.info
Chapter 10
6. You can clearly see the MAC address and SSID of the probe request; however,
this output can be improved. We can use the following command to make it
more readable:
tshark –n –i mon0 subtype probereq –T fields –e separator= -e
wlan.sa –e wlan_mgt.ssid
8. So, now we have the output in a readable format, what next? What we do is create
a Python script that will run the command and record the output for later analysis.
Before running the code, you will need to ensure that you have your monitoring
interface ready and that a file called results.txt is created in the directory you
are in. The Python script is as follows:
import subprocess
import datetime
results = open("results.txt", "a")
while 1:
blah = subprocess.check_output(["tshark –n –i mon0 subtype
probereq –T fields –e separator= -e wlan.sa –e wlan_mgt.ssid –c
100"], shell=True)
splitblah = blah.split("\n")
for value in splitblah[:-1]:
splitvalue = value.split("\t")
MAC = str(splitvalue[1])
SSID = str(splitvalue[2])
time = str(datetime.datetime.now())
Results.write(MAC+" "+SSID+" "+time+"\r\n")
[ 181 ]
www.it-ebooks.info
WPS and Probes
You may ask yourself what the purpose of this is. This can be achieved by simply performing
the original tshark command and adding a >> results.txt command to the end.
You would be correct; however, what we have created is a framework for integration
with other tools, visualization platforms, databases, and services.
For example, using the WiGLE database that maps SSIDs to locations, you can add a few
lines of code to take the SSID variable and query the WiGLE database.
[ 182 ]
www.it-ebooks.info
Chapter 10
Alternatively, you could set up a MySQL database and output the results there to perform
the SQL commands on it.
This section has provided you with the first steps to create your own probe-monitoring tools.
Through experimentation and using this simple code as the first step, a multitude of useful
tools can be created.
Set yourself up a MySQL database to record the data and reconfigure the preceding Python
script to output the results to the database. Then, build another script (or do it in the same
one) to retrieve the data and output it to Maltego.
Reconfigure the script to query WiGLE, and collect geolocation data for probe requests.
Output this data through Maltego.
Summary
In this chapter, we discussed the attacks against WPS that have come about since the release
of the original book and also performed an initial foray into integrating wireless tools with
Python. Alas, we have come to end of the book, I hope it's been informative and interesting.
See you in another seven years for the third edition.
[ 183 ]
www.it-ebooks.info
www.it-ebooks.info
Pop Quiz Answers
Q1 3
Q2 3
Q3 1
[ 185 ]
www.it-ebooks.info
Pop Quiz Answers
Q1 4
Q2 2
Q3 1
Q1 3
Q2 1
Q3 2
Q1 1
Q2 1
Q3 1
Q4 4
Q1 1
Q2 1
Q3 2
Q4 4
[ 186 ]
www.it-ebooks.info
Appendix
Q1 2
Q2 2
Q3 4
Q4 1
Q1 2
Q2 2
Q3 4
Q4 2
[ 187 ]
www.it-ebooks.info
www.it-ebooks.info
Index
A C
access point Caffe Latte attack
configuring 5-7 about 123
configuring, to use WEP 8 conducting 124-127
configuring, to use WPA 8 client
connecting to 9 baiting 154
connecting to, wireless card used 9-11 deauthenticating 128-130
default accounts, cracking on 91-93 deauthentication attack 152-154
setting up 5 security configurations, finding 151
tables, filling 54 control frames
accounts about 15
cracking, Brute-force attacks used 93 viewing 22-25
adapter 29-31 Cowpatty
aircrack-NG suite used, for cracking WPA-PSK 81
URL 44
airodump-NG utility D
URL 47
AP data
setting up, FreeRADIUS-WPE (Wireless Pwnage collecting 179-182
Edition) used 158-161 data frames
AP-less WPA cracking 134 about 15
AP-less WPA-Personal cracking 132, 133 viewing 22-25
application hijacking data packets
challenge 151 analyzing 28
injecting 28
B sniffing, for network 26, 27
deauthentication attack
Brute-force attacks about 127
used, for cracking accounts 93 on client 152-154
default accounts
cracking, on access points 91, 92
[ 189 ]
www.it-ebooks.info
Denial of Service (DoS) attacks M
about 54, 94
deauthentication attack 94-99 MAC filters
disassociation attack 100 about 44
disassociation attack instructions 44-47
about 127 management frames
on client 130 about 15
discovery phase, wireless penetration viewing 22-25
testing 170, 171 man-in-the-middle attack (MITM)
about 138-142
E over pure wireless 142
used, for Wireless Eavesdropping 142-147
EAP-TTLS 166 Message Integrity Check (MIC) 74
Enterprises Mis-Association attack
security, best practices 166 orchestrating 118-123
Ettercap 151 monitor mode interface
evil twin creating 16-18
about 100 multiple monitor mode interfaces, creating 19
and access point MAC spoofing 100 MSCHAP-v2 166
and channel hopping 107
and MAC spoofing 101-106 O
F Open Authentication
about 47
filters bypassing 47, 48
working with 26
FreeRADIUS-WPE (Wireless Pwnage Edition) P
RADIUS, working with 161
setting up 157 Pairwise Master Key (PMK) 82
URL 158 Pairwise Transient Key (PTK) 73
used, for setting up AP 158-161 Password-Based Key Derivation
Function (PBKDF2) 73
H PEAP (Protected Extensible
Authentication Protocol)
hacker attacking 161, 162
tasks 118 attack, variations 166
Hirte attack cracking 162-166
URL 131 EAP-TTLS 166
WEP, cracking with 131, 132 versions 161
Honeypot attacks 118-123 planning phase, wireless penetration
Hydra 93 testing 170
Preferred Network List (PNL) 118
K Pre-Shared key (PSK) 72
probe
Kali
data, collecting 179-183
installing 3-5
rate, limiting 183
installing, on VirtualBox 5, 29
sniffing 179
URL 2
promiscous mode 15
[ 190 ]
www.it-ebooks.info
R network, connecting to 87-90
packets, decrypting 84-87
Radio Frequency (RF) 7 Wi-Fi Protection Access v2 (WPAv2) 58
RADIUS WiFishing 154
receiving 167 wireless card
regulatory domains configuring 8, 9
adapter, experimenting with 31-34 setting up 8
exploring 35 used, for access point connection 9-11
role 31 Wireless Eavesdropping
reporting phase, wireless penetration MITM used 142-147
testing 172 wireless lab
rogue access point hardware, requisites 2
about 107 software, requisites 2
challenge 115 wireless packets
WEP, cracking 108-115 sniffing 19-21
wireless penetration testing
S about 169
attacking phase 171, 172
session hijacking discovery phase 170, 171
over wireless 147-151 planning phase 170
Shared Key Authentication reporting phase 172
about 48, 49 wireless penetration testing, attacking phase
bypassing 49-54 clients, compromising 172
SSIDs encryption, cracking 171
deauthentication, selecting 44 infrastructure, cracking 172
hidden SSIDs, uncovering 38-43 Wireshark traces 22
WLAN
V access points 91
VirtualBox attacks 154
Kali, installing on 5 authentication 54
encryption, flaws 90
encryption 58
W WLAN frames
WEP (Wired Equivalent Privacy) about 14
cracking 59-72, 108-115 control frames 15
cracking, with fake authentication 72 data frames 15
cracking, with Hirte attack 131, 132 management frames 15
protocol 58 WLAN Packet Sniffing
WEP configuration and Injection 35
connection 11 WLAN Sniffing 29
WEP network WPA2 72
connecting to 87, 88 WPA-Enterprise
WEP packets receiving 167
decrypting 84-87 WPA-PSK
Wi-Fi Protected Access (WPA) cracking, Cowpatty used 81
about 72 weak passphrase, cracking 75-80
[ 191 ]
www.it-ebooks.info
WPA/WPA2 PSK
cracking, speeding up 81-84
WPS (Wireless Protected Setup)
attacks 175-178
rate, limiting 179
[ 192 ]
www.it-ebooks.info
Thank you for buying
Kali Linux Wireless Penetration Testing Beginner's Guide
www.it-ebooks.info
Mastering Kali Linux for Advanced Penetration
Testing
ISBN: 978-1-78216-312-1 Paperback: 356 pages
www.it-ebooks.info
Kali Linux Cookbook
ISBN: 978-1-78328-959-2 Paperback: 260 pages
www.it-ebooks.info