c - Simple buffer overflow via xinetd -
i'm trying make simple buffer overflow tutorial runs program below service on port 8000 via xinetd. code compiled using
gcc -o bof bof.c -fno-stack-protector
ubuntu has stack protection turned off well.
exploiting locally i.e
python -c ---snippet--- | ./bof
is successful , hidden function executed, displaying text file contents.
however, running service , performing
python -c ---snippet--- | nc localhost 8000
returns nothing when exploiting. missing here?
#include <stdio.h> void secret() { int c; file *file; file = fopen("congratulations.txt", "r"); if (file) { while ((c= getc(file)) !=eof) putchar(c); fclose(file); } void textdisplay() { char buffer[56]; scanf("%s", buffer); printf("you entered: %s\n", buffer); } int main() { textdisplay(); return 0; }
output buffered default. disable can following @ top of main:
setbuf(stdin, null);
this should fix issue.
Comments
Post a Comment