Skip to content

Instantly share code, notes, and snippets.

@jaysoncena
Created September 19, 2019 15:41
Show Gist options
  • Save jaysoncena/8cf8f05b27d00f1acafed42d0b8c5ce3 to your computer and use it in GitHub Desktop.
Save jaysoncena/8cf8f05b27d00f1acafed42d0b8c5ce3 to your computer and use it in GitHub Desktop.
#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