GetResourceData() public method

public GetResourceData ( ) : byte[]
return byte[]
Esempio n. 1
0
 public byte[] decrypt(EmbeddedResource resource)
 {
     if (!CanDecrypt)
         throw new ApplicationException("Can't decrypt resources");
     var encryptedData = resource.GetResourceData();
     return decrypt(encryptedData);
 }
Esempio n. 2
0
        public void initialize(ISimpleDeobfuscator simpleDeobfuscator, IDeobfuscator deob)
        {
            if (methodsDecrypter == null)
                return;

            encryptedResource = BabelUtils.findEmbeddedResource(module, methodsDecrypter, simpleDeobfuscator, deob);
            if (encryptedResource == null) {
                Log.w("Could not find encrypted methods resource");
                return;
            }

            addImageReader("", new ResourceDecrypter(module).decrypt(encryptedResource.GetResourceData()));
        }
Esempio n. 3
0
 protected static byte[] decryptResourceV3(EmbeddedResource resource)
 {
     return decryptResourceV3(resource.GetResourceData());
 }
 public void ShowBinary(EmbeddedResource er, bool showingGridBinary)
 {
     ShowBinary(er.GetResourceData(), showingGridBinary);
 }
Esempio n. 5
0
 protected static byte[] decryptResourceV41SL(EmbeddedResource resource)
 {
     var data = resource.GetResourceData();
     byte k = data[0];
     for (int i = 0; i < data.Length - 1; i++)
         data[i + 1] ^= (byte)((k << (i & 5)) + i);
     return inflateIfNeeded(data, 1, data.Length - 1);
 }
Esempio n. 6
0
        public void initialize(ISimpleDeobfuscator simpleDeobfuscator, IDeobfuscator deob)
        {
            if (methodsDecrypter == null)
                return;

            encryptedResource = BabelUtils.findEmbeddedResource(module, methodsDecrypter, simpleDeobfuscator, deob);
            if (encryptedResource != null)
                addImageReader("", resourceDecrypter.decrypt(encryptedResource.GetResourceData()));
        }
        private void SaveResourceFile(EmbeddedResource er, string outputFile)
        {
            byte[] bytes = er.GetResourceData();
            using (FileStream fs = File.Create(outputFile))
            {
                fs.Write(bytes, 0, bytes.Length);
            }
            _form.SetStatusText(String.Format("{0} saved.", outputFile));

            if (PathUtils.IsResourceExt(outputFile))
            {
                using (ResourceReader rr = new ResourceReader(er.GetResourceStream()))
                {
                    string resxFile = Path.ChangeExtension(outputFile, ".resx");
                    using (ResXResourceWriter xw = new ResXResourceWriter(resxFile))
                    {
                        IDictionaryEnumerator de = rr.GetEnumerator();
                        while (de.MoveNext())
                        {
                            bool handled = false;
                            if (de.Value != null)
                            {
                                Type type = de.Value.GetType();
                                if (type.FullName.EndsWith("Stream"))
                                {
                                    Stream s = de.Value as Stream;
                                    if (s != null)
                                    {
                                        byte[] tmpBytes = new byte[s.Length];
                                        if (s.CanSeek) s.Seek(0, SeekOrigin.Begin);
                                        s.Read(tmpBytes, 0, tmpBytes.Length);
                                        xw.AddResource(de.Key.ToString(), new MemoryStream(tmpBytes));
                                        handled = true;
                                    }
                                }
                            }
                            if (handled) continue;
                            xw.AddResource(de.Key.ToString(), de.Value);
                        }
                    }
                }
            }
            else if (PathUtils.IsBamlExt(outputFile))
            {
                try
                {
                    using (StreamWriter sw = File.CreateText(Path.ChangeExtension(outputFile, ".xaml")))
                    {
                        sw.WriteLine(_form.ResourceHandler.DecompileBaml(new MemoryStream(bytes)));
                    }
                }
                catch (Exception ex)
                {
                    _form.SetStatusText(String.Format("Failed to translate {0}: {1}", er.Name, ex.Message));
                }
            }
        }
Esempio n. 8
0
        public void initialize(ISimpleDeobfuscator simpleDeobfuscator, IDeobfuscator deob)
        {
            if (resolverType == null)
                return;

            encryptedResource = BabelUtils.findEmbeddedResource(module, resolverType, simpleDeobfuscator, deob);
            if (encryptedResource == null) {
                Log.w("Could not find embedded assemblies resource");
                return;
            }

            var decrypted = resourceDecrypter.decrypt(encryptedResource.GetResourceData());
            var reader = new BinaryReader(new MemoryStream(decrypted));
            int numAssemblies = reader.ReadInt32();
            embeddedAssemblyInfos = new EmbeddedAssemblyInfo[numAssemblies];
            for (int i = 0; i < numAssemblies; i++) {
                string name = reader.ReadString();
                var data = reader.ReadBytes(reader.ReadInt32());
                var mod = ModuleDefinition.ReadModule(new MemoryStream(data));
                embeddedAssemblyInfos[i] = new EmbeddedAssemblyInfo(name, DeobUtils.getExtension(mod.Kind), data);
            }
        }
Esempio n. 9
0
 public void initialize(ModuleDefinition module, EmbeddedResource resource)
 {
     var decrypted = resourceDecrypter.decrypt(resource.GetResourceData());
     var reader = new BinaryReader(new MemoryStream(decrypted));
     while (reader.BaseStream.Position < reader.BaseStream.Length)
         offsetToString[getOffset((int)reader.BaseStream.Position)] = reader.ReadString();
 }
Esempio n. 10
0
 public void initialize(ModuleDefinition module, EmbeddedResource resource)
 {
     key = resource.GetResourceData();
     if (key.Length != 0x100)
         throw new ApplicationException(string.Format("Unknown key length: {0}", key.Length));
 }