Beispiel #1
0
            public MethodInfos(MainType mainType, PeImage peImage, PeHeader peHeader, McHeader mcHeader)
            {
                this.mainType = mainType;
                this.peImage = peImage;
                this.peHeader = peHeader;
                this.mcHeader = mcHeader;

                structSize = getStructSize(mcHeader);

                uint methodInfosRva = peHeader.getRva2(0x0FF8, mcHeader.readUInt32(0x005A));
                uint encryptedDataRva = peHeader.getRva2(0x0FF0, mcHeader.readUInt32(0x0046));

                methodInfosOffset = peImage.rvaToOffset(methodInfosRva);
                encryptedDataOffset = peImage.rvaToOffset(encryptedDataRva);
            }
Beispiel #2
0
 static uint getStructSize(McHeader mcHeader)
 {
     uint magicLo = mcHeader.readUInt32(0x8C0);
     uint magicHi = mcHeader.readUInt32(0x8C4);
     foreach (var info in encryptionInfos_McHeader8C0h) {
         if (magicLo == info.MagicLo && magicHi == info.MagicHi)
             return 0xC + 6 * ENCRYPTED_DATA_INFO_SIZE;
     }
     return 0xC + 3 * ENCRYPTED_DATA_INFO_SIZE;
 }
Beispiel #3
0
        void decryptResources(byte[] fileData, PeImage peImage, PeHeader peHeader, McHeader mcHeader)
        {
            uint resourceRva = peHeader.getRva1(0x0E10, mcHeader.readUInt32(0x00A0));
            uint resourceSize = peHeader.readUInt32(0x0E14) ^ mcHeader.readUInt32(0x00AA);
            if (resourceRva == 0 || resourceSize == 0)
                return;
            if (resourceRva != peImage.Cor20Header.resources.virtualAddress ||
                resourceSize != peImage.Cor20Header.resources.size) {
                Log.w("Invalid resource RVA and size found");
            }

            Log.v("Decrypting resources @ RVA {0:X8}, {1} bytes", resourceRva, resourceSize);

            int resourceOffset = (int)peImage.rvaToOffset(resourceRva);
            for (int i = 0; i < resourceSize; i++)
                fileData[resourceOffset + i] ^= mcHeader[i % 0x2000];
        }