/// <summary> /// Provides a record-by-record processing functionality for the cmdlet. /// </summary> protected override void ProcessRecord() { WebPageSteganography stegoPage = new WebPageSteganography(this.Path, this.Passphrase); stegoPage.WriteValue(this.Message); string check = stegoPage.ReadValue(); this.WriteVerbose(check); this.WriteObject("Message saved."); }
/// <summary> /// The handler for HTTP GET requests. /// </summary> /// <param name="processor">The HTTP processor.</param> public void HttpGetHandler(HttpProcessor processor) { processor.WriteSuccess(); Cryptkeeper myCrypt = new Cryptkeeper(this.passphrase); DerivedValue derived = new DerivedValue(this.passphrase); string result = derived.GetString(3, 10); // No result? No handshake. Done. if (processor.RequestURL.IndexOf(result) == -1) return; // Parse out the host name and fetch the next page. string hostname = string.Empty; string absolutePath = processor.RequestURL; string[] values = absolutePath.Split(new string[] { result }, StringSplitOptions.RemoveEmptyEntries); absolutePath = values[0].Trim(); string hostBase64 = values[1].Trim(); byte[] hostBytes = System.Convert.FromBase64String(hostBase64); hostname = Encoding.ASCII.GetString(hostBytes); Uri link = new Uri(string.Concat("http://", hostname, absolutePath)); try { WebClient web = new WebClient(); byte[] page = web.DownloadData(link); web.Dispose(); WebPageSteganography stegopage = new WebPageSteganography(page, this.passphrase); string message = string.Empty; if (this.MessageQueue.Count > 0) { message = (string)this.MessageQueue.Dequeue(); } stegopage.WriteValue(message); page = stegopage.GetBytes(); processor.StreamOutput.Write(page); processor.StreamOutput.Flush(); processor.WriteSuccess(); } catch (Exception ex) { processor.StreamOutput.Write("<html><p>Ping! Something odd happened while retrieving ... " + link.ToString() + "</p><p>" + ex.ToString() + "</p></html>"); } }