Пример #1
0
        public bool HideFileSystem(string imagePath, string fileSystemData, string password = "", StorageMethod storageMethod = StorageMethod.EOF)
        {
            StegoProvider prov;

            if (storageMethod == StorageMethod.EOF)
            {
                prov = Providers.XOREOF;
            }
            else
            {
                prov = Providers.XORIDAT;
            }

            provider = (SteganographyProvider)Activator.CreateInstance(prov.ProviderType, imagePath, false);
            provider.SetPassword(password, false);

            if (Imprint(DataType.FileSystem, fileSystemData))
            {
                using (FileStream fs = File.Open(imagePath, FileMode.Create, FileAccess.Write, FileShare.Read))
                    provider.WriteToStream(fs);

                return(true);
            }

            return(false);
        }
Пример #2
0
        public bool HideText(string imagePath, string hideText, string password = "", int fileSlot = 0)
        {
            StegoProvider prov;

            if (fileSlot == 0)
            {
                prov = Providers.XOREOF;
            }
            else
            {
                prov = Providers.XORIDAT;
            }

            provider = (SteganographyProvider)Activator.CreateInstance(prov.ProviderType, imagePath, false);
            provider.SetPassword(password, false);

            if (Imprint(DataType.Text, hideText))
            {
                using (FileStream fs = File.Open(imagePath, FileMode.Create, FileAccess.Write, FileShare.Read))
                    provider.WriteToStream(fs);

                return(true);
            }

            return(false);
        }
Пример #3
0
        public (DataType t, object data) ReadData(StorageMethod storageSlot)
        {
            DataType t    = DataType.None;
            object   data = null;

            using (MemoryStream stream = new MemoryStream())
            {
                pngOriginal.WriteToStream(stream, true, true);
                stream.Seek(0, SeekOrigin.Begin);
            }

            bool hasEOF = false;
            int  IDATs  = 0;

            foreach (PNGChunk chunk in pngOriginal.Chunks)
            {
                if (chunk.Name == "_EOF")
                {
                    hasEOF = true;
                }
                if (chunk.Name == "IDAT")
                {
                    IDATs++;
                }
            }

            StegoProvider pr = Providers.XOREOF;

            if (storageSlot == StorageMethod.IDAT)
            {
                pr = Providers.XORIDAT;
            }

            if (!hasEOF && storageSlot == StorageMethod.EOF)
            {
                provider = null; Logger.Log($"There is no data in {storageSlot.ToString()}", Logger.LOG_LEVEL.ERR);
            }
            else if (IDATs <= 1)
            {
                provider = null; Logger.Log($"There is no data in {storageSlot.ToString()}", Logger.LOG_LEVEL.ERR);
            }
            else
            {
                try
                {
                    provider = (SteganographyProvider)Activator.CreateInstance(pr.ProviderType, pngOriginal, true);
                    provider.SetPassword(password);
                    t = provider.Extract(out data);
                    return(t, data);
                }
                catch (InvalidPasswordException)
                {
                    Logger.Log("The password was incorrect.", Logger.LOG_LEVEL.ERR);
                }
            }

            return(DataType.None, null);
        }