Advertisement
Guest User

Untitled

a guest
Nov 15th, 2022
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.29 KB | None | 0 0
  1. #include <fcgi_stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(void)
  5. {
  6.    
  7.   int len = 0;
  8.   while(FCGI_Accept() >= 0) {
  9.         FILE * fp = fopen("/wwwdata/example.txt", "w+");
  10.         char *content_type = getenv("CONTENT_TYPE");
  11.         char *contentLength = getenv("CONTENT_LENGTH");      
  12.  
  13.         if (contentLength != NULL)
  14.             len = atoi(contentLength);            
  15.         else
  16.             len = 0;        
  17.        
  18.         printf("Content-type: text/html\r\n"
  19.                "\r\n"
  20.                "<!DOCTYPE html><html><head><meta content='text/html;charset=utf-8' http-equiv='Content-Type'><meta charset='utf-8' http-equiv='encoding'><script type='text/javascript'>"
  21.                "function f(){var x = new XMLHttpRequest();x.open('POST', '/i/a.out', true);x.timeout = 300000;"
  22.                 "var f = new FormData();"
  23.                 "f.append('f', window.document.getElementById('f').files[0]);"
  24.                 "x.send(f);"
  25.                "}</script></head><body>"
  26.                "<b>%d</b><input type='file' id='f' name='f' accept='image/png'><p onClick='f();'>PRESS!</p></body></html>\n"
  27.                ,len);
  28.      
  29.         if (len > 0 && content_type != NULL)
  30.             for(int i = 0; i < len; i++)
  31.                 putc(content_type[i], fp);
  32.        
  33.    
  34.         fclose(fp);
  35.         FCGI_Finish();
  36.     }    
  37. }
  38.  
Tags: Linux lighttpd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement