Search

[reversing.kr] easy elf

Tags
reversing
Category
reversing.kr
Last edited time
2022/01/07 12:50
Visibility
Public

1. 문제

1) 문제 확인
뭔가를 맞춰야 하는것 같다
2) 코드흐름 파악
int __cdecl main() { write(1, "Reversing.Kr Easy ELF\n\n", 0x17u); sub_8048434(); if ( sub_8048451() == 1 ) sub_80484F7(); else write(1, "Wrong\n", 6u); return 0; } .... int sub_8048434() { return __isoc99_scanf((const char *)&unk_8048650, input); }
C
복사
input은 bss 영역이다. 저기다 입력을 하고 sub_804851() 함수의 반환값이 1인지 아닌지 체크를 한다.
_BOOL4 sub_8048451() { if ( input[1] != 0x31 ) return 0; input[0] ^= 0x34u; input[2] ^= 0x32u; input[3] ^= 0x88u; if ( input[4] != 0x58 ) return 0; if ( input[5] ) return 0; if ( input[2] != 0x7C ) return 0; if ( input[0] == 0x78 ) return input[3] == 0xDDu; return 0; }
C
복사
bss영역에 입력한 값을 한바이트 씩 비교한다. 그냥 저 조건문에 맞게끔 입력을 하면 된다

2. 접근방법

pe보다 익숙한 elf라 금방 풀었다. 문제 그대로 easy
from pwn import * p=process('./Easy_ELF') script=''' b*0x08048454 ''' #gdb.attach(p,script) p.recvuntil("ELF\n\n") pay=p8(0x4c) pay+=p8(0x31) pay+=p8(0x4e) pay+=p8(0x55) pay+=p8(0x58) pay+=p8(0x00) p.sendline(pay) log.info(p.recvline()) log.info(chr(0x4c)+chr(0x31)+chr(0x4e)+chr(0x55)+chr(0x58)) p.interactive()
C
복사

3. 풀이

[+] Starting local process './Easy_ELF': pid 7920 [*] Correct! [*] L1NUX [*] Switching to interactive mode [*] Process './Easy_ELF' stopped with exit code 0 (pid 7920) [*] Got EOF while reading in interactive
C
복사

4. 몰랐던 개념