I'll be adding more challenges on this writeup as I do more , but basically pwnable.kr is a website which offers practice on binexp (binary exploitation / pwn) challenges , the have challenges based in different levels !
Sounds fairly easy , so it's basically about file descriptors!, so let's connect and take a look on the challeng:
So we got three files, where as fd
is our binary, and the flag
which contains our flag, and fd.c
which is the source code of fd
So we break down the source code to understand what it does and it looks like it takes an argument which is to be an input and then we got int fd = atoi(argv[1]) - 0x1234
which means the input you gave in will be converted to int, then read(fd,buf,32)
where the buf is assigned to buffer of 32 characters.
So let's get back to school we have 3 types of file descriptors:
So first thing I do is to know the int value of 0x1234 which is being substracted to argv[1]
okay basically 0x1234
= 4660
, so what it does watever input we put in will be substracted with 0x1234
then it'll take our input and then checks if buf is equal with LETMEWIN
and if it is , it'll give us the flag , if not then we can't read the flag it'll print learn about Linux file IO
, Basically we have to make argv[1] - 0x1234 = 0
so as stdin is specified and then we can be able to input buf
:
FLAG : mommy! I think I know what a file descriptor is!!