コード例 #1
0
ファイル: MachineState.cs プロジェクト: matthargett/bugreport
 public MachineState(MachineState copyMe)
 {
     instructionPointer = copyMe.instructionPointer;
     registers = new RegisterCollection(copyMe.registers);
     dataSegment = new Dictionary<UInt32, AbstractValue>(copyMe.dataSegment);
     zeroFlag = copyMe.zeroFlag;
 }
コード例 #2
0
        private static RegisterCollection createRegistersForLinuxStart()
        {
            var linuxMainDefaultValues = new RegisterCollection();

            var arg0 = new AbstractValue(1).AddTaint();

            var argvBuffer         = new[] { arg0 };
            var argvPointer        = new AbstractValue(argvBuffer);
            var argvPointerBuffer  = new[] { argvPointer };
            var argvPointerPointer = new AbstractValue(argvPointerBuffer);
            var stackBuffer        = AbstractValue.GetNewBuffer(0x200);

            var buffer         = new AbstractBuffer(stackBuffer);
            var modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(0x100));

            // linux ABI dictates
            modifiedBuffer[5] = argvPointerPointer;

            // gcc generates code that accesses this at some optimization levels
            modifiedBuffer[0xfc] = new AbstractValue(1);

            var stackPointer = new AbstractValue(modifiedBuffer);

            linuxMainDefaultValues[RegisterName.ESP] = stackPointer;

            return(linuxMainDefaultValues);
        }
コード例 #3
0
ファイル: MachineState.cs プロジェクト: matthargett/bugreport
 public MachineState(RegisterCollection registers)
 {
     dataSegment = new Dictionary<UInt32, AbstractValue>();
     this.registers = registers;
     instructionPointer = 0x00;
     zeroFlag = false;
 }
コード例 #4
0
 public void SetUp()
 {
     var registers = new RegisterCollection();
     registers[RegisterName.ESP] = new AbstractValue(AbstractValue.GetNewBuffer(1));
     state = new MachineState(registers);
     contract = new GLibcStartMainContract();
 }
コード例 #5
0
ファイル: MachineState.cs プロジェクト: matthargett/bugreport
 public MachineState(RegisterCollection registers)
 {
     dataSegment        = new Dictionary <UInt32, AbstractValue>();
     this.registers     = registers;
     instructionPointer = 0x00;
     zeroFlag           = false;
 }
コード例 #6
0
ファイル: MachineState.cs プロジェクト: matthargett/bugreport
 public MachineState(MachineState copyMe)
 {
     instructionPointer = copyMe.instructionPointer;
     registers          = new RegisterCollection(copyMe.registers);
     dataSegment        = new Dictionary <UInt32, AbstractValue>(copyMe.dataSegment);
     zeroFlag           = copyMe.zeroFlag;
 }
コード例 #7
0
        public void SetUp()
        {
            var registers = new RegisterCollection();

            registers[RegisterName.ESP] = new AbstractValue(AbstractValue.GetNewBuffer(1));
            state    = new MachineState(registers);
            contract = new GLibcStartMainContract();
        }
コード例 #8
0
 public RegisterCollection(RegisterCollection _copyMe)
 {
     registers = new AbstractValue[8];
     for (UInt32 i = 0; i < registers.Length; ++i)
     {
         registers[i] = new AbstractValue(_copyMe.registers[i]);
     }
 }
コード例 #9
0
 public RegisterCollection(RegisterCollection _copyMe)
 {
     registers = new AbstractValue[8];
     for (UInt32 i = 0; i < registers.Length; ++i)
     {
         registers[i] = new AbstractValue(_copyMe.registers[i]);
     }
 }
コード例 #10
0
        public void InitialRegisters()
        {
            var registers = new RegisterCollection();

            registers[RegisterName.EAX] = one;
            state = new MachineState(registers);
            var newState = X86Emulator.Run(reportItems, state, new byte[] { 0x90 });

            Assert.AreEqual(one, newState.Registers[RegisterName.EAX]);
            Assert.AreNotSame(state, newState);
            Assert.AreNotEqual(state, newState);
        }
