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

The connecting part for the CovertChannel and the framework. More...

Public Member Functions

 ChannelManager ()
 Constructor.
 
 ~ChannelManager ()
 Destructor.
 
void setErrorStream (std::ostream *stream)
 Sets the stream that is used to output error messages of the channelmanager. More...
 
vector< string > getChannelNames ()
 Returns a list with available covert channels. More...
 
vector< string > getChannelInfos ()
 Returns a list with descriptions of all available covert channels. More...
 
vector< string > getChannelIDs ()
 Returns a list with IDs of the available covert channels. More...
 
unsigned int channelCount ()
 Returns the amount of available channels. More...
 
void setChannelArguments (string ip, string arguments)
 Sets the arguments of the current covert channel. More...
 
void addChannel (CovertChannel *channel)
 adds an CovertChannel to the available Channels (m_channels) More...
 
void setOutputStream (std::ostream *stream)
 Sets the stream, that the covert channel uses as the output for received messages. More...
 
void setMessageCallback (function< void(string, string)> message_callback)
 Sets a function that is called, when a covert channel receives a message. More...
 
void outputMessage (string ip, string message)
 Writes a message to the selected output stream. More...
 
void packetReceived (string ip, GenericPacket packet)
 Is called, when a packet is received on the network. More...
 
void sendPacket (string ip, GenericPacket packet, string protocol)
 sends a packet to m_network More...
 
bool openConnection (string ip, string channel_id)
 Starts a conversation. More...
 
void closeConnection (string ip)
 Stops a conversation. More...
 
unsigned int connectionCount ()
 Returns the number of open connections.
 
bool connection (string ip)
 Checks for an open connection with a specific ip. More...
 
void sendMessage (string ip, string message)
 Sends a message to the given ip. More...
 
bool setAdapter (string name)
 Sets the network adapter that is used to send (win32 only) and receive messages. More...
 
unsigned int adapterCount ()
 Returns the number of available network adapters.
 
vector< string > networkAdapters ()
 Returns a list of available network adapters. More...
 
string adapterDescription (string adapter_name)
 Returns the description of an adapter. More...
 
vector< string > adapterAddresses ()
 Returns the network addresses of the currently set adapter. More...
 

Private Member Functions

void outputErrorMessage (string message)
 Outputs an error message to the stream set with 'setErrorStream'. More...
 
CovertChannelcreateChannel (string ip, CovertChannel *channel)
 Covert channel factory. More...
 

Private Attributes

map< string, CovertChannel * > m_channels
 
std::ostream * m_output_stream
 Stream that is used to output messages received by a covert channel.
 
std::ostream * m_error_stream
 Stream that is used to output error messages.
 
NetworkConnectorm_network
 Pointer to NetworkConnector that is used to access network functionalities.
 
map< string, CovertChannel * > m_ip_mapping
 
function< void(string, string)> m_message_callback
 

Detailed Description

The connecting part for the CovertChannel and the framework.

You can add and remove covert channels you want to use. You pass the data you want to send to this class. It is connected to the network via a SocketConnector.

Member Function Documentation

vector< string > whisper_library::ChannelManager::adapterAddresses ( )

Returns the network addresses of the currently set adapter.

Returns
Vector of Ipv4 addresses in dotted form.
string whisper_library::ChannelManager::adapterDescription ( string  adapter_name)

Returns the description of an adapter.

Parameters
adapter_nameunique name of the adapter. Can be retrieved by calling 'networkAdapters'.
Returns
adapter description as a string. If the description is NULL, an empty string is returned.
void whisper_library::ChannelManager::addChannel ( CovertChannel channel)

adds an CovertChannel to the available Channels (m_channels)

Parameters
channelan Instance of the Covert Channel you want to add. Can be created with the default constructor and is only used for information and Channel creation by calling CovertChannel::instance()
unsigned int whisper_library::ChannelManager::channelCount ( )

Returns the amount of available channels.

Returns
Number of available channels
void whisper_library::ChannelManager::closeConnection ( string  ip)

Stops a conversation.

Closes the covert channel and stops listening for packets of the given ip.

Parameters
ipIpv4 address of the host you no longer want to communicate with
bool whisper_library::ChannelManager::connection ( string  ip)

Checks for an open connection with a specific ip.

Parameters
ipIpv4 address of the host that you want to check
Returns
True, if there is an open connection, otherwise false
CovertChannel * whisper_library::ChannelManager::createChannel ( string  ip,
CovertChannel channel 
)
private

