Esempio n. 1
0
        public Sections(Reader reader)
        {
            this.memStream = reader.memStream;
            this.binaryParser = reader.binaryParser;
            this.sectionCount = (int)(reader.GetFileHeader().GetNumberOfSections());
            long optHeaderAddress = reader.GetDOSHeader().GetFileAddress() + fileHeaderLength;
            long dataDirectoryAddress = optHeaderAddress + optHeaderLength;
            sectionAddress = (dataDirectoryAddress + dataDirectorySize) + sectionPadding + 0x4;

            for (int i = 0; i < sectionCount; i++)
            {
                long count = sectionLength * i;
                long offset = sectionAddress + count;
                memStream.Position = offset;
                string name = Encoding.Default.GetString(binaryParser.ReadBytes(8));
                UInt32 virtualSize = (UInt32)(memStream.Position = binaryParser.ReadUInt32());
                memStream.Position = offset + 0xc;
                UInt32 virtualAddress = (UInt32)(memStream.Position = binaryParser.ReadUInt32());
                memStream.Position = offset + 0x10;
                UInt32 rawDataSize = (UInt32)(memStream.Position = binaryParser.ReadUInt32());
                memStream.Position = offset + 0x14;
                UInt32 rawDataAddress = (UInt32)(memStream.Position = binaryParser.ReadUInt32());
                memStream.Position = offset + 0x18;
                UInt32 relocAddress = (UInt32)(memStream.Position = binaryParser.ReadUInt32());
                memStream.Position = offset + 0x1c;
                UInt32 lineAddress = (UInt32)(memStream.Position = binaryParser.ReadUInt32());
                memStream.Position = offset + 0x20;
                UInt16 relocCount = (UInt16)(memStream.Position = binaryParser.ReadUInt16());
                memStream.Position = offset + 0x22;
                UInt16 lineCount = (UInt16)(memStream.Position = binaryParser.ReadUInt16());

                this.allSections.Add(new Section(name, virtualAddress, virtualSize, rawDataSize, rawDataAddress, relocAddress, lineAddress, relocCount, lineCount));
            }
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            byte[] ram = new byte[66];

            Console.Title = "KrutNA's Interpreter";
            Console.Write("Path: ");

            var          path = Console.ReadLine().Replace("\"", "");
            BinaryParser binaryParser;

            // Checks file
            if (!File.Exists(path))
            {
                Console.WriteLine("File not founded!\n" +
                                  "Press any key to continue...");
                Console.Read();
                return;
            }

            using (BinaryReader reader = new BinaryReader(File.OpenRead(path)))
            {
                binaryParser = new BinaryParser();
                binaryParser.ReadBytes(reader, ref ram);
            }

            var interpreter = new Interpreter.Interpreter();

            interpreter.DoInterpretation(ref ram);

            if (interpreter.isError)
            {
                return;
            }

            Console.Write("\nDone!\n" +
                          "Press any key to continue...");
            Console.ReadKey();
        }
Esempio n. 3
0
        public PACSAMStatus GetStatus()
        {
            // Transceive
            RApdu response = Transcieve(CLA, (byte)PACSAMCommand.GetStatus);

            // Parse and test DESFire status code
            if (response.IsError)
            {
                throw new Iso7816Exception(response.SW12, "GetStatus");
            }

            PACSAMStatus status = new PACSAMStatus();
            BinaryParser parser = new BinaryParser(response.Data, ByteEndianess.BigEndian);

            // Applet state
            status.AppletState = (PACSAMAppletState)parser.ReadUInt8();

            // ESN
            status.ESN = parser.ReadUInt32();

            // Encoding Profile
            status.Profile = parser.ReadUInt16();

            // System Diversifier
            status.SystemDiversifier = parser.ReadBytes(PACSAMStatus.SystemDivLength);

            // DESFire Authentication Status
            status.DESFireStatus = (DESFireAuthStatus)parser.ReadUInt8();

            // PLAID Authentication Status
            status.PlaidStatus = (PlaidAuthStatus)parser.ReadUInt8();

            // PIN Authentication Status
            status.PINStatus = Convert.ToBoolean(parser.ReadUInt8());

            // Done
            return(status);
        }