1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Merge branch 'develop'

This commit is contained in:
Matias Fontanini
2017-03-23 19:31:10 -07:00
15 changed files with 128 additions and 27 deletions

View File

@@ -49,8 +49,14 @@ SET(LIBTINS_VERSION "${LIBTINS_VERSION_MAJOR}.${LIBTINS_VERSION_MINOR}")
# Required Packages
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
# Allow disabling packet capture mechanism
OPTION(LIBTINS_ENABLE_PCAP "Enable capturing packets via libpcap" ON)
# Look for libpcap
FIND_PACKAGE(PCAP REQUIRED)
IF(LIBTINS_ENABLE_PCAP)
FIND_PACKAGE(PCAP REQUIRED)
SET(TINS_HAVE_PCAP ON)
ENDIF()
# Set some Windows specific flags
IF(WIN32)
@@ -194,10 +200,10 @@ ENDIF(WIN32)
OPTION(LIBTINS_USE_PCAP_SENDPACKET "Use pcap_sendpacket to send l2 packets"
${USE_PCAP_SENDPACKET_DEFAULT})
IF(LIBTINS_USE_PCAP_SENDPACKET)
IF(LIBTINS_ENABLE_PCAP AND LIBTINS_USE_PCAP_SENDPACKET)
SET(TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET ON)
MESSAGE(STATUS "Using pcap_sendpacket to send l2 packets.")
ENDIF(LIBTINS_USE_PCAP_SENDPACKET)
ENDIF()
# Add a target to generate API documentation using Doxygen
FIND_PACKAGE(Doxygen QUIET)
@@ -255,8 +261,12 @@ ADD_CUSTOM_TARGET(uninstall
# Add subdirectories
# ******************
ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(examples)
ADD_SUBDIRECTORY(src)
IF(LIBTINS_ENABLE_PCAP)
ADD_SUBDIRECTORY(examples)
ELSE()
MESSAGE(STATUS "Not building examples as pcap support is disabled")
ENDIF()
# Only include googletest if the git submodule has been fetched
IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/googletest/CMakeLists.txt")

View File

@@ -28,4 +28,7 @@
/* Have WPA2Decrypter callbacks */
#cmakedefine TINS_HAVE_WPA2_CALLBACKS
/* Have libpcap */
#cmakedefine TINS_HAVE_PCAP
#endif // TINS_CONFIG_H

View File

@@ -40,6 +40,7 @@
#include "constants.h"
#include "pdu.h"
#include "hw_address.h"
#include "macros.h"
/**
* \cond
@@ -124,8 +125,10 @@ PDU* pdu_from_flag(Constants::Ethernet::e flag, const uint8_t* buffer,
uint32_t size, bool rawpdu_on_no_match = true);
PDU* pdu_from_flag(Constants::IP::e flag, const uint8_t* buffer,
uint32_t size, bool rawpdu_on_no_match = true);
#ifdef TINS_HAVE_PCAP
PDU* pdu_from_dlt_flag(int flag, const uint8_t* buffer,
uint32_t size, bool rawpdu_on_no_match = true);
#endif // TINS_HAVE_PCAP
PDU* pdu_from_flag(PDU::PDUType type, const uint8_t* buffer, uint32_t size);
Constants::Ethernet::e pdu_flag_to_ether_type(PDU::PDUType flag);

View File

@@ -32,9 +32,12 @@
#include <string>
#include <stdint.h>
#include "data_link_type.h"
#include "macros.h"
#ifdef TINS_HAVE_PCAP
#include "data_link_type.h"
namespace Tins {
class PDU;
@@ -154,6 +157,9 @@ private:
mutable bpf_program filter_;
std::string string_filter_;
};
} // Tins
#endif // TINS_HAVE_PCAP
#endif // TINS_OFFLINE_PACKET_FILTER_H

View File

@@ -33,11 +33,13 @@
#include "utils.h"
#include <string>
#include <iterator>
#include <pcap.h>
#include "data_link_type.h"
#include "macros.h"
#include "cxxstd.h"
#ifdef TINS_HAVE_PCAP
#include <pcap.h>
#include "data_link_type.h"
struct timeval;
namespace Tins {
@@ -220,6 +222,9 @@ private:
pcap_t* handle_;
pcap_dumper_t* dumper_;
};
}
} // Tins
#endif // TINS_HAVE_PCAP
#endif // TINS_PACKET_WRITER_H

View File

@@ -33,6 +33,9 @@
#include "pdu.h"
#include "macros.h"
// This class is only available if pcap is enabled
#ifdef TINS_HAVE_PCAP
namespace Tins {
/**
@@ -111,4 +114,6 @@ private:
} // Tins
#endif // TINS_HAVE_PCAP
#endif // TINS_PKTAP_H

View File

@@ -35,6 +35,8 @@
#include "endianness.h"
#include "small_uint.h"
#ifdef TINS_HAVE_PCAP
namespace Tins {
/**
@@ -135,6 +137,9 @@ private:
ppi_header header_;
byte_array data_;
};
}
} // Tins
#endif // TINS_HAVE_PCAP
#endif // TINS_PPI_H

View File

@@ -31,8 +31,6 @@
#ifndef TINS_SNIFFER_H
#define TINS_SNIFFER_H
#include <pcap.h>
#include <string>
#include <memory>
#include <stdexcept>
@@ -44,6 +42,10 @@
#include "exceptions.h"
#include "internals.h"
#ifdef TINS_HAVE_PCAP
#include <pcap.h>
namespace Tins {
class SnifferIterator;
class SnifferConfiguration;
@@ -645,4 +647,6 @@ void Tins::BaseSniffer::sniff_loop(Functor function, uint32_t max_packets) {
} // Tins
#endif // TINS_HAVE_PCAP
#endif // TINS_SNIFFER_H

View File

@@ -36,13 +36,16 @@
#include <vector>
#include <algorithm>
#include <stdint.h>
#include "sniffer.h"
#include "macros.h"
#include "tcp.h"
#include "utils.h"
#include "ip.h"
#include "ip_address.h"
#ifdef TINS_HAVE_PCAP
#include "sniffer.h"
namespace Tins {
class Sniffer;
class RawPDU;
@@ -385,4 +388,6 @@ bool TCPStreamFollower::callback(PDU& pdu,
} // Tins
#endif // TINS_HAVE_PCAP
#endif // TINS_TCP_STREAM_H

View File

@@ -14,8 +14,7 @@ INCLUDE_DIRECTORIES(
${PCAP_INCLUDE_DIR}
)
ADD_LIBRARY(
tins ${LIBTINS_TYPE}
set(SOURCES
arp.cpp
bootp.cpp
handshake_capturer.cpp
@@ -43,19 +42,14 @@ ADD_LIBRARY(
loopback.cpp
mpls.cpp
network_interface.cpp
offline_packet_filter.cpp
packet_sender.cpp
packet_writer.cpp
ppi.cpp
pdu.cpp
pktap.cpp
radiotap.cpp
address_range.cpp
rawpdu.cpp
rsn_information.cpp
sll.cpp
snap.cpp
sniffer.cpp
tcp.cpp
tcp_ip/ack_tracker.cpp
tcp_ip/flow.cpp
@@ -63,7 +57,6 @@ ADD_LIBRARY(
tcp_ip/stream.cpp
tcp_ip/stream_follower.cpp
tcp_ip/stream_identifier.cpp
tcp_stream.cpp
timestamp.cpp
udp.cpp
utils.cpp
@@ -77,9 +70,28 @@ ADD_LIBRARY(
dot11/dot11_control.cpp
)
SET(PCAP_DEPENDENT_SOURCES
sniffer.cpp
packet_writer.cpp
pktap.cpp
tcp_stream.cpp
offline_packet_filter.cpp
ppi.cpp
)
IF(LIBTINS_ENABLE_PCAP)
message(STATUS "SETTING TO ${PCAP_DEPENDENT_SOURCES}")
SET(SOURCES ${SOURCES} ${PCAP_DEPENDENT_SOURCES})
ENDIF()
ADD_LIBRARY(
tins ${LIBTINS_TYPE}
${SOURCES}
)
TARGET_LINK_LIBRARIES(tins ${PCAP_LIBRARY} ${OPENSSL_LIBRARIES} ${LIBTINS_OS_LIBS})
SET_TARGET_PROPERTIES(tins PROPERTIES OUTPUT_NAME tins )
SET_TARGET_PROPERTIES(tins PROPERTIES OUTPUT_NAME tins)
SET_TARGET_PROPERTIES(tins PROPERTIES VERSION ${LIBTINS_VERSION} SOVERSION ${LIBTINS_VERSION} )
# Install instructions for this target

View File

@@ -355,6 +355,12 @@ SNAP* SessionKeys::ccmp_decrypt_unicast(const Dot11Data& dot11, RawPDU& raw) con
counter[14] = (total_sz >> 8) & 0xff;
counter[15] = total_sz & 0xff;
if (dot11.subtype() == Dot11::QOS_DATA_DATA) {
const uint32_t offset = (dot11.from_ds() && dot11.to_ds()) ? 30 : 24;
AAD[offset] = static_cast<const Dot11QoSData&>(dot11).qos_control() & 0x0f;
counter[1] = AAD[offset];
}
AES_encrypt(counter, MIC, &ctx);
xor_range(MIC, AAD, MIC, 16);
AES_encrypt(MIC, MIC, &ctx);

View File

@@ -28,7 +28,9 @@
*/
#include "internals.h"
#include <pcap.h>
#ifdef TINS_HAVE_PCAP
#include <pcap.h>
#endif // TINS_HAVE_PCAP
#include "ip.h"
#include "ethernetII.h"
#include "ieee802_3.h"
@@ -179,6 +181,7 @@ Tins::PDU* pdu_from_flag(Constants::IP::e flag,
return 0;
}
#ifdef TINS_HAVE_PCAP
PDU* pdu_from_dlt_flag(int flag,
const uint8_t* buffer,
uint32_t size,
@@ -208,6 +211,7 @@ PDU* pdu_from_dlt_flag(int flag,
return rawpdu_on_no_match ? new RawPDU(buffer, size) : 0;
};
}
#endif // TINS_HAVE_PCAP
Tins::PDU* pdu_from_flag(PDU::PDUType type, const uint8_t* buffer, uint32_t size) {
switch(type) {

View File

@@ -2,6 +2,6 @@ SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
INCLUDE_DIRECTORIES(${gtest_INCLUDE_DIRS})
ADD_SUBDIRECTORY(src)
IF (ENABLE_ACTIVE_TESTS)
IF (ENABLE_ACTIVE_TESTS AND LIBTINS_ENABLE_PCAP)
ADD_SUBDIRECTORY(active_tests)
ENDIF()

View File

@@ -75,9 +75,7 @@ CREATE_TEST(loopback)
CREATE_TEST(matches_response)
CREATE_TEST(mpls)
CREATE_TEST(network_interface)
CREATE_TEST(offline_packet_filter)
CREATE_TEST(pdu)
CREATE_TEST(ppi)
CREATE_TEST(pppoe)
CREATE_TEST(radiotap)
CREATE_TEST(rc4_eapol)
@@ -87,11 +85,16 @@ CREATE_TEST(snap)
CREATE_TEST(stp)
CREATE_TEST(tcp)
CREATE_TEST(tcp_ip)
CREATE_TEST(tcp_stream)
CREATE_TEST(udp)
CREATE_TEST(utils)
CREATE_TEST(wep_decrypt)
IF(LIBTINS_ENABLE_PCAP)
CREATE_TEST(offline_packet_filter)
CREATE_TEST(ppi)
CREATE_TEST(tcp_stream)
ENDIF()
IF(LIBTINS_ENABLE_WPA2)
CREATE_TEST(wpa2_decrypt)
ENDIF()

View File

@@ -11,6 +11,7 @@
#include "dot11/dot11_data.h"
#include "udp.h"
#include "tcp.h"
#include "arp.h"
using namespace Tins;
@@ -21,8 +22,9 @@ class WPA2DecryptTest : public testing::Test {
public:
typedef HWAddress<6> address_type;
static const uint8_t ccmp_packets[7][652];
static const uint8_t ccmp_qos_packets[6][212];
static const uint8_t tkip_packets[7][211];
static const size_t ccmp_packets_size[], tkip_packets_size[];
static const size_t ccmp_packets_size[], ccmp_qos_packets_size[], tkip_packets_size[];
struct handshake {
handshake(const string& ssid, const address_type& bssid, const address_type& client_hw)
@@ -79,6 +81,15 @@ const uint8_t WPA2DecryptTest::ccmp_packets[7][652] = {
{0, 0, 24, 0, 142, 88, 0, 0, 16, 108, 108, 9, 192, 0, 100, 0, 0, 41, 0, 0, 190, 202, 53, 174, 8, 66, 44, 0, 0, 13, 147, 130, 54, 58, 0, 12, 65, 130, 178, 85, 0, 12, 65, 130, 178, 83, 240, 252, 1, 0, 0, 32, 0, 0, 0, 0, 119, 49, 71, 116, 105, 136, 85, 205, 132, 196, 180, 119, 142, 132, 254, 142, 107, 185, 34, 64, 127, 182, 129, 59, 98, 183, 207, 159, 167, 27, 149, 169, 74, 170, 255, 149, 57, 187, 223, 19, 162, 165, 18, 63, 50, 153, 100, 9, 247, 29, 231, 199, 141, 125, 148, 9, 183, 62, 244, 101, 50, 254, 146, 237, 122, 204, 152, 151, 197, 153, 31, 122, 219, 59, 230, 26, 123, 231, 100, 31, 201, 119, 175, 228, 12, 189, 233, 235, 65, 148, 46, 143, 49, 144, 44, 76, 79, 143, 126, 163, 219, 81, 122, 250, 102, 252, 179, 97, 116, 151, 128, 138, 29, 29, 171, 64, 93, 233, 245, 44, 35, 244, 249, 140, 160, 198, 188, 44, 120, 38, 104, 52, 107, 70, 115, 34, 239, 117, 195, 195, 20, 193, 85, 224, 22, 142, 205, 27, 155, 34, 62, 19, 32, 199, 200, 3, 59, 253, 188, 180, 177, 41, 150, 247, 98, 199, 127, 43, 239, 236, 116, 51, 19, 185, 188, 97, 156, 151, 64, 144, 20, 103, 61, 23, 210, 236, 235, 23, 216, 116, 121, 14, 191, 150, 210, 255, 195, 230, 167, 53, 254, 207, 35, 28, 18, 209, 240, 112, 156, 181, 151, 30, 81, 215, 6, 225, 106, 153, 48, 91, 102, 171, 115, 62, 46, 70, 255, 39, 183, 219, 199, 73, 97, 127, 92, 18, 153, 206, 150, 200, 7, 153, 82, 151, 34, 170, 177, 94, 178, 149, 202, 164, 210, 176, 112, 106, 73, 213, 101, 14, 195, 115, 168, 153, 217, 52, 76, 130, 116, 159, 226, 247, 234, 238, 6, 250, 141, 149, 133, 208, 40, 106, 172, 130, 187, 114, 216, 250, 124, 47, 4, 227, 198, 97, 125, 69, 2, 219, 87, 123, 79, 150, 116, 187, 239, 120, 236, 199, 185, 96, 30, 112, 233, 237, 179, 28, 46, 149, 102, 253, 150, 133, 179, 71, 7, 119, 201, 39, 196, 106, 251, 100, 195, 201, 47, 109, 227, 158, 27, 70, 207, 241, 222, 179, 225, 220, 189, 224, 97, 134, 11, 150, 127, 235, 224, 222, 110, 141, 224, 0, 167, 126, 72, 155, 185, 162, 128, 141, 120, 39, 165, 5, 211, 222, 20, 11, 129, 222, 142, 149, 130, 136, 106, 105, 118, 135, 9, 220, 180, 196, 117, 66, 82, 215, 186, 107, 252, 85, 41, 131, 238, 85, 233, 197, 228, 157, 49, 42, 57, 52, 40, 235, 240, 208, 248, 180, 26, 153, 227, 223, 33, 247, 236, 162, 226, 253, 63, 144, 199, 157, 164, 56, 185, 19, 8, 197, 210, 129, 90, 177, 16, 119, 165, 208, 244, 247, 253, 121, 10, 51, 15, 215, 140, 231, 51, 198, 168, 11, 54, 126, 135, 145, 13, 161, 192, 119, 16, 184, 30, 235, 23, 133, 20, 247, 139, 30, 235, 110, 211, 13, 39, 76, 4, 153, 83, 236, 215, 52, 107, 75, 188, 73, 74, 60, 203, 80, 194, 127, 7, 65, 225, 195, 139, 166, 176, 22, 151, 54, 204, 159, 5, 254, 82, 145, 230, 163, 254, 191, 206, 29, 198, 78, 198, 232, 238, 247, 104, 245, 100, 67, 108, 90, 88, 177, 136, 32, 28, 76, 108, 195, 172, 251, 121, 158, 23, 52, 33, 118, 205, 239, 50, 163, 118, 65, 150, 69, 109, 152, 70, 31, 235, 102, 126, 254, 209, 228, 148, 203, 137, 34, 20, 69, 141, 180, 177, 154, 155, 35, 101, 1, 78, 207, 67, 117, 29, 104, 9, 244, 3, 220, 131, 61, 190, 202, 53, 174}
};
const uint8_t WPA2DecryptTest::ccmp_qos_packets[6][212] = {
{ 0, 0, 18, 0, 46, 72, 0, 0, 0, 2, 133, 9, 160, 0, 220, 0, 0, 0, 128, 0, 0, 0, 255, 255, 255, 255, 255, 255, 234, 8, 107, 231, 33, 218, 234, 8, 107, 231, 33, 218, 16, 118, 178, 33, 38, 40, 0, 0, 0, 0, 100, 0, 49, 0, 0, 7, 84, 101, 115, 116, 105, 110, 103, 1, 8, 130, 132, 139, 150, 12, 18, 24, 36, 3, 1, 6, 5, 4, 0, 1, 0, 0, 42, 1, 2, 50, 4, 48, 72, 96, 108, 45, 26, 239, 17, 27, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 61, 22, 6, 7, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 8, 0, 0, 0, 0, 0, 0, 0, 64, 221, 24, 0, 80, 242, 2, 1, 1, 128, 0, 3, 164, 0, 0, 39, 164, 0, 0, 66, 67, 94, 0, 98, 50, 47, 0, 221, 9, 0, 3, 127, 1, 1, 0, 0, 255, 127, 48, 20, 1, 0, 0, 15, 172, 4, 1, 0, 0, 15, 172, 4, 1, 0, 0, 15, 172, 2, 0, 0 },
{ 0, 0, 18, 0, 46, 72, 0, 0, 0, 2, 133, 9, 160, 0, 220, 0, 0, 0, 136, 2, 58, 1, 140, 123, 157, 105, 9, 17, 234, 8, 107, 231, 33, 218, 234, 8, 107, 231, 33, 218, 0, 0, 6, 0, 170, 170, 3, 0, 0, 0, 136, 142, 2, 3, 0, 95, 2, 0, 138, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 36, 134, 168, 19, 133, 30, 4, 145, 162, 245, 14, 253, 175, 250, 91, 26, 133, 121, 10, 46, 52, 193, 62, 33, 9, 195, 138, 114, 186, 130, 13, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 18, 0, 46, 72, 0, 0, 0, 2, 133, 9, 160, 0, 212, 0, 0, 0, 136, 1, 58, 1, 234, 8, 107, 231, 33, 218, 140, 123, 157, 105, 9, 17, 234, 8, 107, 231, 33, 218, 0, 0, 0, 0, 170, 170, 3, 0, 0, 0, 136, 142, 2, 3, 0, 117, 2, 1, 10, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 185, 15, 144, 240, 135, 131, 195, 230, 224, 206, 6, 115, 152, 193, 57, 247, 207, 189, 130, 18, 16, 144, 246, 255, 72, 6, 64, 54, 1, 177, 13, 141, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 241, 201, 157, 151, 101, 162, 70, 81, 34, 123, 24, 54, 82, 23, 135, 43, 0, 22, 48, 20, 1, 0, 0, 15, 172, 4, 1, 0, 0, 15, 172, 4, 1, 0, 0, 15, 172, 2, 12, 0 },
{ 0, 0, 18, 0, 46, 72, 0, 0, 0, 2, 133, 9, 160, 0, 224, 0, 0, 0, 136, 2, 58, 1, 140, 123, 157, 105, 9, 17, 234, 8, 107, 231, 33, 218, 234, 8, 107, 231, 33, 218, 16, 0, 6, 0, 170, 170, 3, 0, 0, 0, 136, 142, 2, 3, 0, 151, 2, 19, 202, 0, 16, 0, 0, 0, 0, 0, 0, 0, 2, 36, 134, 168, 19, 133, 30, 4, 145, 162, 245, 14, 253, 175, 250, 91, 26, 133, 121, 10, 46, 52, 193, 62, 33, 9, 195, 138, 114, 186, 130, 13, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 182, 188, 36, 244, 126, 153, 16, 21, 165, 68, 51, 21, 99, 232, 1, 0, 56, 224, 33, 172, 28, 130, 64, 168, 64, 122, 19, 12, 113, 96, 203, 205, 46, 209, 246, 12, 195, 191, 81, 52, 92, 168, 228, 34, 174, 105, 66, 199, 79, 39, 39, 68, 148, 221, 76, 238, 31, 239, 18, 205, 180, 164, 77, 85, 4, 160, 255, 90, 11, 0, 228, 34, 79 },
{ 0, 0, 18, 0, 46, 72, 0, 0, 0, 2, 133, 9, 160, 0, 216, 0, 0, 0, 136, 1, 58, 1, 234, 8, 107, 231, 33, 218, 140, 123, 157, 105, 9, 17, 234, 8, 107, 231, 33, 218, 16, 0, 0, 0, 170, 170, 3, 0, 0, 0, 136, 142, 2, 3, 0, 95, 2, 3, 10, 0, 16, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 180, 81, 43, 43, 243, 213, 192, 56, 174, 32, 141, 69, 172, 1, 201, 193, 0, 0 },
{ 0, 0, 21, 0, 42, 72, 8, 0, 0, 0, 133, 9, 128, 4, 225, 0, 0, 0, 39, 0, 7, 136, 65, 44, 0, 234, 8, 107, 231, 33, 218, 140, 123, 157, 105, 9, 17, 236, 8, 107, 231, 33, 218, 16, 0, 6, 0, 5, 0, 0, 32, 0, 0, 0, 0, 27, 145, 139, 201, 131, 102, 105, 133, 248, 73, 15, 118, 83, 59, 241, 213, 220, 137, 172, 31, 142, 107, 61, 249, 216, 186, 52, 53, 203, 197, 91, 208, 23, 153, 118, 224, 221, 43, 248, 239, 148, 101, 122, 191 }
};
const uint8_t WPA2DecryptTest::tkip_packets[7][211] = {
// Beacon
{0, 0, 18, 0, 46, 72, 0, 0, 0, 2, 108, 9, 160, 0, 221, 3, 0, 0, 128, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 27, 17, 210, 27, 235, 0, 27, 17, 210, 27, 235, 128, 178, 129, 97, 244, 15, 0, 0, 0, 0, 100, 0, 17, 0, 0, 4, 78, 79, 68, 79, 1, 4, 130, 132, 139, 150, 3, 1, 1, 5, 4, 0, 1, 0, 0, 48, 20, 1, 0, 0, 15, 172, 2, 1, 0, 0, 15, 172, 2, 1, 0, 0, 15, 172, 2, 0, 0, 221, 9, 0, 3, 127, 1, 1, 0, 32, 255, 127},
@@ -96,6 +107,10 @@ const size_t WPA2DecryptTest::ccmp_packets_size[] = {
168, 181, 181, 239, 159, 404, 652
};
const size_t WPA2DecryptTest::ccmp_qos_packets_size[] = {
212, 151, 173, 207, 151, 99
};
const size_t WPA2DecryptTest::tkip_packets_size[] = {
108, 149, 171, 211, 149, 134, 134
};
@@ -147,6 +162,21 @@ TEST_F(WPA2DecryptTest, DecryptCCMPUsingBeacon) {
}
}
TEST_F(WPA2DecryptTest, DecryptCCMPQosUsingBeacon) {
Crypto::WPA2Decrypter decrypter;
decrypter.add_ap_data("password1", "Testing");
for(size_t i = 0; i < 6; ++i) {
RadioTap radio(ccmp_qos_packets[i], ccmp_qos_packets_size[i]);
if (i > 4) {
ASSERT_TRUE(decrypter.decrypt(radio));
EXPECT_TRUE(radio.find_pdu<ARP>() != 0);
}
else {
ASSERT_FALSE(decrypter.decrypt(radio));
}
}
}
TEST_F(WPA2DecryptTest, DecryptCCMPWithoutUsingBeacon) {
Crypto::WPA2Decrypter decrypter;
decrypter.add_ap_data("Induction", "Coherer", "00:0c:41:82:b2:55");