コード例 #11
0
        public void Copy()
        {
            registers[RegisterName.ESP] = new AbstractValue(new AbstractBuffer(AbstractValue.GetNewBuffer(10)));
            var newRegisters = new RegisterCollection(registers);
            for (UInt32 i = 0; i < 7; i++)
            {
                var register = (RegisterName)i;
                Assert.AreNotSame(newRegisters[register], registers[register]);
            }

            Assert.AreNotSame(newRegisters[RegisterName.ESP].PointsTo, registers[RegisterName.ESP].PointsTo);
        }
コード例 #12
0
        public void Copy()
        {
            registers[RegisterName.ESP] = new AbstractValue(new AbstractBuffer(AbstractValue.GetNewBuffer(10)));
            var newRegisters = new RegisterCollection(registers);

            for (UInt32 i = 0; i < 7; i++)
            {
                var register = (RegisterName)i;
                Assert.AreNotSame(newRegisters[register], registers[register]);
            }

            Assert.AreNotSame(newRegisters[RegisterName.ESP].PointsTo, registers[RegisterName.ESP].PointsTo);
        }
コード例 #13
0
        public void Equality()
        {
            var same = new MachineState(new RegisterCollection());

            same.DataSegment[0] = new AbstractValue(2);
            var same2 = new MachineState(new RegisterCollection());

            same2.DataSegment[0] = new AbstractValue(2);

            var registers = new RegisterCollection();

            registers[RegisterName.EAX] = new AbstractValue(1);
            var differentViaRegisters = new MachineState(registers);

            differentViaRegisters.DataSegment[0] = new AbstractValue(2);

            Assert.IsTrue(same.Equals(same2));
            Assert.IsFalse(differentViaRegisters.Equals(same));

            Assert.IsTrue(same == same2);
            Assert.IsTrue(same != differentViaRegisters);

            Assert.AreEqual(same.GetHashCode(), same2.GetHashCode());
            Assert.AreNotEqual(same.GetHashCode(), differentViaRegisters.GetHashCode());

            registers = new RegisterCollection();
            var differentViaDataSegmentKey = new MachineState(registers);

            differentViaDataSegmentKey.DataSegment[1] = new AbstractValue(2);

            Assert.IsFalse(same.Equals(differentViaDataSegmentKey));

            registers = new RegisterCollection();
            var differentViaDataSegmentValue = new MachineState(registers);

            differentViaDataSegmentValue.DataSegment[0] = new AbstractValue(1);

            Assert.IsFalse(same.Equals(differentViaDataSegmentValue));
        }
コード例 #14
0
 public void SetUp()
 {
     registers = new RegisterCollection();
 }
コード例 #15
0
 public void SetUp()
 {
     registers = new RegisterCollection();
 }
コード例 #16
0
        public void Equality()
        {
            var same = new MachineState(new RegisterCollection());
            same.DataSegment[0] = new AbstractValue(2);
            var same2 = new MachineState(new RegisterCollection());
            same2.DataSegment[0] = new AbstractValue(2);

            var registers = new RegisterCollection();
            registers[RegisterName.EAX] = new AbstractValue(1);
            var differentViaRegisters = new MachineState(registers);
            differentViaRegisters.DataSegment[0] = new AbstractValue(2);

            Assert.IsTrue(same.Equals(same2));
            Assert.IsFalse(differentViaRegisters.Equals(same));

            Assert.IsTrue(same == same2);
            Assert.IsTrue(same != differentViaRegisters);

            Assert.AreEqual(same.GetHashCode(), same2.GetHashCode());
            Assert.AreNotEqual(same.GetHashCode(), differentViaRegisters.GetHashCode());

            registers = new RegisterCollection();
            var differentViaDataSegmentKey = new MachineState(registers);
            differentViaDataSegmentKey.DataSegment[1] = new AbstractValue(2);

            Assert.IsFalse(same.Equals(differentViaDataSegmentKey));

            registers = new RegisterCollection();
            var differentViaDataSegmentValue = new MachineState(registers);
            differentViaDataSegmentValue.DataSegment[0] = new AbstractValue(1);

            Assert.IsFalse(same.Equals(differentViaDataSegmentValue));
        }
コード例 #17
0
 public void InitialRegisters()
 {
     var registers = new RegisterCollection();
     registers[RegisterName.EAX] = one;
     state = new MachineState(registers);
     var newState = X86Emulator.Run(reportItems, state, new byte[] {0x90});
     Assert.AreEqual(one, newState.Registers[RegisterName.EAX]);
     Assert.AreNotSame(state, newState);
     Assert.AreNotEqual(state, newState);
 }