Created
September 19, 2019 15:41
-
-
Save jaysoncena/8cf8f05b27d00f1acafed42d0b8c5ce3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
void trickme(FILE *f) | |
{ | |
char buf[24]; | |
long i, fsize, read_size; | |
puts("How many bytes do you want to read? (max: 24)"); | |
scanf("%ld", &i); | |
if (i > 24) { | |
puts("You can't trick me..."); | |
return; | |
} | |
fseek(f, 0, SEEK_END); | |
fsize = ftell(f); | |
fseek(f, 0, SEEK_SET); | |
read_size = i > fsize ? i : fsize; | |
fread(buf, 1, read_size, f); | |
fclose(f); | |
puts(buf); | |
} | |
int main(void) | |
{ | |
FILE *f = fopen("./exploit", "r"); | |
setbuf(f, 0); | |
if (!f) | |
puts("Error opening ./exploit"); | |
else | |
trickme(f); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment