Пример #1
0
        internal static AssembliesSet LoadAssemblies(string imagesFolder)
        {
            AssembliesSet set = new AssembliesSet();

            foreach (string file in Directory.GetFiles(imagesFolder, "*.png"))
            {
                byte[] data = null;
                data = SteganographyProvider.Extraction(File.ReadAllBytes(file));
                data = AssemblyPacker.UnPack(data);
                set.TryAppendAssembly(data);
            }
            return(set);
        }
Пример #2
0
        internal static void PackAssemblies(string imagesFolder, string outputImagesFolder, string dllsFolder)
        {
            ImageSet images = new ImageSet();

            if (!Directory.Exists(outputImagesFolder))
            {
                Directory.CreateDirectory(outputImagesFolder);
            }

            Dictionary <string, long> imagesVolume = new Dictionary <string, long>();
            var imageFiles = Directory
                             .GetFiles(imagesFolder, "*.*")
                             .Where(file => file.ToLower().EndsWith("bmp") || file.ToLower().EndsWith("png") || file.ToLower().EndsWith("jpg") || file.ToLower().EndsWith("jpeg"))
                             .ToList();

            foreach (string file in imageFiles)
            {
                images.Append(file);
            }

            foreach (string file in Directory.GetFiles(dllsFolder, "*.dll"))
            {
                byte[] packed    = AssemblyPacker.Pack(file);
                string imageFile = images.FindImage(packed.Length);
                if (imageFile == null)
                {
                    Console.WriteLine("Not found image to write dll " + file + " (need " + packed.Length + " bytes)");
                }
                else
                {
                    string outImagefile = Path.Combine(outputImagesFolder, Path.GetFileNameWithoutExtension(file) + "_" + Path.GetFileNameWithoutExtension(imageFile) + ".png");
                    Bitmap bmp          = SteganographyProvider.Injection(File.ReadAllBytes(imageFile), packed);
                    bmp.Save(outImagefile, ImageFormat.Png);
                }
            }
        }