March 19, 2017

pwnable.kr leg solution


Daddy told me I should study arm
But I prefer to study my leg!
아빠는 내게 ARM(팔)에 대해 알려주었다.
근데 나는 다리에 더 관심이 많은 걸!





If the value of key1 () + key2 () + key3 () is the same as the input value(=key), you can see the contents of the flag.
key1()+key2()+key3()의 값이 입력한 값(=key)와 동일하면 flag 내용을 볼 수 있다.






Even if there is no return instruction, the value in r0 is returned.
리턴 명령어가 별도로 없어도 r0에 들어가 있는 값이 리턴 된다.

Key1 () returns the value of the pc register. The PC has the address of the next next instruction. The address of the next next instruction of 0x00008cdc is 0x00008ce4. This value is returned(In ARM mode, the address value increases by +4 bytes.).
key1()은 pc 레지스터의 값을 리턴하고 있다. PC는 다다음 명령어의 주소를 갖고 있다. 0x00008cdc의 다다음 명령어의 주소는 0x00008ce4이다. 이 값이 리턴 된다(ARM 모드는 +4 Byte씩 주소 값이 증가한다.).






Key2() returns r3+4. 0x00008d08 + 4 = 0x00008d0c is returned.
key2()는 r3에 4를 더한 값을 리턴한다. 0x00008d08+4 = 0x00008d0c가 리턴 된다.






Key3() returns r3 value. r3 has the lr register value.
key3()은 r3의 값을 리턴 하는데, r3에는 lr 레지스터의 값을 갖는다.

The lr register has the return address of the function. The return address is the next line of the key3() function, 0x00008d80.
lr 레지스터는 함수의 복귀 주소를 갖는다. 복귀 주소는 key3() 함수의 다음 라인 0x00008d80이다.







0x00008ce4 + 0x00008d0c + 0x00008d80 = 0x1a770(=DEC 108400)