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

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -