AdSense

Sunday, October 16, 2016

WI-FI PT / 2 - ATTACKS AGAINST INFRASTRUCTURE / 2.2 - Attack against MAC filters


2.2 - Attack against MAC filters

- One of the most used security measure consists on protecting the access to a network with a MAC filter implemented on the Access Point. However, during this practice it will be shown that filtering MACs is actually useless, because that filter can be defeated. MAC filtering is based on the usual wired firewalls, where there is a list of allowed and denied devices. Actually, MAC filtering is added by the AP software and is not really present in the 802.11's security standard.

- For instance, let's filter the access of the attacker "kali" (00:C0:CA:72:1A:36) with the AP's option MAC Restrict Mode equal to Deny:




- As we can see, now there is just one legitimate client connected, "roch". 

- About "kali"s wlan0 interface, it is verified that its MAC address is 00:C0:CA:72:1A:36:












- If "kali" tries to connect to the network "spaniard" it will be rejected due to the filter:





- This screenshot shows that the status is of failured connection: Access Point = Not-Associated:












- Wireshark detects Authentication failure packets between the AP (Motorola) and the attacker "kali" (Alfa card):



- To start the attack from "kali", the first step would be to write down the legitimate connected client "roch"s MAC, it is 28:C6:8E:63:15:6B, which is shown by airodump-ng in clear text. In shortly that number will be of great value:



- The interface wlan0 is turned off:



- With the command macchanger the wlan0's MAC address is replaced by legitimate client "roch"s MAC, which has been shown by airodump-ng in clear text:



- The interface wlan0 is turned on:



- It is checked that now wlan0 has got a different MAC address than the original one:













- Then, the connection to "spaniard" is tried again:



- The connection is successful, because the status has changed to Access Point = 00:25:F2:9B:91:23



- The conclusion of this practice is that an attacker whose access to a network is prohibited due to a MAC filter implemented at the AP is able to beat the filter just spoofing its own MAC address, replacing it with the MAC of a legitimate client. How to know the good client's MAC? as usual, airodump-ng helps to solve that step.

- What is really shocking is to verify that even the AP gets confused, because it reads the spoofed MAC address of the attacker "kali" as if it was the good one:






WI-FI PT / 2 - ATTACKS AGAINST INFRASTRUCTURE / 2.1 - Uncovering hidden SSIDs


2.1 - UNCOVERING HIDDEN SSIDs

- Every Access Point offers the option, known as "Closed Network", of hidding the SSID when broadcasting beacon frames to announce itself. This option is usually considered a security measure, but as it will be explained here, it is actually easy to uncover the hidden SSID.

- At the AP used in this practice, "Closed Network" can be enabled in this way:



- Then, capturing beacon frames from the AP, Wireshark is not able to detect the SSID, actually showing the field in blank:



- The attacker "kali" uses airodump-ng to detect that the victim "roch" is connected to the AP, but it is not able to learn the ESSID, just showing that it has got a length of 8 characters: <length: 8>:



- The trick consists on forcing the client "roch" to deauthenticate, knowing that later it will try to reconnect to the AP. Using aireplay-ng 5 packets are sent to the Access Point whose MAC address is 00:25:F2:9B:91:23, through "kali"s interface (00:C0:CA:72:1A:36), forcing the "roch" client (28:C6:8E:63:15:6B) to be disconnected:



- Using this filter at Wireshark (wlan.bssid == 00:25:F2:9B:91:23) && !(wlan.fc.type_subtype == 0x08), meaning packets different than subtype beacon frame (0x08), the deauthentication packets can be observed:


















- Next, waiting just some instants, when client "roch" tries to reconnect by means of a Probe Request packet, the AP answers with a Probe Response message, showing the expected SSID in clear text ("spaniard"):



This attack is based on the fact that Probe Request/Response exchanged packets need to use the SSID. This packets are not encrypted and are very easy to be sniffed from the air. So, forcing to deauthenticate a client, and waiting for the reconnection process, the SSID is sooner or later achieved. Of course, waiting for a client to connect by itself would be also a valid way of achieving the same goal, although in that case it would be taking a passive attitude during the attack. 




Saturday, October 15, 2016

WI-FI PT / 1 - SNIFFING, CAPTURING, ANALYZING AND INJECTING PACKETS ON WI-FI NETWORKS


The following techniques are essential in the process of penetration testing for a wireless network.

1.1 - Connecting the wireless interface card

- We start plugging-in the Alpha USB device to the computer "kali" and then booting it. From the console, we can use iwconfig to confirm that the wireless card has been detected and the drivers properly loaded. The virtual interface used for wireless connections will be wlan0:



- Next, bringing the interface wlan0 up:



- Checking that wlan0 is actually up:













1.2 – Sniffing packets

- The first step in the sniffing process would be to use the command airmon-ng in order to put the card into monitor mode, also known as promiscuous mode in the wired networks. It means that the wireless interface will accept all the packets off the air in the working channel, regardless its destination.

- The command airmon-ng, without options, detects the available card wlan0:



- Because It is not possible to use directly wlan0 in monitor mode, a monitor mode interface is created, called mon0, virtually attached to wlan0, that will be able to read wireless frames off the air:



- Checking that mon0 has been properly created: 



- Verifying that mon0 is working in monitor mode:



- Its MAC address is 00-c0-a0-71-1a-36, same as wlan0:



1.3 - Capturing packets

- For the purpose of capturing and analyzing the sniffed packets, the tool Wireshark can be launched:


Under Capture -> Interfaces:




















- The interface mon0 is picked up, and then Start:




1.4 – Analyzing packets

- At next image, captured broadcast packets from Alfa Network interface card can be seen. The Protocol field is 802.11, as expected for wireless packets:



- Expanding the third row, the additional information is telling that the frame includes a "Probe Request" broadcast , because the client's Alfa wireless card is requesting information from any available access point:




- Next, with the purpose of expanding a little bit this practice, the client is connected to the network created by the Access Point, whose SSID is "spaniard":



- The Acces Point asks for authentication to allow the client to join the network "spaniard":



- Again, from Wireshark, captured packets sniffed by the interface mon0:



- Now, there are a lot of different frames in the air:



- In order to filter packets created by the Access Point, the filter wlan.bssid == 00:25:f2:9b:91:23 is used, being the hexadecimal number the Motorola AP's MAC address:



- These packets are coming from source Motorola_9b:91:23 and destination broadcast, being its type Beacon frame. With these packets, the AP is announcing itself to any client that could be listening. As expected, the BSSID is the AP's MAC address, 00:25:f2:9b:91:23. A lot more information of the AP is available from capturing packets with Wireshark, as it will be seen alongside later chapters.


1.5 – Working with channels

- A very interesting command is airodump-ng, which helps to determine in which channel the interface is running on. It is very important to remember that a wireless interface can work only in one channel at a given instant. This means that it is not posible for a wireless card to sniff on all channels and bands at the same time.

- With the purpose of sniffing packets from and to an specific AP, it is necessary to lock up the wireless card on the same channel that the AP, the 6 in this case:



- Setting mon0 on channel 6:





- After the airodump-ng command, it is necessary to add the MAC address of the AP and the monitoring interface mon0:



- Then, all the information about the AP and the clients connected to it is seen. Also, the encryption methods used, and son on. Anyway, these concepts will be studied in more details at next chapter:

















- As said before, the working channel for the wireless interface is the 6:



- It can be verified that now the working frequency is 2.437 GHz, corresponding to channel 6 center:



- Another useful utility of airodump-ng is the ability to make the interface hopping from different bands and channels:



- As the time goes by 4, 12, 24, 32, 40 seconds …, the interface hops between channels 6, 5, 3, 13, 2 …



- As previously said, the interface is working in a single channel for a given second, regardless it can hop to another channel some seconds later.

- This option is essential so that the wireless interface card can detect different Access Points in the sorrounding area, each of them working in a different band or channel. Again:



1.6 - Injecting packets

- This practice consists of the Alfa card being able to inject arbitrary packets into the air without actually being connected to the AP. So, first of all we need to disconnect the attacker "kali" from the "spaniard" network.

- Injecting packets from the client “kali” means that it will be acting as a new AP, in other words a “spoofed AP”. For that, “kali” will be creating arbitrarily beacon frames as if it would be an AP broadcasting its SSID “example”.

- One of the commands to achieve this goal is mkd3, adding the mon0 interface, option b for “beacon flood mode”, option -n for name SSID “example”:



- These packets are captured by Wireshark:



- Also, from the client “roch” the spoofed AP's SSID “example” can be detected:



- Another option could be to use the aireplay-ng command, to inject packets into a network, for instance “spaniard” In this case, the wireless interface detects the AP and then injects “probe request” packets, even without actually being connected to the AP. The used options are -9 (tests injection and quality), -e (setting the target AP's SSID), -a (setting the target AP's BSSID or MAC address), and finally the used interface mon0.



- From this practice it can be deduced that anyone can create and broadcast beacon frames (imitating a real or legitimate AP, being SSIDs in clear text or unencrypted), or inject probe request packets. These security tricks will be very valuable for attacks seen at next chapter.




WI-FI PT / 0 - INTRODUCTION


0.0 - Introduction

According to INCIBE (National Institute of Cibersecurity, Spain) nearly 8 out of 10 users utilize wireless networks for Internet access. Also, the report noted that around 43% of users do not adopt any measures of security in their wireless connections. Previous figures give a hint of the need to implement, educate and train the general public in computer security, specifically in the wireless field.

Nowadays most computers and networks use wireless connections. This type of connection allows to access the Internet without needing a physical cable network. The biggest advantage is that the computer can be used anywhere, at home or office, while in range of the wireless router. However, there are potential risks associated to wireless networks, unless the network is properly protected, because any information sent or received could be intercepted off the air and the wireless network could be tampered. If the wireless network is unprotected, shared files and data could be at risk and network performance be compromised. Security is one of the most important issues when it comes to wireless networks. Since the birth of these, it has been attempted to ensure totally safe communications protocols, but with limited success. Unlike cable communications, where the information is contained in a very specific physical medium, wireless communications information is in the air, available to anyone who has the will and the means to intercept, analyze, and use with malicious purposes.

To illustrate the process of penetration testing for a wireless network, along this work a great number of practices will be carried out simulating attacks against clients, wireless access points, cryptographic systems and authentication mechanisms commonly available. Starting with a brief introduction to the most important characteristics of wireless frames specified in the IEEE 802.11 standard, as well as a description of the testing laboratory where carried out the practices.


0.1 - Wireless Local Area Network (WLAN)

For the purpose of having a thorough understanding of the subsequente chapters and the whole contents, it is neccessary to make a brief introduction to the main features and characteristics of wireless technologies.

A Wireless Local Area Network (WLAN) is a set of two or more devices that are able to communicate wirelessly between them. Most of WLANs are based on the standard IEEE 802.11 by the Institute of Electrical and Electronics Engineers. IEEE 802.11 is a set of specifications for the Medium Access Control (L2 sublayer) and the Physical Layer (L1) regarding wireless transmissions working within 2.4 and 5 GHz frequency bands. This standard provides directions for the products using Wi-Fi, propietary brand owned by the Wi-Fi Alliance, which is the trade association in charge of promoting interoperability between wireless devices manufacturers.

The IEEE 802.11 architecture uses different components and concepts:

- client or station (STA): it is a device like a computer, cell phone, ..., containing a wireless adapter card to provide wireless connectivity.

- Access Point (AP): its function is to bridge between the wireless STAs and the existing network backbone for network access.

- Independent Basic Service Set (IBSS): also known as "ad-hoc mode", consists of at least two STAs, used when there are no APs available.

- Basic Service Set (BSS): also known as "infrastructure mode", it is a wireless network that consists only of one AP providing service to one or more wireless clients. All clients in a BSS communicate through the AP, both between them and to a wired network.

- Extended Service Set (ESS): it is a set of two or more interconnected BSSs sharing the same SSID (network name) and security credentials. An ESS allows for mobility and roaming, because clients can move from one BSS to another BSS seamlessly. An ESS defines a single logical network segment bounded by a router.
- Distribution System (DS): a DS is the component used to interconnect BSSs. In other words, APs of multiple BSSs belonging to the same ESS are interconnected through a DS. A DS can work either wired or wireless.

- Service Set Identifier (SSID): it is a 1 to 32 Byte string used to identify a BSS or ESS. Also considered as the "network name", it is human readable.

- Basic Service Set Identification (BSSID): it is a 6 Bytes string that defines uniquely a BSS. For a BSS working in "infrastucture mode" the BSSID is the MAC address of the AP. The BSSID is the formal name of a BSS (in contrast to the informal name, the SSID), and it is always associated to only one BSS. It is important to notice that inside an ESS each of the belonging BSSs uses its own BSSID, whereas all of them use the same SSID. For an IBSS or "ad-hoc mode", the BBSID is a locally administered MAC address randomely generated.


0.2 - Versions, Frequency bands and Channels

The most important versions of 802.11 protocol are a,b,g,n,ac depending on the frequency of work. Also, the new version ac is expected to improve dramatically wireless transmissions by year 2014. The key features of 802.11 versions are as follows:

