Whisper Library
 All Classes Functions Variables Typedefs Enumerations Friends
whisper_library::TcpHeaderCovertChannel Class Reference

A covert channel using tcp header fields. More...

Inheritance diagram for whisper_library::TcpHeaderCovertChannel:
Inheritance graph

Public Member Functions

 TcpHeaderCovertChannel (function< void(string)> output, function< void(GenericPacket)> send)
 Constructor. More...
 
CovertChannelinstance ()
 
void sendMessage (string message)
 
void receivePacket (GenericPacket &packet)
 
void setArguments (string arguments)
 configures the covert channel More...
 
void setOutput (function< void(string)> output)
 sets the output method More...
 
void setSend (function< void(GenericPacket)> send)
 sets the methode used to send packets
 
void initialize ()
 Initializes the covert channel. Is called after construction.
 
string name () const
 
string info () const
 
string protocol () const
 
unsigned short port () const
 
std::string id () const
 
- Public Member Functions inherited from whisper_library::CovertChannel
 CovertChannel ()
 Creates a CovertChannel.
 
virtual ~CovertChannel ()
 Destructor. More...
 
virtual void sendMessage (std::string message)=0
 sends a message More...
 

Private Member Functions

vector< bitset< 3 > > encodeMessageWithLength (string message)
 
void modifyTcpPacket (TcpPacket &packet, bitset< 3 > data)
 
bitset< 3 > extractData (TcpPacket &packet)
 

Private Attributes

vector< bitset< 3 > > m_data_blocks
 This vector stores the bit blocks we received in the current communication.
 
int m_remaining_packets
 
BitSetCoder< 3 > m_coder
 The encoder/decoder we use, to split messages into bit blocks.
 
TcpPacketGeneratorm_generator
 A TcpPacketGenerator acting as client used for sending messages.
 
function< void(string)> m_output
 callback function pointer that is used to return received messages as a string
 
function< void(GenericPacket)> m_send
 function pointer that is used to send Tcp Packets via the socket
 

Detailed Description

A covert channel using tcp header fields.

Covert Channel, that uses 3 bits of the TCP Header, that are not used, to hide a message. To use this class, call 'sendMessage' with your message as a string. Received packets are used to call 'receiveMessage'. The decoded message is given to the callback function 'm_output'.

Constructor & Destructor Documentation

whisper_library::TcpHeaderCovertChannel::TcpHeaderCovertChannel ( function< void(string)>  output,
function< void(GenericPacket)>  send 
)

Constructor.

Parameters
outputa function pointer that is called, when a complete message arrived. Its parameter is this message.
senda function pointer that is called to send a TcpPacket via the socket.

Member Function Documentation

vector< bitset< 3 > > whisper_library::TcpHeaderCovertChannel::encodeMessageWithLength ( string  message)
private

encodeMessageWithLength splits the message into parts of 3 bits and adds length blocks inbetween.

bitset< 3 > whisper_library::TcpHeaderCovertChannel::extractData ( whisper_library::TcpPacket packet)
private

extractData extracts the data we hid in the packet.

string whisper_library::TcpHeaderCovertChannel::id ( ) const
virtual
Returns
the ID of the covert channel

Implements whisper_library::CovertChannel.

string whisper_library::TcpHeaderCovertChannel::info ( ) const
virtual

Returns a string with basic information about the tcp header covert channel

Implements whisper_library::CovertChannel.

CovertChannel * whisper_library::TcpHeaderCovertChannel::instance ( )
virtual
Returns
an instance of this covert channel

Implements whisper_library::CovertChannel.

void whisper_library::TcpHeaderCovertChannel::modifyTcpPacket ( whisper_library::TcpPacket packet,
bitset< 3 >  data 
)
private

modifyTcpPacket sets the reserved bits of packet to the value of data.

string whisper_library::TcpHeaderCovertChannel::name ( ) const
virtual

Returns a string with the name of the covert channel "TCP Header Covert Channel"

Implements whisper_library::CovertChannel.

unsigned short whisper_library::TcpHeaderCovertChannel::port ( ) const
virtual
Returns
the used port

Implements whisper_library::CovertChannel.

string whisper_library::TcpHeaderCovertChannel::protocol ( ) const
virtual

Returns the protocol used by this covert channel

Implements whisper_library::CovertChannel.

void whisper_library::TcpHeaderCovertChannel::receivePacket ( GenericPacket packet)
virtual

This function is called, when a new packet arrives at the socket. It collects them and returns the message via the callback function "m_output".

Implements whisper_library::CovertChannel.

void whisper_library::TcpHeaderCovertChannel::sendMessage ( string  message)

SendMessage sends a message of type string through the Tcp Header Covert Channel.

void whisper_library::TcpHeaderCovertChannel::setArguments ( string  arguments)
inlinevirtual

configures the covert channel

Parameters
argumentsArguments that are given to the covert channel

Implements whisper_library::CovertChannel.

void whisper_library::TcpHeaderCovertChannel::setOutput ( function< void(string)>  output)
virtual

sets the output method

Parameters
outputthe method the covert channel uses to output the received messages

Implements whisper_library::CovertChannel.

Member Data Documentation

int whisper_library::TcpHeaderCovertChannel::m_remaining_packets
private

Stores the number of packets, we expect to receive in the current communication. 0 means, all packets were received and the channel is ready to receive a new length packet.