이전에 풀었던 sub랑 비슷한 형식의 문제인 듯 하다.
Partial RELRO, Canary, NX가 걸려있는 64bit 바이너리이다.
이번에는 정수 세개를 입력받는다.
[main]
// local variable allocation has failed, the output may be wrong!
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
__int64 v4; // [rsp+8h] [rbp-78h]
__int64 v5; // [rsp+10h] [rbp-70h]
__int64 v6; // [rsp+18h] [rbp-68h]
__int64 v7[11]; // [rsp+20h] [rbp-60h]
unsigned __int64 v8; // [rsp+78h] [rbp-8h]
v8 = __readfsqword(0x28u);
setup(*(_QWORD *)&argc, argv, envp);
while ( 1 )
{
v4 = 0LL;
v5 = 0LL;
v6 = 0LL;
memset(v7, 0, 0x50uLL);
printf("Input: ", argv, v7);
if ( (unsigned int)__isoc99_scanf("%ld %ld %ld", &v4, &v5, &v6) != 3 )
break;
v7[v6] = v4 + v5;
argv = (const char **)v7[v6];
printf("Result: %ld", argv);
}
result = 0;
__readfsqword(0x28u);
return result;
}
v4, v5, v6에 long형 정수를 각각 입력받은 후, v7[v6]에 v4 + v5를 넣어준다.
이 때, v7은 0x58byte이지만 v6은 훨씬 더 큰 수를 입력할 수 있기 때문에 out of bound취약점이 발생한다.
[win]
int win()
{
return system("cat /flag");
}
"cat /flag"를 해주는 win함수도 존재한다.
ret의 위치는 v7로부터 0x68만큼 떨어진 곳에 있는 것을 확인할 수 있다. 즉, 배열의 인덱스로 v7[13]에 ret가 존재한다!
그러므로 v6에는 13을 넣어주고 v4 + v5가 win의 주소가 되도록 정수를 입력하면 된다.
'pwnable > pwnable.xyz' 카테고리의 다른 글
[pwnable.xyz] note (0) | 2020.05.08 |
---|---|
[pwnable.xyz] GrowUp (0) | 2020.04.25 |
[pwnable.xyz] misalignment (0) | 2020.04.17 |
[pwnable.xyz] sub (0) | 2020.04.13 |
[pwnable.xyz] Welcome (0) | 2020.04.11 |