-
Notifications
You must be signed in to change notification settings - Fork 0
/
fd.txt
32 lines (27 loc) · 890 Bytes
/
fd.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#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;
}
La differenza di fd.c deve essere esadecimale -> 4660(10)=0x1234=1234(16)
In questo modo il file descriptor usato è 0 che è quello in lettura in stdin
-----------------------------------------------------------------
| input: | (echo LETMEWIN) | ./fd 4660 |
|--------|------------------------------------------------------|
| flag: | mommy! I think I know what a file descriptor is!! |
-----------------------------------------------------------------