Version
Frequency (GHz)
Bandwidth
(MHz)
Data Rate
(Mbps)
Modulation
Indoor range
(metres)
Outdoor range
(metres)
802.11a
5
20
up to 54
OFDM
35
120
802.11b
2.4
20
up to 11
DSSS
35
140
802.11g
2.4
20
up to 54
OFDM/DSSS
38
140
802.11n
2.4/5
20/40
up to 72.2/150
OFDM
70
250
802.11ac 
5
20/40/80/160
from 87.6 to 866.7
OFDM




Orthogonal Frequency Division Multiplexing (OFDM) is a technique to encode digital data on multiple carrier frequencies. This scheme is used as a digital multi-carrier modulation method, in which a large number of closely spaced orthogonal sub-carrier signals are used to carry data on several parallel data streams or channels.

Direct-sequence Spread Spectrum (DSSS) is a modulation technique where the transmitted signal takes up more bandwidth than the information signal that modulates the carrier or broadcast frequency. 'Spread spectrum' comes from the fact that the carrier signals occur over the full bandwidth (spectrum) of a device's transmitting frequency.

As seen at the previous chart, the most important frequency bands used in wireless communications are 2.4 GHz and 5 GHz. Each spectrum is subdivided into channels with a center frequency and bandwidth. The 2.4 GHz band is divided into 15 channels spaced 5 MHz apart, starting at channel 1 which is centered on 2.412 GHz. The latest channels have some restrictions of use depending on the regulatory domains.





The IEEE 802.11 workgroups are in charge of establishing the technical features of frequency ranges, but each country applies his own regulations for allowable channels, users and maximum power levels within those frequency ranges, from a legal perspective. For instance, channel 14 is forbidden in the US and many other countries because it is set for other uses, and 12 and 13 channels are not used to avoid interferences with channel 11. Actually, channel 14 is legal only in Japan.

There is also a problem of "overlapping channels", which can be avoided using those channels that don't have interferences regarding to working frequencies. As we can see at the next image, for 2.4 GHz band, channels 1 (2.412 GHz), 6 (2.437 GHz), 11 (2.462 GHz) and 14 (2.484 Ghz) don't interfer because they don't use adjacent frequencies.




0.3 -  Lab Setup

0.3.1 - General description

Because this blog has got an eminently practical approachment, it is essential to set up a lab in which different experiments and practical tests can be developed. Although with some exceptions that will be detailed at the right moment, the wireless testing lab setup used in most of our practices consists of the following elements:

  • 1 Access Point Motorola SBG941, monitored from 1 PC Desktop equipped with Windows 7.
  • 1 Laptop ("kali") whose role will be as attacker or hacker, equipped with Kali Linux distribution and an Alfa Network AWUS036H wireless network USB adapter. The most important tool used for launching the attacks will be Aircrack-ng, whereas Wireshark being used for anylizing the captured packets.
  • 1 Laptop ("roch") whose roles will be as victim, equipped with Windows 7 and wireless network interface: a NetGear N600 Wireless Dual-Band USB adapter.


The layout of the topology would be as follows:


Let's examine all these elements one by one.

0.3.2 - Access Point

The most common Access Point used in this work will be a Motorola SBG941 Wireless Cable Gateway:




This Motorola SBG941 Wireless Cable Gateway combines a cable modem, an integrated 4 port router (10/100Base-TX RJ-45) and a 802.11 a/b/g/n wireless access point. The gateway is DOCSIS 2.0 standard compliant, compatible with DOCSIS 1.0/1.1 standard. The integrated AP supports WEP and WPA/WPA2 (TKIP and AES) wireless encryption. It uses WMM (QoS) to prioritize the traffic over the network. A WPS button allows for easy wireless security configuration. The router provides VPN pass-through for IPSec and PPTP. A built-in SPI firewall protects the network against intruders and Denial of Service (DoS) attacks. The Transmit Power is 17 dBm and the Receiver Sensitivity is -74 dBm.

The PC Desktop is connected to the Access Point through an Ethernet cable, using one of the 4 available ports. To configure and monitorize the access point the default gateway IP 192.168.0.1 is entered at the browser:



The network created by the Access Point uses the name or SSID (Service Set IP) "spaniard", working in the subnet 192.168.0.0/24. It is very important to notice that AP's wireless MAC address is 00:25:F2:9B:91:23, as we can see at the next image, because this MAC address will be used very frequently during the practical tests:



Also, for the special purpose of demonstrating attacks against WPA/WPA2 Entreprise with RADIUS server autentication, a D-Link DIR-615 router will be used at Chapter 6.10, where further explanations about this router will be given:


0.3.3 - The attacker

