/// <summary>
/// Interactive Mode allows the user to key in message after message, and have the message sent over the covert channel.
/// </summary>
private void InteractiveMode()
{
// Update the screen with the parameters of the chat session
this.PrintInteractiveMode(ChannelTools.CommunicationMode.Alice);
// Wait for the client connection
this.WriteVerbose("Waiting for client connect . . .");
NamedPipeServerStream pipeServer = new NamedPipeServerStream(
this.CmdletGuid,
PipeDirection.InOut);
DerivedValue derived = new DerivedValue(this.Passphrase);
string handshake = derived.GetString(3, 12);
this.WriteVerbose(string.Format("Handshaking with {0}.", handshake));
pipeServer.WaitForConnection();
this.WriteVerbose("Connected. Ready to send chat messages.");
try
{
// Read the request from the client
IncogStream stream = new IncogStream(pipeServer, this.Passphrase, this.TargetEntropy);
// Verify our identity to the connected client using a handshake string
stream.WriteString(handshake);
do
{
Console.Write("{0}> ", this.CmdletName);
string line = Console.ReadLine();
if (line == string.Empty) continue;
stream.WriteString(line);
if (line.ToLower() == "exit") break;
}
while (true);
}
catch (System.IO.IOException e)
{
// Catch the IOException that is raised if the pipe is broken or disconnected.
this.WriteWarning(e.Message);
}
pipeServer.Close();
}