Covert channel factory.

Creates a covert channel instance and returns a pointer to the object.

Parameters
ipIpv4 address you want to communicate with using the created channel
channelinstance of the CovertChannel you want to create
Returns
Pointer to the created covert channel instance
vector< string > whisper_library::ChannelManager::getChannelIDs ( )

Returns a list with IDs of the available covert channels.

Returns
A vector<string> with channel IDs
vector< string > whisper_library::ChannelManager::getChannelInfos ( )

Returns a list with descriptions of all available covert channels.

The order matches the name list retrieved by calling 'getChannelNames'.

Returns
A vector with descriptions of all covert channels
vector< string > whisper_library::ChannelManager::getChannelNames ( )

Returns a list with available covert channels.

Returns
Returns a vector with the names of all available covert channels
vector< string > whisper_library::ChannelManager::networkAdapters ( )

Returns a list of available network adapters.

The name of a network adapter uniquely identifies it and is used to select it by calling 'setAdapter'.

Returns
Vector with the unique names
bool whisper_library::ChannelManager::openConnection ( string  ip,
string  channel_id 
)

Starts a conversation.

Opens a connection to a specific ip using the covert channel that matches the id. After calling this, you can send messages to that ip by calling 'sendMessage'.

Parameters
ipIpv4 you want to communicate with
channel_idid of the channel you want to use, to hide the coversation.
void whisper_library::ChannelManager::outputErrorMessage ( string  message)
private

Outputs an error message to the stream set with 'setErrorStream'.

Parameters
messageerror message that is display to the user
void whisper_library::ChannelManager::outputMessage ( string  ip,
string  message 
)

Writes a message to the selected output stream.

Change the output stream by calling 'setOutputStream'.

Parameters
ipthe sender ip of the message
messagethe message to be written
void whisper_library::ChannelManager::packetReceived ( string  ip,
GenericPacket  packet 
)

Is called, when a packet is received on the network.

It is then forwarded to the channel with the specified ip.

Parameters
ipIp of the sender of the packet
packetthe packet that was received
void whisper_library::ChannelManager::sendMessage ( string  ip,
string  message 
)

Sends a message to the given ip.

There needs to be an open connection to be able to send a message to that ip.

Parameters
ipIpv4 adress that you want to send the message to
messagethe message as string
void whisper_library::ChannelManager::sendPacket ( string  ip,
GenericPacket  packet,
string  protocol 
)

sends a packet to m_network

Interprets the given GenericPacket as an packet of the protocol and sends it to the given ip.

Parameters
ipthe receivers IP
packetthe packet to send
protocolthe protocol used to send the packet
bool whisper_library::ChannelManager::setAdapter ( string  name)

Sets the network adapter that is used to send (win32 only) and receive messages.

Parameters
nameunique name of the adapter. A list of adapters can be retrieved by calling 'networkAdapters'.
Returns
true if setting the adapter was successful
void whisper_library::ChannelManager::setChannelArguments ( string  ip,
string  arguments 
)

Sets the arguments of the current covert channel.

The string arguments is parsed by the channel to set channel specific options. More information on which arguments are supported can be found in the specific covertchannel source.

Parameters
ipdestination ip the covert channel is used to communicate with
argumentsargument string that is given to the channel
void whisper_library::ChannelManager::setErrorStream ( std::ostream *  stream)

Sets the stream that is used to output error messages of the channelmanager.

Parameters
streamstream that is used to output error messages
void whisper_library::ChannelManager::setMessageCallback ( function< void(string, string)>  message_callback)

Sets a function that is called, when a covert channel receives a message.

Parameters
message_callbackPointer to a function that is called, when a message is received. The first argument is the ip(v4) in dotted form, the message was received from. The second argument is the received message.
void whisper_library::ChannelManager::setOutputStream ( std::ostream *  stream)

Sets the stream, that the covert channel uses as the output for received messages.

Parameters
streama pointer to the output stream

Member Data Documentation

map<string, CovertChannel*> whisper_library::ChannelManager::m_channels
private

Holds an instance of each available covert channel type. Used just to pull information from, not for communication.

map<string, CovertChannel*> whisper_library::ChannelManager::m_ip_mapping
private

Maps Ipv4 addresses in dotted form to a pointer of the covert channel that is used to communicate with that ip

function<void(string, string)> whisper_library::ChannelManager::m_message_callback
private

Pointer to the function that is called when a covert channel receives a message. The first argument is the ip(v4) in dotted form, the message was received from. The second argument is the received message.