Master canary 글을 참고하면 좋다.
Master canary
SSP(Stack Smashing Protector) 보호기법은 스택 버퍼오버플로우를 방지하기 위해 개발된 기법이다. SSP는 스택 buffer와 SFP(Stack Frame Pointer) 사이에 랜덤 값인 canary를 넣어서 함수 종료 시점에서 __stack..
koharinn.tistory.com
int __cdecl main(int argc, const char **argv, const char **envp) { const char **v4; // [rsp+0h] [rbp-60h] __int64 v5; // [rsp+18h] [rbp-48h] pthread_t newthread; // [rsp+20h] [rbp-40h] __int64 v7; // [rsp+28h] [rbp-38h] char buf; // [rsp+30h] [rbp-30h] unsigned __int64 canary; // [rsp+58h] [rbp-8h] v4 = argv; canary = __readfsqword(0x28u); initialize();
while ( 1 ) { while ( 1 ) { puts("1. Create thread"); puts("2. Input"); puts("3. Exit"); printf("> ", v4); __isoc99_scanf("%d", &v7); if ( v7 != 2 ) break; printf("Size: ", &v7); __isoc99_scanf("%d", &v5); printf("Data: ", &v5); read_bytes(global_buffer, v5); printf("Data: %s", global_buffer); } if ( v7 == 3 ) break; if ( v7 == 1 ) { if ( pthread_create(&newthread, 0LL, thread_routine, 0LL) < 0 ) { perror("thread create error"); exit(0); } } else { puts("Nope"); } } printf("Leave comment: ", &v7); read(0, &buf, 0x400uLL); return 0; }
char *__fastcall thread_routine(void *a1) { char *result; // rax char v2; // [rsp+0h] [rbp-110h] result = &v2; global_buffer = (__int64)&v2; return result; }
unsigned __int64 __fastcall read_bytes(__int64 global_buf, unsigned __int64 size) { unsigned __int64 result; // rax unsigned __int64 v3; // [rsp+18h] [rbp-18h] __int64 v4; // [rsp+20h] [rbp-10h] v3 = 0LL; v4 = 0LL; while ( 1 ) { result = v3; if ( v3 >= size ) break; if ( read(0, (void *)(global_buf + v4), 1uLL) != 1 ) exit(-1); ++v4; ++v3; } return result; }
[Dreamhack] pwn-library (0) | 2024.01.10 |
---|---|
[Dreamhack] shell-basic (2) | 2024.01.10 |
[Dreamhack] welcome (0) | 2021.02.09 |
[Dreamhack] tcache_dup2 (0) | 2020.08.29 |
[Dreamhack] basic_heap_overflow (0) | 2020.07.08 |