The laptop used as an attacker is named "kali", being equipped fromt the software perspective with a Kali Linux distro as operative system. Also, Aircrack-ng and Wireshark applications are often used. From the hardware perspective, an Alfa Network AWUS036H wireless network USB adapter.

Kali is a Debian Linux distribution offered by Offensive Security Ltd., considered by its authors as the successor of the well-known BackTrack. It is used for digital forensics, penetration testing, and generally for any computer security purpose. Kali is preinstalled with a suite of penetration-testing programs, including Nmap, Wireshark, John the Ripper , Metasploit, OpenVas, etc .., and the most important for our purposes, Aircrack-ng (penetration-testing wireless LANs). Kali Linux can be run from a hard disk, live CD, or live USB. Kali is distributed in 32- and 64-bit images for use on hosts based on the x86 instruction set, as well as an image for the ARM architecture for use on the Raspberry Pi computer and on Samsung's ARM Chromebook.



Aircrack-ng is a suite of tools for auditing wireless networks, consisting of a detector, packet sniffer, WEP and WPA/WPA2-PSK cracker and analysis tool for 802.11 wireless LANs. It works with any wireless network interface controller whose driver supports raw monitoring mode and can sniff 802.11a, 802.11b and 802.11g traffic. The program runs under Linux and Windows. It can recover keys once enough data packets have been captured. It implements the standard FMS attack along with some optimizations like KoreK attacks. As well as the PTW attacks, new method based on the RC4 cipher, decreasing the number of initialization vectors or IVs needed to decrypt a WEP key, making the attack much faster compared to other WEP cracking tools.




The most important tools included with Aircrack-ng are:

  • aircrack-ng cracks WEP and WPA (Dictionary attack) keys.
  • airdecap-ng decrypts WEP or WPA encrypted capture files with known key.
  • airmon-ng places different cards in monitor mode.
  • aireplay-ng packet injector (Linux, and Windows with CommView drivers).
  • airodump-ng packet sniffer, places air traffic into PCAP or IVS files showing information.
  • airtun-ng virtual tunnel interface creator.
  • packetforge-ng creates encrypted packets for injection.
  • ivstools tools to merge and convert.
  • airbase-ng incorporates techniques for attacking clients, as opposed to Access Points.
  • airdecloak-ng removes WEP cloaking from PACP files.
  • airdriver-ng tools for managing wireless drivers
  • airolib-ng stores and manages ESSID and password lists and compute Pairwise Master Keys
  • airserv-ng allows to access the wireless card from other computers.
  • buddy-ng helps server for easside-ng, runs on a remote computer
  • tkiptun-ng WPA/TKIP attack
  • wesside-ng automatic tool for recovering wep key.

Another essential software tool to be used is Wireshark, formerly known as Ethereal, a protocol analyzer used for analyzing and solving problems in communication networks, for software and protocol development, and as an educational tool. It has all the standard features of a protocol analyzer. The functionality provided is similar to tcpdump, but it adds a graphical interface and many options for organizing and filtering of information. So, you see all the traffic passing through a network, setting promiscuous mode configuration. It also includes a text-based version named tshark, examining data from a live network or from a capture file saved to disk. You can analyze the information captured through the details and summaries for each package. Wireshark includes a complete language filter, and the ability to follow the reconstructed stream of a TCP session. 

Wireshark is free software, and runs on most Unix and compatible operating systems, including Linux, Solaris, FreeBSD, NetBSD, OpenBSD, and Mac OS X, as well as Microsoft Windows.



From the hardware perspective, the hacker laptop is equipped with an Alfa Network AWUS036H wireless adapter. Its key features are:

- 54Mbps via USB 2.0 (also USB 1.1) for desktop and notebook computers
- Maximum advertised output of 1 Watt
- Compact size and great flexibility
- Plug-and-Play compatible with Microsoft Windows and Linux (drivers integrated in BackTrackR5)
- High security 64/128/256bit WEP Encryption, TKIP, WPA, 802.11x
- Packet sniffing
- Packet injection

- As we will se later, its MAC address is 00:c0:ca:72:1a:36



0.3.4 - The victim

The role of victim of the attacks launched from "kali" will be the laptop named "roch" (also the legitimiate AP will be attacked), equipped with operative system Windows 7 and a wireless network interface.

Laptop "roch" uses the Netgear N600 Wireless Dual Band USB Adapter. Dual band technology avoids interference, ensuring high speeds and great ranges. It includes an easy setup with the Smart Wizard® CD, while Push 'N' Connect gives a secured connection just pushing a button.

Its MAC address is 28:c6:8e:63:15:6b