private void button2_Click(object sender, EventArgs e) { try { Application.DoEvents(); System.Threading.Thread.Sleep(1500); string fpath = Application.StartupPath + "\\Image\\encryptedText.txt"; EncryptFile(pictureBox1.Image, fpath); string fpath1 = Application.StartupPath + "\\Image\\encrypted.jpg"; EncryptFile(pictureBox1.Image, fpath1); string text = File.ReadAllText(textBox1.Text); bmp1 = new Bitmap(Bitmap.FromFile(Application.StartupPath + "\\input\\blank.jpg")); bmp = SteganographyHelper.embedText(text, bmp1); bmp.Save(Application.StartupPath + "\\Image\\EncryptedImage.jpg", ImageFormat.Jpeg); // Save the encrypted image panelCanvas.Image = Image.FromFile(Application.StartupPath + "\\Image\\EncryptedImage.jpg"); Application.DoEvents(); System.Threading.Thread.Sleep(1500); Cipher_text = Encrypt_text(txt_plain_text.Text, key); con.Open(); cmd = new SqlCommand("insert into encryption values('" + txt_plain_text.Text + "','" + key + "','" + Cipher_text + "')", con); cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Input Image and Text Encrypted Successfully"); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private static void Output() { // The password used to hide the information on the previous step var _PASSWORD = "******"; // The path to the image that contains the hidden information ///Users/surajfehintola/RiderProjects/Steganography/Steganography.ConsoleApplication/img/screen.png var pathImageWithHiddenInformation = @"/Users/surajfehintola/RiderProjects/Steganography/Steganography.ConsoleApplication/img/image_example_with_hidden_information.png"; // Create an instance of the SteganographyHelper var helper = new SteganographyHelper(); // Retrieve the encrypted data from the image var encryptedData = SteganographyHelper.ExtractText( new Bitmap( Image.FromFile(pathImageWithHiddenInformation) ) ); // Decrypt the retrieven data on the image var decryptedData = StringCipher.Decrypt(encryptedData, _PASSWORD); // Display the secret text in the console or in a messagebox // In our case is "Hello, no one should know that my password is 12345" Console.WriteLine(decryptedData); //MessageBox.Show(decryptedData); }
private void encodeButton_Click(object sender, EventArgs e) { if ((bmpFile == null) || (sourceFile == null)) { MessageBox.Show("You have to load bmp file and file to encrypt!"); } else { Image containerImg = Image.FromFile(bmpFile); Image toHideImg = Image.FromFile(sourceFile); Bitmap containerBitmap = new Bitmap(containerImg); Bitmap toHideBitap = new Bitmap(toHideImg); try { afterPictureBox.Image = SteganographyHelper.EncryptBitmap(containerBitmap, toHideBitap, nrBit); } catch (Exception) { MessageBox.Show("The file couldnot be encoded"); } } }
private static void Input() { // Declare the password that will allow you to retrieve the encrypted data later var _PASSWORD = "******"; // The String data to conceal on the image var _DATA_TO_HIDE = "Hello, no one should know that my password is 12345"; // Declare the path where the original image is located var pathOriginalImage = @"/Users/surajfehintola/RiderProjects/Steganography/Steganography.ConsoleApplication/img/screen.png"; // Declare the new name of the file that will be generated with the hidden information var pathResultImage = @"/Users/surajfehintola/RiderProjects/Steganography/Steganography.ConsoleApplication/img/image_example_with_hidden_information.png"; // Create an instance of the SteganographyHelper var helper = new SteganographyHelper(); // Encrypt your data to increase security // Remember: only the encrypted data should be stored on the image var encryptedData = StringCipher.Encrypt(_DATA_TO_HIDE, _PASSWORD); // Create an instance of the original image without indexed pixels var originalImage = SteganographyHelper.CreateNonIndexedImage(Image.FromFile(pathOriginalImage)); // Conceal the encrypted data on the image ! var imageWithHiddenData = SteganographyHelper.MergeText(encryptedData, originalImage); // Save the image with the hidden information somewhere :) // In this case the generated file will be image_example_with_hidden_information.png imageWithHiddenData.Save(pathResultImage); }
public string Decrypt() { HttpRequest httpRequest = HttpContext.Current.Request; HttpPostedFile postedFile = httpRequest.Files["Image"]; string secretKey = httpRequest.Params["SecretKey"]; byte[] key; try { key = Convert.FromBase64String(secretKey); } catch (Exception) { HttpResponseMessage response = this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invaid key length"); throw new HttpResponseException(response); } List <int> selectedBitList = new List <int>(); httpRequest.Params["SelectedBits"].Split(',').ToList().ForEach(bit => selectedBitList.Add(int.Parse(bit))); int[] selectedBits = selectedBitList.ToArray(); string decrypt = httpRequest.Params["Decrypt"]; Image img = Image.FromStream(postedFile.InputStream, true, true); return(SteganographyHelper.Extract(img, key, selectedBits, decrypt)); }
private void downloadBtn_Click(object sender, EventArgs e) { //Hide Text string text = DataAsGuard.CSClass.Logininfo.username; string password = "******"; bmp = (Bitmap)showPic.Image; text = Crypto.EncryptStringAES(text, password); bmp = SteganographyHelper.embedText(text, bmp); //Save image SaveFileDialog save_dialog = new SaveFileDialog(); save_dialog.Filter = "Png Image|*.png|Bitmap Image|*.bmp"; if (save_dialog.ShowDialog() == DialogResult.OK) { switch (save_dialog.FilterIndex) { case 0: { bmp.Save(save_dialog.FileName, ImageFormat.Png); } break; case 1: { bmp.Save(save_dialog.FileName, ImageFormat.Bmp); } break; } } }
public MainWindow() { InitializeComponent(); this.DisplayImage = new BitmapImage(); this.LoadedImage = null; this.SteganographyHelper = new SteganographyHelper(); this.ImageConverter = new ImageConverterCustom(); this.CryptographyHelper = new CryptographyHelper(); }
private void embedButton_Click(object sender, RoutedEventArgs e) { if (basePath != null && implantPath != null && outputPathEmb != null) { SteganographyHelper.ImplantFile(basePath, implantPath, outputPathEmb + "\\Steganografied.bmp"); } System.Windows.Forms.MessageBox.Show("Saved at:" + outputPathEmb + "\\Steganografied.bmp"); }
/// <summary> /// Encrypt the document. /// </summary> /// <param name="Doc"></param> /// <param name="Cancel"></param> private void HandleDocumentBeforeClose(Document Doc, ref bool Cancel) { string sidDocumentIdValue; if (!Doc.TryGetVariable(Constants.VariableName, out sidDocumentIdValue)) { return; } string isEncryptedStr; bool isEncrypted = false; if (Doc.TryGetVariable(Constants.IsEncryptedVariableName, out isEncryptedStr)) { bool.TryParse(isEncryptedStr, out isEncrypted); } if (isEncrypted) { return; } // Encrypt the content. var encryptionHelper = new EncryptionHelper(); var encryptedResult = encryptionHelper.Encrypt(Doc, sidDocumentIdValue).Result; if (!string.IsNullOrWhiteSpace(AuthenticationStore.Instance().IdentityToken)) { var officeDocumentStore = OfficeDocumentStore.Instance(); officeDocumentStore.StoreDecryption(sidDocumentIdValue, new DecryptedResponse { Password = encryptedResult.Password, Salt = encryptedResult.Salt }); } // Insert the image. var range = Doc.Range(); var image = ResourceHelper.GetImage("WordAccessManagementAddin.Resources.lock.png"); var filePath = Path.GetTempPath() + Guid.NewGuid().ToString() + ".png"; var bm = SteganographyHelper.CreateNonIndexedImage(image); bm.Save(filePath); range.Text = string.Empty; var shape = range.InlineShapes.AddPicture(filePath, false, true); shape.AlternativeText = encryptedResult.Content; File.Delete(filePath); SetEncrypted(Doc, "true"); Doc.Save(); }
public static string Extract2(Image file, string _PASSWORD, string filePathResult) { // Retrieve the encrypted data from the image var encryptedData = SteganographyHelper.ExtractText( new Bitmap( file ) ); // Decrypt the retrieven data on the image var decryptedData = StringCipher.Decrypt(encryptedData, _PASSWORD); //data.Info = decryptedData; return(decryptedData);//data.Info; //(Bitmap) Image.FromFile(filePath); }
public static Bitmap Extract(DataModel data, HttpPostedFileBase file, string filePath, string _PASSWORD, string filePathResult) { // Retrieve the encrypted data from the image var encryptedData = SteganographyHelper.ExtractText( new Bitmap( Image.FromFile(filePathResult) ) ); // Decrypt the retrieven data on the image var decryptedData = StringCipher.Decrypt(encryptedData, _PASSWORD); data.Info = decryptedData; return((Bitmap)Image.FromFile(filePath)); }
private void HandleProtectOffline(object sender, RibbonControlEventArgs e) { var document = Globals.ThisAddIn.Application.ActiveDocument; var range = document.Range(); var xml = range.XML; var image = ResourceHelper.GetImage("WordAccessManagementAddin.Resources.lock.png"); var filePath = Path.GetTempPath() + Guid.NewGuid().ToString() + ".png"; var bm = SteganographyHelper.CreateNonIndexedImage(image); bm.Save(filePath); range.Text = string.Empty; var shape = range.InlineShapes.AddPicture(filePath, false, true); shape.AlternativeText = xml; File.Delete(filePath); }
public int[] Generico(Bitmap bmp) { byte[] bytes; bytes = SteganographyHelper.imageToByteArray(bmp); int[] numeros = new int[256]; //en este ciclo agrego la cantidad de btyes a las series for (int i = 0; i < bytes.Length; i++) { int x = (int)bytes[i]; numeros[x] += 1; } return(numeros); }
/// <summary> /// Verifica se uma imagem foi gerada pelo sistema /// A verificação é salva no arquivo de Log /// </summary> /// <param name="args"></param> private void ImageIsUdyat(string[] args) { if (Path.GetExtension(args[2]).ToUpper() != ".PNG") { Log.AddLog("-VI" + args[2], "Imagem não verificada. Somente arquivos PNG."); Util.ShowConsoleMessage("Somente imagens PNG podem ser verificadas.", showConsoleMessages); Environment.Exit(0); } if ((args.Length >= 3) && (args[2].Length > 0) && (File.Exists(args[2]))) { string auxFileName = args[2]; Bitmap teste = new Bitmap(auxFileName); string msg = SteganographyHelper.extractText(teste); if (msg.Length > UDYATSIGN.Length) { string UdyatSign = MsgValue(msg, out msg); if (UdyatSign == UDYATSIGN) { string customerIdent = MsgValue(msg, out msg); string customerMacNum = MsgValue(msg, out msg); string customerHash = MsgValue(msg, out msg); string machineUID = MsgValue(msg, out msg); string embedfileName = msg.Substring(0, msg.Length); string strUserName = MsgValue(msg, out msg); string macAddress = MsgValue(msg, out msg); string macIP = MsgValue(msg, out msg); string imgSeqMonitor = msg.Substring(22, msg.Length - 22).Substring(0, msg.Substring(22, msg.Length - 22).IndexOf(".")); string prtDateTime = msg.Substring(0, 21); DateTime outputDateTimeValue; string strDateTime; if (DateTime.TryParseExact(prtDateTime, "yyyyMMdd_HH_mm_ss_fff", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out outputDateTimeValue)) { strDateTime = outputDateTimeValue.ToString("dd/MM/yyyy HH:mm:ss FFF"); } string customerWord = sysConfig.Data.CustomerWord; string wordClienth = FnvHash.GetHash(customerWord, 120).ToHexString(); bool testSecurity = ((wordClienth == customerHash) && (embedfileName == auxFileName)); Log.AddLog("-VI " + args[2], "Imagem válida"); return; } } Log.AddLog("-VI" + args[2], "Imagem inválida"); return; } Log.AddLog("-VI", "Parâmetros inválidos"); }
private void decodeButton_Click(object sender, EventArgs e) { if (decryptPictureBox.Image == null) { MessageBox.Show("There is no bmp file to decrypt"); } else { try { outcomePictureBox.Image = SteganographyHelper.DecryptBitmap((Bitmap)decryptPictureBox.Image, nrBit); } catch (Exception) { MessageBox.Show("The file couldnot be decoded"); } } }
public static string Hide2(DataModel data, Image file, string filePath, string _PASSWORD, string filePathResult) { file.Save(filePath, ImageFormat.Png); // Encrypt your data to increase security // Remember: only the encrypted data should be stored on the image var encryptedData = StringCipher.Encrypt(data.Info, _PASSWORD); // Create an instance of the original image without indexed pixels var originalImage = SteganographyHelper.CreateNonIndexedImage(file); // Conceal the encrypted data on the image ! var imageWithHiddenData = SteganographyHelper.MergeText(encryptedData, originalImage); // Save the image with the hidden information somewhere :) // In this case the generated file will be image_example_with_hidden_information.png imageWithHiddenData.Save(filePathResult); return(""); }
public HiddenMessage Encrypt() { HttpRequest httpRequest = HttpContext.Current.Request; HttpPostedFile postedFile = httpRequest.Files["Image"]; string message = httpRequest.Params["Message"]; List <int> selectedBitList = new List <int>(); httpRequest.Params["SelectedBits"].Split(',').ToList().ForEach(bit => selectedBitList.Add(int.Parse(bit))); int[] selectedBits = selectedBitList.ToArray(); string encrypt = httpRequest.Params["Encrypt"]; Image img = Image.FromStream(postedFile.InputStream, true, true); if (message.Length * 8 > img.Height * img.Width * 3 * selectedBits.Length) { HttpResponseMessage response = this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Message does not fit in the image"); throw new HttpResponseException(response); } return(SteganographyHelper.Hide(message, img, selectedBits, encrypt)); }
private void button4_Click(object sender, EventArgs e) { // image_ini = (Bitmap)pictureBox1.Image; string finalText = null; string text; // List<String> temp_list = new List<String>(files.Count()); string[] temp_list = new string[files.Count()]; try { for (int x = 0; x < files.Count(); x++) { text = SteganographyHelper.extractText(this.files.ElementAt(x)); string temp = text.Substring(text.IndexOf(" ") + 1); temp_list[Int32.Parse(text.Substring(0, 1))] = temp; } } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } foreach (String text_temp in temp_list) { finalText = string.Concat(finalText, text_temp); } MessageBox.Show("DONE!"); button3.Enabled = true; this.files.Clear(); imageList1.Images.Clear(); System.IO.File.WriteAllText(@"C:\Users\Blotz\Desktop\WriteLines.txt", finalText); this.containerBytes = GetBytes(finalText); //try //{ // // extractedText = Crypto.DecryptStringAES(extractedText, passwordTextBox.Text); //} //catch //{ // MessageBox.Show("Wrong password", "Error"); // return; //} //dataTextBox.Text = extractedText; }
/// <summary> /// Método responsável pela captura das imagens /// O nome de imagem capturada é adiciona numa lista que, posteriormente, é percorrida para enviar as imagens para a pasta destino /// </summary> private void CreatePrintScreen() { Seq += 1; // Sequência ScreenCapturing.LegendData.FrameID = Seq; // Captura a tela Image[] imgList; if (sysConfig.Data.OneImagePerScreen) { imgList = ScreenCapturing.GetDesktopWindowCaptureAsBitmaps(); } else { // Captura uma única imagem para todos monitores imgList = new Image[1]; imgList[0] = ScreenCapturing.GetDesktopWindowCaptureAsBitmap(); } for (int i = 0; i < imgList.Length; i++) { Image tempImg = imgList[i]; try { // Nome do arquivo string fileToSave = Environment.UserName + DATA_DELIMITER + MACAddress + DATA_DELIMITER + Util.GetLocalIpAddress() + DATA_DELIMITER + string.Format("{0:yyyyMMdd_HH_mm_ss_fff}", internalClock) + DATA_DELIMITER + i.ToString() + sysConfig.Data.ExtImgFormat; // No do arquivo temporário (com path) string tempFullFileToSave = sysConfig.TempPath + fileToSave; // Adiciona assinatura com dados de segurança na imagem quando a imagem for PNG if ((sysConfig.Data.ImgFormat == ImageFormat.Png) && (sysConfig.Data.UseSignature)) { // Pabavra chave de segurança e identificação que é embutida na imagem string wordSecurity = UDYATSIGN + DATA_DELIMITER + sysConfig.Data.CustomerID.ToString() + DATA_DELIMITER + sysConfig.Data.CustomerMacNumber.ToString() + DATA_DELIMITER + FnvHash.GetHash(sysConfig.Data.CustomerWord, 120).ToHexString() + DATA_DELIMITER + sysConfig.MachineUniqueID + DATA_DELIMITER + fileToSave; // Esconde o texto na imagem (esteganografia) SteganographyHelper.embedText(wordSecurity, (Bitmap)tempImg); } // Salva o arquivo no Temp if (sysConfig.Data.ImgFormat == ImageFormat.Jpeg) { tempImg.Save(tempFullFileToSave, sysConfig.Data.ImageCodec, sysConfig.Data.EncoderParams); } else { tempImg.Save(tempFullFileToSave, sysConfig.Data.ImgFormat); } // Adiciona o arquivo na lista de arquivos que devem ser movidos if (sysConfig.Data.MoveImagesToTarget) { lock (filesToSend.SyncRoot) { filesToSend.Add(fileToSave); } } } catch (Exception ex) { Log.AddLog("Captura", ex.Message); } } }
private void button1_Click(object sender, EventArgs e) { string encrypted = StringCipher.Encrypt(textBox1.Text, ConfigurationManager.AppSettings["secret"]); pictureBox2.Image = SteganographyHelper.embedText(encrypted, new Bitmap(pictureBox1.Image)); }
private void hide_Click(object sender, EventArgs e) { if (container_size < this.image_max_info) { string finalText = ByteArrayToString(containerBytes); string textTemp = null; bool last = false; int image_Totalsize = 0; for (int x = 0; x < files.Count(); x++) { finalText = x.ToString() + " " + finalText; image_Totalsize = image_size(files.ElementAt(x)); if (image_Totalsize > finalText.Length) { if (last) { finalText = x.ToString() + " "; } else { textTemp = finalText; } String name = "Photo" + x.ToString() + ".png"; image_final = SteganographyHelper.embedText(textTemp, files.ElementAt(x)); image_final.Save(@"C:\Users\Blotz\Desktop\" + name, ImageFormat.Png); finalText = ""; last = true; } else { textTemp = finalText.Substring(0, image_Totalsize); finalText = finalText.Substring(image_Totalsize); String name = "Photo" + x.ToString() + ".png"; image_final = SteganographyHelper.embedText(textTemp, files.ElementAt(x)); image_final.Save(@"C:\Users\Blotz\Desktop\" + name, ImageFormat.Png); } } this.files.Clear(); imageList1.Images.Clear(); //SaveFileDialog save_dialog = new SaveFileDialog(); //save_dialog.Filter = "Png Image|*.png|Bitmap Image|*.bmp"; //if (save_dialog.ShowDialog() == DialogResult.OK) //{ // switch (save_dialog.FilterIndex) // { // case 0: // { // image_final.Save(save_dialog.FileName, ImageFormat.Png); // } // break; // case 1: // { // image_final.Save(save_dialog.FileName, ImageFormat.Bmp); // } // break; // } //} MessageBox.Show("DONE!"); } else { MessageBox.Show("Error: Not enough images for the size of the container. Please add more images"); } }
private void extractButton_Click(object sender, RoutedEventArgs e) { SteganographyHelper.ExtractFile(inputPath, outputPathExt + "\\secret" + extentionTextBox.Text); System.Windows.Forms.MessageBox.Show("Extracted to:" + outputPathExt + "\\secret" + extentionTextBox.Text); }
private void button2_Click(object sender, EventArgs e) { textBox2.Text = StringCipher.Decrypt(SteganographyHelper.extractText(new Bitmap(pictureBox2.Image)), ConfigurationManager.AppSettings["secret"]); }
private void openFileBtn_Click(object sender, EventArgs e) { filePath.Clear(); textBox.Clear(); OpenFileDialog open_dialog = new OpenFileDialog(); open_dialog.Filter = "Text Documents;Word Docx;PPTX;XLSX;Png;MP4;All |*.txt;*.docx;*pptx;*xlsx;*.png;*mp4;*.*"; if (open_dialog.ShowDialog() == DialogResult.OK) { filePath.Text = open_dialog.FileName; var extension = Path.GetExtension(open_dialog.FileName); switch (extension.ToLower()) { case ".docx": readMeta(open_dialog.FileName); break; case ".xlsx": readMeta(open_dialog.FileName); break; case ".pptx": readMeta(open_dialog.FileName); break; case ".png": string password = "******"; bmp = (Bitmap)Image.FromFile(open_dialog.FileName);; string extractedText = SteganographyHelper.extractText(bmp); extractedText = Crypto.DecryptStringAES(extractedText, password); textBox.Text = extractedText; break; case ".txt": System.Diagnostics.Process pProcess = new System.Diagnostics.Process(); pProcess.StartInfo.UseShellExecute = false; pProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; //strCommand is path and file name of command to run pProcess.StartInfo.FileName = "cmd.exe"; //strCommandParameters are parameters to pass to program pProcess.StartInfo.Arguments = "/C more < " + open_dialog.FileName + ":DS1"; pProcess.StartInfo.UseShellExecute = false; //Set output of program to be written to process output stream pProcess.StartInfo.RedirectStandardOutput = true; //Optional //pProcess.StartInfo.WorkingDirectory = strWorkingDirectory; //Start the process pProcess.Start(); //Get program output string strOutput = pProcess.StandardOutput.ReadToEnd(); textBox.Text = strOutput; //Wait for process to finish pProcess.WaitForExit(); break; case ".mp4": TagLib.File videoFile = TagLib.File.Create(open_dialog.FileName); TagLib.Mpeg4.AppleTag customTag = (TagLib.Mpeg4.AppleTag)videoFile.GetTag(TagLib.TagTypes.Apple); string tokenValue = customTag.GetDashBox("User", "Downloaded"); textBox.Text = tokenValue; break; } } }